Skip to content

Commit

Permalink
Add some merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
omarahmed1111 committed Oct 25, 2023
1 parent 3a50abf commit 3c98255
Show file tree
Hide file tree
Showing 11 changed files with 1,002 additions and 1,659 deletions.
2,562 changes: 951 additions & 1,611 deletions include/ur_print.hpp

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions scripts/templates/print.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ from templates import helper as th
%elif loop and th.type_traits.is_pointer_to_pointer(itype):
details::printPtr(os, ${caller.body()});
%elif th.type_traits.is_handle(itype):
${x}_params::serializePtr(os, ${caller.body()});
details::printPtr(os, ${caller.body()});
%elif iname and iname.startswith("pfn"):
os << reinterpret_cast<void*>(${caller.body()});
%else:
Expand Down Expand Up @@ -85,7 +85,7 @@ def findMemberType(_item):
os << "}";
%elif findMemberType(item) is not None and findMemberType(item)['type'] == "union":
os << ".${iname} = ";
${x}_params::serializeUnion(os, ${deref}(params${access}${item['name']}), params${access}${th.param_traits.tagged_member(item)});
details::printUnion(os, ${deref}(params${access}${item['name']}), params${access}${th.param_traits.tagged_member(item)});
%elif th.type_traits.is_array(item['type']):
os << ".${iname} = {";
for(auto i = 0; i < ${th.type_traits.get_array_length(item['type'])}; i++){
Expand Down Expand Up @@ -122,9 +122,9 @@ template <> struct is_handle<${th.make_type_name(n, tags, obj)}> : std::true_typ
%endfor
template <typename T>
inline constexpr bool is_handle_v = is_handle<T>::value;
template <typename T> inline void serializePtr(std::ostream &os, const T *ptr);
template <typename T> inline void serializeFlag(std::ostream &os, uint32_t flag);
template <typename T> inline void serializeTagged(std::ostream &os, const void *ptr, T value, size_t size);
template <typename T> inline ${x}_result_t printPtr(std::ostream &os, const T *ptr);
template <typename T> inline ${x}_result_t printFlag(std::ostream &os, uint32_t flag);
template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const void *ptr, T value, size_t size);

%for spec in specs:
%for obj in spec['objects']:
Expand Down Expand Up @@ -160,7 +160,7 @@ template <typename T> inline void serializeTagged(std::ostream &os, const void *
%if re.match(r"enum", obj['type']):
${X}_APIEXPORT inline std::ostream &operator<<(std::ostream &os, ${th.make_enum_name(n, tags, obj)} value);
%elif re.match(r"struct", obj['type']):
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ${obj['type']} ${th.make_type_name(n, tags, obj)} params);
${X}_APIEXPORT inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ${obj['type']} ${th.make_type_name(n, tags, obj)} params);
%endif
%endfor # obj in spec['objects']
%endfor
Expand Down Expand Up @@ -390,6 +390,10 @@ for item in obj['members']:
%for tbl in th.get_pfncbtables(specs, meta, n, tags):
%for obj in tbl['functions']:

///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ${th.make_pfncb_param_type(n, tags, obj)} type
/// @returns
/// std::ostream &
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ${th.make_pfncb_param_type(n, tags, obj)} *params) {
<%
params_dict = dict()
Expand All @@ -407,14 +411,15 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
%endfor
%endfor

namespace ${x}_params {

template <typename T> inline void serializePtr(std::ostream &os, const T *ptr) {
namespace details {
///////////////////////////////////////////////////////////////////////////////
// @brief Print pointer value
template <typename T> inline ${x}_result_t printPtr(std::ostream &os, const T *ptr) {
if (ptr == nullptr) {
os << "nullptr";
} else if constexpr (std::is_pointer_v<T>) {
os << (const void *)(ptr) << " (";
serializePtr(os, *ptr);
printPtr(os, *ptr);
os << ")";
} else if constexpr (std::is_void_v<T> || is_handle_v<T *>) {
os << (const void *)ptr;
Expand Down
24 changes: 11 additions & 13 deletions source/adapters/cuda/ur_interface_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable(
if (UR_RESULT_SUCCESS != result) {
return result;
}
pDdiTable->pfnInit = urInit;
pDdiTable->pfnTearDown = urTearDown;
pDdiTable->pfnAdapterGet = urAdapterGet;
pDdiTable->pfnAdapterRelease = urAdapterRelease;
pDdiTable->pfnAdapterRetain = urAdapterRetain;
Expand Down Expand Up @@ -280,17 +278,17 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetCommandBufferExpProcAddrTable(
pDdiTable->pfnReleaseExp = urCommandBufferReleaseExp;
pDdiTable->pfnFinalizeExp = urCommandBufferFinalizeExp;
pDdiTable->pfnAppendKernelLaunchExp = urCommandBufferAppendKernelLaunchExp;
pDdiTable->pfnAppendMemcpyUSMExp = urCommandBufferAppendMemcpyUSMExp;
pDdiTable->pfnAppendMembufferCopyExp = urCommandBufferAppendMembufferCopyExp;
pDdiTable->pfnAppendMembufferCopyRectExp =
urCommandBufferAppendMembufferCopyRectExp;
pDdiTable->pfnAppendMembufferReadExp = urCommandBufferAppendMembufferReadExp;
pDdiTable->pfnAppendMembufferReadRectExp =
urCommandBufferAppendMembufferReadRectExp;
pDdiTable->pfnAppendMembufferWriteExp =
urCommandBufferAppendMembufferWriteExp;
pDdiTable->pfnAppendMembufferWriteRectExp =
urCommandBufferAppendMembufferWriteRectExp;
pDdiTable->pfnAppendUSMMemcpyExp = urCommandBufferAppendUSMMemcpyExp;
pDdiTable->pfnAppendMemBufferCopyExp = urCommandBufferAppendMemBufferCopyExp;
pDdiTable->pfnAppendMemBufferCopyRectExp =
urCommandBufferAppendMemBufferCopyRectExp;
pDdiTable->pfnAppendMemBufferReadExp = urCommandBufferAppendMemBufferReadExp;
pDdiTable->pfnAppendMemBufferReadRectExp =
urCommandBufferAppendMemBufferReadRectExp;
pDdiTable->pfnAppendMemBufferWriteExp =
urCommandBufferAppendMemBufferWriteExp;
pDdiTable->pfnAppendMemBufferWriteRectExp =
urCommandBufferAppendMemBufferWriteRectExp;
pDdiTable->pfnEnqueueExp = urCommandBufferEnqueueExp;

return retVal;
Expand Down
23 changes: 14 additions & 9 deletions source/adapters/null/ur_null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ context_t::context_t() {

//////////////////////////////////////////////////////////////////////////
urDdiTable.USM.pfnHostAlloc =
[](ur_context_handle_t hContext, const ur_usm_desc_t *pUSMDesc,
ur_usm_pool_handle_t pool, size_t size, void **ppMem) {
[]([[maybe_unused]] ur_context_handle_t hContext,
[[maybe_unused]] const ur_usm_desc_t *pUSMDesc,
[[maybe_unused]] ur_usm_pool_handle_t pool, size_t size,
void **ppMem) {
if (size == 0) {
*ppMem = nullptr;
return UR_RESULT_ERROR_UNSUPPORTED_SIZE;
Expand All @@ -180,9 +182,11 @@ context_t::context_t() {

//////////////////////////////////////////////////////////////////////////
urDdiTable.USM.pfnDeviceAlloc =
[](ur_context_handle_t hContext, ur_device_handle_t hDevice,
const ur_usm_desc_t *pUSMDesc, ur_usm_pool_handle_t pool,
size_t size, void **ppMem) {
[]([[maybe_unused]] ur_context_handle_t hContext,
[[maybe_unused]] ur_device_handle_t hDevice,
[[maybe_unused]] const ur_usm_desc_t *pUSMDesc,
[[maybe_unused]] ur_usm_pool_handle_t pool, size_t size,
void **ppMem) {
if (size == 0) {
*ppMem = nullptr;
return UR_RESULT_ERROR_UNSUPPORTED_SIZE;
Expand All @@ -195,16 +199,17 @@ context_t::context_t() {
};

//////////////////////////////////////////////////////////////////////////
urDdiTable.USM.pfnFree = [](ur_context_handle_t hContext, void *pMem) {
urDdiTable.USM.pfnFree = []([[maybe_unused]] ur_context_handle_t hContext,
void *pMem) {
free(pMem);
return UR_RESULT_SUCCESS;
};

//////////////////////////////////////////////////////////////////////////
urDdiTable.USM.pfnGetMemAllocInfo =
[](ur_context_handle_t hContext, const void *pMem,
ur_usm_alloc_info_t propName, size_t propSize, void *pPropValue,
size_t *pPropSizeRet) {
[]([[maybe_unused]] ur_context_handle_t hContext, const void *pMem,
ur_usm_alloc_info_t propName, [[maybe_unused]] size_t propSize,
void *pPropValue, size_t *pPropSizeRet) {
switch (propName) {
case UR_USM_ALLOC_INFO_TYPE:
*reinterpret_cast<ur_usm_type_t *>(pPropValue) =
Expand Down
4 changes: 2 additions & 2 deletions source/common/unified_malloc_framework/src/critnib/critnib.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,8 @@ int critnib_find(struct critnib *c, uintptr_t key, enum find_dir_t dir,
uintptr_t *rkey, void **rvalue) {
uint64_t wrs1, wrs2;
struct critnib_leaf *k;
uintptr_t _rkey;
void **_rvalue;
uintptr_t _rkey = 0;
void **_rvalue = 0;

/* <42 ≡ ≤41 */
if (dir < -1) {
Expand Down
8 changes: 1 addition & 7 deletions test/fuzz/urFuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
return ret;
}

LoaderConfig config;
ur_result_t res = urInit(0, config.handle);
if (res != UR_RESULT_SUCCESS) {
return -1;
}

test_state.adapters.resize(test_state.num_entries);
res = urAdapterGet(test_state.num_entries, test_state.adapters.data(),
ur_result_t res = urAdapterGet(test_state.num_entries, test_state.adapters.data(),
&test_state.num_adapters);
if (res != UR_RESULT_SUCCESS || test_state.num_adapters == 0) {
return -1;
Expand Down
4 changes: 2 additions & 2 deletions test/loader/loader_lifetime/urLoaderInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "fixtures.hpp"
#include <ur_params.hpp>
#include <ur_print.hpp>

using urLoaderInitTestWithParam =
::testing::TestWithParam<ur_device_init_flags_t>;
Expand All @@ -17,7 +17,7 @@ INSTANTIATE_TEST_SUITE_P(
UR_DEVICE_INIT_FLAG_FPGA | UR_DEVICE_INIT_FLAG_VPU),
[](const ::testing::TestParamInfo<ur_device_init_flags_t> &info) {
std::stringstream ss;
ur_params::serializeFlag<ur_device_init_flag_t>(ss, info.param);
ur::print::details::printFlag<ur_device_init_flag_t>(ss, info.param);
return GTestSanitizeString(ss.str());
});

Expand Down
2 changes: 1 addition & 1 deletion test/loader/platforms/platforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using namespace logger;

//////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[]) {
int main([[maybe_unused]] int argc, [[maybe_unused]] char *argv[]) {
auto out = create_logger("TEST");

ur_result_t status;
Expand Down
1 change: 1 addition & 0 deletions tools/urinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target_compile_definitions(urinfo PRIVATE
UR_VERSION="${PROJECT_VERSION}"
)
target_include_directories(urinfo PRIVATE
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/source/common
)
target_link_libraries(urinfo PRIVATE
Expand Down
4 changes: 1 addition & 3 deletions tools/urinfo/urinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ devices which are currently visible in the local execution environment.
}
}

~app() {
urLoaderConfigRelease(loaderConfig);
}
~app() { urLoaderConfigRelease(loaderConfig); }
};
} // namespace urinfo

Expand Down
4 changes: 3 additions & 1 deletion tools/urinfo/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#pragma once

#include "ur_api.h"
#include "ur_params.hpp"
#include "ur_print.hpp"
#include <algorithm>
#include <cstdlib>
#include <iostream>
Expand All @@ -16,6 +16,8 @@
#include <unordered_map>
#include <vector>

using namespace ur::print;

#define UR_CHECK(ACTION) \
if (auto error = ACTION) { \
std::cerr << "error: " #ACTION " failed: " << error << "\n"; \
Expand Down

0 comments on commit 3c98255

Please sign in to comment.