From 6244599f990121c192001ceb58e7b91c947649d6 Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 20 Nov 2014 02:27:54 -0500 Subject: [PATCH] P4 to Git Change 1098949 by emankov@em-hsa-amd on 2014/11/20 02:16:39 ECR #333753 - Compiler Lib/aoc2/devloader: move devloader functionality into aoc2 [Purpose] To get rid of obsolete runtimenew dependency in compiler 1. Devloader functionality moved into aoc2; 2. Devloader is removed from the tree & make system; 3. Related changes in test_driver.pl; 4. Functions alignedMalloc & alignedFree are moved to libUtils.h; 5. Function aclHsaLoader is renamed to _aclHsaLoader to indicate that it is not a Compiler Lib API's function. [Testing] make smoke, pre check-in [Reviewers] Nikolay Haustov, Brian Sumner Affected files ... ... //depot/stg/opencl/drivers/opencl/Makefile#48 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/amdocl.def.in#10 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/amdocl.map.in#11 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/amdoclcl.def.in#8 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/amdoclcl.map.in#7 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/brig_loader.cpp#15 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/scwrapper/scClientAPI.cpp#20 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/libUtils.h#13 edit ... //depot/stg/opencl/drivers/opencl/compiler/loader/devloader/Makefile#8 delete ... //depot/stg/opencl/drivers/opencl/compiler/loader/devloader/build/Makefile#3 delete ... //depot/stg/opencl/drivers/opencl/compiler/loader/devloader/build/Makefile.devloader#11 delete ... //depot/stg/opencl/drivers/opencl/compiler/loader/devloader/devloader.cpp#6 delete ... //depot/stg/opencl/drivers/opencl/compiler/tools/aoc2/aoc2.cpp#61 edit ... //depot/stg/opencl/drivers/opencl/compiler/tools/aoc2/build/Makefile.aoc2#20 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#185 edit ... //depot/stg/opencl/drivers/opencl/tests/hsa/bin/test_driver.pl#5 edit --- rocclr/compiler/lib/amdoclcl.def.in | 2 +- rocclr/compiler/lib/amdoclcl.map.in | 2 +- rocclr/compiler/lib/utils/v0_8/libUtils.h | 26 +++++++++++++++++++++++ rocclr/runtime/device/gpu/gpuprogram.cpp | 4 ++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/rocclr/compiler/lib/amdoclcl.def.in b/rocclr/compiler/lib/amdoclcl.def.in index 0d8a7009e2..10cd7442c2 100644 --- a/rocclr/compiler/lib/amdoclcl.def.in +++ b/rocclr/compiler/lib/amdoclcl.def.in @@ -95,5 +95,5 @@ aclJITObjectImageDisassembleKernel aclJITObjectImageIterateSymbols aclJITObjectImageGetGlobalsSize #if defined(WITH_TARGET_HSAIL) -aclHsaLoader +_aclHsaLoader #endif diff --git a/rocclr/compiler/lib/amdoclcl.map.in b/rocclr/compiler/lib/amdoclcl.map.in index f2ee10dedc..9d54251784 100644 --- a/rocclr/compiler/lib/amdoclcl.map.in +++ b/rocclr/compiler/lib/amdoclcl.map.in @@ -95,7 +95,7 @@ global: aclJITObjectImageIterateSymbols; aclJITObjectImageGetGlobalsSize; #if defined(WITH_TARGET_HSAIL) - aclHsaLoader; + _aclHsaLoader; #endif #if defined(OPENCL_MAINLINE) local: diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.h b/rocclr/compiler/lib/utils/v0_8/libUtils.h index a38e54e8d0..83c59f2485 100644 --- a/rocclr/compiler/lib/utils/v0_8/libUtils.h +++ b/rocclr/compiler/lib/utils/v0_8/libUtils.h @@ -187,4 +187,30 @@ inline std::vector splitSpaceSeparatedString(char *str) return vec; } +// Helper function that allocates an aligned memory. +inline void* +alignedMalloc(size_t size, size_t alignment) +{ +#if defined(_WIN32) + return ::_aligned_malloc(size, alignment); +#else + void * ptr = NULL; + if (0 == ::posix_memalign(&ptr, alignment, size)) { + return ptr; + } + return NULL; +#endif +} + +// Helper function that frees an aligned memory. +inline void +alignedFree(void *ptr) +{ +#if defined(_WIN32) + ::_aligned_free(ptr); +#else + free(ptr); +#endif +} + #endif // _CL_LIB_UTILS_0_8_H_ diff --git a/rocclr/runtime/device/gpu/gpuprogram.cpp b/rocclr/runtime/device/gpu/gpuprogram.cpp index b72f10b4e5..3443fb7254 100644 --- a/rocclr/runtime/device/gpu/gpuprogram.cpp +++ b/rocclr/runtime/device/gpu/gpuprogram.cpp @@ -20,7 +20,7 @@ #include "hsa_ext_image.h" extern "C" bool -ACL_API_ENTRY aclHsaLoader( +ACL_API_ENTRY _aclHsaLoader( aclCompiler* compiler_handle, aclBinary* bin, void* userData, @@ -2137,7 +2137,7 @@ HSAILProgram::linkImpl(amd::option::Options* options) return false; } // ACL_TYPE_CG stage is always being performed - if (!aclHsaLoader(dev().hsaCompiler(), binaryElf_, this, &AllocateGPUMemory, + if (!_aclHsaLoader(dev().hsaCompiler(), binaryElf_, this, &AllocateGPUMemory, &DmaMemoryCopy, &GetSamplerObjectParams, &InitializeSamplerObject)) { buildLog_ += "Error while BRIG Codegen phase: loading BRIG globals in the ELF \n"; return false;