[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
arsenm updated this revision to Diff 252715. arsenm added a comment. Herald added a subscriber: hiraditya. Handle wave64 library CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/AMDGPU.h clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1010.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1011.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1012.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc clang/test/Driver/amdgpu-visibility.cl clang/test/Driver/rocm-detect.cl clang/test/Driver/rocm-device-libs.cl clang/test/Driver/rocm-not-found.cl llvm/include/llvm/Support/TargetParser.h llvm/lib/Support/TargetParser.cpp Index: llvm/lib/Support/TargetParser.cpp === --- llvm/lib/Support/TargetParser.cpp +++ llvm/lib/Support/TargetParser.cpp @@ -99,9 +99,9 @@ {{"gfx906"},{"gfx906"}, GK_GFX906, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32}, {{"gfx908"},{"gfx908"}, GK_GFX908, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32}, {{"gfx909"},{"gfx909"}, GK_GFX909, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32}, - {{"gfx1010"}, {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32}, - {{"gfx1011"}, {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32}, - {{"gfx1012"}, {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32}, + {{"gfx1010"}, {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32}, + {{"gfx1011"}, {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32}, + {{"gfx1012"}, {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32}, }; const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef Table) { Index: llvm/include/llvm/Support/TargetParser.h === --- llvm/include/llvm/Support/TargetParser.h +++ llvm/include/llvm/Support/TargetParser.h @@ -151,7 +151,10 @@ // Common features. FEATURE_FAST_FMA_F32 = 1 << 4, - FEATURE_FAST_DENORMAL_F32 = 1 << 5 + FEATURE_FAST_DENORMAL_F32 = 1 << 5, + + // Wavefront 32 is available. + FEATURE_WAVE32 = 1 << 6 }; StringRef getArchNameAMDGCN(GPUKind AK); Index: clang/test/Driver/rocm-not-found.cl === --- /dev/null +++ clang/test/Driver/rocm-not-found.cl @@ -0,0 +1,11 @@ +// REQUIRES: clang-driver + +// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't +// find a ROCm install, unless -nogpulib was passed. + +// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib. + +// RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK +// OK-NOT: cannot find ROCm installation. Index: clang/test/Driver/rocm-device-libs.cl === --- /dev/null +++ clang/test/Driver/rocm-device-libs.cl @@ -0,0 +1,162 @@ +// REQUIRES: clang-driver +// REQUIRES: amdgpu-registered-target + +// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on + +// RUN:
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
arsenm updated this revision to Diff 252708. arsenm added a comment. Cleanup a bit. This should eventually merge with the HIP library handling when it switches to using clang cc1 instead of llc CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/AMDGPU.h clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc clang/test/Driver/amdgpu-visibility.cl clang/test/Driver/rocm-detect.cl clang/test/Driver/rocm-device-libs.cl clang/test/Driver/rocm-not-found.cl Index: clang/test/Driver/rocm-not-found.cl === --- /dev/null +++ clang/test/Driver/rocm-not-found.cl @@ -0,0 +1,11 @@ +// REQUIRES: clang-driver + +// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't +// find a ROCm install, unless -nogpulib was passed. + +// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib. + +// RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK +// OK-NOT: cannot find ROCm installation. Index: clang/test/Driver/rocm-device-libs.cl === --- /dev/null +++ clang/test/Driver/rocm-device-libs.cl @@ -0,0 +1,121 @@ +// REQUIRES: clang-driver +// REQUIRES: amdgpu-registered-target + +// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900 %s + + + +// Make sure the different denormal default is respected for gfx8 +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// Make sure the non-canonical name works +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=fiji \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX900 %s + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-finite-math-only \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-FINITE-ONLY,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa\ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-fp32-correctly-rounded-divide-sqrt \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
arsenm updated this revision to Diff 252692. arsenm added a comment. Use -nogpulib instead of -nodefaultlibs CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/AMDGPU.h clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc clang/test/Driver/amdgpu-visibility.cl clang/test/Driver/rocm-detect.cl clang/test/Driver/rocm-device-libs.cl clang/test/Driver/rocm-not-found.cl Index: clang/test/Driver/rocm-not-found.cl === --- /dev/null +++ clang/test/Driver/rocm-not-found.cl @@ -0,0 +1,11 @@ +// REQUIRES: clang-driver + +// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't +// find a ROCm install, unless -nogpulib was passed. + +// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib. + +// RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK +// OK-NOT: cannot find ROCm installation. Index: clang/test/Driver/rocm-device-libs.cl === --- /dev/null +++ clang/test/Driver/rocm-device-libs.cl @@ -0,0 +1,121 @@ +// REQUIRES: clang-driver +// REQUIRES: amdgpu-registered-target + +// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900 %s + + + +// Make sure the different denormal default is respected for gfx8 +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// Make sure the non-canonical name works +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=fiji \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX900 %s + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-finite-math-only \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-FINITE-ONLY,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa\ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-fp32-correctly-rounded-divide-sqrt \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
arsenm updated this revision to Diff 252630. arsenm added a comment. Herald added a subscriber: kerbowa. Rebase CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/AMDGPU.h clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc clang/test/Driver/amdgpu-visibility.cl clang/test/Driver/rocm-detect.cl clang/test/Driver/rocm-device-libs.cl clang/test/Driver/rocm-not-found.cl Index: clang/test/Driver/rocm-not-found.cl === --- /dev/null +++ clang/test/Driver/rocm-not-found.cl @@ -0,0 +1,11 @@ +// REQUIRES: clang-driver + +// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't +// find a ROCm install, unless -nodefaultlibs was passed. + +// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nodefaultlibs. + +// RUN: %clang -### -nodefaultlibs --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK +// OK-NOT: cannot find ROCm installation. Index: clang/test/Driver/rocm-device-libs.cl === --- /dev/null +++ clang/test/Driver/rocm-device-libs.cl @@ -0,0 +1,121 @@ +// REQUIRES: clang-driver +// REQUIRES: amdgpu-registered-target + +// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900 %s + + + +// Make sure the different denormal default is respected for gfx8 +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// Make sure the non-canonical name works +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=fiji \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX900 %s + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-finite-math-only \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-FINITE-ONLY,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa\ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-fp32-correctly-rounded-divide-sqrt \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
yaxunl added inline comments. Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:94 +llvm::sys::path::append(IncludePath, InstallPath, "include"); +#if 0 +llvm::sys::path::append(LibDevicePath, InstallPath, "lib", debugging code needs to be removed CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
yaxunl added a comment. Add Scott since this may affect comgr. Probably need to add -nodefaultlibs in comgr after this change. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
arsenm updated this revision to Diff 230197. arsenm added a comment. Rebase CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/AMDGPU.h clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl clang/test/Driver/Inputs/rocm-device-libs/lib/irif.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc clang/test/Driver/amdgpu-visibility.cl clang/test/Driver/rocm-detect.cl clang/test/Driver/rocm-device-libs.cl clang/test/Driver/rocm-not-found.cl Index: clang/test/Driver/rocm-not-found.cl === --- /dev/null +++ clang/test/Driver/rocm-not-found.cl @@ -0,0 +1,11 @@ +// REQUIRES: clang-driver + +// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't +// find a ROCm install, unless -nodefaultlibs was passed. + +// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nodefaultlibs. + +// RUN: %clang -### -nodefaultlibs --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK +// OK-NOT: cannot find ROCm installation. Index: clang/test/Driver/rocm-device-libs.cl === --- /dev/null +++ clang/test/Driver/rocm-device-libs.cl @@ -0,0 +1,121 @@ +// REQUIRES: clang-driver +// REQUIRES: amdgpu-registered-target + +// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900 %s + + + +// Make sure the different denormal default is respected for gfx8 +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// Make sure the non-canonical name works +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=fiji \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX900 %s + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-finite-math-only \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-FINITE-ONLY,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa\ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-fp32-correctly-rounded-divide-sqrt \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
arsenm marked an inline comment as done. arsenm added inline comments. Comment at: lib/Driver/ToolChains/AMDGPU.h:25 +/// TODO: Generalize to handle libclc. +class RocmInstallationDetector { +private: arsenm wrote: > yaxunl wrote: > > I don't think we should detect ROCm installation here. We are compiling > > code for amdgpu not only on ROCm, but also on amdgpu-pro and windows. Many > > cases, people want to compile code for amdgpu on systems without ROCm > > installed. > > > > Compiilng code for amdgpu does not really depend on ROCm. We only depend on > > device library. > > > > It makes more sense to have a AMDGPUDeviceLibDetector which works on ROCm, > > amdgpu-pro, and windows. Also we need an option -amdgpu-device-lib-path to > > override the default amdgpu device lib path. > Being able to cross compile without a rocm installation is one of my primary > goals here. I don't know what the install paths look like for those other > drivers. It would be best if everything could agree on a single default > install location for these to search, which is mostly a naming problem. In > the patch as-is, the rocm-path is serving as -amdgpu-device-lib-path, but > this is a naming question Except we don't have an omni-purpose bitcode library set. It's the ROCm-Device-Libs. rocm is the only semi-coherently defined platform at the moment CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
arsenm marked an inline comment as done. arsenm added inline comments. Comment at: lib/Driver/ToolChains/AMDGPU.h:25 +/// TODO: Generalize to handle libclc. +class RocmInstallationDetector { +private: yaxunl wrote: > I don't think we should detect ROCm installation here. We are compiling code > for amdgpu not only on ROCm, but also on amdgpu-pro and windows. Many cases, > people want to compile code for amdgpu on systems without ROCm installed. > > Compiilng code for amdgpu does not really depend on ROCm. We only depend on > device library. > > It makes more sense to have a AMDGPUDeviceLibDetector which works on ROCm, > amdgpu-pro, and windows. Also we need an option -amdgpu-device-lib-path to > override the default amdgpu device lib path. Being able to cross compile without a rocm installation is one of my primary goals here. I don't know what the install paths look like for those other drivers. It would be best if everything could agree on a single default install location for these to search, which is mostly a naming problem. In the patch as-is, the rocm-path is serving as -amdgpu-device-lib-path, but this is a naming question CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
yaxunl added inline comments. Comment at: lib/Driver/ToolChains/AMDGPU.h:25 +/// TODO: Generalize to handle libclc. +class RocmInstallationDetector { +private: I don't think we should detect ROCm installation here. We are compiling code for amdgpu not only on ROCm, but also on amdgpu-pro and windows. Many cases, people want to compile code for amdgpu on systems without ROCm installed. Compiilng code for amdgpu does not really depend on ROCm. We only depend on device library. It makes more sense to have a AMDGPUDeviceLibDetector which works on ROCm, amdgpu-pro, and windows. Also we need an option -amdgpu-device-lib-path to override the default amdgpu device lib path. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59321/new/ https://reviews.llvm.org/D59321 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs
arsenm created this revision. arsenm added reviewers: yaxunl, ashi1. Herald added subscribers: jdoerfert, t-tye, tpr, dstuttard, nhaehnle, wdng, jvesely, kzhuravl. This is pending finalization of what the device library build path/names are. I'm also not sure if some of the standard default library control flags should be used for these purposes, or if new ones are necessary https://reviews.llvm.org/D59321 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Options.td lib/Driver/Driver.cpp lib/Driver/ToolChains/AMDGPU.cpp lib/Driver/ToolChains/AMDGPU.h test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl test/Driver/Inputs/rocm-device-libs/lib/irif.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc test/Driver/amdgpu-visibility.cl test/Driver/rocm-detect.cl test/Driver/rocm-device-libs.cl test/Driver/rocm-not-found.cl Index: test/Driver/rocm-not-found.cl === --- /dev/null +++ test/Driver/rocm-not-found.cl @@ -0,0 +1,11 @@ +// REQUIRES: clang-driver + +// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't +// find a ROCm install, unless -nodefaultlibs was passed. + +// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR +// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nodefaultlibs. + +// RUN: %clang -### -nodefaultlibs --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK +// OK-NOT: cannot find ROCm installation. Index: test/Driver/rocm-device-libs.cl === --- /dev/null +++ test/Driver/rocm-device-libs.cl @@ -0,0 +1,121 @@ +// REQUIRES: clang-driver +// REQUIRES: amdgpu-registered-target + +// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900 %s + + + +// Make sure the different denormal default is respected for gfx8 +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// Make sure the non-canonical name works +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=fiji \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx900 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX900 %s + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-denorms-are-zero \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa \ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-finite-math-only \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \ +// RUN: %S/opencl.cl \ +// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-FINITE-ONLY,GFX803 %s + + + +// RUN: %clang -### -target amdgcn-amd-amdhsa\ +// RUN: -x cl -mcpu=gfx803 \ +// RUN: -cl-fp32-correctly-rounded-divide-sqrt \ +// RUN: --rocm-path=%S/Inputs/rocm-device-libs \