Simple File I/O in Cuda C++

后端 未结 2 2001
情歌与酒
情歌与酒 2021-01-05 17:14

Im working on Cuda C++ right now. But I\'m having problems about reading and writing into files with CUDA.

How can I implement file input output processes in Cuda C+

相关标签:
2条回答
  • 2021-01-05 17:25

    Read the file using ordinary host (C++) file operations. Then transfer the data to the device if you need it there, using ordinary cudaMalloc and cudaMemcpy operations.

    You won't be able to implement file I/O directly in CUDA C++, as there is no API for this and the GPU does not connect directly to the file system. You have to go through the OS for file system services.

    0 讨论(0)
  • 2021-01-05 17:50

    For your file to get into CUDA memory space you will have to use the CUDA memcpy command after allocating memory for the information (so do a cudaMalloc(your, malloc, params, here) and a cudaMemcpy(your, memcpy, params,here) after you have loaded parsed and stored in memory the file as you would normally in C++.

    You could try making a cuda system to access the file directly, but that is a process I would not envy trying to write, and the gain to effort ratio would render it a non-viable venture (apart from a proof of concept excercise).

    Hope that helps!:)

    0 讨论(0)
提交回复
热议问题