1

most explanations of the last parameter is"Flags for extensions (must be 0 for now)".Link here:http://www.cs.cmu.edu/afs/cs/academic/class/15668-s11/www/cuda-doc/html/group__CUDART__MEMORY_ga475419a9b21a66036029d5001ea908c.html#ga475419a9b21a66036029d5001ea908c

so what does it specifically mean? Could someone help me with providing some code explanations?

John Conde
  • 217,595
  • 99
  • 455
  • 496
user12551
  • 145
  • 1
  • 2
  • 9
  • 5
    The current documentation is [here](https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gc00502b44e5f1bdc0b424487ebb08db0) and it states "`flags` provides for future releases. For now, it must be set to 0. " That means it is just a placeholder. In some future CUDA release (beyond cuda 7.0), there may be a use for that value. Currently it doesn't cause any behavioral change, but you are still supposed to specify it as zero. – Robert Crovella Apr 14 '15 at 16:47
  • 1
    In general, the `cudaHostGetDevicePointer` function is used with [zero-copy](http://stackoverflow.com/questions/21611252/is-cuda-pinned-memory-zero-copy) *mapped* memory, which is accessible from both host and device. To access it from device, you need the device pointer (in a non-UVA environment). This function provides the device pointer associated with a previously allocated/pinned/mapped host pointer. [Here](http://stackoverflow.com/questions/20345702/how-can-i-check-the-progress-of-matrix-multiplication) is a usage example. – Robert Crovella Apr 14 '15 at 16:49
  • @RobertCrovella looks that there is nothing that i can do with it right now, i might just simply set it 0.Thank you very much for you quick response!! – user12551 Apr 14 '15 at 17:54
  • @user12551 You not only _can_ set it to `0`, you _must_ set it to `0`. This is to ensure that you don't cause problems by unintentionally setting flags in a future version of CUDA if they start using this flags field. – reirab Apr 14 '15 at 20:26
  • 1
    I consider flags words that never get set to any value other than 0, to be an epic triumph of API design. It means the API was so future-proof that no opt-ins were needed. There are some conspicuous failures to include flags words elsewhere in the CUDA APIs. (I'm looking at you, `cudaEventCreateWithFlags()`) – ArchaeaSoftware Apr 15 '15 at 01:47

1 Answers1

3

The current documentation for cudaHostGetDevicePointer is here.

From the documentation:

flags provides for future releases. For now, it must be set to 0.

That means it is just a placeholder. In some future CUDA release (beyond CUDA 7.0), there may be a use for that value. Currently it doesn't cause any behavioral change, but you are still required to specify it as zero. Specifying it as zero should enable compatibility (no behavioral change) in any future CUDA release, even if the non-zero values result in a difference in behavior.

Regarding the use of the the cudaHostGetDevicePointer function:

It is used with zero-copy mapped memory, which is accessible from both host and device. To access it from device, you need the device pointer, which may be different from the host pointer in a non-UVA environment. This function provides the device pointer associated with a previously allocated/pinned/mapped host pointer.

Here is a usage example.

Community
  • 1
  • 1
Robert Crovella
  • 143,785
  • 11
  • 213
  • 257