Skip to content
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
2 changes: 1 addition & 1 deletion .github/intel-llvm-mirror-base-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
92690a39bcb6bd40dce506d08ce4636564f314f2
5f86594c35c62c45d6928e07a7191c62d69248dd
8 changes: 7 additions & 1 deletion cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ endif()

function(add_ur_target_compile_options name)
if(NOT MSVC)
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
if (NOT LLVM_ENABLE_PROJECTS)
# If UR is built as part of LLVM (i.e. as part of SYCL), then
# _FORTIFY_SOURCE will be set globally in advance to a potentially
# different value. To avoid redefinition errors, only set the
# macro for a "standalone" build.
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
endif()
target_compile_options(${name} PRIVATE
# Warning options
-Wall
Expand Down
12 changes: 8 additions & 4 deletions include/ur_api.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion include/ur_print.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions scripts/core/EXP-BINDLESS-IMAGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Enums
* ${X}_EXP_EXTERNAL_MEM_TYPE_WIN32_NT
* ${X}_EXP_EXTERNAL_MEM_TYPE_WIN32_NT_DX12_RESOURCE
* ${X}_EXP_EXTERNAL_MEM_TYPE_DMA_BUF
* ${X}_EXP_EXTERNAL_MEM_TYPE_WIN32_NT_DX11_RESOURCE

* ${x}_exp_external_semaphore_type_t
* ${X}_EXP_EXTERNAL_SEMAPHORE_TYPE_OPAQUE_FD
Expand Down Expand Up @@ -301,6 +302,9 @@ Changelog
| || * ${X}_EXP_EXTERNAL_MEM_TYPE_DMA_BUF |
| || * ${x}BindlessImagesSupportsImportingHandleTypeExp |
+----------+-------------------------------------------------------------+
| 26.0 || Added support for importing DX11 resources |
| || * ${X}_EXP_EXTERNAL_MEM_TYPE_WIN32_NT_DX11_RESOURCE |
+----------+-------------------------------------------------------------+

Contributors
--------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions scripts/core/exp-bindless-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ etors:
desc: "Win32 NT DirectX 12 resource handle"
- name: DMA_BUF
desc: "dma_buf file descriptor"
- name: WIN32_NT_DX11_RESOURCE
desc: "Win32 NT DirectX 11 resource handle"
--- #--------------------------------------------------------------------------
type: enum
desc: "Dictates the type of external semaphore handle."
Expand Down
2 changes: 1 addition & 1 deletion scripts/core/program.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ etors:
- name: BINARY_SIZES
desc: "[size_t[]] Return program binary sizes for each device."
- name: BINARIES
desc: "[unsigned char[]] Return program binaries for all devices for this Program. These are not null-terminated."
desc: "[unsigned char *[]] Write program binaries into caller-provided buffers for each device. These are not null-terminated."
- name: NUM_KERNELS
desc: "[size_t][optional-query] Number of kernels in Program, return type size_t."
- name: KERNEL_NAMES
Expand Down
2 changes: 1 addition & 1 deletion scripts/templates/print.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ur_bool
%>case ${ename}: {
%if th.value_traits.is_array(vtype):
<% atype = th.value_traits.get_array_name(vtype) %>
%if 'void' in atype:
%if 'void' in atype or '*' in atype:
const ${atype} const *tptr = (const ${atype} const*)ptr;
%else:
const ${atype} *tptr = (const ${atype} *)ptr;
Expand Down
4 changes: 4 additions & 0 deletions source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportExternalMemoryExp(
extMemDesc.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE;
extMemDesc.flags = CUDA_EXTERNAL_MEMORY_DEDICATED;
break;
case UR_EXP_EXTERNAL_MEM_TYPE_WIN32_NT_DX11_RESOURCE:
extMemDesc.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE;
extMemDesc.flags = CUDA_EXTERNAL_MEMORY_DEDICATED;
break;
default:
return UR_RESULT_ERROR_INVALID_VALUE;
}
Expand Down
8 changes: 8 additions & 0 deletions source/adapters/hip/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportExternalMemoryExp(
extMemDesc.flags = hipExternalMemoryDedicated;
#else
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
#endif
break;
case UR_EXP_EXTERNAL_MEM_TYPE_WIN32_NT_DX11_RESOURCE:
#if HIP_VERSION >= 50600000
extMemDesc.type = hipExternalMemoryHandleTypeD3D11Resource;
extMemDesc.flags = hipExternalMemoryDedicated;
#else
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
#endif
break;
default:
Expand Down
112 changes: 5 additions & 107 deletions source/adapters/level_zero/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,32 +309,23 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()

if (UrL0Debug & UR_L0_DEBUG_BASIC) {
logger.setLegacySink(std::make_unique<ur_legacy_sink>());
#ifdef UR_ADAPTER_LEVEL_ZERO_V2
setEnvVar("ZEL_ENABLE_LOADER_LOGGING", "1");
setEnvVar("ZEL_LOADER_LOGGING_LEVEL", "trace");
setEnvVar("ZEL_LOADER_LOG_CONSOLE", "1");
setEnvVar("ZE_ENABLE_VALIDATION_LAYER", "1");
#endif
};

if (UrL0Debug & UR_L0_DEBUG_VALIDATION) {
setEnvVar("ZE_ENABLE_VALIDATION_LAYER", "1");
setEnvVar("ZE_ENABLE_PARAMETER_VALIDATION", "1");
}

PlatformCache.Compute = [](Result<PlatformVec> &result) {
static std::once_flag ZeCallCountInitialized;
try {
std::call_once(ZeCallCountInitialized, []() {
if (UrL0LeaksDebug) {
ZeCallCount = new std::map<std::string, int>;
}
});
} catch (...) {
result = exceptionToResult(std::current_exception());
return;
}
if (UrL0LeaksDebug) {
setEnvVar("ZE_ENABLE_VALIDATION_LAYER", "1");
setEnvVar("ZEL_ENABLE_BASIC_LEAK_CHECKER", "1");
}

PlatformCache.Compute = [](Result<PlatformVec> &result) {
uint32_t UserForcedSysManInit = 0;
// Check if the user has disabled the default L0 Env initialization.
const int UrSysManEnvInitEnabled = [&UserForcedSysManInit] {
Expand Down Expand Up @@ -426,7 +417,6 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
useInitDrivers = true;
}

#ifdef UR_ADAPTER_LEVEL_ZERO_V2
if ((loader_version.major == 1 && loader_version.minor < 21) ||
(loader_version.major == 1 && loader_version.minor == 21 &&
loader_version.patch < 2)) {
Expand All @@ -435,7 +425,6 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
"WARNING: Level Zero Loader version is older than 1.21.2. "
"Please update to the latest version for API logging support.\n");
}
#endif
}

if (useInitDrivers) {
Expand Down Expand Up @@ -552,97 +541,6 @@ void globalAdapterOnDemandCleanup() {
}

ur_result_t adapterStateTeardown() {
// Print the balance of various create/destroy native calls.
// The idea is to verify if the number of create(+) and destroy(-) calls are
// matched.
if (ZeCallCount && (UrL0LeaksDebug) != 0) {
bool LeakFound = false;
// clang-format off
//
// The format of this table is such that each row accounts for a
// specific type of objects, and all elements in the raw except the last
// one are allocating objects of that type, while the last element is known
// to deallocate objects of that type.
//
std::vector<std::vector<std::string>> CreateDestroySet = {
{"zeContextCreate", "zeContextDestroy"},
{"zeCommandQueueCreate", "zeCommandQueueDestroy"},
{"zeModuleCreate", "zeModuleDestroy"},
{"zeKernelCreate", "zeKernelDestroy"},
{"zeEventPoolCreate", "zeEventPoolDestroy"},
{"zeCommandListCreateImmediate", "zeCommandListCreate", "zeCommandListDestroy"},
{"zeEventCreate", "zeEventDestroy"},
{"zeFenceCreate", "zeFenceDestroy"},
{"zeImageCreate","zeImageViewCreateExt", "zeImageDestroy"},
{"zeSamplerCreate", "zeSamplerDestroy"},
{"zeMemAllocDevice", "zeMemAllocHost", "zeMemAllocShared", "zeMemFree"},
};

// A sample output aimed below is this:
// ------------------------------------------------------------------------
// zeContextCreate = 1 \---> zeContextDestroy = 1
// zeCommandQueueCreate = 1 \---> zeCommandQueueDestroy = 1
// zeModuleCreate = 1 \---> zeModuleDestroy = 1
// zeKernelCreate = 1 \---> zeKernelDestroy = 1
// zeEventPoolCreate = 1 \---> zeEventPoolDestroy = 1
// zeCommandListCreateImmediate = 1 |
// zeCommandListCreate = 1 \---> zeCommandListDestroy = 1 ---> LEAK = 1
// zeEventCreate = 2 \---> zeEventDestroy = 2
// zeFenceCreate = 1 \---> zeFenceDestroy = 1
// zeImageCreate = 0 \---> zeImageDestroy = 0
// zeSamplerCreate = 0 \---> zeSamplerDestroy = 0
// zeMemAllocDevice = 0 |
// zeMemAllocHost = 1 |
// zeMemAllocShared = 0 \---> zeMemFree = 1
//
// clang-format on
// TODO: use logger to print this messages
std::cerr << "Check balance of create/destroy calls\n";
std::cerr << "----------------------------------------------------------\n";
std::stringstream ss;
for (const auto &Row : CreateDestroySet) {
int diff = 0;
for (auto I = Row.begin(); I != Row.end();) {
const char *ZeName = (*I).c_str();
const auto &ZeCount = (*ZeCallCount)[*I];

bool First = (I == Row.begin());
bool Last = (++I == Row.end());

if (Last) {
ss << " \\--->";
diff -= ZeCount;
} else {
diff += ZeCount;
if (!First) {
ss << " | ";
std::cerr << ss.str() << "\n";
ss.str("");
ss.clear();
}
}
ss << std::setw(30) << std::right << ZeName;
ss << " = ";
ss << std::setw(5) << std::left << ZeCount;
}

if (diff) {
LeakFound = true;
ss << " ---> LEAK = " << diff;
}

std::cerr << ss.str() << '\n';
ss.str("");
ss.clear();
}

ZeCallCount->clear();
delete ZeCallCount;
ZeCallCount = nullptr;
if (LeakFound)
return UR_RESULT_ERROR_INVALID_MEM_OBJECT;
}

// Due to multiple DLLMain definitions with SYCL, register to cleanup the
// Global Adapter after refcnt is 0
#if defined(_WIN32)
Expand Down
23 changes: 0 additions & 23 deletions source/adapters/level_zero/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ bool setEnvVar(const char *name, const char *value) {

ZeUSMImportExtension ZeUSMImport;

std::map<std::string, int> *ZeCallCount = nullptr;

void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
switch (ZeError) {
#define ZE_ERRCASE(ERR) \
Expand Down Expand Up @@ -137,31 +135,10 @@ void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
} // switch
}

#ifdef UR_ADAPTER_LEVEL_ZERO_V2
ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *, const char *,
bool) {
return ZeResult;
}
#else
ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName,
const char *ZeArgs, bool TraceError) {
UR_LOG(DEBUG, "ZE ---> {}{}", ZeName, ZeArgs);

if (ZeResult == ZE_RESULT_SUCCESS) {
if (UrL0LeaksDebug) {
++(*ZeCallCount)[ZeName];
}
return ZE_RESULT_SUCCESS;
}

if (TraceError) {
const char *ErrorString = "Unknown";
zeParseError(ZeResult, ErrorString);
UR_LOG(ERR, "Error ({}) in {}", ErrorString, ZeName);
}
return ZeResult;
}
#endif

// Specializations for various L0 structures
template <> ze_structure_type_t getZeStructureType<ze_event_pool_desc_t>() {
Expand Down
3 changes: 0 additions & 3 deletions source/adapters/level_zero/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,6 @@ class ZeUSMImportExtension {
// Helper wrapper for working with USM import extension in Level Zero.
extern ZeUSMImportExtension ZeUSMImport;

// This will count the calls to Level-Zero
extern std::map<std::string, int> *ZeCallCount;

// Some opencl extensions we know are supported by all Level Zero devices.
constexpr char ZE_SUPPORTED_EXTENSIONS[] =
"cl_khr_il_program cl_khr_subgroups cl_intel_subgroups "
Expand Down
3 changes: 3 additions & 0 deletions source/adapters/level_zero/image_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,9 @@ ur_result_t urBindlessImagesImportExternalMemoryExp(
case UR_EXP_EXTERNAL_MEM_TYPE_WIN32_NT_DX12_RESOURCE:
importWin32->flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE;
break;
case UR_EXP_EXTERNAL_MEM_TYPE_WIN32_NT_DX11_RESOURCE:
importWin32->flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D11_TEXTURE;
break;
default:
delete importWin32;
delete externalMemoryData;
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/level_zero/v2/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ ur_result_t ur_exp_command_buffer_handle_t_::registerExecutionEventUnlocked(
}

ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() {
UR_CALL_NOCHECK(commandListManager.lock()->releaseSubmittedKernels());

if (currentExecution) {
currentExecution->release();
}
Expand Down
3 changes: 1 addition & 2 deletions source/loader/layers/sanitizer/msan/msan_ddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ ur_result_t urEnqueueUSMFill2DFallback(ur_queue_handle_t hQueue, void *pMem,
ur_result_t Result = getContext()->urDdiTable.Enqueue.pfnUSMFill2D(
hQueue, pMem, pitch, patternSize, pPattern, width, height,
numEventsInWaitList, phEventWaitList, phEvent);
if (Result == UR_RESULT_SUCCESS ||
Result != UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
if (Result != UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
return Result;
}

Expand Down
4 changes: 2 additions & 2 deletions source/loader/layers/validation/ur_valddi.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading