P4 to Git Change 1398063 by lmoriche@lmoriche_opencl_dev2 on 2017/04/13 12:12:33

SWDEV-102733 - [OCL-LC-ROCm] Cmake build Write CMakeLists.txt to enable building with and without the DK environment
	- Make it possible to build with libstdc++

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#19 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/utils/libelf/memfile.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/appprofile.cpp#16 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#19 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#63 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#22 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#126 edit
... //depot/stg/opencl/drivers/opencl/runtime/thread/semaphore.cpp#9 edit


[ROCm/clr commit: a615e4fbb6]
This commit is contained in:
foreman
2017-04-13 12:17:47 -04:00
parent 2b2c709a6b
commit 211ca254bf
8 changed files with 31 additions and 20 deletions
@@ -9,6 +9,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <cstring>
#if defined(__GNUC__) #if defined(__GNUC__)
#include <unistd.h> #include <unistd.h>
@@ -8,6 +8,7 @@
#include "appprofile.hpp" #include "appprofile.hpp"
#include "adl.h" #include "adl.h"
#include <cstdlib> #include <cstdlib>
#include <cstring>
#ifdef BRAHMA #ifdef BRAHMA
extern int SearchProfileOfAnApplication(const wchar_t* fileName, ADLApplicationProfile ** lppProfile); extern int SearchProfileOfAnApplication(const wchar_t* fileName, ADLApplicationProfile ** lppProfile);
@@ -7,6 +7,7 @@
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <iterator>
#include "os/os.hpp" #include "os/os.hpp"
#include "rocdevice.hpp" #include "rocdevice.hpp"
@@ -52,7 +53,7 @@ HSAILProgram::compileImpl_LC(
amd::option::Options* options) amd::option::Options* options)
{ {
using namespace amd::opencl_driver; using namespace amd::opencl_driver;
std::auto_ptr<Compiler> C(newCompilerInstance()); std::unique_ptr<Compiler> C(newCompilerInstance());
std::vector<Data*> inputs; std::vector<Data*> inputs;
Data* input = C->NewBufferReference(DT_CL, Data* input = C->NewBufferReference(DT_CL,
@@ -390,24 +391,31 @@ checkLLVM_BIN()
} }
} }
#if defined(DEBUG) #if defined(DEBUG)
std::string clangExe(llvmBin_ + "/clang"); static const std::string tools[] = { "clang", "llvm-link", "ld.lld" };
struct stat buf;
if (stat(clangExe.c_str(), &buf)) { for (const std::string tool : tools) {
std::string msg("Could not find the Clang binary in " + llvmBin_); std::string exePath(llvmBin_ + "/" + tool);
LogWarning(msg.c_str()); struct stat buf;
if (stat(exePath.c_str(), &buf)) {
std::string msg(exePath + " not found");
LogWarning(msg.c_str());
}
else if ((buf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0) {
std::string msg("Cannot execute " + exePath);
LogWarning(msg.c_str());
}
} }
#endif // defined(DEBUG) #endif // defined(DEBUG)
} }
#endif // defined(ATI_OS_LINUX) #endif // defined(ATI_OS_LINUX)
std::auto_ptr<amd::opencl_driver::Compiler> amd::opencl_driver::Compiler*
HSAILProgram::newCompilerInstance() HSAILProgram::newCompilerInstance()
{ {
#if defined(ATI_OS_LINUX) #if defined(ATI_OS_LINUX)
pthread_once(&once, checkLLVM_BIN); pthread_once(&once, checkLLVM_BIN);
#endif // defined(ATI_OS_LINUX) #endif // defined(ATI_OS_LINUX)
return std::auto_ptr<amd::opencl_driver::Compiler>( return amd::opencl_driver::CompilerFactory().CreateAMDGPUCompiler(llvmBin_);
amd::opencl_driver::CompilerFactory().CreateAMDGPUCompiler(llvmBin_));
} }
#endif // defined(WITH_LIGHTNING_COMPILER) #endif // defined(WITH_LIGHTNING_COMPILER)
@@ -31,6 +31,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <memory>
/*! \addtogroup HSA /*! \addtogroup HSA
* @{ * @{
@@ -29,6 +29,7 @@
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include <istream> #include <istream>
#include <iterator>
namespace roc { namespace roc {
@@ -479,7 +480,7 @@ HSAILProgram::linkImpl_LC(
bool createLibrary) bool createLibrary)
{ {
using namespace amd::opencl_driver; using namespace amd::opencl_driver;
std::auto_ptr<Compiler> C(newCompilerInstance()); std::unique_ptr<Compiler> C(newCompilerInstance());
std::vector<Data*> inputs; std::vector<Data*> inputs;
for (auto program : (const std::vector<HSAILProgram*>&)inputPrograms) { for (auto program : (const std::vector<HSAILProgram*>&)inputPrograms) {
@@ -681,7 +682,7 @@ bool
HSAILProgram::linkImpl_LC(amd::option::Options *options) HSAILProgram::linkImpl_LC(amd::option::Options *options)
{ {
using namespace amd::opencl_driver; using namespace amd::opencl_driver;
std::auto_ptr<Compiler> C(newCompilerInstance()); std::unique_ptr<Compiler> C(newCompilerInstance());
// call LinkLLVMBitcode // call LinkLLVMBitcode
std::vector<Data*> inputs; std::vector<Data*> inputs;
@@ -175,7 +175,7 @@ private:
#if defined(WITH_LIGHTNING_COMPILER) #if defined(WITH_LIGHTNING_COMPILER)
CodeObjectMD* metadata_; //!< Runtime metadata CodeObjectMD* metadata_; //!< Runtime metadata
//! Return a new transient compiler instance. //! Return a new transient compiler instance.
static std::auto_ptr<amd::opencl_driver::Compiler> newCompilerInstance(); static amd::opencl_driver::Compiler* newCompilerInstance();
#endif // defined(WITH_LIGHTNING_COMPILER) #endif // defined(WITH_LIGHTNING_COMPILER)
}; };
@@ -87,12 +87,12 @@ Memory::Memory(
, isParent_(false) , isParent_(false)
, vDev_(NULL) , vDev_(NULL)
, forceSysMemAlloc_(false) , forceSysMemAlloc_(false)
, mapCount_(0)
, svmHostAddress_(svmPtr) , svmHostAddress_(svmPtr)
, svmPtrCommited_(false) , svmPtrCommited_(false)
, canBeCached_(true) , canBeCached_(true)
, lockMemoryOps_("Memory Ops Lock", true) , lockMemoryOps_("Memory Ops Lock", true)
{ {
std::atomic_init(&mapCount_, 0u);
} }
Memory::Memory( Memory::Memory(
@@ -117,6 +117,7 @@ Memory::Memory(
, isParent_(false) , isParent_(false)
, vDev_(NULL) , vDev_(NULL)
, forceSysMemAlloc_(false) , forceSysMemAlloc_(false)
, mapCount_(0)
, svmHostAddress_(parent.getSvmPtr()) , svmHostAddress_(parent.getSvmPtr())
, svmPtrCommited_(parent.isSvmPtrCommited()) , svmPtrCommited_(parent.isSvmPtrCommited())
, canBeCached_(true) , canBeCached_(true)
@@ -144,8 +145,6 @@ Memory::Memory(
(CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_WRITE_ONLY | (CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_WRITE_ONLY |
CL_MEM_HOST_NO_ACCESS); CL_MEM_HOST_NO_ACCESS);
} }
std::atomic_init(&mapCount_, 0u);
} }
void void
@@ -1284,11 +1283,11 @@ static int
round_to_even(float v) round_to_even(float v)
{ {
// clamp overflow // clamp overflow
if (v >= -(float)INT_MIN) { if (v >= -(float)std::numeric_limits<int>::min()) {
return INT_MAX; return std::numeric_limits<int>::max();
} }
if (v <= (float)INT_MIN) { if (v <= (float)std::numeric_limits<int>::min()) {
return INT_MIN; return std::numeric_limits<int>::min();
} }
static const unsigned int magic[2] = { 0x4b000000u, 0xcb000000u }; static const unsigned int magic[2] = { 0x4b000000u, 0xcb000000u };
@@ -15,8 +15,8 @@
namespace amd { namespace amd {
Semaphore::Semaphore() Semaphore::Semaphore()
: state_(0)
{ {
std::atomic_init(&state_, 0);
#ifdef _WIN32 #ifdef _WIN32
handle_ = static_cast<void*>(CreateSemaphore(NULL, 0, LONG_MAX, NULL)); handle_ = static_cast<void*>(CreateSemaphore(NULL, 0, LONG_MAX, NULL));
assert(handle_ != NULL && "CreateSemaphore failed"); assert(handle_ != NULL && "CreateSemaphore failed");