Skip to content

Commit

Permalink
Backout of Indexing changes
Browse files Browse the repository at this point in the history
Change-Id: Ife811c6561def33795c02886351750e129d9dc65
  • Loading branch information
sys-d3djenkins authored and paigeale committed Apr 25, 2018
1 parent 963b385 commit 858e183
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 1,231 deletions.
12 changes: 7 additions & 5 deletions IGC/AdaptorOCL/OCL/BuiltinResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Used by BuiltinResource.rc
//
#define OCL_BC_START 120
#define OCL_BC_ELF 120
#define OCL_BC_RS_COMMON 121
#define OCL_BC_RS_V1 122
#define OCL_BC_RS_V2 123
#define OCL_BC_END 124
#define OCL_BC_32 120
#define OCL_BC_64 121
#define OCL_BC 122
#define OCL_BC_RS_COMMON 123
#define OCL_BC_RS_V1 124
#define OCL_BC_RS_V2 125
#define OCL_BC_END 125

5 changes: 4 additions & 1 deletion IGC/AdaptorOCL/OCL/BuiltinResource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// BC
//
OCL_BC_ELF BIN "igdclbif.bin"

OCL_BC BC "OCLBiFImpl.bc"
OCL_BC_32 BC "IGCsize_t_32.bc"
OCL_BC_64 BC "IGCsize_t_64.bc"
/////////////////////////////////////////////////////////////////////////////

8 changes: 5 additions & 3 deletions IGC/AdaptorOCL/OCL/Resource/BuiltinResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Used by BuiltinResource.rc
//
#define OCL_BC_START 120
#define OCL_BC_ELF 120
#define OCL_BC_RS 121
#define OCL_BC_END 122
#define OCL_BC_32 120
#define OCL_BC_64 121
#define OCL_BC 122
#define OCL_BC_RS 123
#define OCL_BC_END 124

5 changes: 4 additions & 1 deletion IGC/AdaptorOCL/OCL/Resource/BuiltinResource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// BC
//
OCL_BC_ELF BIN "igdclbif.bin"

OCL_BC BC "OCLBiFImpl.bc"
OCL_BC_32 BC "IGCsize_t_32.bc"
OCL_BC_64 BC "IGCsize_t_64.bc"
/////////////////////////////////////////////////////////////////////////////

22 changes: 16 additions & 6 deletions IGC/AdaptorOCL/UnifyIROCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ namespace IGC

static void CommonOCLBasedPasses(
OpenCLProgramContext* pContext,
std::unique_ptr<llvm::Module> BuiltinGenericModule)
std::unique_ptr<llvm::Module> BuiltinGenericModule,
std::unique_ptr<llvm::Module> BuiltinSizeModule)
{
IGCPassManager mpm(pContext, "Unify");

Expand Down Expand Up @@ -194,6 +195,11 @@ static void CommonOCLBasedPasses(
}
pContext->getModule()->setDataLayout(dataLayout);
BuiltinGenericModule->setDataLayout(dataLayout);
if( BuiltinSizeModule )
{
BuiltinSizeModule->setDataLayout(dataLayout);
}

MetaDataUtils *pMdUtils = pContext->getMetaDataUtils();

//extracting OCL version major before SPIRMetadataTranslation pass deletes its metadata node
Expand Down Expand Up @@ -261,7 +267,7 @@ static void CommonOCLBasedPasses(
}

mpm.add(new PreBIImportAnalysis());
mpm.add(createBuiltInImportPass(std::move(BuiltinGenericModule)));
mpm.add(createBuiltInImportPass(std::move(BuiltinGenericModule), std::move(BuiltinSizeModule)));
mpm.add(new UndefinedReferencesPass());

// Estimate maximal function size in the module and disable subroutine if not profitable.
Expand Down Expand Up @@ -432,14 +438,16 @@ static void CommonOCLBasedPasses(

void UnifyIROCL(
OpenCLProgramContext* pContext,
std::unique_ptr<llvm::Module> BuiltinGenericModule)
std::unique_ptr<llvm::Module> BuiltinGenericModule,
std::unique_ptr<llvm::Module> BuiltinSizeModule)
{
CommonOCLBasedPasses(pContext, std::move(BuiltinGenericModule));
CommonOCLBasedPasses(pContext, std::move(BuiltinGenericModule), std::move(BuiltinSizeModule));
}

void UnifyIRSPIR(
OpenCLProgramContext* pContext,
std::unique_ptr<llvm::Module> BuiltinGenericModule)
std::unique_ptr<llvm::Module> BuiltinGenericModule,
std::unique_ptr<llvm::Module> BuiltinSizeModule)
{
int pointerSize = getPointerSize(*pContext->getModule());

Expand All @@ -448,13 +456,15 @@ void UnifyIRSPIR(
{
pContext->getModule()->setTargetTriple("vISA_32");
BuiltinGenericModule->setTargetTriple("vISA_32");
BuiltinSizeModule->setTargetTriple("vISA_32");
}
else // pointer size 64bit
{
pContext->getModule()->setTargetTriple("vISA_64");
BuiltinGenericModule->setTargetTriple("vISA_64");
BuiltinSizeModule->setTargetTriple("vISA_64");
}

CommonOCLBasedPasses(pContext, std::move(BuiltinGenericModule));
CommonOCLBasedPasses(pContext, std::move(BuiltinGenericModule), std::move(BuiltinSizeModule));
}
}
6 changes: 4 additions & 2 deletions IGC/AdaptorOCL/UnifyIROCL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ namespace IGC
{
void UnifyIROCL(
OpenCLProgramContext* pContext,
std::unique_ptr<llvm::Module> BuiltinGenericModule);
std::unique_ptr<llvm::Module> BuiltinGenericModule,
std::unique_ptr<llvm::Module> BuiltinSizeModule);

void UnifyIRSPIR(
OpenCLProgramContext* pContext,
std::unique_ptr<llvm::Module> BuiltinGenericModule);
std::unique_ptr<llvm::Module> BuiltinGenericModule,
std::unique_ptr<llvm::Module> BuiltinSizeModule);
}
61 changes: 51 additions & 10 deletions IGC/AdaptorOCL/dllInterfaceCompute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "Compiler/MetaDataApi/IGCMetaDataHelper.h"
#include "Compiler/MetaDataApi/IGCMetaDataDefs.h"
#include "Compiler/Optimizer/BuiltInFuncImport.h"

#include "common/debug/Dump.hpp"
#include "common/debug/Debug.hpp"
#include "common/igc_regkeys.hpp"
#include "common/secure_mem.h"

#include "CLElfLib/ElfReader.h"
#include "usc.h"

#include "AdaptorOCL/OCL/sp/gtpin_igc_ocl.h"
Expand Down Expand Up @@ -692,7 +692,9 @@ bool TranslateBuild(
do
{
std::unique_ptr<llvm::Module> BuiltinGenericModule = nullptr;
std::unique_ptr<llvm::Module> BuiltinSizeModule = nullptr;
std::unique_ptr<llvm::MemoryBuffer> pGenericBuffer = nullptr;
std::unique_ptr<llvm::MemoryBuffer> pSizeTBuffer = nullptr;
{
// IGC has two BIF Modules:
// 1. kernel Module (pKernelModule)
Expand All @@ -716,25 +718,64 @@ bool TranslateBuild(

// Load the builtin module - Generic BC
{
char Resource[5] = { '-' };
_snprintf(Resource, sizeof(Resource), "#%d", OCL_BC_ELF);
pGenericBuffer.reset(llvm::LoadBufferFromResource(Resource, "BIN"));
CLElfLib::CElfReader * pElfReader2 =
CLElfLib::CElfReader::Create(pGenericBuffer->getBufferStart(), pGenericBuffer->getBufferSize());
auto returned_module = BIImport::Construct(*pKernelModule, pElfReader2, true);
BuiltinGenericModule = std::move(returned_module);
char Resource[5] = { '-' };
_snprintf(Resource, sizeof(Resource), "#%d", OCL_BC);

pGenericBuffer.reset(llvm::LoadBufferFromResource(Resource, "BC"));
assert(pGenericBuffer && "Error loading the Generic builtin resource");

llvm::Expected<std::unique_ptr<llvm::Module>> ModuleOrErr =
getLazyBitcodeModule(pGenericBuffer->getMemBufferRef(), toLLVMContext(oclContext));
if (llvm::Error EC = ModuleOrErr.takeError())
assert(0 && "Error lazily loading bitcode for generic builtins");
else
BuiltinGenericModule = std::move(*ModuleOrErr);

assert(BuiltinGenericModule &&
"Error loading the Generic builtin module from buffer");
}

// Load the builtin module - pointer depended
{
char ResNumber[5] = { '-' };
switch (PtrSzInBits)
{
case 32:
_snprintf(ResNumber, sizeof(ResNumber), "#%d", OCL_BC_32);
break;
case 64:
_snprintf(ResNumber, sizeof(ResNumber), "#%d", OCL_BC_64);
break;
default:
assert(0 && "Unknown bitness of compiled module");
}

// the MemoryBuffer becomes owned by the module and does not need to be managed
pSizeTBuffer.reset(llvm::LoadBufferFromResource(ResNumber, "BC"));
assert(pSizeTBuffer && "Error loading builtin resource");

llvm::Expected<std::unique_ptr<llvm::Module>> ModuleOrErr =
getLazyBitcodeModule(pSizeTBuffer->getMemBufferRef(), toLLVMContext(oclContext));
if (llvm::Error EC = ModuleOrErr.takeError())
assert(0 && "Error lazily loading bitcode for size_t builtins");
else
BuiltinSizeModule = std::move(*ModuleOrErr);

assert(BuiltinSizeModule
&& "Error loading builtin module from buffer");
}

BuiltinGenericModule->setDataLayout(BuiltinSizeModule->getDataLayout());
BuiltinGenericModule->setTargetTriple(BuiltinSizeModule->getTargetTriple());
}

if (llvm::StringRef(oclContext.getModule()->getTargetTriple()).startswith("spir"))
{
IGC::UnifyIRSPIR(&oclContext, std::move(BuiltinGenericModule));
IGC::UnifyIRSPIR(&oclContext, std::move(BuiltinGenericModule), std::move(BuiltinSizeModule));
}
else // not SPIR
{
IGC::UnifyIROCL(&oclContext, std::move(BuiltinGenericModule));
IGC::UnifyIROCL(&oclContext, std::move(BuiltinGenericModule), std::move(BuiltinSizeModule));
}

if (!(oclContext.oclErrorMessage.empty()))
Expand Down
8 changes: 7 additions & 1 deletion IGC/BiFModule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1038,4 +1038,10 @@ set_property(TARGET "${IGC_BUILD__PROJ__BiFModule_OCL}" PROPERTY PROJECT_LABEL "

# ======================================================================================================
# ======================================================================================================
# ======================================================================================================
# ======================================================================================================

if(LLVM_ON_UNIX)
add_subdirectory(linux)
#NOTE: Transfer names of projects to parent scope.
set(IGC_BUILD__PROJ__BiFLib_OCL "${IGC_BUILD__PROJ__BiFLib_OCL}" PARENT_SCOPE)
endif()
75 changes: 33 additions & 42 deletions IGC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3480,42 +3480,6 @@ if(LLVM_ON_WIN32)
)
endif()

# Link targets/dependencies (in required link order).
# NOTE: Since the libraries are grouped in the same link group (in GCC/CLANG),
# there is no longer need to order in most dependant first manner.
set(IGC_BUILD__LLVM_LIBS_TO_LINK
"LLVMipo"
"LLVMIRReader"
"LLVMBitWriter"
"LLVMAsmParser"
"LLVMBitReader"
"LLVMLinker"
"LLVMCodeGen"
"LLVMScalarOpts"
"LLVMInstCombine"
"LLVMTransformUtils"
"LLVMAnalysis"
"LLVMTarget"
"LLVMObjCARCOpts"
"LLVMVectorize"
"LLVMInstrumentation"
"LLVMObject"
"LLVMMCParser"
"LLVMProfileData"
"LLVMMC"
"LLVMCore"
"LLVMSupport"
"LLVMDemangle"
)


# In case LLVM targets have not been already created do so.
if(NOT TARGET LLVMCore)
igc_llvm_library_add(${IGC_BUILD__LLVM_LIBS_TO_LINK})
endif()



# ===================================== Projects and source groups =====================================

# Suffixes of main projects.
Expand Down Expand Up @@ -3571,7 +3535,6 @@ igc_sg_define(IGC__DriverInterface)
# Built-in Functions (and resources).
if(IGC_OPTION__BIF_LINK_BC)
add_subdirectory(BiFModule)
add_subdirectory(ElfPackager)
endif()

add_subdirectory(OCLFE)
Expand Down Expand Up @@ -3652,8 +3615,6 @@ add_library("${IGC_BUILD__PROJ__igc_dll}" SHARED
${IGC_BUILD__HDR__IGC__fcl_dll}
${IGC_BUILD__RES__IGC__fcl_dll}
)

add_dependencies("${IGC_BUILD__PROJ__igc_dll}" "${IGC_BUILD__PROJ_NAME_PREFIX}ElfPackager")

target_include_directories(${IGC_BUILD__PROJ__igc_dll} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/AdaptorOCL/ocl_igc_shared"
Expand Down Expand Up @@ -3758,17 +3719,14 @@ foreach(_libBuildSuffix ${IGC_BUILD__MAIN_IGC_LIB_SUFFIXES})

if(MSVC AND IGC_OPTION__BIF_LINK_BC)
add_dependencies("${IGC_BUILD__PROJ${_libBuildSuffix}}" "${IGC_BUILD__PROJ__BiFModule_OCL}")
add_dependencies("${IGC_BUILD__PROJ${_libBuildSuffix}}" "${IGC_BUILD__PROJ__ElfPackager}")
endif()
endforeach()

#FCL
add_dependencies("${IGC_BUILD__PROJ__fcl_dll}" "${IGC_BUILD__LLVM_PACKAGE}")
add_dependencies("${IGC_BUILD__PROJ__fcl_dll}" "${IGC_BUILD__PROJ__BiFModule_OCL}")
add_dependencies("${IGC_BUILD__PROJ__fcl_dll}" "${IGC_BUILD__PROJ__ElfPackager}")
if(IGC_OPTION__BIF_LINK_BC)
add_dependencies("${IGC_BUILD__PROJ__BiFModule_OCL}" "${IGC_BUILD__LLVM_PACKAGE}")
add_dependencies("${IGC_BUILD__PROJ__ElfPackager}" "${IGC_BUILD__LLVM_PACKAGE}")
endif()
add_dependencies("${IGC_BUILD__PROJ__GenISAIntrinsics}" "${IGC_BUILD__LLVM_PACKAGE}")

Expand All @@ -3783,6 +3741,39 @@ if(LLVM_ON_WIN32)
endif()


# Link targets/dependencies (in required link order).
# NOTE: Since the libraries are grouped in the same link group (in GCC/CLANG),
# there is no longer need to order in most dependant first manner.
set(IGC_BUILD__LLVM_LIBS_TO_LINK
"LLVMipo"
"LLVMIRReader"
"LLVMBitWriter"
"LLVMAsmParser"
"LLVMBitReader"
"LLVMLinker"
"LLVMCodeGen"
"LLVMScalarOpts"
"LLVMInstCombine"
"LLVMTransformUtils"
"LLVMAnalysis"
"LLVMTarget"
"LLVMMC"
"LLVMCore"
"LLVMSupport"
"LLVMObjCARCOpts"
"LLVMVectorize"
"LLVMInstrumentation"
"LLVMObject"
"LLVMMCParser"
"LLVMDemangle"
)


# In case LLVM targets have not been already created do so.
if(NOT TARGET LLVMCore)
igc_llvm_library_add(${IGC_BUILD__LLVM_LIBS_TO_LINK})
endif()

foreach(_libBuildSuffix ${IGC_BUILD__MAIN_IGC_LIB_SUFFIXES})
get_property(_targetType TARGET "${IGC_BUILD__PROJ${_libBuildSuffix}}" PROPERTY TYPE)
if(_targetType MATCHES "^STATIC_LIBRARY$")
Expand Down

0 comments on commit 858e183

Please sign in to comment.