Transfer information from GPU to CPU

Yang_QI1
Yang_QI1 Altair Community Member
edited December 2023 in Community Q&A

Hi,

I was trying to count agglomerate information at each timestep based on particles contact with each other and have finished the code with CPU API.  Now I want my code to work on GPU cuda. What I did was collecting contact particle id pairs in contact model and process these info in body force. However, I found it difficult to transfer those contact id pairs in calculateForce() from GPU to CPU. And the mark and process particle only work for each individual particle rather than a pair. So is there a method to transfer the contact pair from GPU to CPU?

Regards,

Yang Qi

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited December 2023

    Hi Yang Qi,

     

    What was the issue with writing the code directly on GPU? That would be the fastest approach.  What can be useful is to use custom properties to tag particles as in contact.  Particle Custom properties are passed automatically between Contact Model and Body Force on CUDA.

     

     Regards

    Stephen

  • satri
    satri Altair Community Member

    Hey

    I have a bunch of custom properties that get modified in the GPU file (.cu)

    I used this gpu file and modified to my requirements

    (https://community.altair.com/discussion/35370/edem-cuda-api-contact-model-example-hertz-mindlin-effective-sphere?utm_source=community-search&utm_medium=organic-search&utm_term=Hertz+mindlin+gpu)

    I have not put the custom properties in the cpp file; I only added it to the gpu file (.cu).

    I want to use them in the CPU file for post-processing. I am not able to see the custom property on EDEM gui.

    Should i define the custom property again in the cpp file?

    Should i do some extra processing such as what is mentioned here

    (https://community.altair.com/discussion/39619/edem-cuda-api-tutorial-2-cuda-custom-properties-and-parameters?utm_source=community-search&utm_medium=organic-search&utm_term=custom+properties+in+cuda)

    This tutorial talks about passing information from cpu to gpu. but does not mention anything about gpu to cpu. Please tell me how i can access the information of changed custom properties in cpu for post procesing?

  • Stephen Cole
    Stephen Cole
    Altair Employee

    Hi, the custom properties need to be defined in the cpp. EDEM registers these when the model is loaded in the Creator. Once defined in the cpp they can be called and used in the .cu file.

    Regards

    Stephen

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.