FLAME’s Future
249
xmachine_message* message = get_first_message(list);
while(message) {
if (message->id == agent->id) {
agent->state += message->state;
return 0;
}
message = get_next_message(message, list);
}
return 0;
}
However the code does not work in FLAME GPU, causing the simulation
to crash or hang. Instead, an extra flag ‘finished’ needs to be introduced
to tell the code to leave the ‘while’ loop.
int MyFunction(xmahine_memory* agent, xmachine_message_list* list) {
bool finished = false;
xmachine_message* message = get_first_message(list);
while(message) {
if (!finished) {
if (message->id == agent->id) {
agent->state += message->state;
finished = true;
}
}
message = get_next_message(message, list);
}
return 0;
}
Discrete versus Continuous. In the GPU version, agents are defined as
nature discrete or continuous. This affects how messages are parsed and
handled during the simulation. This required modelers to understand
this in advance, which was not seen in the grid version. The grid version
allows easier writing of the agents and all are handled the same way.
Agent Birth and Death. Both architectures were able to handle agent addition similarly. Similar to the problem of dynamic memory allocation,
agents can be introduced in the system if predetermined for the GPU.
With every simulation the agent would be introduced using an environment agent, which keeps track of the maximum agents and generates
a new agent by using the thread id :ID = M axid + threadID, where
threadID = blockIDx.x × blockDimx + threadId.x.
This guarantees that all generated IDs are unique (although not sequential), without using complicated atomic operations. The GPU, however,
can only add one agent at a time step, whereas the Grid version could
add multiple agents per step.
Real-time Visualization. The Grid version allows simulations to run as
batch files producing results on disk. The results are later downloaded
Précédent

- 278/329

Suivant