forked from ICLDisco/parsec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import Level Zero device from PR ICLDisco#486; port to new device int…
…erface
- Loading branch information
Showing
15 changed files
with
1,438 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
if(DPCPP_EXECUTABLE) | ||
get_filename_component( _dpcpp_path ${DPCPP_EXECUTABLE} PATH ) | ||
else(DPCPP_EXECUTABLE) | ||
set(_dpcpp_path "") | ||
endif(DPCPP_EXECUTABLE) | ||
find_program( DPCPP_EXECUTABLE NAMES dpcpp HINTS ${_dpcpp_path} ENV PATH ) | ||
mark_as_advanced( DPCPP_EXECUTABLE ) | ||
|
||
if( DPCPP_EXECUTABLE ) | ||
execute_process(COMMAND ${DPCPP_EXECUTABLE} --version | ||
RESULT_VARIABLE _res | ||
OUTPUT_VARIABLE _out | ||
ERROR_VARIABLE _err) | ||
if( _res EQUAL 0 ) | ||
string(REGEX MATCH "([^\n]+)" _ ${_out}) | ||
message(STATUS "Found dpcpp: ${DPCPP_EXECUTABLE} version ${CMAKE_MATCH_1}") | ||
|
||
get_filename_component( _dpcpp_dir ${DPCPP_EXECUTABLE} DIRECTORY ) | ||
get_filename_component( _dpcpp_lib_dir "${_dpcpp_dir}/../lib" ABSOLUTE ) | ||
|
||
find_library(SYCL_LIBRARY sycl HINTS "${_dpcpp_lib_dir}" "${SYCL_LIBRARY_DIR}" ENV "SYCL_LIBRARY_DIR") | ||
if( SYCL_LIBRARY ) | ||
message(STATUS "SYCL library: ${SYCL_LIBRARY}") | ||
|
||
get_filename_component( _dpcpp_inc_dir "${_dpcpp_dir}/../include" ABSOLUTE ) | ||
find_file(_sycl_include_file "sycl.hpp" HINTS "${_dpcpp_inc_dir}" "${_dpcpp_inc_dir}/sycl/CL" "${SYCL_INCLUDE_DIR}" ENV "SYCL_INCLUDE_DIR") | ||
if(_sycl_include_file) | ||
get_filename_component(SYCL_INCLUDE_DIR "${_sycl_include_file}" DIRECTORY) | ||
message(STATUS "SYCL include dir: ${SYCL_INCLUDE_DIR}") | ||
set(PARSEC_HAVE_DPCPP "TRUE" CACHE BOOL "True if PaRSEC provide support for dpc++") | ||
else(_sycl_include_file) | ||
message(WARNING "Found DPC++, and SYCL library, but could not find SYCL include directory. Define SYCL_INCLUDE_DIR to enable DPC++ support") | ||
set(PARSEC_HAVE_DPCPP "FALSE" CACHE BOOL "True if PaRSEC provide support for dpc++") | ||
endif(_sycl_include_file) | ||
else( SYCL_LIBRARY ) | ||
message(WARNING "Found DPC++, but did not find SYCL library. Define SYCL_LIBRARY_DIR to enable DPC++ support") | ||
set(PARSEC_HAVE_DPCPP "FALSE" CACHE BOOL "True if PaRSEC provide support for dpc++") | ||
endif( SYCL_LIBRARY ) | ||
else( _res EQUAL 0 ) | ||
set(PARSEC_HAVE_DPCPP "FALSE" CACHE BOOL "True if PaRSEC provide support for dpc++") | ||
message(WARNING "${DPCPP_EXECUTABLE} does not work: 'dpcpp -v' returned ${_res}, with error ${_err}") | ||
message(WARNING "dpc++ support is disabled, set DPCPP_EXECUTABLE to the path of dpcpp to enable DPC++ support, and/or fix your environment to run dpcpp") | ||
endif( _res EQUAL 0 ) | ||
endif( DPCPP_EXECUTABLE ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
if(LEVEL_ZERO_FOUND) | ||
if(TARGET level_zero::ze_loader) | ||
message(STATUS "level-zero is found and TARGET level_zero::ze_loader is defined") | ||
return() | ||
endif(TARGET level_zero::ze_loader) | ||
|
||
# If the user defines LEVEL_ZERO_INCLUDE_DIR and LEVEL_ZERO_LIBRARY_DIR, CMake's find_package declares that LEVEL_ZERO_FOUND is 1, but does not define the target. | ||
check_library_exists("ze_loader" "zeInit" ${LEVEL_ZERO_LIBRARY_DIR} LEVEL_ZERO_HAVE_ZE_LOADER) | ||
check_include_file("${LEVEL_ZERO_INCLUDE_DIR}/level_zero/ze_api.h" LEVEL_ZERO_HAVE_ZE_API_H) | ||
if(LEVEL_ZERO_HAVE_ZE_LOADER AND LEVEL_ZERO_HAVE_ZE_API_H) | ||
message(STATUS "Defining level_zero::ze_loader target with interface ${LEVEL_ZERO_INCLUDE_DIR}/level_zero/ze_api.h and library ${LEVEL_ZERO_LIBRARY_DIR}/libze_loader.so") | ||
add_library(level_zero::ze_loader UNKNOWN IMPORTED GLOBAL) | ||
set_property(TARGET level_zero::ze_loader PROPERTY IMPORTED_LOCATION "${LEVEL_ZERO_LIBRARY_DIR}/libze_loader.so") | ||
set_property(TARGET level_zero::ze_loader PROPERTY INTERFACE "${LEVEL_ZERO_INCLUDE_DIR}/level_zero/ze_api.h") | ||
include_directories("${LEVEL_ZERO_INCLUDE_DIR}/") | ||
return() | ||
else(LEVEL_ZERO_HAVE_ZE_LOADER AND LEVEL_ZERO_HAVE_ZE_API_H) | ||
if(NOT LEVEL_ZERO_HAVE_ZE_LOADER) | ||
message(STATUS "LEVEL_ZERO_FOUND is set, but could not find ze_loader library in ${LEVEL_ZERO_LIBRARY_DIR}") | ||
endif(NOT LEVEL_ZERO_HAVE_ZE_LOADER) | ||
if(NOT LEVEL_ZERO_HAVE_ZE_API_H) | ||
message(STATUS "LEVEL_ZERO_FOUND is set, but could not find level_zero/ze_api.h in ${LEVEL_ZERO_INCLUDE_DIR}") | ||
endif(NOT LEVEL_ZERO_HAVE_ZE_API_H) | ||
endif(LEVEL_ZERO_HAVE_ZE_LOADER AND LEVEL_ZERO_HAVE_ZE_API_H) | ||
endif(LEVEL_ZERO_FOUND) | ||
|
||
if(LEVEL_ZERO_ROOT_DIR) | ||
message(STATUS "Trying to locate level-zero library and headers under ${LEVEL_ZERO_ROOT_DIR}") | ||
find_library(ZE_LOADER_LIBRARY "ze_loader" HINTS "${LEVEL_ZERO_ROOT_DIR}/lib" "${LEVEL_ZERO_ROOT_DIR}/lib64" NO_DEFAULT_PATH) | ||
find_path (LEVEL_ZERO_INCLUDE_DIR NAMES "level_zero/ze_api.h" PATHS "${LEVEL_ZERO_ROOT_DIR}/include" NO_DEFAULT_PATH) | ||
|
||
if(ZE_LOADER_LIBRARY AND LEVEL_ZERO_INCLUDE_DIR) | ||
get_filename_component(ZE_LOADER_LIBRARY_DIR ${ZE_LOADER_LIBRARY} DIRECTORY) | ||
check_library_exists("ze_loader" "zeInit" ${ZE_LOADER_LIBRARY_DIR} ZE_LOADER_HAVE_ZEINIT) | ||
|
||
if(ZE_LOADER_HAVE_ZEINIT) | ||
message(STATUS "Found ze_loader library in ${ZE_LOADER_LIBRARY} and level_zero/ze_api.h in ${LEVEL_ZERO_INCLUDE_DIR}") | ||
add_library(level_zero::ze_loader UNKNOWN IMPORTED GLOBAL) | ||
set_property(TARGET level_zero::ze_loader PROPERTY IMPORTED_LOCATION "${ZE_LOADER_LIBRARY}") | ||
set_property(TARGET level_zero::ze_loader PROPERTY INTERFACE "${LEVEL_ZERO_INCLUDE_DIR}/level_zero/ze_api.h") | ||
include_directories("${LEVEL_ZERO_INCLUDE_DIR}/") | ||
set(LEVEL_ZERO_FOUND TRUE) | ||
else(ZE_LOADER_HAVE_ZEINIT) | ||
if(NOT ZE_LOADER_HAVE_ZEINIT) | ||
message(WARNING "Found ze_loader library under ${ZE_LOADER_LIBRARY}, but could not find symbol zeInit in this library -- falling back to package config search") | ||
endif(NOT ZE_LOADER_HAVE_ZEINIT) | ||
endif(ZE_LOADER_HAVE_ZEINIT) | ||
else(ZE_LOADER_LIBRARY AND LEVEL_ZERO_INCLUDE_DIR) | ||
if(NOT ZE_LOADER_LIBRARY) | ||
message(WARNING "Could not find ze_loader library under provided LEVEL_ZERO_ROOT_DIR='${LEVEL_ZERO_ROOT_DIR}' (tried subdirectories lib/ and lib64/) -- falling back to package config search") | ||
endif(NOT ZE_LOADER_LIBRARY) | ||
if(NOT LEVEL_ZERO_INCLUDE_DIR) | ||
message(WARNING "Cound not find level_zero/ze_api.h under provided LEVEL_ZERO_ROOT_DIR=${LEVEL_ZERO_ROOT_DIR}' (tried subdirectory include) -- falling back to package config search") | ||
endif(NOT LEVEL_ZERO_INCLUDE_DIR) | ||
endif(ZE_LOADER_LIBRARY AND LEVEL_ZERO_INCLUDE_DIR) | ||
endif(LEVEL_ZERO_ROOT_DIR) | ||
|
||
if(NOT LEVEL_ZERO_FOUND) | ||
find_package(PkgConfig QUIET) | ||
|
||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(LEVEL_ZERO level-zero) | ||
if(LEVEL_ZERO_FOUND) | ||
pkg_get_variable(LEVEL_ZERO_LIBRARY_DIR level-zero libdir) | ||
pkg_get_variable(LEVEL_ZERO_INCLUDE_DIR level-zero includedir) | ||
add_library(level_zero::ze_loader UNKNOWN IMPORTED GLOBAL) | ||
set_property(TARGET level_zero::ze_loader PROPERTY IMPORTED_LOCATION "${LEVEL_ZERO_LIBRARY_DIR}/libze_loader.so") | ||
set_property(TARGET level_zero::ze_loader PROPERTY INTERFACE "${LEVEL_ZERO_INCLUDE_DIR}/level_zero/ze_api.h") | ||
include_directories("${LEVEL_ZERO_INCLUDE_DIR}/") | ||
endif(LEVEL_ZERO_FOUND) | ||
endif(PKG_CONFIG_FOUND) | ||
endif(NOT LEVEL_ZERO_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# For now assume that the upper level did the CUDA search and that all | ||
# necessary dependencies on CUDA have been correctly setup | ||
|
||
if( PARSEC_HAVE_LEVEL_ZERO AND PARSEC_HAVE_DPCPP ) | ||
SET(MCA_${COMPONENT}_${MODULE} ON) | ||
FILE(GLOB MCA_${COMPONENT}_${MODULE}_SOURCES ${MCA_BASE_DIR}/${COMPONENT}/${MODULE}/[^\\.]*.c) | ||
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/parsec/mca/device/level_zero/device_level_zero_dpcpp_interface.o | ||
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/parsec/mca/device/level_zero/device_level_zero_dpcpp_interface.cpp | ||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/parsec/mca/device/level_zero | ||
COMMAND ${DPCPP_EXECUTABLE} | ||
-I${LEVEL_ZERO_INCLUDE_DIR} | ||
-I${SYCL_INCLUDE_DIR} | ||
-I${PROJECT_SOURCE_DIR} | ||
-I${PROJECT_SOURCE_DIR}/parsec/include | ||
-I${PROJECT_BINARY_DIR}/parsec/include | ||
-I${PROJET_BINARY_DIR} | ||
-Wall -fpic -g -c ${PROJECT_SOURCE_DIR}/parsec/mca/device/level_zero/device_level_zero_dpcpp_interface.cpp) | ||
SET_SOURCE_FILES_PROPERTIES( | ||
${PROJECT_BINARY_DIR}/parsec/mca/device/level_zero/device_level_zero_dpcpp_interface.o | ||
PROPERTIES | ||
EXTERNAL_OBJECT true | ||
GENERATED true) | ||
add_library(parsec-dpcpp ${PROJECT_BINARY_DIR}/parsec/mca/device/level_zero/device_level_zero_dpcpp_interface.o) | ||
target_link_libraries(parsec PRIVATE parsec-dpcpp ${SYCL_LIBRARY}) | ||
install(TARGETS parsec-dpcpp | ||
EXPORT parsec-targets | ||
DESTINATION ${PARSEC_INSTALL_LIBDIR}) | ||
SET(MCA_${COMPONENT}_${MODULE}_CONSTRUCTOR "${COMPONENT}_${MODULE}_static_component") | ||
install(FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/mca/device/level_zero/device_level_zero.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/mca/device/level_zero/device_level_zero_internal.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/mca/device/level_zero/device_level_zero_dpcpp.h | ||
DESTINATION include/parsec/mca/device/level_zero ) | ||
else (PARSEC_HAVE_LEVEL_ZERO AND PARSEC_HAVE_DPCPP) | ||
MESSAGE(STATUS "Module ${MODULE} not selectable: does not have LEVEL_ZERO (${PARSEC_HAVE_LEVEL_ZERO}) or DPCPP (${PARSEC_HAVE_DPCPP})") | ||
SET(MCA_${COMPONENT}_${MODULE} OFF) | ||
endif(PARSEC_HAVE_LEVEL_ZERO AND PARSEC_HAVE_DPCPP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright (c) 2023 The University of Tennessee and The University | ||
* of Tennessee Research Foundation. All rights | ||
* reserved. | ||
*/ | ||
|
||
#ifndef PARSEC_DEVICE_LEVEL_ZERO_H_HAS_BEEN_INCLUDED | ||
#define PARSEC_DEVICE_LEVEL_ZERO_H_HAS_BEEN_INCLUDED | ||
|
||
#include "parsec.h" | ||
|
||
#if defined(PARSEC_HAVE_DEV_LEVEL_ZERO_SUPPORT) | ||
#include "parsec/mca/device/device.h" | ||
#include "parsec/mca/device/device_gpu.h" | ||
#include "parsec/mca/device/level_zero/device_level_zero_dpcpp.h" | ||
|
||
#include <level_zero/ze_api.h> | ||
|
||
BEGIN_C_DECLS | ||
|
||
struct parsec_level_zero_task_s; | ||
typedef struct parsec_level_zero_task_s parsec_level_zero_task_t; | ||
|
||
struct parsec_level_zero_exec_stream_s; | ||
typedef struct parsec_level_zero_exec_stream_s parsec_level_zero_exec_stream_t; | ||
|
||
struct parsec_device_level_zero_module_s; | ||
typedef struct parsec_device_level_zero_module_s parsec_device_level_zero_module_t; | ||
|
||
struct parsec_device_level_zero_driver_s; | ||
typedef struct parsec_device_level_zero_driver_s parsec_device_level_zero_driver_t; | ||
|
||
struct parsec_level_zero_workspace_s; | ||
typedef struct parsec_level_zero_workspace_s parsec_level_zero_workspace_t; | ||
|
||
extern parsec_device_base_component_t parsec_device_level_zero_component; | ||
|
||
struct parsec_level_zero_task_s { | ||
parsec_gpu_task_t super; | ||
}; | ||
|
||
struct parsec_device_level_zero_driver_s { | ||
ze_driver_handle_t ze_driver; | ||
ze_context_handle_t ze_context; | ||
uint32_t ref_count; | ||
parsec_sycl_wrapper_platform_t *swp; | ||
}; | ||
|
||
struct parsec_device_level_zero_module_s { | ||
parsec_device_gpu_module_t super; | ||
uint8_t level_zero_index; | ||
parsec_device_level_zero_driver_t *driver; | ||
ze_device_handle_t ze_device; | ||
parsec_sycl_wrapper_device_t *swd; | ||
int memory_index; | ||
}; | ||
|
||
PARSEC_OBJ_CLASS_DECLARATION(parsec_device_level_zero_module_t); | ||
|
||
struct parsec_level_zero_exec_stream_s { | ||
parsec_gpu_exec_stream_t super; | ||
/* There is exactly one task per active fence (max_fences being the uppoer bound). | ||
* Upon fence completion the complete_stage function associated with the task is | ||
* called, and this will decide what is going on next with the task. If the task | ||
* remains in the system the function is supposed to update it. | ||
*/ | ||
ze_fence_handle_t *fences; | ||
ze_command_list_handle_t *command_lists; | ||
ze_command_queue_handle_t level_zero_cq; | ||
parsec_sycl_wrapper_queue_t *swq; | ||
}; | ||
|
||
/**************************************************** | ||
** GPU-DATA Specific Starts Here ** | ||
****************************************************/ | ||
/** | ||
* Overload the default data_copy_t with a GPU specialized type | ||
*/ | ||
typedef parsec_data_copy_t parsec_gpu_data_copy_t; | ||
|
||
END_C_DECLS | ||
|
||
#define PARSEC_LEVEL_ZERO_CHECK_ERROR(STR, ERROR, CODE) \ | ||
do { \ | ||
if( ZE_RESULT_SUCCESS != (ERROR) ) { \ | ||
parsec_warning( "%s:%d %s returns Error 0x%x", __FILE__, __LINE__,\ | ||
(STR), (ERROR) ); \ | ||
CODE; \ | ||
} \ | ||
} while(0) | ||
#else | ||
#error "should be defined" | ||
#endif /* defined(PARSEC_HAVE_DEV_LEVEL_ZERO_SUPPORT) */ | ||
|
||
#endif /* PARSEC_DEVICE_LEVEL_ZERO_H_HAS_BEEN_INCLUDED */ |
Oops, something went wrong.