Commit 8109c4dc authored by Lukasz Wesierski's avatar Lukasz Wesierski Committed by Alex

Enable clang7 and update of README

Change-Id: I806894b4cff57d8bbb8c11831dde12d473d3c414
parent b1fbc24b
......@@ -43,7 +43,7 @@ void CIF_GET_INTERFACE_CLASS(FclOclDeviceCtx, 1)::SetOclApiVersion(uint32_t oclV
}
CodeType::CodeType_t CIF_GET_INTERFACE_CLASS(FclOclDeviceCtx, 2)::GetPreferredIntermediateRepresentation() {
return CodeType::llvmBc;
return CodeType::spirV;
}
FclOclTranslationCtxBase *CIF_GET_INTERFACE_CLASS(FclOclDeviceCtx, 1)::CreateTranslationCtxImpl(CIF::Version_t ver,
......
......@@ -37,6 +37,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(VME_TYPES_DEFINED TRUE)
endif()
set(CCLANG_BUILD_INTREE_LLVM FALSE)
if(EXISTS ${LLVM_SOURCE_DIR}/projects/opencl-clang)
set(CCLANG_BUILD_INTREE_LLVM TRUE)
set(VME_TYPES_DEFINED TRUE)
set(CLANG_SOURCE_DIR ${LLVM_SOURCE_DIR}/tools/clang)
endif()
# Decompress Clang
# Add bogus targets to identify the .7z file and the decompressed .exe file
add_library(CLANG_7Z UNKNOWN IMPORTED)
......@@ -119,18 +126,19 @@ endif()
if(NOT DEFINED COMMON_CLANG_LIBRARY_NAME)
if(EXISTS ${_clang7zLocation})
set(COMMON_CLANG_LIBRARY_NAME common_clang)
set(COMMON_CLANG_LIBRARY_NAME common_clang${_cpuSuffix})
else()
set(COMMON_CLANG_LIBRARY_NAME opencl_clang)
set(COMMON_CLANG_LIBRARY_NAME common_clang)
endif()
endif()
if(WIN32)
set(COMMON_CLANG_LIB_FULL_NAME "${COMMON_CLANG_LIBRARY_NAME}${_cpuSuffix}${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(COMMON_CLANG_LIB_FULL_NAME "${COMMON_CLANG_LIBRARY_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
else()
set(COMMON_CLANG_LIB_FULL_NAME "lib${COMMON_CLANG_LIBRARY_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
if(NOT ${CCLANG_BUILD_INTREE_LLVM})
# Add step to preform the extraction
add_custom_command(
OUTPUT ${IGC_TARGET__TOOLS_CLANG_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}
......@@ -142,6 +150,7 @@ endif()
DEPENDS CLANG_7Z
COMMENT "Extracting Clang packages using: ${_extractCmd}"
)
endif()
add_custom_target(UnzipClang
DEPENDS ${IGC_TARGET__TOOLS_CLANG_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}
......@@ -152,7 +161,7 @@ endif()
add_custom_target(GetClang)
add_library(common_clang_dll UNKNOWN IMPORTED GLOBAL)
if(EXISTS ${_clang7zLocation})
if(EXISTS ${_clang7zLocation} AND NOT ${CCLANG_BUILD_INTREE_LLVM})
# Use precompiled common clang bundle.
message(STATUS "Use precompiled common clang from ${_clang7zLocation}")
......@@ -162,7 +171,6 @@ endif()
else()
# Do not use precompiled common clang.
message(STATUS "Precompiled common clang bundle ${_clang7zLocation} does not exist. Try to compile from sources.")
set(VME_TYPES_DEFINED FALSE)
# if not specified from outside
# try to use common clang component from one of fixed locations
if(NOT IGC_CCLANG_HOME_DIR)
......@@ -178,7 +186,7 @@ endif()
get_filename_component(IGC_CCLANG_HOME_DIR "${IGC_CCLANG_HOME_DIR}" ABSOLUTE)
# Set build directory
set(IGC_CCLANG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/clang_build)
if(EXISTS ${IGC_CCLANG_HOME_DIR})
if(EXISTS ${IGC_CCLANG_HOME_DIR} OR ${CCLANG_BUILD_INTREE_LLVM})
set(CCLANG_INSTALL_ARTIFACTS_DIR ${IGC_TARGET__TOOLS_CLANG_DIR})
message(STATUS "Trigger common clang compilation from ${IGC_CCLANG_HOME_DIR} to ${CCLANG_INSTALL_ARTIFACTS_DIR}")
......@@ -189,10 +197,46 @@ endif()
get_filename_component(CCLANG_OCL_HEADERS_DIR "${IGC_BUILD__GFX_DEV_SRC_DIR}/../opencl_headers" ABSOLUTE)
endif()
endif(NOT CCLANG_OCL_HEADERS_DIR)
add_subdirectory(${IGC_CCLANG_HOME_DIR} ${IGC_CCLANG_BUILD_DIR})
add_dependencies(GetClang "${CCLANG_LIB_NAME}")
set_property(TARGET common_clang_dll PROPERTY "IMPORTED_LOCATION" "${IGC_CCLANG_BUILD_DIR}/install/lib/${COMMON_CLANG_LIB_FULL_NAME}")
if(${CCLANG_BUILD_INTREE_LLVM})
message("Common clang build-in-tree")
set(clang_filename "clang${CMAKE_EXECUTABLE_SUFFIX}")
add_custom_command(
OUTPUT "${IGC_TARGET__TOOLS_CLANG_DIR}/${clang_filename}"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:clang>" "${IGC_TARGET__TOOLS_CLANG_DIR}/${clang_filename}"
DEPENDS clang
)
add_custom_command(
OUTPUT "${IGC_TARGET__TOOLS_CLANG_DIR}/${COMMON_CLANG_LIB_FULL_NAME}"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${COMMON_CLANG_LIBRARY_NAME}>" "${IGC_TARGET__TOOLS_CLANG_DIR}/${COMMON_CLANG_LIB_FULL_NAME}"
DEPENDS ${COMMON_CLANG_LIBRARY_NAME}
)
set(cclang_header_filename "opencl-c.h")
add_custom_command(
OUTPUT "${IGC_TARGET__TOOLS_CLANG_DIR}/${cclang_header_filename}"
COMMAND ${CMAKE_COMMAND} -E copy "${CLANG_SOURCE_DIR}/lib/Headers/${cclang_header_filename}" "${IGC_TARGET__TOOLS_CLANG_DIR}/${cclang_header_filename}"
DEPENDS cl_headers
)
add_custom_target(copy_cclang_files ALL
DEPENDS ${IGC_TARGET__TOOLS_CLANG_DIR}/${clang_filename} ${IGC_TARGET__TOOLS_CLANG_DIR}/${COMMON_CLANG_LIB_FULL_NAME} ${IGC_TARGET__TOOLS_CLANG_DIR}/${cclang_header_filename}
)
add_dependencies(GetClang copy_cclang_files)
set_property(TARGET common_clang_dll PROPERTY "IMPORTED_LOCATION" ${IGC_TARGET__TOOLS_CLANG_DIR}/${COMMON_CLANG_LIB_FULL_NAME})
else()
add_subdirectory(${IGC_CCLANG_HOME_DIR} ${IGC_CCLANG_BUILD_DIR})
add_subdirectory(${IGC_CCLANG_BUILD_DIR})
add_subdirectory(${IGC_CCLANG_HOME_DIR} ${IGC_CCLANG_BUILD_DIR})
add_dependencies(GetClang "${CCLANG_LIB_NAME}")
set_property(TARGET common_clang_dll PROPERTY "IMPORTED_LOCATION" "${IGC_CCLANG_BUILD_DIR}/install/lib/${COMMON_CLANG_LIB_FULL_NAME}")
endif()
else()
message(FATAL_ERROR "Can not compile common clang: unknown location of common clang sources")
endif()
......@@ -820,10 +864,12 @@ endfunction()
# ======================================== Precompiled headers =========================================
set(IGC_BUILD__BIF_OCL_PCH_SRC "${IGC_TARGET__TOOLS_CLANG_DIR}/opencl-c.h")
if(NOT ${CCLANG_BUILD_INTREE_LLVM})
add_custom_command(
OUTPUT ${IGC_BUILD__BIF_OCL_PCH_SRC}
DEPENDS GetClang
)
endif()
set(IGC_BUILD__BIF_RS_PCH_SRC "${IGC_OPTION__BIF_SRC_RS_DIR}/rs_pch.h")
set(IGC_BUILD__BIF_RS_PCH32 "${IGC_BUILD__BIF_DIR}/rs32.pch")
......
......@@ -297,6 +297,8 @@ bool SPIRMetaDataTranslation::runOnModule(Module& M)
// In SPIR, compiler options are represented by a named node with a single item pointing to a list.
// since the name node is a list, this creates a list of lists where the first item in the outer list
// is the actual compiler options list.
if (!spirMDUtils.empty_CompilerOptions())
{
SPIRMD::InnerCompilerOptionsMetaDataListHandle compilerOptions = spirMDUtils.getCompilerOptionsItem(0);
SPIRMD::InnerCompilerOptionsMetaDataList::const_iterator coi = compilerOptions->begin();
SPIRMD::InnerCompilerOptionsMetaDataList::const_iterator coe = compilerOptions->end();
......@@ -364,6 +366,7 @@ bool SPIRMetaDataTranslation::runOnModule(Module& M)
break;
}
}
}
// Handling Floating Point Contractions
if (spirMDUtils.isFloatingPointContractionsHasValue())
......
......@@ -849,7 +849,7 @@ namespace TC
\*****************************************************************************/
bool AreVMETypesDefined()
{
return false;
return true;
}
/*****************************************************************************\
......
......@@ -28,43 +28,47 @@ https://opensource.org/licenses/MIT
IGC is supported on the following 32/64 bits Linux operating systems:
* Ubuntu 14.04, 16.04, 17.04
* Ubuntu 14.04, 16.04, 17.04, 18.04
## Building
1. Install prerequisites
Building IGC needs flex, bison, clang 4.0, cmake version later than 3.4.3 and
libz. You can install required packages on ubuntu 16.04 like below:
Building IGC needs flex, bison, cmake version later than 3.4.3 and
libz. You can install required packages on ubuntu 18.04 like below:
```
$ sudo apt-get install flex bison clang-4.0 libz-dev cmake
$ sudo apt-get install flex bison libz-dev cmake
```
2. Download all dependencies and create workspace folder as below:
```
workspace
|- clang_source https://github.com/llvm-mirror/clang
|- common_clang https://github.com/intel/opencl-clang
|- llvm_patches https://github.com/intel/llvm-patches
|- llvm_source https://github.com/llvm-mirror/llvm
|- igc https://github.com/intel/intel-graphics-compiler
Example command:
$ git clone -b release_40 https://github.com/llvm-mirror/clang clang_source
$ git clone -b ocl-open-40 https://github.com/intel/opencl-clang common_clang
<workspace>
|- igc https://github.com/intel/intel-graphics-compiler
|- llvm_patches https://github.com/intel/llvm-patches
|- llvm_source https://github.com/llvm-mirror/llvm
|- projects/opencl-clang https://github.com/intel/opencl-clang
|- projects/llvm-spirv https://github.com/KhronosGroup/SPIRV-LLVM-Translator
|- tools/clang https://github.com/llvm-mirror/clang
```
This can be done using the following commands:
```
$ cd <workspace>
$ git clone -b release_70 https://github.com/llvm-mirror/llvm llvm_source
$ git clone -b release_70 https://github.com/llvm-mirror/clang llvm_source/tools/clang
$ git clone -b release_70 https://github.com/intel/opencl-clang llvm_source/projects/opencl-clang
$ git clone -b release_70 https://github.com/KhronosGroup/SPIRV-LLVM-Translator llvm_source/projects/llvm-spirv
$ git clone https://github.com/intel/llvm-patches llvm_patches
[If seeing LLVM7.1.0 issue, please do following]
In CMakeLists.txt
Change set(EXPECTED_LLVM_VERSION "7.0.0") to set(EXPECTED_LLVM_VERSION "7.1.0")
$ git clone -b release_40 https://github.com/llvm-mirror/llvm llvm_source
$ git clone -b release_70 https://github.com/llvm-mirror/llvm llvm7.1.0_source
$ git clone https://github.com/intel/intel-graphics-compiler igc
[If using specific release]
git checkout -b tag igc_release_2019-01-15
$ cd igc && git checkout -b tag igc_release_2019-01-15
```
3. Under workspace create a build folder. For example:
```
$ cd <workspace>
$ mkdir build
```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment