Skip to content

Commit b4a7c8c

Browse files
authored
Merge branch 'adapters' into ext_oneapi_queue_priority-hip
2 parents f7d789d + ce152a6 commit b4a7c8c

File tree

136 files changed

+6969
-637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+6969
-637
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ source/adapters/hip @oneapi-src/unified-runtime-hip-write
1010
# OpenCL adapter
1111
source/adapters/opencl @oneapi-src/unified-runtime-opencl-write
1212

13+
# Native CPU adapter
14+
source/adapters/native_cpu @oneapi-src/unified-runtime-native-cpu-write
15+
1316
# Command-buffer experimental feature
1417
source/adapters/**/command_buffer.* @oneapi-src/unified-runtime-command-buffer-write
1518
scripts/core/EXP-COMMAND-BUFFER.rst @oneapi-src/unified-runtime-command-buffer-write

.github/workflows/cmake.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ jobs:
164164
matrix:
165165
adapter: [
166166
{name: CUDA, triplet: nvptx64-nvidia-cuda},
167-
{name: HIP, triplet: spir64}, # should be amdgcn-amdhsa, but build scripts for device binaries are currently broken for this target.
167+
{name: HIP, triplet: amdgcn-amd-amdhsa},
168168
{name: L0, triplet: spir64}
169169
]
170170
build_type: [Debug, Release]
@@ -196,12 +196,18 @@ jobs:
196196
-DUR_BUILD_TESTS=ON
197197
-DUR_BUILD_ADAPTER_${{matrix.adapter.name}}=ON
198198
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++
199+
-DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib
199200
-DUR_CONFORMANCE_TARGET_TRIPLES=${{matrix.adapter.triplet}}
201+
${{ matrix.adapter.name == 'HIP' && '-DAMD_ARCH=gfx1030' || '' }}
202+
${{ matrix.adapter.name == 'HIP' && '-DUR_HIP_PLATFORM=AMD' || '' }}
200203
201204
- name: Build
202205
# This is so that device binaries can find the sycl runtime library
203-
run: LD_LIBRARY_PATH=${{github.workspace}}/dpcpp_compiler/lib
204-
cmake --build ${{github.workspace}}/build -j $(nproc)
206+
run: cmake --build ${{github.workspace}}/build -j $(nproc)
207+
208+
- name: Test adapter specific
209+
working-directory: ${{github.workspace}}/build
210+
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "adapter-specific" --timeout 180
205211

206212
# Temporarily disabling platform test for L0, because of hang
207213
# See issue: #824
@@ -261,6 +267,12 @@ jobs:
261267
working-directory: ${{github.workspace}}/build
262268
run: bin/codegen
263269

270+
# conda init adds content to user's profile making it failing (if conda is gone)
271+
- name: Cleanup after conda init
272+
run: |
273+
cat ${HOME}/.profile || true
274+
rm ${HOME}/.profile || true
275+
264276
windows-build:
265277
name: Build - Windows
266278
strategy:

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ option(UR_BUILD_ADAPTER_L0 "build level 0 adapter from SYCL" OFF)
3939
option(UR_BUILD_ADAPTER_OPENCL "build opencl adapter from SYCL" OFF)
4040
option(UR_BUILD_ADAPTER_CUDA "build cuda adapter from SYCL" OFF)
4141
option(UR_BUILD_ADAPTER_HIP "build hip adapter from SYCL" OFF)
42+
option(UR_BUILD_ADAPTER_NATIVE_CPU "build native_cpu adapter from SYCL" OFF)
4243
option(UR_BUILD_EXAMPLE_CODEGEN "Build the codegen example." OFF)
4344
option(VAL_USE_LIBBACKTRACE_BACKTRACE "enable libbacktrace validation backtrace for linux" OFF)
45+
set(UR_DPCXX "" CACHE FILEPATH "Path of the DPC++ compiler executable")
46+
set(UR_SYCL_LIBRARY_DIR "" CACHE PATH
47+
"Path of the SYCL runtime library directory")
4448

4549
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
4650
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ List of options provided by CMake:
131131
| UR_BUILD_ADAPTER_OPENCL | Fetch and use opencl adapter from SYCL | ON/OFF | OFF |
132132
| UR_BUILD_ADAPTER_CUDA | Fetch and use cuda adapter from SYCL | ON/OFF | OFF |
133133
| UR_BUILD_ADAPTER_HIP | Fetch and use hip adapter from SYCL | ON/OFF | OFF |
134+
| UR_BUILD_ADAPTER_NATIVE_CPU | Fetch and use native-cpu adapter from SYCL | ON/OFF | OFF |
134135
| UR_HIP_PLATFORM | Build hip adapter for AMD or NVIDIA platform | AMD/NVIDIA | AMD |
135136
| UR_ENABLE_COMGR | Enable comgr lib usage | AMD/NVIDIA | AMD |
137+
| UR_DPCXX | Path of the DPC++ compiler executable to build CTS device binaries | File path | `""` |
138+
| UR_SYCL_LIBRARY_DIR | Path of the SYCL runtime library directory to build CTS device binaries | Directory path | `""` |
136139

137140
### Additional make targets
138141

examples/codegen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ if(LLVM_FOUND AND PkgConfig_FOUND AND LLVMSPIRVLib_FOUND)
4343
)
4444
endif()
4545
else()
46-
message(STATUS "The environment did not satisfy dependency requirements (LLVM, PkgConfig, LLVMSPIRVLib) for codegen example (skipping target).")
46+
message(FATAL_ERROR "The environment did not satisfy dependency requirements (LLVM, PkgConfig, LLVMSPIRVLib) for codegen example (skipping target).")
4747
endif()

include/ur.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ class ur_function_v(IntEnum):
196196
ADAPTER_RETAIN = 179 ## Enumerator for ::urAdapterRetain
197197
ADAPTER_GET_LAST_ERROR = 180 ## Enumerator for ::urAdapterGetLastError
198198
ADAPTER_GET_INFO = 181 ## Enumerator for ::urAdapterGetInfo
199+
PROGRAM_BUILD_EXP = 197 ## Enumerator for ::urProgramBuildExp
200+
PROGRAM_COMPILE_EXP = 198 ## Enumerator for ::urProgramCompileExp
201+
PROGRAM_LINK_EXP = 199 ## Enumerator for ::urProgramLinkExp
199202

200203
class ur_function_t(c_int):
201204
def __str__(self):
@@ -2253,6 +2256,11 @@ class ur_exp_command_buffer_sync_point_t(c_ulong):
22532256
class ur_exp_command_buffer_handle_t(c_void_p):
22542257
pass
22552258

2259+
###############################################################################
2260+
## @brief The extension string which defines support for test
2261+
## which is returned when querying device extensions.
2262+
UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP = "ur_exp_multi_device_compile"
2263+
22562264
###############################################################################
22572265
## @brief Supported peer info
22582266
class ur_exp_peer_info_v(IntEnum):
@@ -2569,6 +2577,37 @@ class ur_program_dditable_t(Structure):
25692577
("pfnCreateWithNativeHandle", c_void_p) ## _urProgramCreateWithNativeHandle_t
25702578
]
25712579

2580+
###############################################################################
2581+
## @brief Function-pointer for urProgramBuildExp
2582+
if __use_win_types:
2583+
_urProgramBuildExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2584+
else:
2585+
_urProgramBuildExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2586+
2587+
###############################################################################
2588+
## @brief Function-pointer for urProgramCompileExp
2589+
if __use_win_types:
2590+
_urProgramCompileExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2591+
else:
2592+
_urProgramCompileExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2593+
2594+
###############################################################################
2595+
## @brief Function-pointer for urProgramLinkExp
2596+
if __use_win_types:
2597+
_urProgramLinkExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, c_ulong, POINTER(ur_device_handle_t), c_ulong, POINTER(ur_program_handle_t), c_char_p, POINTER(ur_program_handle_t) )
2598+
else:
2599+
_urProgramLinkExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, c_ulong, POINTER(ur_device_handle_t), c_ulong, POINTER(ur_program_handle_t), c_char_p, POINTER(ur_program_handle_t) )
2600+
2601+
2602+
###############################################################################
2603+
## @brief Table of ProgramExp functions pointers
2604+
class ur_program_exp_dditable_t(Structure):
2605+
_fields_ = [
2606+
("pfnBuildExp", c_void_p), ## _urProgramBuildExp_t
2607+
("pfnCompileExp", c_void_p), ## _urProgramCompileExp_t
2608+
("pfnLinkExp", c_void_p) ## _urProgramLinkExp_t
2609+
]
2610+
25722611
###############################################################################
25732612
## @brief Function-pointer for urKernelCreate
25742613
if __use_win_types:
@@ -3754,6 +3793,7 @@ class ur_dditable_t(Structure):
37543793
("Context", ur_context_dditable_t),
37553794
("Event", ur_event_dditable_t),
37563795
("Program", ur_program_dditable_t),
3796+
("ProgramExp", ur_program_exp_dditable_t),
37573797
("Kernel", ur_kernel_dditable_t),
37583798
("Sampler", ur_sampler_dditable_t),
37593799
("Mem", ur_mem_dditable_t),
@@ -3856,6 +3896,18 @@ def __init__(self, version : ur_api_version_t):
38563896
self.urProgramGetNativeHandle = _urProgramGetNativeHandle_t(self.__dditable.Program.pfnGetNativeHandle)
38573897
self.urProgramCreateWithNativeHandle = _urProgramCreateWithNativeHandle_t(self.__dditable.Program.pfnCreateWithNativeHandle)
38583898

3899+
# call driver to get function pointers
3900+
ProgramExp = ur_program_exp_dditable_t()
3901+
r = ur_result_v(self.__dll.urGetProgramExpProcAddrTable(version, byref(ProgramExp)))
3902+
if r != ur_result_v.SUCCESS:
3903+
raise Exception(r)
3904+
self.__dditable.ProgramExp = ProgramExp
3905+
3906+
# attach function interface to function address
3907+
self.urProgramBuildExp = _urProgramBuildExp_t(self.__dditable.ProgramExp.pfnBuildExp)
3908+
self.urProgramCompileExp = _urProgramCompileExp_t(self.__dditable.ProgramExp.pfnCompileExp)
3909+
self.urProgramLinkExp = _urProgramLinkExp_t(self.__dditable.ProgramExp.pfnLinkExp)
3910+
38593911
# call driver to get function pointers
38603912
Kernel = ur_kernel_dditable_t()
38613913
r = ur_result_v(self.__dll.urGetKernelProcAddrTable(version, byref(Kernel)))

include/ur_api.h

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ typedef enum ur_function_t {
205205
UR_FUNCTION_ADAPTER_RETAIN = 179, ///< Enumerator for ::urAdapterRetain
206206
UR_FUNCTION_ADAPTER_GET_LAST_ERROR = 180, ///< Enumerator for ::urAdapterGetLastError
207207
UR_FUNCTION_ADAPTER_GET_INFO = 181, ///< Enumerator for ::urAdapterGetInfo
208+
UR_FUNCTION_PROGRAM_BUILD_EXP = 197, ///< Enumerator for ::urProgramBuildExp
209+
UR_FUNCTION_PROGRAM_COMPILE_EXP = 198, ///< Enumerator for ::urProgramCompileExp
210+
UR_FUNCTION_PROGRAM_LINK_EXP = 199, ///< Enumerator for ::urProgramLinkExp
208211
/// @cond
209212
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
210213
/// @endcond
@@ -8030,6 +8033,131 @@ urCommandBufferEnqueueExp(
80308033
///< command-buffer execution instance.
80318034
);
80328035

8036+
#if !defined(__GNUC__)
8037+
#pragma endregion
8038+
#endif
8039+
// Intel 'oneAPI' Unified Runtime Experimental APIs for multi-device compile
8040+
#if !defined(__GNUC__)
8041+
#pragma region multi device compile(experimental)
8042+
#endif
8043+
///////////////////////////////////////////////////////////////////////////////
8044+
#ifndef UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
8045+
/// @brief The extension string which defines support for test
8046+
/// which is returned when querying device extensions.
8047+
#define UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP "ur_exp_multi_device_compile"
8048+
#endif // UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
8049+
8050+
///////////////////////////////////////////////////////////////////////////////
8051+
/// @brief Produces an executable program from one program, negates need for the
8052+
/// linking step.
8053+
///
8054+
/// @details
8055+
/// - The application may call this function from simultaneous threads.
8056+
/// - Following a successful call to this entry point, the program passed
8057+
/// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type
8058+
/// for each device in `phDevices`.
8059+
///
8060+
/// @remarks
8061+
/// _Analogues_
8062+
/// - **clBuildProgram**
8063+
///
8064+
/// @returns
8065+
/// - ::UR_RESULT_SUCCESS
8066+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8067+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8068+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8069+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8070+
/// + `NULL == hProgram`
8071+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8072+
/// + `NULL == phDevices`
8073+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8074+
/// + If `hProgram` isn't a valid program object.
8075+
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
8076+
/// + If an error occurred when building `hProgram`.
8077+
UR_APIEXPORT ur_result_t UR_APICALL
8078+
urProgramBuildExp(
8079+
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
8080+
uint32_t numDevices, ///< [in] number of devices
8081+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8082+
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
8083+
);
8084+
8085+
///////////////////////////////////////////////////////////////////////////////
8086+
/// @brief Produces an executable program from one or more programs.
8087+
///
8088+
/// @details
8089+
/// - The application may call this function from simultaneous threads.
8090+
/// - Following a successful call to this entry point `hProgram` will
8091+
/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type
8092+
/// for each device in `phDevices`.
8093+
///
8094+
/// @remarks
8095+
/// _Analogues_
8096+
/// - **clCompileProgram**
8097+
///
8098+
/// @returns
8099+
/// - ::UR_RESULT_SUCCESS
8100+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8101+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8102+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8103+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8104+
/// + `NULL == hProgram`
8105+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8106+
/// + `NULL == phDevices`
8107+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8108+
/// + If `hProgram` isn't a valid program object.
8109+
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
8110+
/// + If an error occurred while compiling `hProgram`.
8111+
UR_APIEXPORT ur_result_t UR_APICALL
8112+
urProgramCompileExp(
8113+
ur_program_handle_t hProgram, ///< [in][out] handle of the program to compile.
8114+
uint32_t numDevices, ///< [in] number of devices
8115+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8116+
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
8117+
);
8118+
8119+
///////////////////////////////////////////////////////////////////////////////
8120+
/// @brief Produces an executable program from one or more programs.
8121+
///
8122+
/// @details
8123+
/// - The application may call this function from simultaneous threads.
8124+
/// - Following a successful call to this entry point the program returned
8125+
/// in `phProgram` will contain a binary of the
8126+
/// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in
8127+
/// `phDevices`.
8128+
///
8129+
/// @remarks
8130+
/// _Analogues_
8131+
/// - **clLinkProgram**
8132+
///
8133+
/// @returns
8134+
/// - ::UR_RESULT_SUCCESS
8135+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8136+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8137+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8138+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8139+
/// + `NULL == hContext`
8140+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8141+
/// + `NULL == phDevices`
8142+
/// + `NULL == phPrograms`
8143+
/// + `NULL == phProgram`
8144+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8145+
/// + If one of the programs in `phPrograms` isn't a valid program object.
8146+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
8147+
/// + `count == 0`
8148+
/// - ::UR_RESULT_ERROR_PROGRAM_LINK_FAILURE
8149+
/// + If an error occurred while linking `phPrograms`.
8150+
UR_APIEXPORT ur_result_t UR_APICALL
8151+
urProgramLinkExp(
8152+
ur_context_handle_t hContext, ///< [in] handle of the context instance.
8153+
uint32_t numDevices, ///< [in] number of devices
8154+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8155+
uint32_t count, ///< [in] number of program handles in `phPrograms`.
8156+
const ur_program_handle_t *phPrograms, ///< [in][range(0, count)] pointer to array of program handles.
8157+
const char *pOptions, ///< [in][optional] pointer to linker options null-terminated string.
8158+
ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created.
8159+
);
8160+
80338161
#if !defined(__GNUC__)
80348162
#pragma endregion
80358163
#endif
@@ -8531,6 +8659,17 @@ typedef struct ur_program_build_params_t {
85318659
const char **ppOptions;
85328660
} ur_program_build_params_t;
85338661

8662+
///////////////////////////////////////////////////////////////////////////////
8663+
/// @brief Function parameters for urProgramBuildExp
8664+
/// @details Each entry is a pointer to the parameter passed to the function;
8665+
/// allowing the callback the ability to modify the parameter's value
8666+
typedef struct ur_program_build_exp_params_t {
8667+
ur_program_handle_t *phProgram;
8668+
uint32_t *pnumDevices;
8669+
ur_device_handle_t **pphDevices;
8670+
const char **ppOptions;
8671+
} ur_program_build_exp_params_t;
8672+
85348673
///////////////////////////////////////////////////////////////////////////////
85358674
/// @brief Function parameters for urProgramCompile
85368675
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8541,6 +8680,17 @@ typedef struct ur_program_compile_params_t {
85418680
const char **ppOptions;
85428681
} ur_program_compile_params_t;
85438682

8683+
///////////////////////////////////////////////////////////////////////////////
8684+
/// @brief Function parameters for urProgramCompileExp
8685+
/// @details Each entry is a pointer to the parameter passed to the function;
8686+
/// allowing the callback the ability to modify the parameter's value
8687+
typedef struct ur_program_compile_exp_params_t {
8688+
ur_program_handle_t *phProgram;
8689+
uint32_t *pnumDevices;
8690+
ur_device_handle_t **pphDevices;
8691+
const char **ppOptions;
8692+
} ur_program_compile_exp_params_t;
8693+
85448694
///////////////////////////////////////////////////////////////////////////////
85458695
/// @brief Function parameters for urProgramLink
85468696
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8553,6 +8703,20 @@ typedef struct ur_program_link_params_t {
85538703
ur_program_handle_t **pphProgram;
85548704
} ur_program_link_params_t;
85558705

8706+
///////////////////////////////////////////////////////////////////////////////
8707+
/// @brief Function parameters for urProgramLinkExp
8708+
/// @details Each entry is a pointer to the parameter passed to the function;
8709+
/// allowing the callback the ability to modify the parameter's value
8710+
typedef struct ur_program_link_exp_params_t {
8711+
ur_context_handle_t *phContext;
8712+
uint32_t *pnumDevices;
8713+
ur_device_handle_t **pphDevices;
8714+
uint32_t *pcount;
8715+
const ur_program_handle_t **pphPrograms;
8716+
const char **ppOptions;
8717+
ur_program_handle_t **pphProgram;
8718+
} ur_program_link_exp_params_t;
8719+
85568720
///////////////////////////////////////////////////////////////////////////////
85578721
/// @brief Function parameters for urProgramRetain
85588722
/// @details Each entry is a pointer to the parameter passed to the function;

0 commit comments

Comments
 (0)