Skip to content

Commit

Permalink
Make compiler_flags setting take precedence over the compiler flag en…
Browse files Browse the repository at this point in the history
…v var (#622)

* Make compiler_flags setting take precedence over the compiler flag env var

* Apply same change to SYCL backend.
  • Loading branch information
MalachiTimothyPhillips authored Sep 28, 2022
1 parent eaef90e commit 50a8a9b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/occa/internal/modes/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ namespace occa {
compiler = "nvcc";
}

if (env::var("OCCA_CUDA_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_CUDA_COMPILER_FLAGS");
} else if (kernelProps.get<std::string>("compiler_flags").size()) {
if (kernelProps.get<std::string>("compiler_flags").size()) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (env::var("OCCA_CUDA_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_CUDA_COMPILER_FLAGS");
} else {
compilerFlags = "-O3";
}
Expand Down
8 changes: 4 additions & 4 deletions src/occa/internal/modes/dpcpp/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ namespace occa
void setCompilerFlags(occa::json &dpcpp_properties) noexcept
{
std::string compiler_flags;
if (env::var("OCCA_DPCPP_COMPILER_FLAGS").size())
if (dpcpp_properties.has("compiler_flags"))
{
compiler_flags = env::var("OCCA_DPCPP_COMPILER_FLAGS");
compiler_flags = dpcpp_properties["compiler_flags"].toString();
}
else if (dpcpp_properties.has("compiler_flags"))
else if (env::var("OCCA_DPCPP_COMPILER_FLAGS").size())
{
compiler_flags = dpcpp_properties["compiler_flags"].toString();
compiler_flags = env::var("OCCA_DPCPP_COMPILER_FLAGS");
}
dpcpp_properties["compiler_flags"] = compiler_flags;
}
Expand Down
6 changes: 3 additions & 3 deletions src/occa/internal/modes/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ namespace occa {
compiler = "hipcc";
}

if (env::var("OCCA_HIP_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_HIP_COMPILER_FLAGS");
} else if (kernelProps.get<std::string>("compiler_flags").size()) {
if (kernelProps.get<std::string>("compiler_flags").size()) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (env::var("OCCA_HIP_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_HIP_COMPILER_FLAGS");
} else {
compilerFlags = "-O3";
}
Expand Down
6 changes: 3 additions & 3 deletions src/occa/internal/modes/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ namespace occa {
std::string compilerFlags;

// Use "-cl-opt-disable" for debug-mode
if (env::var("OCCA_OPENCL_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_OPENCL_COMPILER_FLAGS");
} else if (kernelProps.has("compiler_flags")) {
if (kernelProps.has("compiler_flags")) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (env::var("OCCA_OPENCL_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_OPENCL_COMPILER_FLAGS");
}

std::string ocl_c_ver = "2.0";
Expand Down
6 changes: 3 additions & 3 deletions src/occa/internal/modes/serial/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ namespace occa {
#endif
}

if (compilerLanguageFlag == sys::language::CPP && env::var("OCCA_CXXFLAGS").size()) {
if (kernelProps.get<std::string>("compiler_flags").size()) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (compilerLanguageFlag == sys::language::CPP && env::var("OCCA_CXXFLAGS").size()) {
compilerFlags = env::var("OCCA_CXXFLAGS");
} else if (compilerLanguageFlag == sys::language::C && env::var("OCCA_CFLAGS").size()) {
compilerFlags = env::var("OCCA_CFLAGS");
} else if (kernelProps.get<std::string>("compiler_flags").size()) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (compilerLanguageFlag == sys::language::CPP && env::var("CXXFLAGS").size()) {
compilerFlags = env::var("CXXFLAGS");
} else if (compilerLanguageFlag == sys::language::C && env::var("CFLAGS").size()) {
Expand Down

0 comments on commit 50a8a9b

Please sign in to comment.