Efficiently solving a variant of the N-body problem #281
Replies: 1 comment 4 replies
-
Thank you for moving the discussion here. I will look into it and let you know. |
Beta Was this translation helpful? Give feedback.
-
Thank you for moving the discussion here. I will look into it and let you know. |
Beta Was this translation helpful? Give feedback.
-
This is a continuation of a google groups conversation https://groups.google.com/g/arrayfire-users/c/NFBMVR8vu5w
To restate my problem quite briefly for this thread, I am trying to a variant of the N-body problem (a simulation of n particles each interacting with every other particle)
Specifically I am making a type of simulation called "particle life" ("plife") loosely inspired by Conway's Game of Life. I've written a bit about it here if you'd like to read more about it.
My current AF implementation is creating two N x N arrays such that each 2D coordinate corresponds with a particular pair, and then doing all of my calculations on those matrices. After doing some research I have found that while the N x N matrix is used to solve this problem, one of the dimensions operates in time instead of space. This image from NVidia's N-body CUDA website illustrates what I mean. I'm unsure how to implement this using AF, as any loop I create will run on the CPU instead of the GPU. This particular simulation would also benefit greatly from being able to skip most of the computation, since most particles are far enough away from most other particles not to have any effect, but without branching I'm unsure how to achieve this.
Here is some of my code to better illustrate what I am currently doing (my project will likely be open source soon, but I am working on it by myself just for now):
Any help or suggestions would be greatly appreciated! :)
Beta Was this translation helpful? Give feedback.
All reactions