Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/adapters' into georgi/hip_mema…
Browse files Browse the repository at this point in the history
…dvise
  • Loading branch information
GeorgeWeb committed Nov 22, 2023
2 parents e75ff28 + 31b654f commit c81a6e9
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 19 deletions.
4 changes: 2 additions & 2 deletions source/adapters/cuda/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t hContext,
}

UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp(
ur_context_handle_t, uint32_t, const ur_program_handle_t *, uint32_t,
ur_device_handle_t *, const char *, ur_program_handle_t *) {
ur_context_handle_t, uint32_t, ur_device_handle_t *, uint32_t,
const ur_program_handle_t *, const char *, ur_program_handle_t *) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

Expand Down
6 changes: 3 additions & 3 deletions source/adapters/cuda/ur_interface_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable(
if (UR_RESULT_SUCCESS != retVal) {
return retVal;
}
pDdiTable->pfnBuildExp = nullptr;
pDdiTable->pfnCompileExp = nullptr;
pDdiTable->pfnLinkExp = nullptr;
pDdiTable->pfnBuildExp = urProgramBuildExp;
pDdiTable->pfnCompileExp = urProgramCompileExp;
pDdiTable->pfnLinkExp = urProgramLinkExp;
return retVal;
}

Expand Down
4 changes: 2 additions & 2 deletions source/adapters/hip/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t,
}

UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp(
ur_context_handle_t, uint32_t, const ur_program_handle_t *, uint32_t,
ur_device_handle_t *, const char *, ur_program_handle_t *) {
ur_context_handle_t, uint32_t, ur_device_handle_t *, uint32_t,
const ur_program_handle_t *, const char *, ur_program_handle_t *) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

Expand Down
6 changes: 3 additions & 3 deletions source/adapters/hip/ur_interface_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable(
if (UR_RESULT_SUCCESS != retVal) {
return retVal;
}
pDdiTable->pfnBuildExp = nullptr;
pDdiTable->pfnCompileExp = nullptr;
pDdiTable->pfnLinkExp = nullptr;
pDdiTable->pfnBuildExp = urProgramBuildExp;
pDdiTable->pfnCompileExp = urProgramCompileExp;
pDdiTable->pfnLinkExp = urProgramLinkExp;
return retVal;
}

Expand Down
5 changes: 2 additions & 3 deletions source/adapters/level_zero/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ 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 && (UrL0Debug & UR_L0_DEBUG_CALL_COUNT) != 0) {
if (ZeCallCount && (UrL0LeaksDebug) != 0) {
// clang-format off
//
// The format of this table is such that each row accounts for a
Expand Down Expand Up @@ -79,8 +79,7 @@ ur_result_t adapterStateTeardown() {
//
// clang-format on

fprintf(stderr, "ZE_DEBUG=%d: check balance of create/destroy calls\n",
UR_L0_DEBUG_CALL_COUNT);
fprintf(stderr, "Check balance of create/destroy calls\n");
fprintf(stderr,
"----------------------------------------------------------\n");
for (const auto &Row : CreateDestroySet) {
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName,
const char *ZeArgs, bool TraceError) {
urPrint("ZE ---> %s%s\n", ZeName, ZeArgs);

if (UrL0Debug & UR_L0_DEBUG_CALL_COUNT) {
if (UrL0LeaksDebug) {
++(*ZeCallCount)[ZeName];
}

Expand Down
8 changes: 7 additions & 1 deletion source/adapters/level_zero/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ enum UrDebugLevel {
UR_L0_DEBUG_NONE = 0x0,
UR_L0_DEBUG_BASIC = 0x1,
UR_L0_DEBUG_VALIDATION = 0x2,
UR_L0_DEBUG_CALL_COUNT = 0x4,
UR_L0_DEBUG_ALL = -1
};

Expand All @@ -203,6 +202,13 @@ const int UrL0Debug = [] {
return DebugMode;
}();

const int UrL0LeaksDebug = [] {
const char *UrRet = std::getenv("UR_L0_LEAKS_DEBUG");
if (!UrRet)
return 0;
return std::atoi(UrRet);
}();

// Controls Level Zero calls serialization to w/a Level Zero driver being not MT
// ready. Recognized values (can be used as a bit mask):
enum {
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGet(
static std::once_flag ZeCallCountInitialized;
try {
std::call_once(ZeCallCountInitialized, []() {
if (UrL0Debug & UR_L0_DEBUG_CALL_COUNT) {
if (UrL0LeaksDebug) {
ZeCallCount = new std::map<std::string, int>;
}
});
Expand Down
20 changes: 20 additions & 0 deletions source/adapters/native_cpu/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ urProgramLink(ur_context_handle_t hContext, uint32_t count,
DIE_NO_IMPLEMENTATION
}

UR_APIEXPORT ur_result_t UR_APICALL urProgramCompileExp(ur_program_handle_t,
uint32_t,
ur_device_handle_t *,
const char *) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t,
uint32_t,
ur_device_handle_t *,
const char *) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp(
ur_context_handle_t, uint32_t, ur_device_handle_t *, uint32_t,
const ur_program_handle_t *, const char *, ur_program_handle_t *) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL
urProgramRetain(ur_program_handle_t hProgram) {
hProgram->incrementReferenceCount();
Expand Down
15 changes: 15 additions & 0 deletions source/adapters/native_cpu/ur_interface_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,19 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetVirtualMemProcAddrTable(
return retVal;
}

UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable(
ur_api_version_t version, ///< [in] API version requested
ur_program_exp_dditable_t
*pDdiTable ///< [in,out] pointer to table of DDI function pointers
) {
auto retVal = validateProcInputs(version, pDdiTable);
if (UR_RESULT_SUCCESS != retVal) {
return retVal;
}
pDdiTable->pfnBuildExp = urProgramBuildExp;
pDdiTable->pfnCompileExp = urProgramCompileExp;
pDdiTable->pfnLinkExp = urProgramLinkExp;
return retVal;
}

} // extern "C"
20 changes: 20 additions & 0 deletions source/adapters/opencl/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ urProgramLink(ur_context_handle_t hContext, uint32_t count,
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urProgramCompileExp(ur_program_handle_t,
uint32_t,
ur_device_handle_t *,
const char *) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t,
uint32_t,
ur_device_handle_t *,
const char *) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp(
ur_context_handle_t, uint32_t, ur_device_handle_t *, uint32_t,
const ur_program_handle_t *, const char *, ur_program_handle_t *) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

static cl_int mapURProgramBuildInfoToCL(ur_program_build_info_t URPropName) {

switch (static_cast<uint32_t>(URPropName)) {
Expand Down
6 changes: 3 additions & 3 deletions source/adapters/opencl/ur_interface_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable(
if (UR_RESULT_SUCCESS != retVal) {
return retVal;
}
pDdiTable->pfnBuildExp = nullptr;
pDdiTable->pfnCompileExp = nullptr;
pDdiTable->pfnLinkExp = nullptr;
pDdiTable->pfnBuildExp = urProgramBuildExp;
pDdiTable->pfnCompileExp = urProgramCompileExp;
pDdiTable->pfnLinkExp = urProgramLinkExp;
return retVal;
}

Expand Down

0 comments on commit c81a6e9

Please sign in to comment.