Dictionarys on the GPU for Agents.jl


I am working on an Agent Based Model with the Agents.jl framework and I am having performance problems.

I am working with dictonarys to save positions and values. Is there a way to work with dictonaries on the GPU to speed thing up?

Thank you so much!

Perhaps it’s better to describe what you are doing with the dictionaries so that we can advise whether there is a more performance data structure all together. Dictionaries are one of the least performance data structures


George Datseris (he/him)

Sorry for the late reply and thank you for your answer!

I am simulating the spread of an invasive tree species. I have several dispersal functions for different dispersal mechanisms of the tree species (e.g. the spread along a river by water transporting the seeds).

This functions take the location of a tree and return a dictonary with possible locations where the tree could spread to next as keys and the probability for the locations as values (e.g. in dependence of distance along the river).

Thank you!


Well the most obvious thing I can thinnk of is: I am not sure whether you need to store this dictionary. Why do you not make a decision imediatelly about where the seed should be planted based on these probabilities? Where do you pass this dictionary, and why does it need to be passed? Why don’t you pass instead the decided location? If you pass the decided locaiton you don’t need to make a dictionary at all. A vector of positions and avector of probabilities. sample one posiition with a weighted sam[pling based on the probabilities.

Furthermore, can you be more descriptive about the performance problems you are having? What is the problem exactly and what would you expected to have happened instead of the problem?

1 Like

Sometimes it’s the simple question!

Your question about my performance issue actually triggered a search that already helped me find part of the solution.
I had much more agents than I expected; this was simply because a keyword in the initialization was missing that would allow only one agent per position!

Therefore, it now runs already much better!

The passing of the dicts was more for modularity and readability so it’s all ordered in terms of “here I look for possible locations,” “here I combine the locations,” “here I plant my trees.”
But maybe it is possible to “plant the trees” right away without storing the locations at all; I might try this!

Thanks again for your time!

1 Like