Skip to content

Commit

Permalink
Removal of Pointless References in Function Args (#946)
Browse files Browse the repository at this point in the history
Closes #825
  • Loading branch information
mondus committed Oct 26, 2022
1 parent c75f408 commit 891e16d
Show file tree
Hide file tree
Showing 96 changed files with 616 additions and 616 deletions.
10 changes: 5 additions & 5 deletions examples/host_functions/src/main.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
const unsigned int AGENT_COUNT = 1024;

FLAMEGPU_AGENT_FUNCTION(device_function, flamegpu::MessageNone, flamegpu::MessageNone) {
const float &prop_float = FLAMEGPU->environment.getProperty<float>("float");
const int16_t &prop_int16 = FLAMEGPU->environment.getProperty<int16_t>("int16_t");
const uint64_t &prop_uint64_0 = FLAMEGPU->environment.getProperty<uint64_t, 3>("uint64_t", 0);
const uint64_t &prop_uint64_1 = FLAMEGPU->environment.getProperty<uint64_t, 3>("uint64_t", 1);
const uint64_t &prop_uint64_2 = FLAMEGPU->environment.getProperty<uint64_t, 3>("uint64_t", 2);
const float prop_float = FLAMEGPU->environment.getProperty<float>("float");
const int16_t prop_int16 = FLAMEGPU->environment.getProperty<int16_t>("int16_t");
const uint64_t prop_uint64_0 = FLAMEGPU->environment.getProperty<uint64_t, 3>("uint64_t", 0);
const uint64_t prop_uint64_1 = FLAMEGPU->environment.getProperty<uint64_t, 3>("uint64_t", 1);
const uint64_t prop_uint64_2 = FLAMEGPU->environment.getProperty<uint64_t, 3>("uint64_t", 2);
if (blockIdx.x * blockDim.x + threadIdx.x == 0) {
printf("Agent Function[Thread 0]! Properties(Float: %g, int16: %hd, uint64[3]: {%llu, %llu, %llu})\n", prop_float, prop_int16, prop_uint64_0, prop_uint64_1, prop_uint64_2);
}
Expand Down
4 changes: 2 additions & 2 deletions include/flamegpu/exception/FLAMEGPUDeviceException.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class DeviceExceptionManager {
* Free all device memory
*/
~DeviceExceptionManager();
DeviceExceptionBuffer *getDevicePtr(const unsigned int &streamId, const cudaStream_t &stream);
void checkError(const std::string &function, const unsigned int &streamId, const cudaStream_t &stream);
DeviceExceptionBuffer *getDevicePtr(unsigned int streamId, cudaStream_t stream);
void checkError(const std::string &function, unsigned int streamId, cudaStream_t stream);

private:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class DeviceException {
* This is required to process var args, it performs recursion to scrape of each arg
*/
template<typename T, typename... Args>
__device__ void subformat_recurse(DeviceExceptionBuffer *buff, const T &t, Args... args) {
__device__ void subformat_recurse(DeviceExceptionBuffer *buff, const T t, Args... args) {
// Call subformat with T
subformat(buff, t);
// Recurse with the rest of the list
Expand Down
2 changes: 1 addition & 1 deletion include/flamegpu/exception/FLAMEGPUException.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class FLAMEGPUException : public std::exception {
/**
* Sets internal members file and line, which are used by constructor
*/
static void setLocation(const char *_file, const unsigned int &_line);
static void setLocation(const char *_file, unsigned int _line);

protected:
/**
Expand Down
28 changes: 14 additions & 14 deletions include/flamegpu/gpu/CUDAAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CUDAAgent : public AgentInterface {
* @note TODO: This could be improved by iterating the variable list within the state_list, rather than individually looking up vars (the two lists should have all the same vars)
* @note This should probably be addressed when curve is updated to not use individual memcpys
*/
void mapRuntimeVariables(const AgentFunctionData& func, const unsigned int &instance_id) const;
void mapRuntimeVariables(const AgentFunctionData& func, unsigned int instance_id) const;
/**
* Copies population data from the provided host object
* To the device buffers held by this object (overwriting any existing agent data)
Expand All @@ -81,7 +81,7 @@ class CUDAAgent : public AgentInterface {
* @param stream CUDA stream to be used for async CUDA operations
* @note Scatter is required for initialising submodel vars
*/
void setPopulationData(const AgentVector& population, const std::string &state_name, CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t& stream);
void setPopulationData(const AgentVector& population, const std::string &state_name, CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Copies population data the device buffers held by this object
* To the hosts object (overwriting any existing agent data)
Expand Down Expand Up @@ -116,19 +116,19 @@ class CUDAAgent : public AgentInterface {
* @param scatter Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
* @see CUDAFatAgent::processDeath(const unsigned int &, const std::string &, const unsigned int &)
* @see CUDAFatAgent::processDeath(unsigned int, const std::string &, unsigned int)
*/
void processDeath(const AgentFunctionData& func, CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream);
void processDeath(const AgentFunctionData& func, CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Transitions all active agents from the source state to the destination state
* @param _src The source state
* @param _dest The destination state
* @param scatter Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
* @see CUDAFatAgent::transitionState(const unsigned int &, const std::string &, const std::string &, const unsigned int &)
* @see CUDAFatAgent::transitionState(unsigned int, const std::string &, const std::string &, unsigned int)
*/
void transitionState(const std::string &_src, const std::string &_dest, CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream);
void transitionState(const std::string &_src, const std::string &_dest, CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Scatters agents based on their output of the agent function condition
* Agents which failed the condition are scattered to the front and marked as disabled
Expand All @@ -137,11 +137,11 @@ class CUDAAgent : public AgentInterface {
* @param scatter Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
* @see CUDAFatAgent::processFunctionCondition(const unsigned int &, const unsigned int &)
* @see CUDAFatAgent::processFunctionCondition(unsigned int, unsigned int)
* @note Named state must not already contain disabled agents
* @note The disabled agents are re-enabled using clearFunctionCondition(const std::string &)
*/
void processFunctionCondition(const AgentFunctionData& func, CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream);
void processFunctionCondition(const AgentFunctionData& func, CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Scatters agents from the provided device buffer, this is used for host agent creation
* The device buffer must be packed according to the param offsets
Expand All @@ -153,7 +153,7 @@ class CUDAAgent : public AgentInterface {
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
*/
void scatterHostCreation(const std::string &state_name, const unsigned int &newSize, char *const d_inBuff, const VarOffsetStruct &offsets, CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream);
void scatterHostCreation(const std::string &state_name, unsigned int newSize, char *const d_inBuff, const VarOffsetStruct &offsets, CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Sorts all agent variables according to the positions stored inside Message Output scan buffer
* @param state_name The state agents are scattered into
Expand Down Expand Up @@ -183,14 +183,14 @@ class CUDAAgent : public AgentInterface {
void releaseNewBuffer(const AgentFunctionData& func);
/**
* Scatters agents from the currently assigned device agent birth buffer (see member variable newBuffs)
* The device buffer must be packed in the same format as mapNewRuntimeVariables(const AgentFunctionData&, const unsigned int &, const unsigned int &)
* The device buffer must be packed in the same format as mapNewRuntimeVariables(const AgentFunctionData&, unsigned int, unsigned int)
* @param func The agent function being processed
* @param newSize The maximum number of new agents (this will be the size of the agent state executing func)
* @param scatter Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
*/
void scatterNew(const AgentFunctionData& func, const unsigned int &newSize, CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream);
void scatterNew(const AgentFunctionData& func, unsigned int newSize, CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Reenables all disabled agents within the named state
* @param state The named state to enable all agents within
Expand Down Expand Up @@ -240,7 +240,7 @@ class CUDAAgent : public AgentInterface {
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
*/
void initUnmappedVars(CUDAScatter& scatter, const unsigned int& streamId, const cudaStream_t& stream);
void initUnmappedVars(CUDAScatter& scatter, unsigned int streamId, cudaStream_t stream);
/**
* Initialises any agent variables within the CUDAFatAgentStateList of state which are not present in the agent-state's CUDAAgentStateList
* @param state Affected state
Expand All @@ -250,7 +250,7 @@ class CUDAAgent : public AgentInterface {
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
*/
void initExcludedVars(const std::string& state, const unsigned int& count, const unsigned int& offset, CUDAScatter& scatter, const unsigned int& streamId, const cudaStream_t& stream);
void initExcludedVars(const std::string& state, unsigned int count, unsigned int offset, CUDAScatter& scatter, unsigned int streamId, cudaStream_t stream);
/**
* Resets the number of agents in every statelist to 0
*/
Expand All @@ -275,7 +275,7 @@ class CUDAAgent : public AgentInterface {
* @param newSize Number of active agents
* @throw exception::InvalidMemoryCapacity If the new number of disabled + active agents would exceed currently allocated buffer capacity
*/
void setStateAgentCount(const std::string& state, const unsigned int &newSize);
void setStateAgentCount(const std::string& state, unsigned int newSize);
/**
* Returns a list of variable buffers attached to bound agents, not available in this agent
* @param state The state affected state
Expand Down
14 changes: 7 additions & 7 deletions include/flamegpu/gpu/CUDAAgentStateList.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CUDAAgentStateList {
CUDAAgentStateList(
const std::shared_ptr<CUDAFatAgentStateList> &fat_list,
CUDAAgent& cuda_agent,
const unsigned int &_fat_index,
unsigned int _fat_index,
const AgentData& description,
bool _isSubStateList = false);
/**
Expand All @@ -46,7 +46,7 @@ class CUDAAgentStateList {
CUDAAgentStateList(
const std::shared_ptr<CUDAFatAgentStateList> &fat_list,
CUDAAgent& cuda_agent,
const unsigned int &_fat_index,
unsigned int _fat_index,
const AgentData& description,
bool _isSubStateList,
const SubAgentData::Mapping &mapping);
Expand All @@ -56,7 +56,7 @@ class CUDAAgentStateList {
* @param minimumSize The minimum number of agents that must be representable
* @param retainData If true existing buffer data is retained
* @param stream The stream used to perform memcpys if data is retained
* @see CUDAFatAgentStateList::resize(const unsigned int &, const bool &)
* @see CUDAFatAgentStateList::resize(unsigned int, bool)
*/
void resize(unsigned int minimumSize, bool retainData, cudaStream_t stream);
/**
Expand Down Expand Up @@ -105,7 +105,7 @@ class CUDAAgentStateList {
void scatterSort_async(CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Scatters agents from the currently assigned device agent birth buffer (see member variable newBuffs)
* The device buffer must be packed in the same format as CUDAAgent::mapNewRuntimeVariables(const AgentFunctionData&, const unsigned int &, const unsigned int &)
* The device buffer must be packed in the same format as CUDAAgent::mapNewRuntimeVariables(const AgentFunctionData&, unsigned int, unsigned int)
* @param d_newBuff The buffer holding the new agent data
* @param newSize The maximum number of new agents (this will be the size of the agent state executing func)
* @param scatter Scatter instance and scan arrays to be used
Expand All @@ -124,7 +124,7 @@ class CUDAAgentStateList {
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
*/
void initUnmappedVars(CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream);
void initUnmappedVars(CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Initialises any agent variables within the CUDAFatAgentStateList which are not present in this CUDAAgentStateList
* @param count Number of variables to init
Expand All @@ -133,7 +133,7 @@ class CUDAAgentStateList {
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
*/
void initExcludedVars(const unsigned int& count, const unsigned int& offset, CUDAScatter& scatter, const unsigned int& streamId, const cudaStream_t& stream);
void initExcludedVars(unsigned int count, unsigned int offset, CUDAScatter& scatter, unsigned int streamId, cudaStream_t stream);
/**
* Returns the statelist to an empty state
* This resets the size to 0.
Expand All @@ -144,7 +144,7 @@ class CUDAAgentStateList {
* @param newSize Number of active agents
* @throw exception::InvalidMemoryCapacity If the new number of disabled + active agents would exceed currently allocated buffer capacity
*/
void setAgentCount(const unsigned int& newSize);
void setAgentCount(unsigned int newSize);
/**
* Returns a list of variable buffers attached to bound agents, not available in this agent
* @note This access is only intended for DeviceAgentVector's correctly handling of subagents
Expand Down
16 changes: 8 additions & 8 deletions include/flamegpu/gpu/CUDAFatAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CUDAFatAgent {
/**
* Index assigned to the agent when it is added to the CUDAFatAgent
* @note An index is used as two mapped agents from different models may share the same name
* @see CUDAFatAgent::addSubAgent(const AgentData &, const unsigned int &, const std::shared_ptr<SubAgentData> &)
* @see CUDAFatAgent::addSubAgent(const AgentData &, unsigned int, const std::shared_ptr<SubAgentData> &)
*/
const unsigned int agent;
/**
Expand Down Expand Up @@ -78,14 +78,14 @@ class CUDAFatAgent {
*/
void addSubAgent(
const AgentData &description,
const unsigned int &master_fat_index,
unsigned int master_fat_index,
const std::shared_ptr<SubAgentData> &mapping);
/**
* This function builds and returns the state_map required by the named CUDAAgent
* @param fat_index The index of the CUDAAgent within this CUDAFatAgent
* @return a statemap suitable for the named agent
*/
std::unordered_map<std::string, std::shared_ptr<CUDAFatAgentStateList>> getStateMap(const unsigned int &fat_index);
std::unordered_map<std::string, std::shared_ptr<CUDAFatAgentStateList>> getStateMap(unsigned int fat_index);
/**
* Scatters all active agents within the named state to remove agents with death flag set
* This updates the alive agent count
Expand All @@ -95,7 +95,7 @@ class CUDAFatAgent {
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
*/
void processDeath(const unsigned int &agent_fat_id, const std::string &state_name, CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream);
void processDeath(unsigned int agent_fat_id, const std::string &state_name, CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Transitions all active agents from the source state to the destination state
* @param agent_fat_id The index of the CUDAAgent within this CUDAFatAgent
Expand All @@ -115,14 +115,14 @@ class CUDAFatAgent {
* @param streamId The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers
* @param stream CUDA stream to be used for async CUDA operations
*/
void processFunctionCondition(const unsigned int &agent_fat_id, const std::string &state_name, CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream);
void processFunctionCondition(unsigned int agent_fat_id, const std::string &state_name, CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream);
/**
* Marks the specified number of agents within the specified statelist as disabled
* @param agent_fat_id The index of the CUDAAgent within this CUDAFatAgent
* @param state_name The name of the state attached to the named fat agent index
* @param numberOfDisabled The number of agents to be marked as disabled
*/
void setConditionState(const unsigned int &agent_fat_id, const std::string &state_name, const unsigned int numberOfDisabled);
void setConditionState(unsigned int agent_fat_id, const std::string &state_name, unsigned int numberOfDisabled);
/**
* Returns a device pointer of atleast type_size x new_agents bytes available
* @param total_agent_size Total number of bytes required to fit all variables in the agent
Expand All @@ -131,10 +131,10 @@ class CUDAFatAgent {
* @note It is assumed that when splitting the buffer into variables, each variable's sub-buffer will be 64 bit aligned
* @note New buffers are shared between all states and mapped/unmapped agents
*/
void *allocNewBuffer(const size_t &total_agent_size, const unsigned int &new_agents, const size_t &varCount);
void *allocNewBuffer(size_t total_agent_size, unsigned int new_agents, size_t varCount);
/**
* Marks the named buffer as free
* @param buff The buffer to free, this must be a pointer returned by allocNewBuffer(const size_t &, const unsigned int &, const size_t &)
* @param buff The buffer to free, this must be a pointer returned by allocNewBuffer(size_t, unsigned int, size_t)
*/
void freeNewBuffer(void *buff);
/**
Expand Down
Loading

0 comments on commit 891e16d

Please sign in to comment.