0

Is there an alternative to the C function calloc() in SYCL?

Or the only alternative to imitate the behaviour is to use malloc_host() / malloc_device() and then memset()? I've tested out this last option and the performance drops dramatically. That's the main reason I would like to know.

Thank you very much.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
gamersensual
  • 105
  • 6
  • It depends a bit, device memory allocation and movement is expensive because you are using up the time to transfer all that memory from the host (CPU) to the device (GPU) before you can use it. calloc is just a memory allocation so could use either of the memory you suggest. The strategy you need to think about is what memory needs to be transferred onto the device as that affects performance most. Take a look at Chapter 3 of the SYCL book https://link.springer.com/book/10.1007/978-1-4842-5574-2 and also the USM lessons on SYCL Academy https://github.com/codeplaysoftware/syclacademy – Rod Burns Aug 08 '22 at 11:24
  • To get a better answer to your question you will need to provide more context, perhaps once you have done some reading you will be able to do that. – Rod Burns Aug 08 '22 at 11:24
  • Hey! In the original code I just have lots of calloc() calls and then the computation part of the code starts. To paralellize this, I have to first declare and initialize these variables and then copy them to the devices memory, or declare them and then use a special function to initialize them in the device. – gamersensual Aug 15 '22 at 06:01

0 Answers0