artyom-beilis / pytorch_dlprim

DLPrimitives/OpenCL out of tree backend for pytorch
http://blog.dlprimitives.org/
MIT License
227 stars 16 forks source link

Compile Error: cl_mem p=static_cast<cl_mem>(tt.getIntrusivePtr()->storage().data()); #40

Closed madtunebk closed 10 months ago

madtunebk commented 12 months ago

[ 86%] Building CXX object CMakeFiles/pt_ocl.dir/src/utils.cpp.o In file included from /home/nobus/stackwork/pytorch_dlprim/dlprimitives/include/dlprim/opencl_include.hpp:26, from /home/nobus/stackwork/pytorch_dlprim/dlprimitives/include/dlprim/context.hpp:9, from /home/nobus/stackwork/pytorch_dlprim/dlprimitives/include/dlprim/tensor.hpp:9, from /home/nobus/stackwork/pytorch_dlprim/dlprimitives/include/dlprim/core/common.hpp:9, from /home/nobus/stackwork/pytorch_dlprim/src/CLTensor.h:2, from /home/nobus/stackwork/pytorch_dlprim/src/utils.h:2, from /home/nobus/stackwork/pytorch_dlprim/src/utils.cpp:1: /usr/include/CL/cl2.hpp:18:151: note: ‘#pragma message: cl2.hpp has been renamed to opencl.hpp to make it clear that it supports all versions of OpenCL. Please include opencl.hpp directly.’ 18 | #pragma message("cl2.hpp has been renamed to opencl.hpp to make it clear that it supports all versions of OpenCL. Please include opencl.hpp directly.") | ^ /home/nobus/stackwork/pytorch_dlprim/src/utils.cpp: In function ‘cl::Buffer ptdlprim::buffer_from_tensor(const at::Tensor&)’: /home/nobus/stackwork/pytorch_dlprim/src/utils.cpp:38:18: error: ‘static_cast’ from type ‘const void’ to type ‘cl_mem’ {aka ‘_cl_mem’} casts away qualifiers 38 | cl_mem p=static_cast(tt.getIntrusivePtr()->storage().data()); | ^~~~~~~~~~~~~~~ make[2]: [CMakeFiles/pt_ocl.dir/build.make:160: CMakeFiles/pt_ocl.dir/src/utils.cpp.o] Error 1 make[1]: [CMakeFiles/Makefile2:100: CMakeFiles/pt_ocl.dir/all] Error 2 make: *** [Makefile:136: all] Error 2

postusername commented 10 months ago

Its looks like incorrect CV-qualifiers. I fixed it by patch src/utils.cpp with next code:

38 | cl_mem p=static_cast<cl_mem>(const_cast<void*>(tt.getIntrusivePtr()->storage().data()));
artyom-beilis commented 10 months ago

Its looks like incorrect CV-qualifiers. I fixed it by patch src/utils.cpp with next code:

Thanks, fixed and pushed