device-stub.cu 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o - | FileCheck %s
  2. #include "Inputs/cuda.h"
  3. // Make sure that all parts of GPU code init/cleanup are there:
  4. // * constant unnamed string with the kernel name
  5. // CHECK: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
  6. // * constant unnamed string with GPU binary
  7. // CHECK: private unnamed_addr constant{{.*}}\00"
  8. // * constant struct that wraps GPU binary
  9. // CHECK: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* }
  10. // CHECK: { i32 1180844977, i32 1, {{.*}}, i8* null }
  11. // * variable to save GPU binary handle after initialization
  12. // CHECK: @__cuda_gpubin_handle = internal global i8** null
  13. // * Make sure our constructor/destructor was added to global ctor/dtor list.
  14. // CHECK: @llvm.global_ctors = appending global {{.*}}@__cuda_module_ctor
  15. // CHECK: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor
  16. // Test that we build the correct number of calls to cudaSetupArgument followed
  17. // by a call to cudaLaunch.
  18. // CHECK: define{{.*}}kernelfunc
  19. // CHECK: call{{.*}}cudaSetupArgument
  20. // CHECK: call{{.*}}cudaSetupArgument
  21. // CHECK: call{{.*}}cudaSetupArgument
  22. // CHECK: call{{.*}}cudaLaunch
  23. __global__ void kernelfunc(int i, int j, int k) {}
  24. // Test that we've built correct kernel launch sequence.
  25. // CHECK: define{{.*}}hostfunc
  26. // CHECK: call{{.*}}cudaConfigureCall
  27. // CHECK: call{{.*}}kernelfunc
  28. void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); }
  29. // Test that we've built a function to register kernels
  30. // CHECK: define internal void @__cuda_register_kernels
  31. // CHECK: call{{.*}}cudaRegisterFunction(i8** %0, {{.*}}kernelfunc
  32. // Test that we've built contructor..
  33. // CHECK: define internal void @__cuda_module_ctor
  34. // .. that calls __cudaRegisterFatBinary(&__cuda_fatbin_wrapper)
  35. // CHECK: call{{.*}}cudaRegisterFatBinary{{.*}}__cuda_fatbin_wrapper
  36. // .. stores return value in __cuda_gpubin_handle
  37. // CHECK-NEXT: store{{.*}}__cuda_gpubin_handle
  38. // .. and then calls __cuda_register_kernels
  39. // CHECK-NEXT: call void @__cuda_register_kernels
  40. // Test that we've created destructor.
  41. // CHECK: define internal void @__cuda_module_dtor
  42. // CHECK: load{{.*}}__cuda_gpubin_handle
  43. // CHECK-NEXT: call void @__cudaUnregisterFatBinary