Advertisement
gaurish108

CudaMemGetInfoError

Jan 4th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <thrust/host_vector.h>
  2. #include <thrust/device_vector.h>
  3. #include <cuda.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <iostream>
  7.  
  8. int main(void)
  9. {
  10.   size_t free, total;
  11.  
  12.   cudaError_t error=cudaMemGetInfo (&free , &total);
  13.   if(error != cudaSuccess)
  14.   {
  15.     printf("CUDA error: %s\n", cudaGetErrorString(error));
  16.     exit(-1);
  17.   }
  18.  
  19.   std::cout << "Free Memory                                    : " << free  << std::endl ;
  20.   std::cout << "Total amount of memory                         : " << total <<std::endl;
  21.  
  22.  
  23.    //Use Thrust to  initialize all ten integers of a device_vector to 1
  24.     thrust::device_vector<int> D(10, 1);
  25.    
  26.     //Print out the device vector.
  27.     for (int i = 0; i < D.size(); ++i)
  28.      {
  29.       std::cout << D[i] <<std::endl ;
  30.      }
  31.    
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement