Skip to content

Commit

Permalink
[HIP] Enable specifying different default gpu arch for HIP/CUDA.
Browse files Browse the repository at this point in the history
Reviewers: tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68394

llvm-svn: 373634
  • Loading branch information
darkbuck committed Oct 3, 2019
1 parent 9c1503f commit 691e44c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 11 additions & 3 deletions clang/lib/Driver/Driver.cpp
Expand Up @@ -2329,6 +2329,10 @@ class OffloadingActionBuilder final {

/// Flag for -fgpu-rdc.
bool Relocatable = false;

/// Default GPU architecture if there's no one specified.
CudaArch DefaultCudaArch = CudaArch::UNKNOWN;

public:
CudaActionBuilderBase(Compilation &C, DerivedArgList &Args,
const Driver::InputList &Inputs,
Expand Down Expand Up @@ -2518,7 +2522,7 @@ class OffloadingActionBuilder final {
// supported GPUs. sm_20 code should work correctly, if
// suboptimally, on all newer GPUs.
if (GpuArchList.empty())
GpuArchList.push_back(CudaArch::SM_20);
GpuArchList.push_back(DefaultCudaArch);

return Error;
}
Expand All @@ -2530,7 +2534,9 @@ class OffloadingActionBuilder final {
public:
CudaActionBuilder(Compilation &C, DerivedArgList &Args,
const Driver::InputList &Inputs)
: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {}
: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
DefaultCudaArch = CudaArch::SM_20;
}

ActionBuilderReturnCode
getDeviceDependences(OffloadAction::DeviceDependences &DA,
Expand Down Expand Up @@ -2645,7 +2651,9 @@ class OffloadingActionBuilder final {
public:
HIPActionBuilder(Compilation &C, DerivedArgList &Args,
const Driver::InputList &Inputs)
: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {}
: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
DefaultCudaArch = CudaArch::GFX803;
}

bool canUseBundlerUnbundler() const override { return true; }

Expand Down
7 changes: 7 additions & 0 deletions clang/test/Driver/hip-default-gpu-arch.hip
@@ -0,0 +1,7 @@
// REQUIRES: clang-driver
// REQUIRES: x86-registered-target
// REQUIRES: amdgpu-registered-target

// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s

// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803"

0 comments on commit 691e44c

Please sign in to comment.