Skip to content

Commit

Permalink
Breaking Change: Removed CUDASimulation::getAgent()/getCUDAAgent()
Browse files Browse the repository at this point in the history
This feature was not intended for release, users should not have direct access to internal objects. Roughly equivalent functionality is available via DeviceAgentVector in the HostAPI.
  • Loading branch information
Robadob committed Dec 12, 2022
1 parent d7b458a commit 8343b0c
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 63 deletions.
6 changes: 0 additions & 6 deletions include/flamegpu/simulation/CUDASimulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,6 @@ class CUDASimulation : public Simulation {
template<typename T>
std::vector<T> getEnvironmentPropertyArray(const std::string& property_name);
#endif
/**
* Returns the manager for the specified agent
* @todo remove? this is mostly internal methods that modeller doesn't need access to
*/
detail::CUDAAgent& getCUDAAgent(const std::string &agent_name) const;
detail::AgentInterface &getAgent(const std::string &name) override;
/**
* Returns the manager for the specified agent
* @todo remove? this is mostly internal methods that modeller doesn't need access to
Expand Down
1 change: 0 additions & 1 deletion include/flamegpu/simulation/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ class Simulation {
virtual void getPopulationData(AgentVector& population, const std::string& state_name = ModelData::DEFAULT_STATE) = 0;

virtual const RunLog &getRunLog() const = 0;
virtual detail::AgentInterface &getAgent(const std::string &name) = 0;

Config &SimulationConfig();
const Config &getSimulationConfig() const;
Expand Down
26 changes: 0 additions & 26 deletions src/flamegpu/simulation/CUDASimulation.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1380,32 +1380,6 @@ void CUDASimulation::getPopulationData(AgentVector& population, const std::strin
gpuErrchk(cudaDeviceSynchronize());
}

detail::CUDAAgent& CUDASimulation::getCUDAAgent(const std::string& agent_name) const {
CUDAAgentMap::const_iterator it;
it = agent_map.find(agent_name);

if (it == agent_map.end()) {
THROW exception::InvalidCudaAgent("CUDA agent ('%s') not found, in CUDASimulation::getCUDAAgent().",
agent_name.c_str());
}

return *(it->second);
}

detail::AgentInterface& CUDASimulation::getAgent(const std::string& agent_name) {
// Ensure singletons have been initialised
initialiseSingletons();

auto it = agent_map.find(agent_name);

if (it == agent_map.end()) {
THROW exception::InvalidCudaAgent("CUDA agent ('%s') not found, in CUDASimulation::getAgent().",
agent_name.c_str());
}

return *(it->second);
}

detail::CUDAMessage& CUDASimulation::getCUDAMessage(const std::string& message_name) const {
CUDAMessageMap::const_iterator it;
it = message_map.find(message_name);
Expand Down
30 changes: 0 additions & 30 deletions tests/test_cases/simulation/test_cuda_simulation.cu
Original file line number Diff line number Diff line change
Expand Up @@ -291,36 +291,6 @@ TEST(TestCUDASimulation, SetGetPopulationData_InvalidAgent) {
EXPECT_THROW(c.setPopulationData(pop), exception::InvalidAgent);
EXPECT_THROW(c.getPopulationData(pop), exception::InvalidAgent);
}
TEST(TestCUDASimulation, GetAgent) {
ModelDescription m(MODEL_NAME);
AgentDescription a = m.newAgent(AGENT_NAME);
m.newLayer(LAYER_NAME).addAgentFunction(a.newFunction(FUNCTION_NAME, SetGetFn));
a.newVariable<int>(VARIABLE_NAME);
AgentVector pop(a, static_cast<unsigned int>(AGENT_COUNT));
for (int _i = 0; _i < AGENT_COUNT; ++_i) {
AgentVector::Agent i = pop[_i];
i.setVariable<int>(VARIABLE_NAME, _i);
}
CUDASimulation c(m);
c.SimulationConfig().steps = 1;
c.setPopulationData(pop);
c.simulate();
detail::AgentInterface &agent = c.getAgent(AGENT_NAME);
for (int _i = 0; _i < AGENT_COUNT; ++_i) {
int host = 0;
cudaMemcpy(&host, reinterpret_cast<int*>(agent.getStateVariablePtr(ModelData::DEFAULT_STATE, VARIABLE_NAME)) + _i, sizeof(int), cudaMemcpyDeviceToHost);
EXPECT_EQ(host, _i * MULTIPLIER);
host = _i * 2;
cudaMemcpy(reinterpret_cast<int*>(agent.getStateVariablePtr(ModelData::DEFAULT_STATE, VARIABLE_NAME)) + _i, &host, sizeof(int), cudaMemcpyHostToDevice);
}
c.simulate();
agent = c.getAgent(AGENT_NAME);
for (int _i = 0; _i < AGENT_COUNT; ++_i) {
int host = 0;
cudaMemcpy(&host, reinterpret_cast<int*>(agent.getStateVariablePtr(ModelData::DEFAULT_STATE, VARIABLE_NAME)) + _i, sizeof(int), cudaMemcpyDeviceToHost);
EXPECT_EQ(host, _i * 2 * MULTIPLIER);
}
}

TEST(TestCUDASimulation, Step) {
// Test that step does a single step
Expand Down

0 comments on commit 8343b0c

Please sign in to comment.