From 211ca254bfa663dca2ccdca88ca37f52a30818d1 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 13 Apr 2017 12:17:47 -0400
Subject: [PATCH] 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: a615e4fbb6b88622783aec7573c7260a776ece6b]
---
.../lib/loaders/elf/utils/libelf/memfile.cpp | 1 +
.../clr/rocclr/runtime/device/appprofile.cpp | 1 +
.../runtime/device/rocm/roccompiler.cpp | 26 ++++++++++++-------
.../rocclr/runtime/device/rocm/rocdevice.hpp | 1 +
.../rocclr/runtime/device/rocm/rocprogram.cpp | 5 ++--
.../rocclr/runtime/device/rocm/rocprogram.hpp | 2 +-
.../clr/rocclr/runtime/platform/memory.cpp | 13 +++++-----
.../clr/rocclr/runtime/thread/semaphore.cpp | 2 +-
8 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/projects/clr/rocclr/compiler/lib/loaders/elf/utils/libelf/memfile.cpp b/projects/clr/rocclr/compiler/lib/loaders/elf/utils/libelf/memfile.cpp
index 651c1a7505..721e3cd20b 100644
--- a/projects/clr/rocclr/compiler/lib/loaders/elf/utils/libelf/memfile.cpp
+++ b/projects/clr/rocclr/compiler/lib/loaders/elf/utils/libelf/memfile.cpp
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#if defined(__GNUC__)
#include
diff --git a/projects/clr/rocclr/runtime/device/appprofile.cpp b/projects/clr/rocclr/runtime/device/appprofile.cpp
index 16e49986e6..b9181478ca 100644
--- a/projects/clr/rocclr/runtime/device/appprofile.cpp
+++ b/projects/clr/rocclr/runtime/device/appprofile.cpp
@@ -8,6 +8,7 @@
#include "appprofile.hpp"
#include "adl.h"
#include
+#include
#ifdef BRAHMA
extern int SearchProfileOfAnApplication(const wchar_t* fileName, ADLApplicationProfile ** lppProfile);
diff --git a/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp b/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp
index f277addbe4..d6d3cfa552 100644
--- a/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp
+++ b/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
#include "os/os.hpp"
#include "rocdevice.hpp"
@@ -52,7 +53,7 @@ HSAILProgram::compileImpl_LC(
amd::option::Options* options)
{
using namespace amd::opencl_driver;
- std::auto_ptr C(newCompilerInstance());
+ std::unique_ptr C(newCompilerInstance());
std::vector inputs;
Data* input = C->NewBufferReference(DT_CL,
@@ -390,24 +391,31 @@ checkLLVM_BIN()
}
}
#if defined(DEBUG)
- std::string clangExe(llvmBin_ + "/clang");
- struct stat buf;
- if (stat(clangExe.c_str(), &buf)) {
- std::string msg("Could not find the Clang binary in " + llvmBin_);
- LogWarning(msg.c_str());
+ static const std::string tools[] = { "clang", "llvm-link", "ld.lld" };
+
+ for (const std::string tool : tools) {
+ std::string exePath(llvmBin_ + "/" + tool);
+ 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(ATI_OS_LINUX)
-std::auto_ptr
+amd::opencl_driver::Compiler*
HSAILProgram::newCompilerInstance()
{
#if defined(ATI_OS_LINUX)
pthread_once(&once, checkLLVM_BIN);
#endif // defined(ATI_OS_LINUX)
- return std::auto_ptr(
- amd::opencl_driver::CompilerFactory().CreateAMDGPUCompiler(llvmBin_));
+ return amd::opencl_driver::CompilerFactory().CreateAMDGPUCompiler(llvmBin_);
}
#endif // defined(WITH_LIGHTNING_COMPILER)
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocdevice.hpp b/projects/clr/rocclr/runtime/device/rocm/rocdevice.hpp
index 5481789772..f381545cd1 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocdevice.hpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocdevice.hpp
@@ -31,6 +31,7 @@
#include
#include
+#include
/*! \addtogroup HSA
* @{
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp b/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp
index 48e49c4cea..2f6f0e2a3a 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp
@@ -29,6 +29,7 @@
#include
#include
#include
+#include
namespace roc {
@@ -479,7 +480,7 @@ HSAILProgram::linkImpl_LC(
bool createLibrary)
{
using namespace amd::opencl_driver;
- std::auto_ptr C(newCompilerInstance());
+ std::unique_ptr C(newCompilerInstance());
std::vector inputs;
for (auto program : (const std::vector&)inputPrograms) {
@@ -681,7 +682,7 @@ bool
HSAILProgram::linkImpl_LC(amd::option::Options *options)
{
using namespace amd::opencl_driver;
- std::auto_ptr C(newCompilerInstance());
+ std::unique_ptr C(newCompilerInstance());
// call LinkLLVMBitcode
std::vector inputs;
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp b/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp
index 451dd96650..a9ab7d2191 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp
@@ -175,7 +175,7 @@ private:
#if defined(WITH_LIGHTNING_COMPILER)
CodeObjectMD* metadata_; //!< Runtime metadata
//! Return a new transient compiler instance.
- static std::auto_ptr newCompilerInstance();
+ static amd::opencl_driver::Compiler* newCompilerInstance();
#endif // defined(WITH_LIGHTNING_COMPILER)
};
diff --git a/projects/clr/rocclr/runtime/platform/memory.cpp b/projects/clr/rocclr/runtime/platform/memory.cpp
index 9370e6c53f..7c409339f7 100644
--- a/projects/clr/rocclr/runtime/platform/memory.cpp
+++ b/projects/clr/rocclr/runtime/platform/memory.cpp
@@ -87,12 +87,12 @@ Memory::Memory(
, isParent_(false)
, vDev_(NULL)
, forceSysMemAlloc_(false)
+ , mapCount_(0)
, svmHostAddress_(svmPtr)
, svmPtrCommited_(false)
, canBeCached_(true)
, lockMemoryOps_("Memory Ops Lock", true)
{
- std::atomic_init(&mapCount_, 0u);
}
Memory::Memory(
@@ -117,6 +117,7 @@ Memory::Memory(
, isParent_(false)
, vDev_(NULL)
, forceSysMemAlloc_(false)
+ , mapCount_(0)
, svmHostAddress_(parent.getSvmPtr())
, svmPtrCommited_(parent.isSvmPtrCommited())
, canBeCached_(true)
@@ -144,8 +145,6 @@ Memory::Memory(
(CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_WRITE_ONLY |
CL_MEM_HOST_NO_ACCESS);
}
-
- std::atomic_init(&mapCount_, 0u);
}
void
@@ -1284,11 +1283,11 @@ static int
round_to_even(float v)
{
// clamp overflow
- if (v >= -(float)INT_MIN) {
- return INT_MAX;
+ if (v >= -(float)std::numeric_limits::min()) {
+ return std::numeric_limits::max();
}
- if (v <= (float)INT_MIN) {
- return INT_MIN;
+ if (v <= (float)std::numeric_limits::min()) {
+ return std::numeric_limits::min();
}
static const unsigned int magic[2] = { 0x4b000000u, 0xcb000000u };
diff --git a/projects/clr/rocclr/runtime/thread/semaphore.cpp b/projects/clr/rocclr/runtime/thread/semaphore.cpp
index 235ca45d9a..d443163b29 100644
--- a/projects/clr/rocclr/runtime/thread/semaphore.cpp
+++ b/projects/clr/rocclr/runtime/thread/semaphore.cpp
@@ -15,8 +15,8 @@
namespace amd {
Semaphore::Semaphore()
+ : state_(0)
{
- std::atomic_init(&state_, 0);
#ifdef _WIN32
handle_ = static_cast(CreateSemaphore(NULL, 0, LONG_MAX, NULL));
assert(handle_ != NULL && "CreateSemaphore failed");