Skip to content

[SYCL-PTX] Libclc binding for SYCL device #1914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 13 additions & 2 deletions libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
LIB_DIR lib
DIRS ${dirs} ${DARCH} ${DARCH}-${OS} ${DARCH}-${VENDOR}-${OS}
DEPS convert-clc.cl )
set( libspirv_files )
libclc_configure_lib_source(libspirv_files
set( libspirv_files_base )
libclc_configure_lib_source(libspirv_files_base
LIB_DIR libspirv
DIRS ${dirs} ${DARCH} ${DARCH}-${OS} ${DARCH}-${VENDOR}-${OS}
DEPS convert-spirv.cl convert-core.cl)
Expand All @@ -244,6 +244,17 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
endif()
message( " DEVICE: ${d} ( ${${d}_aliases} )" )

# FIXME: this is a hack, remove once we can use sycldevice in the triple
# without changing the language
# see issue: https://github.com/intel/llvm/issues/1814
set(libspirv_files ${libspirv_files_base})
if( ${ARCH} STREQUAL nvptx OR ${ARCH} STREQUAL nvptx64 )
add_libclc_sycl_binding(libspirv_files
TRIPLE ${t}
COMPILE_OPT ${mcpu}
FILES generic/libspirv/sycldevice-binding.cpp)
endif()

add_libclc_builtin_set(libspirv-${arch_suffix}
TRIPLE ${t}
TARGET_ENV libspirv
Expand Down
52 changes: 52 additions & 0 deletions libclc/cmake/modules/AddLibclc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,55 @@ function(libclc_configure_lib_source OUT_LIST)
set( ${OUT_LIST} ${rel_files} PARENT_SCOPE )

endfunction(libclc_configure_lib_source OUT_LIST)

# add_libclc_sycl_binding(arch_suffix
# TRIPLE string
# Triple used to compile
# FILES string ...
# List of file that should be built for this library
# COMPILE_OPT
# Compilation options
# )
#
# Build the sycl binding file for SYCLDEVICE.
# The path to the generated object file are appended in OUT_LIST.
#
# The mangling for sycl device is not yet fully
# compatible with standard mangling.
# For various reason, we need a mangling specific
# for the Default address space (mapping to generic in SYCL).
# The Default address space is not accessible in CL mode,
# so we build this file in sycl mode for mangling purposes.
#
# FIXME: all the files should be compiled with the sycldevice triple
# but this is not possible at the moment as this will trigger
# the SYCL mode which we don't want.
#
function(add_libclc_sycl_binding OUT_LIST)
cmake_parse_arguments(ARG
""
"TRIPLE"
"FILES;COMPILE_OPT"
${ARGN})

foreach( file ${ARG_FILES} )
file( TO_CMAKE_PATH ${LIBCLC_ROOT_DIR}/${file} SYCLDEVICE_BINDING )
if( EXISTS ${SYCLDEVICE_BINDING} )
set( SYCLDEVICE_BINDING_OUT ${CMAKE_CURRENT_BINARY_DIR}/sycldevice-binding-${ARG_TRIPLE}/sycldevice-binding.bc )
add_custom_command( OUTPUT ${SYCLDEVICE_BINDING_OUT}
COMMAND ${LLVM_CLANG}
-target ${ARG_TRIPLE}-sycldevice
-fsycl
-fsycl-device-only
-Dcl_khr_fp64
-I${LIBCLC_ROOT_DIR}/generic/include
${ARG_COMPILE_OPT}
${SYCLDEVICE_BINDING}
-o ${SYCLDEVICE_BINDING_OUT}
MAIN_DEPENDENCY ${SYCLDEVICE_BINDING}
DEPENDS ${SYCLDEVICE_BINDING} ${LLVM_CLANG}
VERBATIM )
set( ${OUT_LIST} "${${OUT_LIST}};${SYCLDEVICE_BINDING_OUT}" PARENT_SCOPE )
endif()
endforeach()
endfunction(add_libclc_sycl_binding OUT_LIST)
4 changes: 4 additions & 0 deletions libclc/generic/include/lp64_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ typedef half __clc_vec16_fp16_t __attribute__((ext_vector_type(16)));

typedef __clc_int64_t __clc_size_t;

#ifdef __SYCL_DEVICE_ONLY__
typedef __ocl_event_t __clc_event_t;
#else
typedef event_t __clc_event_t;
#endif

#endif // CLC_LP64_TYPES
Loading