Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions buildbot/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def do_configure(args):
libclc_targets_to_build = ''
libclc_gen_remangled_variants = 'OFF'
sycl_build_pi_cuda = 'OFF'
sycl_build_pi_esimd_cpu = 'ON'
sycl_build_pi_esimd_cpu = 'OFF'
sycl_build_pi_rocm = 'OFF'
sycl_build_pi_rocm_platform = 'AMD'
sycl_werror = 'ON'
Expand All @@ -45,8 +45,8 @@ def do_configure(args):
if args.arm:
llvm_targets_to_build = 'ARM;AArch64'

if args.disable_esimd_cpu:
sycl_build_pi_esimd_cpu = 'OFF'
if args.enable_esimd_cpu_emulation:
sycl_build_pi_esimd_cpu = 'ON'

if args.cuda or args.rocm:
llvm_enable_projects += ';libclc'
Expand Down Expand Up @@ -181,7 +181,7 @@ def main():
parser.add_argument("--rocm", action='store_true', help="switch from OpenCL to ROCm")
parser.add_argument("--rocm-platform", type=str, choices=['AMD', 'NVIDIA'], default='AMD', help="choose ROCm backend")
parser.add_argument("--arm", action='store_true', help="build ARM support rather than x86")
parser.add_argument("--disable-esimd-cpu", action='store_true', help="build without ESIMD_CPU support")
parser.add_argument("--enable-esimd-cpu-emulation", action='store_true', help="build with ESIMD_CPU emulation support")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it rather be

Suggested change
parser.add_argument("--enable-esimd-cpu-emulation", action='store_true', help="build with ESIMD_CPU emulation support")
parser.add_argument("--enable-esimd-cpu-emulation", action='store_false', help="build with ESIMD_CPU emulation support")

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, store_true means 'True' will be applied to 'enable-esimd-cpu-emulation' member variable with --enable-esimd-cpu-emuation. store_false means 'False' for the variable. This is same for other plugins that are enabled with similar command line option like CUDA - Line 180.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store_true will set the variable to true when the option is available, otherwise it will remain default (BTW, default=False might be needed). Isn't that the intent?

Copy link
Contributor Author

@dongkyunahn-intel dongkyunahn-intel Aug 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I verified that current code works as the intent.

  • Without --enable-esimd-cpu-emulation command line argument, libpi_esimd_cpu.so is not generated
  • With the command line argument, libpi_esimd_cpu.so is generated

The store_true option automatically creates a default value of False. - https://stackoverflow.com/questions/8203622/argparse-store-false-if-unspecified

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

parser.add_argument("--no-assertions", action='store_true', help="build without assertions")
parser.add_argument("--docs", action='store_true', help="build Doxygen documentation")
parser.add_argument("--no-werror", action='store_true', help="Don't treat warnings as errors")
Expand Down
14 changes: 13 additions & 1 deletion sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS
sycl
pi_opencl
pi_level_zero
pi_esimd_cpu
libsycldevice
${XPTIFW_LIBS}
)
Expand Down Expand Up @@ -292,6 +291,19 @@ if(SYCL_BUILD_PI_ROCM)
list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS libspirv-builtins pi_rocm)
endif()

# TODO : Remove 'if (NOT MSVC)' when CM_EMU supports Windows
# environment
if (NOT MSVC)
if (SYCL_BUILD_PI_ESIMD_CPU)
list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS pi_esimd_cpu libcmrt-headers)
if (MSVC)
list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS libcmrt-libs libcmrt-dlls)
else()
list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS libcmrt-sos)
endif()
endif()
endif()

# Use it as fake dependency in order to force another command(s) to execute.
add_custom_command(OUTPUT __force_it
COMMAND "${CMAKE_COMMAND}" -E echo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ void (*cm_fence_ptr)(void);
char *(*sycl_get_surface_base_addr_ptr)(int);
char *(*__cm_emu_get_slm_ptr)(void);
void (*cm_slm_init_ptr)(size_t);
void (*sycl_get_cm_buffer_params_ptr)(void *, char **, uint32_t *,
std::mutex **);
void (*sycl_get_cm_image_params_ptr)(void *, char **, uint32_t *, uint32_t *,
uint32_t *, std::mutex **);
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// pointer table file ('esimd_emu_functions_v1.h') included in 'struct
// ESIMDDeviceInterface' definition.
#include <cstdint>
#include <mutex>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
Expand Down
8 changes: 6 additions & 2 deletions sycl/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ endif()
add_subdirectory(opencl)
add_subdirectory(level_zero)

if (SYCL_BUILD_PI_ESIMD_CPU)
add_subdirectory(esimd_cpu)
# TODO : Remove 'if (NOT MSVC)' when CM_EMU supports Windows
# environment
if (NOT MSVC)
if (SYCL_BUILD_PI_ESIMD_CPU)
add_subdirectory(esimd_cpu)
endif()
endif()
121 changes: 114 additions & 7 deletions sycl/plugins/esimd_cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,90 @@
# PI Esimd CPU library
# Create Shared library for libpi_esimd_cpu.so.

include(ExternalProject)

include_directories("${sycl_inc_dir}")
# FIXME/TODO: 'pi.h' is included in 'pi_esimd_cpu.cpp', and CL_*_INTEL
# and CL_*_KHR definitions in 'pi.h' are from
# ${OPENCL_INCLUDE}. Remove build dependency on OpenCL
include_directories(${OpenCL_INCLUDE_DIR})
include_directories(${LIBCMRT_INCLUDE})

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_build)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install)

if (MSVC)
set(LIBCM ${LLVM_BINARY_DIR}/pi_esimd_cpu_deps/lib/libcm${CMAKE_STATIC_LIBRARY_SUFFIX})
set(LIBIGFXCMRT_EMU ${LLVM_BINARY_DIR}/pi_esimd_cpu_deps/lib/igfxcmrt64_emu${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
set(LIBCM ${LLVM_BINARY_DIR}/pi_esimd_cpu_deps/lib/libcm${CMAKE_SHARED_LIBRARY_SUFFIX})
set(LIBIGFXCMRT_EMU ${LLVM_BINARY_DIR}/pi_esimd_cpu_deps/lib/libigfxcmrt_emu${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()

if (DEFINED CM_LOCAL_SOURCE_DIR)
# Using local CM directory for online building without downloading
if (MSVC)
ExternalProject_Add(cm-emu
DOWNLOAD_COMMAND ""
SOURCE_DIR ${CM_LOCAL_SOURCE_DIR}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_build
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
BUILD_BYPRODUCTS ${LIBCM} ${LIBIGFXCMRT_EMU}
)
else()
ExternalProject_Add(cm-emu
DOWNLOAD_COMMAND ""
SOURCE_DIR ${CM_LOCAL_SOURCE_DIR}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_build
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install
CMAKE_ARGS -DLIBVA_INSTALL_PATH=/usr
-D__SYCL_EXPLICIT_SIMD_PLUGIN__=true
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
BUILD_BYPRODUCTS ${LIBCM} ${LIBIGFXCMRT_EMU}
)
endif()
else ()
# Downloading pre-built CM Package
if (NOT DEFINED CM_PACKAGE_URL)
if (MSVC)
message(FATAL_ERROR "ESIMD_CPU is not supported under Windows environment yet")
else()
# FIXME/TODO : Use 'generic' package instead of 'u18.04'
set (CM_PACKAGE_URL "https://github.com/intel/cm-cpu-emulation/releases/download/v2021-07-21/intel-cmemu-1.0.1.u18.04-release.x86_64.tar.xz")
endif()
endif()
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install)
ExternalProject_Add(cm-emu
URL ${CM_PACKAGE_URL}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/cm-emu-prefix/src/cm-emu/ <INSTALL_DIR>
BUILD_BYPRODUCTS ${LIBCM} ${LIBIGFXCMRT_EMU}
)
endif ()
ExternalProject_Add_Step(cm-emu llvminstall
COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_BINARY_DIR}/pi_esimd_cpu_deps && ${CMAKE_COMMAND} -E copy_directory <INSTALL_DIR>/ ${LLVM_BINARY_DIR}/pi_esimd_cpu_deps
COMMENT "Installing cm-emu into the LLVM binary directory"
DEPENDEES install
)

include_directories(${LLVM_BINARY_DIR}/pi_esimd_cpu_deps/include/igfxcmrt_emu)
include_directories(${LLVM_BINARY_DIR}/pi_esimd_cpu_deps/include/libcm/cm)

# Compilation flag to exclude lines in header files imported from CM
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__SYCL_EXPLICIT_SIMD_PLUGIN__")

set(CMAKE_CXX_STANDARD 17)

# Compilation option modification to prevent build termination caused by
# warnings from CM-imported files
if (MSVC)
string(REPLACE "/W4" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
string(REPLACE "-pedantic" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()

add_library(pi_esimd_cpu SHARED
"${sycl_inc_dir}/CL/sycl/detail/pi.h"
Expand All @@ -31,16 +112,42 @@ else()
)
endif()

add_dependencies(pi_esimd_cpu OpenCL-Headers)
add_dependencies(pi_esimd_cpu cm-emu)
add_dependencies(sycl-toolchain pi_esimd_cpu)

add_dependencies(pi_esimd_cpu
OpenCL-Headers)

target_link_libraries(pi_esimd_cpu PRIVATE sycl)
target_link_libraries(pi_esimd_cpu PRIVATE sycl ${LIBCM} ${LIBIGFXCMRT_EMU})
set_target_properties(pi_esimd_cpu PROPERTIES LINKER_LANGUAGE CXX)

add_common_options(pi_esimd_cpu)

install(TARGETS pi_esimd_cpu
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_esimd_cpu
RUNTIME DESTINATION "bin" COMPONENT pi_esimd_cpu)
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_esimd_cpu
RUNTIME DESTINATION "bin" COMPONENT pi_esimd_cpu)

# Copy CM Header files to $(INSTALL)/include/sycl/CL/
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install/include/libcm/cm/
DESTINATION ${SYCL_INCLUDE_DIR}/CL
COMPONENT libcmrt-headers
FILES_MATCHING PATTERN "*.h"
)

# Copy '.so' files to '$(INSTALL)/lib'
if (MSVC)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install/lib/
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
COMPONENT libcmrt-libs
FILES_MATCHING PATTERN "*.lib"
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install/bin/
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
COMPONENT libcmrt-dlls
FILES_MATCHING PATTERN "*.dll"
)
else()
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install/lib/
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
COMPONENT libcmrt-sos
FILES_MATCHING PATTERN "*.so"
)
endif()
Loading