static.cu 503 B

123456789101112131415161718192021
  1. #include <cuda.h>
  2. #include <cuda_runtime.h>
  3. #include <iostream>
  4. int __host__ file1_sq_func(int x)
  5. {
  6. cudaError_t err;
  7. int nDevices = 0;
  8. err = cudaGetDeviceCount(&nDevices);
  9. if (err != cudaSuccess) {
  10. std::cerr << "nDevices: " << nDevices << std::endl;
  11. std::cerr << "err: " << err << std::endl;
  12. return 1;
  13. }
  14. std::cout << "this library uses cuda code" << std::endl;
  15. std::cout << "you have " << nDevices << " devices that support cuda"
  16. << std::endl;
  17. return x * x;
  18. }