-
Notifications
You must be signed in to change notification settings - Fork 0
Problems with VSCode's IntelliSense syntax highlighting and HIP, ROCm
I had the problem where certain HIP-specific methods, functions and keywords were not properly syntax highlighted even though the correct compiler path and include paths were supplied to VSCode. hipcc
successfully compiled the program and I could run it just fine, but VSCode refused to acknowledge (red squiggly lines beneath) __global__
and hipGetDeviceProperties
to mention a few. It should be sufficient to include the #include <hip/hip_runtime.h>
header, so I took a look in the header, got re-directed to the hip_runtime_api.h
header and found out that the declaration and definition of hipGetDeviceProperties
was "locked behind" a preprocessor directive:
#if defined(__HIP_PLATFORM_AMD__) && !defined(__HIP_PLATFORM_NVIDIA__)
Simply adding #define __HIP__
to the very beginning of my program file, before any headers are included, made the code accessible to IntelliSense.
#define __HIP__
#include <hip/hip_runtime.h>
__device__ void dummy_kernel(char* in, char* out){}
int main()
{
hipDeviceProp_t devProp;
hipError_t err = hipGetDeviceProperties(&devProp, 0);
return 0;
}
Further, for making VSCode understand other HIP syntax like hipThreadIdx_x
I also had to add the following include paths to the IntelliSense Configurations in VSCode to keep the HIP headers know the location of other HIP headers:
/opt/rocm-6.0.0/include/hip/amd_detail
/opt/rocm-6.0.0/include/hip
/opt/rocm-6.0.0/lib/llvm/lib/clang/17.0.0/include
/opt/rocm-6.0.0/lib/llvm/lib/clang/17.0.0
Probably works without specifying 6.0.0 as /opt/rocm
is symlinked to /opt/rocm-6.0.0
in my case, but that might be different if you want to have several versions of ROCm installed at the same time, so I have just in case specified the version too. Also, in the same settings page, remember to tell VSCode the exact path to the hipcc
compiler that you are using, in my case
/opt/rocm-6.0.0/bin/hipcc