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
5 changes: 5 additions & 0 deletions scripts/templates/nullddi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ namespace driver

%endfor
}
%if not fname.endswith("DriverGet") and not re.match("Init", obj['name']):

char *env_str = context.setenv_var_with_driver_id("${fname}", ZEL_NULL_DRIVER_ID);
context.env_vars.push_back(env_str);
%endif

return result;
}
Expand Down
21 changes: 21 additions & 0 deletions source/drivers/null/ze_null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,27 @@ namespace driver
pSysman.isValidFlag = 1;
pSysman.version = ZE_API_VERSION_CURRENT;
}

char *context_t::setenv_var_with_driver_id(const std::string &key, uint32_t driverId)
{
std::string env = key + "=" + std::to_string(driverId);
char *env_str = strdup_safe(env.c_str());
putenv_safe(env_str);
return env_str;
}

context_t::~context_t()
{
for (auto handle : globalBaseNullHandle)
{
delete handle;
}

for (const auto &env_var : env_vars)
{
free(env_var);
}
}
} // namespace driver

namespace instrumented
Expand Down
13 changes: 6 additions & 7 deletions source/drivers/null/ze_null.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,23 @@ namespace driver
zet_dditable_t zetDdiTable = {};
zes_dditable_t zesDdiTable = {};
std::vector<BaseNullHandle*> globalBaseNullHandle;
bool ddiExtensionRequested = false;
bool ddiExtensionRequested = false;
std::vector<char *> env_vars{};
context_t();
~context_t() {
for (auto handle : globalBaseNullHandle) {
delete handle;
}
}
~context_t();

void* get( void )
{
static uint64_t count = 0x80800000;
static uint64_t count = 0x80800000 >> ZEL_NULL_DRIVER_ID;
if (ddiExtensionRequested) {
globalBaseNullHandle.push_back(new BaseNullHandle());
return reinterpret_cast<void*>(globalBaseNullHandle.back());
} else {
return reinterpret_cast<void*>( ++count );
}
}

char *setenv_var_with_driver_id(const std::string &key, uint32_t driverId);
};

extern context_t context;
Expand Down
Loading
Loading