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

Made most __device__ functions/methods __host__ __device__ #10

Merged
merged 5 commits into from
Sep 12, 2020

Conversation

kolayne
Copy link
Member

@kolayne kolayne commented Aug 27, 2020

Is blocked by #8. Current branch (host-device_instead_of_device) is based on move_copy_mechanisms, so the corresponding PR should be approved before approving this, and new commits at move_copy_mechanisms should be merged into this branch if there are any

I think it's wrong to make most functions/methods __device__ only because if their parameters are allocated in host memory, they should be executed on host. This enhancement also makes it possible to perform some object setup while it's in host memory and then copy it to device memory (before it was only possible to create an object in device memory and set it up there). However, it's absolutely ok if some function used in setup or simulation uses some CUDA feature(s) and therefore is made __device__ only (of course, it also requires all "parent" functions (which call that function) to be __device__ either)

@kolayne kolayne force-pushed the host-device_instead_of_device branch from 164c646 to 614b791 Compare August 27, 2020 20:09
@kolayne
Copy link
Member Author

kolayne commented Aug 28, 2020

I haven't edited SimulationMap class at all, because it has a __global__ method friend function, so I'd say SimulationMap is designed to only exist in device memory, but probably this is wrong, I'm not sure

@kolayne kolayne mentioned this pull request Aug 31, 2020
@kolayne kolayne marked this pull request as ready for review September 12, 2020 09:33
# Conflicts:
#	src/MapNode.cu
#	src/MapNode.cuh
Copy link
Member

@tanya-kta tanya-kta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few issues

src/Particle.cuh Outdated Show resolved Hide resolved
@@ -50,7 +50,7 @@ __device__ T *malloc_and_copy(const T *const source, int count)
* @returns Pointer to the created array
*/
template<class T>
__device__ T *device_realloc(T *source, int old_size, int new_size)
__host__ __device__ T *device_realloc(T *source, int old_size, int new_size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

device_realloc is now __host__ __device__, so device in the name of this function sounds strange. It relates to #4

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can ignore it for now and leave it to fixers of #4

Minor documentation fix

Co-authored-by: tanya-kta <46196001+tanya-kta@users.noreply.github.com>
Copy link
Member

@tanya-kta tanya-kta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@tanya-kta tanya-kta merged commit 6006b0d into master Sep 12, 2020
@tanya-kta tanya-kta deleted the host-device_instead_of_device branch September 12, 2020 10:33
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