55#include < cstdint>
66#include < cuda.h>
77
8+ #include < string>
9+
810typedef uint64_t u64 ;
911
1012// CHECK: void exec_kernel(dpct::kernel_function cuFunc, dpct::kernel_library cuMod, dpct::queue_ptr stream) {
@@ -15,9 +17,10 @@ void exec_kernel(CUfunction cuFunc, CUmodule cuMod, CUstream stream) {
1517 // verify the conversion from dpct::kernel_library to uint64_t
1618 mod = (u64 )cuMod;
1719
20+ std::string kernel_name{" kfoo" };
1821 // verify the conversion from uint64_t to dpct::kernel_library
19- // CHECK: cuFunc = dpct::get_kernel_function((dpct::kernel_library)mod, "kfoo" );
20- cuModuleGetFunction (&cuFunc, (CUmodule)mod, " kfoo " );
22+ // CHECK: cuFunc = dpct::get_kernel_function((dpct::kernel_library)mod, kernel_name.c_str() );
23+ cuModuleGetFunction (&cuFunc, (CUmodule)mod, kernel_name. c_str () );
2124
2225 // verify the conversion from dpct::kernel_function to uint64_t
2326 function = (u64 )cuFunc;
@@ -28,3 +31,18 @@ void exec_kernel(CUfunction cuFunc, CUmodule cuMod, CUstream stream) {
2831 // CHECK: dpct::invoke_kernel_function((dpct::kernel_function)function, *stream, sycl::range<3>(100, 100, 100), sycl::range<3>(100, 100, 100), 1024, NULL, config);
2932 cuLaunchKernel ((CUfunction)function, 100 , 100 , 100 , 100 , 100 , 100 , 1024 , stream, NULL , config);
3033}
34+
35+ class CString {
36+ private:
37+ char *str;
38+ public:
39+ CString (): str(NULL ) {};
40+ operator const char * () const { return str; }
41+
42+ operator char * () { return str; }
43+ };
44+
45+ void test_casting (CUmodule mod, CUfunction func, const CString &name) {
46+ // CHECK: func = dpct::get_kernel_function(mod, (const char *)name);
47+ cuModuleGetFunction (&func, mod, name);
48+ }
0 commit comments