Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ID Generation functions on the host and the device. #250

Merged
merged 1 commit into from
Oct 17, 2018

Conversation

ptheywood
Copy link
Member

Constrained to only work for agents with a variable 'id', of a singular integer type (short, int, long long) which may or may not be unsigned.

The maximum id from the initial states file is found and used as the first value available in an init function.
The current next id is maintained through host/device memcpys and state tracking to ensure that the correct value is available at the appropriate location.

i.e. for an agent named 'Agent' the function generate_id_Agent() can be called in a host or xagentOutput device function to generate a new identifier

Closes #247

Function / variable names can be changed if desired.

@mondus
Copy link
Member

mondus commented Oct 12, 2018

Existing models need testing before merge

@ptheywood
Copy link
Member Author

I've now tested this with other models, and renamed generate_id_<AgentName>() to generate_<AgentName>_id() as discussed.

This requires an agent variable named 'id' of an integer type (signed or unsigned) to generate the appropraite function

If an initial states file is provided, the first id assigned by the generate_<agent>_id() function is the maximum+1.
The user can specify a start number if desired.
The value is synchronised between the host and device where appropriate, through memcpy when appropriate.
Device concurrency is handeled using atomicAdd
@ptheywood ptheywood merged commit f84461b into FLAMEGPU:master Oct 17, 2018
@ptheywood ptheywood deleted the generate-unique-ids branch September 3, 2019 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants