Skip to content

Commit 0caa66d

Browse files
let's pretend it all has been done in one commit
1 parent b37d0d4 commit 0caa66d

File tree

16 files changed

+1086
-74
lines changed

16 files changed

+1086
-74
lines changed

devops/scripts/benchmarks/utils/compute_runtime.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,20 @@ def build_compute_runtime(self):
203203
# Remove -Werror...
204204
replace_in_file(cmakelists_path, r"\s-Werror(?:=[a-zA-Z]*)?", "")
205205

206-
log.info("Building Compute Runtime...")
207-
extra_config_args = [
208-
"-DNEO_ENABLE_i915_PRELIM_DETECTION=1",
209-
"-DNEO_ENABLE_I915_PRELIM_DETECTION=1",
210-
"-DNEO_SKIP_UNIT_TESTS=1",
211-
f"-DGMM_DIR={self.gmmlib}",
212-
f"-DLEVEL_ZERO_ROOT={self.level_zero}",
213-
]
214-
if options.build_igc:
215-
extra_config_args.append(f"-DIGC_DIR={self.igc}")
206+
log.info("Building Compute Runtime...")
207+
configure_command = [
208+
"cmake",
209+
f"-B {self.compute_runtime_build}",
210+
f"-S {self.compute_runtime_repo}",
211+
"-DCMAKE_BUILD_TYPE=Debug",
212+
"-DNEO_ENABLE_i915_PRELIM_DETECTION=1",
213+
"-DNEO_ENABLE_I915_PRELIM_DETECTION=1",
214+
"-DNEO_SKIP_UNIT_TESTS=1",
215+
f"-DGMM_DIR={self.gmmlib}",
216+
f"-DLEVEL_ZERO_ROOT={self.level_zero}",
217+
]
218+
if options.build_igc:
219+
configure_command.append(f"-DIGC_DIR={self.igc}")
216220

217221
project.configure(extra_args=extra_config_args)
218222
project.build()

unified-runtime/source/adapters/level_zero/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
165165
${CMAKE_CURRENT_SOURCE_DIR}/v2/memory.hpp
166166
${CMAKE_CURRENT_SOURCE_DIR}/v2/lockable.hpp
167167
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_api.hpp
168+
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_batched.hpp
168169
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_in_order.hpp
169170
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_out_of_order.hpp
170171
${CMAKE_CURRENT_SOURCE_DIR}/v2/usm.hpp
@@ -181,6 +182,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
181182
${CMAKE_CURRENT_SOURCE_DIR}/v2/kernel.cpp
182183
${CMAKE_CURRENT_SOURCE_DIR}/v2/memory.cpp
183184
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_api.cpp
185+
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_batched.cpp
184186
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_create.cpp
185187
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_in_order.cpp
186188
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_out_of_order.cpp

unified-runtime/source/adapters/level_zero/adapter.cpp

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -506,72 +506,71 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
506506
bool forceLoadedAdapter = ur_getenv("UR_ADAPTERS_FORCE_LOAD").has_value();
507507
if (!forceLoadedAdapter) {
508508
#ifdef UR_ADAPTER_LEVEL_ZERO_V2
509-
auto [useV2, reason] = shouldUseV2Adapter();
510-
if (!useV2) {
511-
UR_LOG(INFO, "Skipping L0 V2 adapter: {}", reason);
512-
return;
513-
}
509+
auto [useV2, reason] = shouldUseV2Adapter();
510+
if (!useV2) {
511+
UR_LOG(INFO, "Skipping L0 V2 adapter: {}", reason);
512+
return;
513+
}
514514
#else
515-
auto [useV1, reason] = shouldUseV1Adapter();
516-
if (!useV1) {
517-
UR_LOG(INFO, "Skipping L0 V1 adapter: {}", reason);
518-
return;
519-
}
515+
auto [useV1, reason] = shouldUseV1Adapter();
516+
if (!useV1) {
517+
UR_LOG(INFO, "Skipping L0 V1 adapter: {}", reason);
518+
return;
519+
}
520520
#endif
521521
}
522522

523-
// Check if the user has enabled the default L0 SysMan initialization.
524-
const int UrSysmanZesinitEnable = [&UserForcedSysManInit] {
525-
const char *UrRet = std::getenv("UR_L0_ENABLE_ZESINIT_DEFAULT");
526-
if (!UrRet)
527-
return 0;
528-
UserForcedSysManInit &= 2;
529-
return std::atoi(UrRet);
530-
}();
531-
532-
bool ZesInitNeeded = UrSysmanZesinitEnable && !UrSysManEnvInitEnabled;
533-
// Unless the user has forced the SysMan init, we will check the device
534-
// version to see if the zesInit is needed.
535-
if (UserForcedSysManInit == 0 && checkDeviceIntelGPUIpVersionOrNewer(
536-
0x05004000) == UR_RESULT_SUCCESS) {
537-
if (UrSysManEnvInitEnabled) {
538-
setEnvVar("ZES_ENABLE_SYSMAN", "0");
539-
}
540-
ZesInitNeeded = true;
541-
}
542-
if (ZesInitNeeded) {
523+
// Check if the user has enabled the default L0 SysMan initialization.
524+
const int UrSysmanZesinitEnable = [&UserForcedSysManInit] {
525+
const char *UrRet = std::getenv("UR_L0_ENABLE_ZESINIT_DEFAULT");
526+
if (!UrRet)
527+
return 0;
528+
UserForcedSysManInit &= 2;
529+
return std::atoi(UrRet);
530+
}();
531+
532+
bool ZesInitNeeded = UrSysmanZesinitEnable && !UrSysManEnvInitEnabled;
533+
// Unless the user has forced the SysMan init, we will check the device
534+
// version to see if the zesInit is needed.
535+
if (UserForcedSysManInit == 0 &&
536+
checkDeviceIntelGPUIpVersionOrNewer(0x05004000) == UR_RESULT_SUCCESS) {
537+
if (UrSysManEnvInitEnabled) {
538+
setEnvVar("ZES_ENABLE_SYSMAN", "0");
539+
}
540+
ZesInitNeeded = true;
541+
}
542+
if (ZesInitNeeded) {
543543
#ifdef UR_STATIC_LEVEL_ZERO
544-
getDeviceByUUIdFunctionPtr = zesDriverGetDeviceByUuidExp;
545-
getSysManDriversFunctionPtr = zesDriverGet;
546-
sysManInitFunctionPtr = zesInit;
544+
getDeviceByUUIdFunctionPtr = zesDriverGetDeviceByUuidExp;
545+
getSysManDriversFunctionPtr = zesDriverGet;
546+
sysManInitFunctionPtr = zesInit;
547547
#else
548-
getDeviceByUUIdFunctionPtr = (zes_pfnDriverGetDeviceByUuidExp_t)
549-
ur_loader::LibLoader::getFunctionPtr(processHandle,
550-
"zesDriverGetDeviceByUuidExp");
551-
getSysManDriversFunctionPtr =
552-
(zes_pfnDriverGet_t)ur_loader::LibLoader::getFunctionPtr(
553-
processHandle, "zesDriverGet");
554-
sysManInitFunctionPtr =
555-
(zes_pfnInit_t)ur_loader::LibLoader::getFunctionPtr(processHandle,
556-
"zesInit");
548+
getDeviceByUUIdFunctionPtr =
549+
(zes_pfnDriverGetDeviceByUuidExp_t)ur_loader::LibLoader::getFunctionPtr(
550+
processHandle, "zesDriverGetDeviceByUuidExp");
551+
getSysManDriversFunctionPtr =
552+
(zes_pfnDriverGet_t)ur_loader::LibLoader::getFunctionPtr(
553+
processHandle, "zesDriverGet");
554+
sysManInitFunctionPtr = (zes_pfnInit_t)ur_loader::LibLoader::getFunctionPtr(
555+
processHandle, "zesInit");
557556
#endif
558-
}
559-
if (getDeviceByUUIdFunctionPtr && getSysManDriversFunctionPtr &&
560-
sysManInitFunctionPtr) {
561-
ze_init_flags_t L0ZesInitFlags = 0;
562-
UR_LOG(DEBUG, "\nzesInit with flags value of {}\n",
563-
static_cast<int>(L0ZesInitFlags));
564-
ZesResult = ZE_CALL_NOCHECK(sysManInitFunctionPtr, (L0ZesInitFlags));
565-
} else {
566-
ZesResult = ZE_RESULT_ERROR_UNINITIALIZED;
567-
}
557+
}
558+
if (getDeviceByUUIdFunctionPtr && getSysManDriversFunctionPtr &&
559+
sysManInitFunctionPtr) {
560+
ze_init_flags_t L0ZesInitFlags = 0;
561+
UR_LOG(DEBUG, "\nzesInit with flags value of {}\n",
562+
static_cast<int>(L0ZesInitFlags));
563+
ZesResult = ZE_CALL_NOCHECK(sysManInitFunctionPtr, (L0ZesInitFlags));
564+
} else {
565+
ZesResult = ZE_RESULT_ERROR_UNINITIALIZED;
566+
}
568567

569-
ur_result_t err = initPlatforms(this, platforms, ZesResult);
570-
if (err == UR_RESULT_SUCCESS) {
571-
Platforms = std::move(platforms);
572-
} else {
573-
throw err;
574-
}
568+
ur_result_t err = initPlatforms(this, platforms, ZesResult);
569+
if (err == UR_RESULT_SUCCESS) {
570+
Platforms = std::move(platforms);
571+
} else {
572+
throw err;
573+
}
575574
}
576575

577576
void globalAdapterOnDemandCleanup() {

unified-runtime/source/adapters/level_zero/v2/command_list_manager.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ wait_list_view ur_command_list_manager::getWaitListView(
129129
numWaitEvents + (additionalWaitEvent != nullptr ? 1 : 0);
130130
waitList.resize(totalNumWaitEvents);
131131
for (uint32_t i = 0; i < numWaitEvents; i++) {
132+
phWaitEvents[i]->runBatch();
132133
waitList[i] = phWaitEvents[i]->getZeEvent();
133134
}
134135
if (additionalWaitEvent != nullptr) {
@@ -499,6 +500,14 @@ ur_result_t ur_command_list_manager::appendTimestampRecordingExp(
499500
return UR_RESULT_SUCCESS;
500501
}
501502

503+
ur_result_t ur_command_list_manager::appendRegular(
504+
ze_command_list_handle_t *phCommandLists) {
505+
ZE2UR_CALL(zeCommandListImmediateAppendCommandListsExp,
506+
(getZeCommandList(), 1, phCommandLists, nullptr, 0, nullptr));
507+
508+
return UR_RESULT_SUCCESS;
509+
}
510+
502511
ur_result_t ur_command_list_manager::appendGenericCommandListsExp(
503512
uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists,
504513
ur_event_handle_t phEvent, uint32_t numEventsInWaitList,

unified-runtime/source/adapters/level_zero/v2/command_list_manager.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ struct ur_command_list_manager {
231231
const ur_event_handle_t *phEventWaitList,
232232
ur_event_handle_t phEvent);
233233

234+
ur_result_t appendRegular(ze_command_list_handle_t *phCommandLists);
235+
234236
private:
235237
ur_result_t appendGenericCommandListsExp(
236238
uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists,

unified-runtime/source/adapters/level_zero/v2/event.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <ze_api.h>
1212

13+
#include "adapters/level_zero/v2/usm.hpp"
1314
#include "context.hpp"
1415
#include "event.hpp"
1516
#include "event_pool.hpp"
@@ -123,10 +124,20 @@ void ur_event_handle_t_::setQueue(ur_queue_t_ *hQueue) {
123124
profilingData.reset();
124125
}
125126

127+
void ur_event_handle_t_::setBatch(ur_event_generation_t batch_generation) {
128+
this->batch_generation = batch_generation;
129+
}
130+
126131
void ur_event_handle_t_::setCommandType(ur_command_t commandType) {
127132
this->commandType = commandType;
128133
}
129134

135+
void ur_event_handle_t_::runBatch() {
136+
if (batch_generation != -1) {
137+
hQueue->runBatchIfCurrentBatch(batch_generation);
138+
}
139+
}
140+
130141
void ur_event_handle_t_::recordStartTimestamp() {
131142
// queue and device must be set before calling this
132143
assert(hQueue);
@@ -192,6 +203,8 @@ ur_event_handle_t_::getEventEndTimestampAndHandle() {
192203

193204
ur_queue_t_ *ur_event_handle_t_::getQueue() const { return hQueue; }
194205

206+
ur_event_generation_t ur_event_handle_t_::getBatch() const { return batch_generation; }
207+
195208
ur_context_handle_t ur_event_handle_t_::getContext() const { return hContext; }
196209

197210
ur_command_t ur_event_handle_t_::getCommandType() const { return commandType; }

unified-runtime/source/adapters/level_zero/v2/event.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "common/ur_ref_count.hpp"
2121
#include "event_provider.hpp"
2222

23+
using ur_event_generation_t = int64_t;
24+
2325
namespace v2 {
2426
class event_pool;
2527
}
@@ -68,7 +70,9 @@ struct ur_event_handle_t_ : ur_object {
6870

6971
// Set the queue and command that this event is associated with
7072
void setQueue(ur_queue_t_ *hQueue);
73+
void setBatch(ur_event_generation_t batch_generation);
7174
void setCommandType(ur_command_t commandType);
75+
void runBatch();
7276

7377
void reset();
7478
ze_event_handle_t getZeEvent() const;
@@ -98,6 +102,8 @@ struct ur_event_handle_t_ : ur_object {
98102
// Get the type of the command that this event is associated with
99103
ur_command_t getCommandType() const;
100104

105+
ur_event_generation_t getBatch() const;
106+
101107
// Get the device associated with this event
102108
ur_device_handle_t getDevice() const;
103109

@@ -129,6 +135,8 @@ struct ur_event_handle_t_ : ur_object {
129135
// queue and commandType that this event is associated with, set by enqueue
130136
// commands
131137
ur_queue_t_ *hQueue = nullptr;
138+
// default for non-batched queues
139+
ur_event_generation_t batch_generation = -1;
132140
ur_command_t commandType = UR_COMMAND_FORCE_UINT32;
133141
ur_device_handle_t hDevice = nullptr;
134142

unified-runtime/source/adapters/level_zero/v2/event_pool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void event_pool::free(ur_event_handle_t event) {
5050

5151
event->reset();
5252
freelist.push_back(event);
53+
event->setBatch(-1);
5354

5455
// The event is still in the pool, so we need to increment the refcount
5556
assert(event->RefCount.getCount() == 0);

unified-runtime/source/adapters/level_zero/v2/queue_api.hpp

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)