From 8fb7af2569b730860e484f8075597f955a7b5d62 Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 6 Oct 2016 13:35:57 -0400 Subject: [PATCH] P4 to Git Change 1323311 by lmoriche@lmoriche_opencl_dev on 2016/10/06 13:26:29 SWDEV-94610 - Set the -mcpu target, and add -m32/64. Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#23 edit [ROCm/clr commit: 075595662e915a3c1262eb1394ca6fe4fb7f1c46] --- .../runtime/device/rocm/roccompiler.cpp | 89 +++++++++---------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp b/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp index 5433a7b817..babf1204cd 100644 --- a/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp +++ b/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp @@ -64,6 +64,43 @@ HSAILProgram::compileImpl_LC( inputs.push_back(input); + Buffer* output = C->NewBuffer(DT_LLVM_BC); + if (output == NULL) { + buildLog_ += "Error while creating buffer for the LLVM bitcode"; + return false; + } + + //Set the options for the compiler + std::ostringstream ostrstr; + std::copy(options->clangOptions.begin(), options->clangOptions.end(), + std::ostream_iterator(ostrstr, " ")); + + ostrstr << " -m" << sizeof(void*) * 8; + std::string driverOptions(ostrstr.str()); + + const char* xLang = options->oVariables->XLang; + if (xLang != NULL && strcmp(xLang, "cl")) { + buildLog_ += "Unsupported OpenCL language.\n"; + } + + //FIXME_Nikolay: the program manager should be setting the language + //driverOptions.append(" -x cl"); + + driverOptions.append(" -cl-std=").append(options->oVariables->CLStd); + + // Set the -O# + std::ostringstream optLevel; + optLevel << " -O" << options->oVariables->OptLevel; + driverOptions.append(optLevel.str()); + + // Set the machine target + driverOptions.append(" -mcpu="); + driverOptions.append(dev().deviceInfo().machineTarget_); + + driverOptions.append(options->llvmOptions); + + driverOptions.append(preprocessorOptions(options)); + //Find the temp folder for the OS std::string tempFolder = amd::Os::getEnvironment("TEMP"); if (tempFolder.empty()) { @@ -116,62 +153,18 @@ HSAILProgram::compileImpl_LC( inputs.push_back(inc); } - - //Set the options for the compiler - std::ostringstream ostrstr; - std::copy(options->clangOptions.begin(), options->clangOptions.end(), - std::ostream_iterator(ostrstr, " ")); - std::string driverOptions(ostrstr.str()); - //Set the include path for the temp folder that contains the includes if(!headers.empty()) { driverOptions.append(" -I"); driverOptions.append(tempFolder); } - const char* xLang = options->oVariables->XLang; - if (xLang != NULL && strcmp(xLang, "cl")) { - buildLog_ += "Unsupported OpenCL language.\n"; - } - - //FIXME_Nikolay: the program manager should be setting the language - //driverOptions.append(" -x cl"); - - driverOptions.append(" -cl-std=").append(options->oVariables->CLStd); - - // Set the -O# - std::ostringstream optLevel; - optLevel << " -O" << options->oVariables->OptLevel; - driverOptions.append(optLevel.str()); - - //FIXME_lmoriche: has the CL option been validated? - uint clcStd = (options->oVariables->CLStd[2] - '0') * 100 - + (options->oVariables->CLStd[4] - '0') * 10; - - driverOptions.append(preprocessorOptions(options)); - - Buffer* output = C->NewBuffer(DT_LLVM_BC); - if (output == NULL) { - buildLog_ += "Error while creating buffer for the LLVM bitcode"; - return false; - } - - driverOptions.append(options->llvmOptions); - - // Set fp32-denormals and fp64-denormals - bool fp32Denormals = !options->oVariables->DenormsAreZero - && dev().deviceInfo().gfxipVersion_ >= 900; - - driverOptions.append(" -Xclang -target-feature -Xclang "); - driverOptions.append(fp32Denormals ? "+" : "-") - .append("fp32-denormals,+fp64-denormals"); - if (options->isDumpFlagSet(amd::option::DUMP_CL)) { std::ofstream f(options->getDumpFileName(".cl").c_str(), std::ios::trunc); if(f.is_open()) { f << "/* Compiler options:\n" \ - "-c -emit-llvm -target amdgcn-amd-amdhsa-opencl -x cl" \ - " -include opencl-c.h " << driverOptions + "-c -emit-llvm -target amdgcn-amd-amdhsa-opencl -x cl " + << driverOptions << " -include opencl-c.h " << "\n*/\n\n" << sourceCode; } else { buildLog_ += @@ -179,6 +172,10 @@ HSAILProgram::compileImpl_LC( } } + //FIXME_lmoriche: has the CL option been validated? + uint clcStd = (options->oVariables->CLStd[2] - '0') * 100 + + (options->oVariables->CLStd[4] - '0') * 10; + std::pair hdr; switch(clcStd) { case 120: