From 4ccb3b0eefc06631adb2608710e5ca67d2f9ddfa Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 17 Jul 2014 08:03:17 -0400 Subject: [PATCH] P4 to Git Change 1056202 by emankov@em-hsa-amd on 2014/07/17 07:56:29 ECR #333753 - Compiler Lib: Error if wrong combination of march & OpenCL version HSAIL doesn't support OpenCL version < 2.0 AMDIL doesn't support OpenCL version >= 2.0 Affects only ORCA builds (both 1.2 & 2.0), doesn't affect .hsa build. Testing: smoke_clang, pre check-in Reviewer: Stanislav Mekhanoshin Affected files ... ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/v0_8/if_acl.cpp#38 edit [ROCm/clr commit: 4798473034b9fb7e8d0f7bd246e630535b234166] --- .../lib/backends/common/v0_8/if_acl.cpp | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp b/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp index d46590af92..a5b4b862e2 100644 --- a/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp +++ b/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp @@ -1275,6 +1275,23 @@ internal_compile_failure: #define CONDITIONAL_CMP_ASSIGN(A, B, C) A = (A && B != A) ? (A) : (C) +acl_error +IsValidCompilationOptions(aclBinary *bin) +{ +#if defined(WITH_TARGET_HSAIL) && defined(WITH_TARGET_AMDIL) + amd::option::Options* opts = reinterpret_cast(bin->options); + std::string major = std::string(opts->oVariables->CLStd).substr(2,1); + if (isHSAILTarget(bin->target) && major == "1") { + std::cout << "Error: HSAIL doesn't support OpenCL version < 2.0" << std::endl; + return ACL_INVALID_OPTION; + } + if (isAMDILTarget(bin->target) && major == "2") { + std::cout << "Error: AMDIL doesn't support OpenCL version >= 2.0" << std::endl; + return ACL_INVALID_OPTION; + } +#endif + return ACL_SUCCESS; +} acl_error ACL_API_ENTRY if_aclCompile(aclCompiler *cl, @@ -1284,10 +1301,13 @@ if_aclCompile(aclCompiler *cl, aclType to, aclLogFunction compile_callback) { - acl_error error_code = ACL_SUCCESS; if (bin == NULL || cl == NULL) { return ACL_INVALID_ARG; } + acl_error error_code = IsValidCompilationOptions(bin); + if (error_code != ACL_SUCCESS) { + return error_code; + } #ifdef WITH_TARGET_HSAIL if (isHSAILTarget(bin->target)) { #ifndef DEBUG