@@ -441,6 +441,53 @@ def open_check_file(file_name):
441441 else :
442442 config .substitutions .append (("%cuda_options" , "" ))
443443
444+ # Check for HIP SDK
445+ check_hip_file = "hip_include.cpp"
446+ with open_check_file (check_hip_file ) as fp :
447+ print (
448+ textwrap .dedent (
449+ """
450+ #define __HIP_PLATFORM_AMD__ 1
451+ #include <hip/hip_runtime.h>
452+ int main() { hipError_t r = hipInit(0); return r; }
453+ """
454+ ),
455+ file = fp ,
456+ )
457+ config .hip_libs_dir = lit_config .params .get ("hip_libs_dir" , config .hip_libs_dir )
458+ config .hip_include = lit_config .params .get (
459+ "hip_include" ,
460+ (config .hip_include if config .hip_include else config .sycl_include ),
461+ )
462+
463+ hip_options = hip_options = (
464+ (" -L" + config .hip_libs_dir if config .hip_libs_dir else "" )
465+ + " -lamdhip64 "
466+ + " -I"
467+ + config .hip_include
468+ )
469+ if cl_options :
470+ hip_options = (
471+ " "
472+ + (
473+ config .hip_libs_dir + "/amdhip64.lib "
474+ if config .hip_libs_dir
475+ else "amdhip64.lib"
476+ )
477+ + " /I"
478+ + config .hip_include
479+ )
480+
481+ with test_env ():
482+ sp = subprocess .getstatusoutput (
483+ config .dpcpp_compiler + " -fsycl " + check_hip_file + hip_options
484+ )
485+ if sp [0 ] == 0 :
486+ config .available_features .add ("hip_dev_kit" )
487+ config .substitutions .append (("%hip_options" , hip_options ))
488+ else :
489+ config .substitutions .append (("%hip_options" , "" ))
490+
444491# Check for OpenCL ICD
445492if config .opencl_libs_dir :
446493 if cl_options :
@@ -585,13 +632,6 @@ def remove_level_zero_suffix(devices):
585632 if be not in available_devices or dev not in available_devices [be ]:
586633 lit_config .error ("Unsupported device {}" .format (d ))
587634
588- # Set ROCM_PATH to help clang find the HIP installation.
589- if "target-amd" in config .sycl_build_targets :
590- llvm_config .with_system_environment ("ROCM_PATH" )
591- config .substitutions .append (
592- ("%rocm_path" , os .environ .get ("ROCM_PATH" , "/opt/rocm" ))
593- )
594-
595635if "cuda:gpu" in config .sycl_devices :
596636 if "CUDA_PATH" not in os .environ :
597637 if platform .system () == "Windows" :
0 commit comments