Skip to content

Commit 6db5db0

Browse files
committed
Merge branch 'sycl' into review/yang/fix_metadata_assert
2 parents 934a406 + 7f19a0a commit 6db5db0

34 files changed

+405
-175
lines changed

cmake/FetchLevelZero.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ if (UR_COMPUTE_RUNTIME_TAG STREQUAL "")
104104
set(UR_COMPUTE_RUNTIME_TAG 24.39.31294.12)
105105
endif()
106106
include(FetchContent)
107-
# Sparse fetch only the dir with level zero headers to avoid pulling in the entire compute-runtime.
108-
FetchContentSparse_Declare(compute-runtime-level-zero-headers ${UR_COMPUTE_RUNTIME_REPO} "${UR_COMPUTE_RUNTIME_TAG}" "level_zero/include")
109-
FetchContent_GetProperties(compute-runtime-level-zero-headers)
110-
if(NOT compute-runtime-level-zero-headers_POPULATED)
111-
FetchContent_Populate(compute-runtime-level-zero-headers)
107+
# Sparse fetch only the dir with level zero headers for experimental features to avoid pulling in the entire compute-runtime.
108+
FetchContentSparse_Declare(exp-headers ${UR_COMPUTE_RUNTIME_REPO} "${UR_COMPUTE_RUNTIME_TAG}" "level_zero/include")
109+
FetchContent_GetProperties(exp-headers)
110+
if(NOT exp-headers_POPULATED)
111+
FetchContent_Populate(exp-headers)
112112
endif()
113113
add_library(ComputeRuntimeLevelZero-Headers INTERFACE)
114-
set(COMPUTE_RUNTIME_LEVEL_ZERO_INCLUDE "${compute-runtime-level-zero-headers_SOURCE_DIR}/../..")
114+
set(COMPUTE_RUNTIME_LEVEL_ZERO_INCLUDE "${exp-headers_SOURCE_DIR}/../..")
115115
message(STATUS "Level Zero Adapter: Using Level Zero headers from ${COMPUTE_RUNTIME_LEVEL_ZERO_INCLUDE}")
116116
target_include_directories(ComputeRuntimeLevelZero-Headers
117117
INTERFACE "$<BUILD_INTERFACE:${COMPUTE_RUNTIME_LEVEL_ZERO_INCLUDE}>"

cmake/helpers.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ else()
7979
set(CXX_HAS_CFI_SANITIZE OFF)
8080
endif()
8181

82+
set(CFI_FLAGS "")
83+
if (CFI_HAS_CFI_SANITIZE)
84+
# cfi-icall requires called functions in shared libraries to also be built with cfi-icall, which we can't
85+
# guarantee. -fsanitize=cfi depends on -flto
86+
set(CFI_FLAGS "-flto -fsanitize=cfi -fno-sanitize=cfi-icall -fsanitize-ignorelist=${CMAKE_SOURCE_DIR}/sanitizer-ignorelist.txt")
87+
endif()
88+
8289
function(add_ur_target_compile_options name)
8390
if(NOT MSVC)
8491
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
@@ -95,9 +102,8 @@ function(add_ur_target_compile_options name)
95102
-fPIC
96103
-fstack-protector-strong
97104
-fvisibility=hidden
98-
# cfi-icall requires called functions in shared libraries to also be built with cfi-icall, which we can't
99-
# guarantee. -fsanitize=cfi depends on -flto
100-
$<$<BOOL:${CXX_HAS_CFI_SANITIZE}>:-flto -fsanitize=cfi -fno-sanitize=cfi-icall>
105+
106+
${CFI_FLAGS}
101107
$<$<BOOL:${CXX_HAS_FCF_PROTECTION_FULL}>:-fcf-protection=full>
102108
$<$<BOOL:${CXX_HAS_FSTACK_CLASH_PROTECTION}>:-fstack-clash-protection>
103109

@@ -135,7 +141,7 @@ function(add_ur_target_link_options name)
135141
if(NOT MSVC)
136142
if (NOT APPLE)
137143
target_link_options(${name} PRIVATE
138-
$<$<BOOL:${CXX_HAS_CFI_SANITIZE}>:-flto -fsanitize=cfi -fno-sanitize=cfi-icall>
144+
${CFI_FLAGS}
139145
"LINKER:-z,relro,-z,now,-z,noexecstack"
140146
)
141147
if (UR_DEVELOPER_MODE)

include/ur_api.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,9 @@ typedef enum ur_adapter_info_t {
967967
///< The reference count returned should be considered immediately stale.
968968
///< It is unsuitable for general use in applications. This feature is
969969
///< provided for identifying memory leaks.
970+
UR_ADAPTER_INFO_VERSION = 2, ///< [uint32_t] Specifies the adapter version, initial value of 1 and
971+
///< incremented unpon major changes, e.g. when multiple versions of an
972+
///< adapter may exist in parallel.
970973
/// @cond
971974
UR_ADAPTER_INFO_FORCE_UINT32 = 0x7fffffff
972975
/// @endcond
@@ -988,7 +991,7 @@ typedef enum ur_adapter_info_t {
988991
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
989992
/// + `NULL == hAdapter`
990993
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
991-
/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName`
994+
/// + `::UR_ADAPTER_INFO_VERSION < propName`
992995
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
993996
/// + If `propName` is not supported by the adapter.
994997
/// - ::UR_RESULT_ERROR_INVALID_SIZE
@@ -9560,6 +9563,7 @@ typedef enum ur_exp_launch_property_id_t {
95609563
UR_EXP_LAUNCH_PROPERTY_ID_IGNORE = 0, ///< The property has no effect
95619564
UR_EXP_LAUNCH_PROPERTY_ID_COOPERATIVE = 1, ///< Whether to launch a cooperative kernel
95629565
UR_EXP_LAUNCH_PROPERTY_ID_CLUSTER_DIMENSION = 2, ///< work-group cluster dimensions
9566+
UR_EXP_LAUNCH_PROPERTY_ID_WORK_GROUP_MEMORY = 3, ///< Implicit work group memory allocation
95639567
/// @cond
95649568
UR_EXP_LAUNCH_PROPERTY_ID_FORCE_UINT32 = 0x7fffffff
95659569
/// @endcond
@@ -9573,10 +9577,12 @@ typedef enum ur_exp_launch_property_id_t {
95739577
/// _Analogues_
95749578
/// - **CUlaunchAttributeValue**
95759579
typedef union ur_exp_launch_property_value_t {
9576-
uint32_t clusterDim[3]; ///< [in] dimensions of the cluster (units of work-group) (x, y, z). Each
9577-
///< value must be a divisor of the corresponding global work-size
9578-
///< dimension (in units of work-group).
9579-
int cooperative; ///< [in] non-zero value indicates a cooperative kernel
9580+
uint32_t clusterDim[3]; ///< [in] dimensions of the cluster (units of work-group) (x, y, z). Each
9581+
///< value must be a divisor of the corresponding global work-size
9582+
///< dimension (in units of work-group).
9583+
int cooperative; ///< [in] non-zero value indicates a cooperative kernel
9584+
size_t workgroup_mem_size; ///< [in] non-zero value indicates the amount of work group memory to
9585+
///< allocate in bytes
95809586

95819587
} ur_exp_launch_property_value_t;
95829588

@@ -9617,6 +9623,7 @@ typedef struct ur_exp_launch_property_t {
96179623
/// + NULL == hQueue
96189624
/// + NULL == hKernel
96199625
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
9626+
/// + `NULL == pGlobalWorkOffset`
96209627
/// + `NULL == pGlobalWorkSize`
96219628
/// + `NULL == launchPropList`
96229629
/// + NULL == pGlobalWorkSize
@@ -9645,6 +9652,8 @@ urEnqueueKernelLaunchCustomExp(
96459652
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
96469653
uint32_t workDim, ///< [in] number of dimensions, from 1 to 3, to specify the global and
96479654
///< work-group work-items
9655+
const size_t *pGlobalWorkOffset, ///< [in] pointer to an array of workDim unsigned values that specify the
9656+
///< offset used to calculate the global ID of a work-item
96489657
const size_t *pGlobalWorkSize, ///< [in] pointer to an array of workDim unsigned values that specify the
96499658
///< number of global work-items in workDim that will execute the kernel
96509659
///< function
@@ -11554,6 +11563,7 @@ typedef struct ur_enqueue_kernel_launch_custom_exp_params_t {
1155411563
ur_queue_handle_t *phQueue;
1155511564
ur_kernel_handle_t *phKernel;
1155611565
uint32_t *pworkDim;
11566+
const size_t **ppGlobalWorkOffset;
1155711567
const size_t **ppGlobalWorkSize;
1155811568
const size_t **ppLocalWorkSize;
1155911569
uint32_t *pnumPropsInLaunchPropList;

include/ur_ddi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnEnqueueKernelLaunchCustomExp_t)(
14671467
uint32_t,
14681468
const size_t *,
14691469
const size_t *,
1470+
const size_t *,
14701471
uint32_t,
14711472
const ur_exp_launch_property_t *,
14721473
uint32_t,

include/ur_print.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_adapter_info_t value)
19221922
case UR_ADAPTER_INFO_REFERENCE_COUNT:
19231923
os << "UR_ADAPTER_INFO_REFERENCE_COUNT";
19241924
break;
1925+
case UR_ADAPTER_INFO_VERSION:
1926+
os << "UR_ADAPTER_INFO_VERSION";
1927+
break;
19251928
default:
19261929
os << "unknown enumerator";
19271930
break;
@@ -1962,6 +1965,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_adapter_inf
19621965

19631966
os << ")";
19641967
} break;
1968+
case UR_ADAPTER_INFO_VERSION: {
1969+
const uint32_t *tptr = (const uint32_t *)ptr;
1970+
if (sizeof(uint32_t) > size) {
1971+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint32_t) << ")";
1972+
return UR_RESULT_ERROR_INVALID_SIZE;
1973+
}
1974+
os << (const void *)(tptr) << " (";
1975+
1976+
os << *tptr;
1977+
1978+
os << ")";
1979+
} break;
19651980
default:
19661981
os << "unknown enumerator";
19671982
return UR_RESULT_ERROR_INVALID_ENUMERATION;
@@ -10397,6 +10412,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_exp_launch_property_id
1039710412
case UR_EXP_LAUNCH_PROPERTY_ID_CLUSTER_DIMENSION:
1039810413
os << "UR_EXP_LAUNCH_PROPERTY_ID_CLUSTER_DIMENSION";
1039910414
break;
10415+
case UR_EXP_LAUNCH_PROPERTY_ID_WORK_GROUP_MEMORY:
10416+
os << "UR_EXP_LAUNCH_PROPERTY_ID_WORK_GROUP_MEMORY";
10417+
break;
1040010418
default:
1040110419
os << "unknown enumerator";
1040210420
break;
@@ -10433,6 +10451,13 @@ inline ur_result_t printUnion(
1043310451

1043410452
os << (params.cooperative);
1043510453

10454+
break;
10455+
case UR_EXP_LAUNCH_PROPERTY_ID_WORK_GROUP_MEMORY:
10456+
10457+
os << ".workgroup_mem_size = ";
10458+
10459+
os << (params.workgroup_mem_size);
10460+
1043610461
break;
1043710462
default:
1043810463
os << "<unknown>";
@@ -15100,6 +15125,12 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1510015125

1510115126
os << *(params->pworkDim);
1510215127

15128+
os << ", ";
15129+
os << ".pGlobalWorkOffset = ";
15130+
15131+
ur::details::printPtr(os,
15132+
*(params->ppGlobalWorkOffset));
15133+
1510315134
os << ", ";
1510415135
os << ".pGlobalWorkSize = ";
1510515136

sanitizer-ignorelist.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[cfi-unrelated-cast]
2+
# std::_Sp_counted_ptr_inplace::_Sp_counted_ptr_inplace() (libstdc++).
3+
# This ctor is used by std::make_shared and needs to cast to uninitialized T*
4+
# in order to call std::allocator_traits<T>::construct.
5+
# See: https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/cfi/cfi_ignorelist.txt
6+
fun:_ZNSt23_Sp_counted_ptr_inplace*

scripts/core/adapter.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ etors:
136136
[uint32_t] Reference count of the adapter.
137137
The reference count returned should be considered immediately stale.
138138
It is unsuitable for general use in applications. This feature is provided for identifying memory leaks.
139+
- name: VERSION
140+
desc: >
141+
[uint32_t] Specifies the adapter version, initial value of 1 and
142+
incremented unpon major changes, e.g. when multiple versions of an
143+
adapter may exist in parallel.
139144
--- #--------------------------------------------------------------------------
140145
type: function
141146
desc: "Retrieves information about the adapter"

scripts/core/exp-launch-properties.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ etors:
2929
desc: "Whether to launch a cooperative kernel"
3030
- name: CLUSTER_DIMENSION
3131
desc: "work-group cluster dimensions"
32+
- name: WORK_GROUP_MEMORY
33+
desc: "Implicit work group memory allocation"
3234
--- #--------------------------------------------------------------------------
3335
type: union
3436
desc: "Specifies a launch property value"
@@ -45,6 +47,10 @@ members:
4547
name: cooperative
4648
desc: "[in] non-zero value indicates a cooperative kernel"
4749
tag: $X_EXP_LAUNCH_PROPERTY_ID_COOPERATIVE
50+
- type: size_t
51+
name: workgroup_mem_size
52+
desc: "[in] non-zero value indicates the amount of work group memory to allocate in bytes"
53+
tag: $X_EXP_LAUNCH_PROPERTY_ID_WORK_GROUP_MEMORY
4854
--- #--------------------------------------------------------------------------
4955
type: struct
5056
desc: "Kernel launch property"
@@ -82,6 +88,9 @@ params:
8288
- type: uint32_t
8389
name: workDim
8490
desc: "[in] number of dimensions, from 1 to 3, to specify the global and work-group work-items"
91+
- type: "const size_t*"
92+
name: pGlobalWorkOffset
93+
desc: "[in] pointer to an array of workDim unsigned values that specify the offset used to calculate the global ID of a work-item"
8594
- type: const size_t*
8695
name: pGlobalWorkSize
8796
desc: "[in] pointer to an array of workDim unsigned values that specify the number of global work-items in workDim that will execute the kernel function"
@@ -97,10 +106,10 @@ params:
97106
- type: uint32_t
98107
name: numEventsInWaitList
99108
desc: "[in] size of the event wait list"
100-
- type: const ur_event_handle_t*
109+
- type: const $x_event_handle_t*
101110
name: phEventWaitList
102111
desc: "[in][optional][range(0, numEventsInWaitList)] pointer to a list of events that must be complete before the kernel execution. If nullptr, the numEventsInWaitList must be 0, indicating that no wait event. "
103-
- type: ur_event_handle_t*
112+
- type: $x_event_handle_t*
104113
name: phEvent
105114
desc: "[out][optional] return an event object that identifies this particular kernel execution instance. If phEventWaitList and phEvent are not NULL, phEvent must not refer to an element of the phEventWaitList array."
106115
returns:

source/adapters/cuda/adapter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t,
108108
return ReturnValue(UR_ADAPTER_BACKEND_CUDA);
109109
case UR_ADAPTER_INFO_REFERENCE_COUNT:
110110
return ReturnValue(adapter.RefCount.load());
111+
case UR_ADAPTER_INFO_VERSION:
112+
return ReturnValue(uint32_t{1});
111113
default:
112114
return UR_RESULT_ERROR_INVALID_ENUMERATION;
113115
}

0 commit comments

Comments
 (0)