HIP-CPU icon indicating copy to clipboard operation
HIP-CPU copied to clipboard

Problems to compile

Open vwcruzeiro opened this issue 2 years ago • 1 comments

Hello! We are facing problems compiling HIP-CPU and I am wondering if someone could help us out. Maybe we are missing something...

Trying to compile in a machine with Intel CPUs and AMD GPUs. We have HIP 4.4.21401-bedc5f61 (the latest one we could install), TBB 2018, GCC 7.2.0 and CMake 3.16.4.

When we run the following commands:

mkdir build cd build cmake .. -DCMAKE_CXX_FLAGS="$(hipconfig --cpp_config)" make install

This is what we get:

Scanning dependencies of target bit_extract [ 1%] Building CXX object examples/bit_extract/CMakeFiles/bit_extract.dir/bit_extract.cpp.o /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp: In function ‘void bit_extract_kernel(uint32_t*, const uint32_t*, size_t)’: /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:24:21: error: ‘blockIdx’ was not declared in this scope size_t offset = blockIdx.x * blockDim.x + threadIdx.x; ^~~~~~~~ /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:24:21: note: suggested alternative: ‘clock’ size_t offset = blockIdx.x * blockDim.x + threadIdx.x; ^~~~~~~~ clock /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:24:34: error: ‘blockDim’ was not declared in this scope size_t offset = blockIdx.x * blockDim.x + threadIdx.x; ^~~~~~~~ /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:24:34: note: suggested alternative: ‘clock’ size_t offset = blockIdx.x * blockDim.x + threadIdx.x; ^~~~~~~~ clock /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:24:47: error: ‘threadIdx’ was not declared in this scope size_t offset = blockIdx.x * blockDim.x + threadIdx.x; ^~~~~~~~~ /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:24:47: note: suggested alternative: ‘pthread_t’ size_t offset = blockIdx.x * blockDim.x + threadIdx.x; ^~~~~~~~~ pthread_t /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:25:34: error: ‘gridDim’ was not declared in this scope size_t stride = blockDim.x * gridDim.x; ^~~~~~~ /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:29:18: error: ‘__bitextract_u32’ was not declared in this scope C_d[i] = __bitextract_u32(A_d[i], 8, 4); ^~~~~~~~~~~~~~~~ /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:29:18: note: suggested alternative: ‘__restrict_arr’ C_d[i] = __bitextract_u32(A_d[i], 8, 4); ^~~~~~~~~~~~~~~~ __restrict_arr /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp: In function ‘int main()’: /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:73:9: error: ‘hipLaunchKernelGGL’ was not declared in this scope hipLaunchKernelGGL(bit_extract_kernel, dim3(blocks), dim3(threadsPerBlock), 0, 0, C_d, A_d, N); ^~~~~~~~~~~~~~~~~~ /u/cruzeiro/hip-cpu/examples/bit_extract/bit_extract.cpp:73:9: note: suggested alternative: ‘hipLaunchKernel’ hipLaunchKernelGGL(bit_extract_kernel, dim3(blocks), dim3(threadsPerBlock), 0, 0, C_d, A_d, N); ^~~~~~~~~~~~~~~~~~ hipLaunchKernel make[2]: *** [examples/bit_extract/CMakeFiles/bit_extract.dir/bit_extract.cpp.o] Error 1 make[1]: *** [examples/bit_extract/CMakeFiles/bit_extract.dir/all] Error 2 make: *** [all] Error 2

We also tried using hipcc instead of GCC: CXX=hipcc cmake .. -DCMAKE_CXX_FLAGS="$(hipconfig --cpp_config)" . And this is what we get:

Scanning dependencies of target occupancy [ 20%] Building CXX object examples/occupancy/CMakeFiles/occupancy.dir/occupancy.cpp.o /u/cruzeiro/hip-cpu/examples/occupancy/occupancy.cpp:54:12: error: no matching function for call to 'hipOccupancyMaxPotentialBlockSize' HIP_CHECK(hipOccupancyMaxPotentialBlockSize(&mingridSize, &blockSize, multiply, 0, 0)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /u/cruzeiro/hip-cpu/examples/occupancy/occupancy.cpp:11:9: note: expanded from macro 'HIP_CHECK' if (status != hipSuccess) {
^~~~~~ /opt/rocm-4.5.0/hip/include/hip/hip_runtime_api.h:4473:35: note: candidate function template not viable: no known conversion from 'uint32_t *' (aka 'unsigned int ') to 'int ' for 1st argument static hipError_t host inline hipOccupancyMaxPotentialBlockSize(int gridSize, int blockSize, ^ /opt/rocm-4.5.0/hip/include/hip/hip_runtime_api.h:3722:12: note: candidate function not viable: no known conversion from 'uint32_t *' (aka 'unsigned int ') to 'int ' for 1st argument hipError_t hipOccupancyMaxPotentialBlockSize(int gridSize, int blockSize, ^ /opt/rocm-4.5.0/hip/include/hip/hip_runtime_api.h:4526:19: note: candidate function template not viable: no known conversion from 'uint32_t *' (aka 'unsigned int ') to 'int ' for 1st argument inline hipError_t hipOccupancyMaxPotentialBlockSize(int gridSize, int blockSize, ^ /u/cruzeiro/hip-cpu/examples/occupancy/occupancy.cpp:54:12: error: no matching function for call to 'hipOccupancyMaxPotentialBlockSize' HIP_CHECK(hipOccupancyMaxPotentialBlockSize(&mingridSize, &blockSize, multiply, 0, 0)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /u/cruzeiro/hip-cpu/examples/occupancy/occupancy.cpp:12:40: note: expanded from macro 'HIP_CHECK' std::cout << "Got Status: " << status << " at Line: " << LINE << std::endl;
^~~~~~ /opt/rocm-4.5.0/hip/include/hip/hip_runtime_api.h:4473:35: note: candidate function template not viable: no known conversion from 'uint32_t *' (aka 'unsigned int ') to 'int ' for 1st argument static hipError_t host inline hipOccupancyMaxPotentialBlockSize(int gridSize, int blockSize, ^ /opt/rocm-4.5.0/hip/include/hip/hip_runtime_api.h:3722:12: note: candidate function not viable: no known conversion from 'uint32_t *' (aka 'unsigned int ') to 'int ' for 1st argument hipError_t hipOccupancyMaxPotentialBlockSize(int gridSize, int blockSize, ^ /opt/rocm-4.5.0/hip/include/hip/hip_runtime_api.h:4526:19: note: candidate function template not viable: no known conversion from 'uint32_t *' (aka 'unsigned int ') to 'int ' for 1st argument inline hipError_t hipOccupancyMaxPotentialBlockSize(int gridSize, int blockSize, ^ 2 errors generated when compiling for gfx803. make[2]: *** [examples/occupancy/CMakeFiles/occupancy.dir/occupancy.cpp.o] Error 1 make[1]: *** [examples/occupancy/CMakeFiles/occupancy.dir/all] Error 2

Any ideas of what is wrong?

Thank you very much beforehand!

Vinicius Cruzeiro and Michael Miller

vwcruzeiro avatar Nov 05 '21 02:11 vwcruzeiro

HIP-CPU is self-contained and does not require a HIP install (in fact, it will clash with it, so mixing them is unsupported). We export a CMake namespaced target that you should pass to target_link_libraries which'll take care of setting everything up correctly in what regards the build. Having said that, I'm afraid GCC 7.2.0 is too old, and won't quite work (it doesn't have C++ standard support). Is there any chance to move to GCC 10 or later @vwcruzeiro?

AlexVlx avatar Jun 18 '22 00:06 AlexVlx