From e29dce945a0680f79f944045fc4e872f40cf66a4 Mon Sep 17 00:00:00 2001 From: Malachi Phillips Date: Mon, 19 Sep 2022 17:45:47 -0500 Subject: [PATCH 1/2] Make compiler_flags setting take precedence over the compiler flag env var --- src/occa/internal/modes/cuda/device.cpp | 6 +++--- src/occa/internal/modes/hip/device.cpp | 6 +++--- src/occa/internal/modes/opencl/device.cpp | 6 +++--- src/occa/internal/modes/serial/device.cpp | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/occa/internal/modes/cuda/device.cpp b/src/occa/internal/modes/cuda/device.cpp index d99a67f47..0a6c5b7c1 100644 --- a/src/occa/internal/modes/cuda/device.cpp +++ b/src/occa/internal/modes/cuda/device.cpp @@ -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("compiler_flags").size()) { + if (kernelProps.get("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"; } diff --git a/src/occa/internal/modes/hip/device.cpp b/src/occa/internal/modes/hip/device.cpp index 7b06770ea..390885ab6 100644 --- a/src/occa/internal/modes/hip/device.cpp +++ b/src/occa/internal/modes/hip/device.cpp @@ -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("compiler_flags").size()) { + if (kernelProps.get("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"; } diff --git a/src/occa/internal/modes/opencl/device.cpp b/src/occa/internal/modes/opencl/device.cpp index 16be70241..c5d090751 100644 --- a/src/occa/internal/modes/opencl/device.cpp +++ b/src/occa/internal/modes/opencl/device.cpp @@ -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"; diff --git a/src/occa/internal/modes/serial/device.cpp b/src/occa/internal/modes/serial/device.cpp index ce3df6586..4918265ca 100644 --- a/src/occa/internal/modes/serial/device.cpp +++ b/src/occa/internal/modes/serial/device.cpp @@ -193,12 +193,12 @@ namespace occa { #endif } - if (compilerLanguageFlag == sys::language::CPP && env::var("OCCA_CXXFLAGS").size()) { + if (kernelProps.get("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("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()) { From 01c1f6f37fe9491dd0d8f61ec7c722fa8ecad351 Mon Sep 17 00:00:00 2001 From: Malachi Phillips Date: Tue, 20 Sep 2022 08:50:23 -0500 Subject: [PATCH 2/2] Apply same change to SYCL backend. --- src/occa/internal/modes/dpcpp/utils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/occa/internal/modes/dpcpp/utils.cpp b/src/occa/internal/modes/dpcpp/utils.cpp index a9ac6fceb..ab2c9a2f4 100644 --- a/src/occa/internal/modes/dpcpp/utils.cpp +++ b/src/occa/internal/modes/dpcpp/utils.cpp @@ -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; }