Skip to content
Open
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
24 changes: 23 additions & 1 deletion src/api/gpu/ucx/nixl_device.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@
#include <nixl_types.h>
#include <ucp/api/device/ucp_device_impl.h>

/* Helper function to extract the base filename */
__device__ __forceinline__ static const char* nixl_device_basefile(const char* path) {
const char* base = path;
for (const char* p = path; *p; ++p) {
if (*p == '/') {
base = p + 1;
}
}
return base;
}

/* Helper macro to print a message from NIXL device function including the
* thread and block indices, file and line */
#define nixl_device_printf(_log_level, _fmt, ...) \
printf("%c T%-4d:B%-4d%*s%s:%d] " _fmt "\n", _log_level[0], threadIdx.x, blockIdx.x, \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opening square bracket is missing.

17, "", nixl_device_basefile(__FILE__), __LINE__, ##__VA_ARGS__)

/* Print an error message from NIXL device function */
#define nixl_device_error(_fmt, ...) \
nixl_device_printf("ERROR", _fmt, ##__VA_ARGS__)
Comment on lines +41 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define nixl_device_error(_fmt, ...) \
nixl_device_printf("ERROR", _fmt, ##__VA_ARGS__)
#define NIXL_DEVICE_ERROR(_fmt, ...) \
NIXL_DEVICE_PRINTF("ERROR", _fmt, ##__VA_ARGS__)

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es32-use-all_caps-for-all-macro-names


struct nixlGpuXferStatusH {
ucp_device_request_t device_request;
};
Expand Down Expand Up @@ -67,7 +88,7 @@ nixlGpuConvertUcsStatus(ucs_status_t status) {
if (!UCS_STATUS_IS_ERR(status)) {
return NIXL_IN_PROG;
}
printf("UCX returned error: %d\n", status);
nixl_device_error("UCX backend error: %s", ucs_device_status_string(status));
return NIXL_ERR_BACKEND;
}

Expand Down Expand Up @@ -247,6 +268,7 @@ nixlGpuGetXferStatus(nixlGpuXferStatusH &xfer_status) {
case UCS_INPROGRESS:
return NIXL_IN_PROG;
default:
nixl_device_error("UCX backend error: %s", ucs_device_status_string(status));
return NIXL_ERR_BACKEND;
}
}
Expand Down