C++ CUDA Pointer-to-member -


I am thinking that there is no way to pass any indicator-to-member to a device function in the CUDA is. Since the indicator is actually just relative to the structure / class, it seems that there should be no such reason as it will not work, but I can not get the code to compile.

  #include & lt; Stdio.h & gt; Straight S {int F1; Int F2; Int F3; }; __Device__SX; __global__ zero initialize_S () {x.f1 = 100; X.F2 = 200; X.F3 = 300; } __global__ zero print_S (int S :: * m) {printf ("val:% d \ n", x. * m); } int main () {initialize_S & lt; & Lt; & Lt; 1, 1 & gt; & Gt; & Gt; (); print_S & lt; & Lt; & Lt; 1, 1 & gt; & Gt; & Gt; (And S :: F1); cudaDeviceSynchronize (); }   

When compiling I get the following error with NVCC v5.5 /tmp/tmpxft_000068a5_00000000-16_ptm.o: function in `main ': tmpxft_000068a5_00000000 -3_ptm.cudafe1.cpp: (Text + 0xcf): Undefined context for `print_S (int S :: *) '/tmp/tmpxft_000068a5_00000000-16_ptm.o: function` __device_stub__Z7print_SM1Si (long)' in: tmpxft_000068a5_00000000-3_ptm cudafe1. CPP :(. Text + 0x17f): `Print_s (ET S :: *) 'tmpxft_000068a5_00000000-3_ptm.cudafe1.cpp :(. + Undefined to + xx184) Reference:` Print_ undefined for S (Int S :: *) Reference 'Collection 2: Error: LD has returned 1 exit status

Any help would be appreciated. Thanks!

Edit: after tracing through went by Anvisisi code is actually creating it wrong that looks like:

  extern void __device_stub__Z7print_SM1Si (long ); Zero __device_stub__Z7print_SMlSi (long __par0) {if (CudaSetupArgument ((void *) (char *) & amp; __ par0, sizeof (__ par0), (size_t) 0UL)! = CudaSuccess; return; {volatile static char * __ f __tttw __ ((unused); __f = ((four *) ((zero (*) (long)) print_S); (zero) cudaL aunch (((* four *) ((zero (*) (long)) print_S)));};} # 18 "ptm.cu" void print_S (long __cuda_0) # 18 "ptm.cu" {__device_stub__Z7print_SM1Si (__cuda_0);}   

these "long" By intersecting the generated code to convert "int s :: *" s, and working correctly. Extra zero __device_stub__Z7print_SM1Si (int S :: *); sh NY __device_stub__Z7print_SM1Si (int S :: * __par0) {if (CudaSetupArgument ((void *) (char *) & __ par0, sizeof (__ par0), (size_t) 0UL) = cudaSuccess; return; {volatile static char * __ f __tytb __ ((unused); __f = ((four *) ((zero (*) (int s :: *)) print_S); (yd) cudlawn ((four *) ((zero (*) (Int S :: *)) print_S)));};} # 18 "ptm.cu" void print_S (Int S :: * __cuda_0) # 18 "ptm.cu" {__device_stub__Z7print_SM1Si (__cuda_0); }

It appears to be a boundary in the form of nvcc Has already indicated that I have filed a bug with the compiler team. They are aware of this issue. I do not have any more information about the potential updates or schedules.

A possible solution for Linux / Mac OS has been suggested:

  #include & lt; Stdio.h & gt; Template & lt; Typename T & gt; Structure Dummy {T Inner; T __Host__ __Devance__Mil (zero) {Return within; }; __host__ __device__ dummy (in t): internal (in) {}; }; Straight S {int F1; Int F2; Int F3; }; __Device__SX; __global__ zero initialize_S () {x.f1 = 100; X.F2 = 200; X.F3 = 300; } __global__ void print_S (dummy & lt; int S :: * & gt; m) {printf ("val:% d \ n", x. * (M.get ())); } int main () {initialize_S & lt; & Lt; & Lt; 1, 1 & gt; & Gt; & Gt; (); Print_S & lt; & Lt; & Lt; 1, 1 & gt; & Gt; & Gt; (Dummy & Lt; Int S: * & gt; (& S: F1)); CudaDeviceSynchronize (); }   

I can not comment on the utility above. The above compilation and running on CUDA 6.0 correctly

In addition, the use of a device-to-member appears to work properly in the device code. The extent described here is specific to its use when passed as a __ global __ function parameter.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -