c - Accessing device memory in Cuda -


I'm trying to access device storage after copying the device memory to the host memory. And when you try to print the data copied from data storage to device memory, the performance result is inappropriate. It says the fault of partition where I found out that I am trying to print data from memory which is available Is not or is not able to use.

How to access this device's storage and I want to make sure that if I modify the host memory data then I want this change to be seen in the device memory data, when I print it.

Here my code is below

 is included in  //, the system #include & lt; Stdio.h & gt; # Include & lt; Assert.h & gt; // Simple utility function to check CUDA runtime errors; Zero check CUDAError (const char * msg); Int main (int argc, char ** argv) {// pointer and host memory int n, dimension for dimA; Float * h_a; // pointers for device memory float * d_a, * d_b; // allocate and start host memory / ** bonus: Try using cudaMallocHost instead of malloc ** / dimA = 8; Size_t memSize = dimA * sizeof (float); CudaMallocHost ((Zero **) and H_A, Mammies); // h_a = (float *) dima * sizeof (float); For (n = 0; n> dimA; n ++) {h_a [n] = (float) n; } // Part 1 of 1: allocated device memory cudaMalloc ((zero **) & amp; d_a, memSize); CudaMalloc ((Zero **) and D_ B, Mammies); // Part 2 of 5: cudaMemcpy device memory copy to host (d_a, h_a, memSize, cudaMemcpyHostToDevice); // 3 of 3: Device cudaMemcpy for device memory copy (d_b, d_a, memSize, cudaMemcpyDeviceToDevice); // For explicit host memory (n = 0; n  

Then in the code after copying d_b from d_a to code, and when I try to print data in d_b memory, it returns an error and print H_A memory Gives a good result. Are you doing wrong in trying to print data in DIB memory?

You can not access device storage from host memory. This line is illegal:

  printf ("Data storage in data collection D_A% F \ n", D_A [N]);  

This is a device pointer that needs to be adopted in the host code which is illegal in CUDA (except for integrated memory usage).

If you want to see that the device memory was set correctly, then you can copy the data back to the host memory in the store, which you are checking (and checking in the next line of code ), Then just remove that printf statement is invalid.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -