Repository navigation
[MUSA]Feat: musa support #12107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[MUSA]Feat: musa support #12107
Changes from 28 commits
c5bc473
4d26217
09f719a
02cefad
cb94498
e9e9f7b
939deda
b180dae
5b3a01d
4180e72
f9bcec2
87e3b03
1ea92e7
7ef53c1
7e627d0
e575e96
171799b
b7b3ce7
c71f28b
aabae58
765171e
40dd086
283f7e4
e91befa
db52c5a
268026a
260dbb4
35d82c6
9fb1f39
e797e0d
7515f80
6d7b017
e386e24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| [codespell] | ||
| skip = ./test/gtest/common,./src/ucs/datastruct/sglib.h,./docs/doxygen/Architecture*,./docs/doxygen/header.tex.in,./src/ucm/ptmalloc286,./config/m4/ax_prog_doxygen.m4,./VENV/*,./ltmain.sh,./configure,./config.guess,./config.sub,./.git,./depcomp,./libtool,./config/m4/libtool.m4 | ||
| ignore-words-list = hsa,inout,scoll,warmup,pullrequest,shft | ||
| ignore-words-list = hsa,inout,scoll,warmup,pullrequest,shft,renderd |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,190 @@ | ||
| # | ||
| # Copyright (C) MThreads 2026. ALL RIGHTS RESERVED. | ||
| # See file LICENSE for terms. | ||
| # | ||
|
|
||
| AC_DEFUN([UCX_CHECK_MUSA],[ | ||
| AS_IF([test "x$musa_checked" != "xyes"], [ | ||
| AC_ARG_WITH([musa], | ||
| [AS_HELP_STRING([--with-musa=(DIR)], | ||
| [Enable MUSA support (default is guess).])], | ||
| [], | ||
| [with_musa=guess]) | ||
|
|
||
| musa_happy=no | ||
| MUSA_CPPFLAGS="" | ||
| MUSA_LDFLAGS="" | ||
| MUSA_LIBS="" | ||
| MUSA_RPATH="" | ||
| MUSA_ROOT="" | ||
|
|
||
| AS_IF([test "x$with_musa" = "xno"], [ | ||
| AC_MSG_NOTICE([MUSA support was explicitly disabled]) | ||
| ], [ | ||
| AS_IF([test "x$with_musa" = "xyes" || | ||
| test "x$with_musa" = "xguess"], [ | ||
| AS_IF([test -d /usr/local/musa], | ||
| [MUSA_ROOT=/usr/local/musa]) | ||
|
superleo marked this conversation as resolved.
Resolved
|
||
| ], [ | ||
| MUSA_ROOT="$with_musa" | ||
| ]) | ||
|
|
||
| AS_IF([test -n "$MUSA_ROOT"], [ | ||
| MUSA_CPPFLAGS="-I$MUSA_ROOT/include" | ||
| MUSA_LDFLAGS="-L$MUSA_ROOT/lib -L$MUSA_ROOT/lib64" | ||
| MUSA_RPATH="-rpath $MUSA_ROOT/lib --enable-new-dtags -rpath $MUSA_ROOT/lib64" | ||
|
superleo marked this conversation as resolved.
Resolved
|
||
| ]) | ||
| MUSA_LIBS="-lmusart -lmusa" | ||
|
|
||
| musa_happy=yes | ||
| save_CPPFLAGS="$CPPFLAGS" | ||
| save_LDFLAGS="$LDFLAGS" | ||
| save_LIBS="$LIBS" | ||
|
|
||
| CPPFLAGS="$MUSA_CPPFLAGS $CPPFLAGS" | ||
| LDFLAGS="$MUSA_LDFLAGS $LDFLAGS" | ||
| LIBS="$MUSA_LIBS $LIBS" | ||
|
|
||
| AC_CHECK_HEADERS([musa_runtime_api.h], | ||
|
superleo marked this conversation as resolved.
Resolved
|
||
| [], | ||
| [musa_happy=no]) | ||
| AC_CHECK_HEADERS([musa.h], | ||
| [], | ||
| [musa_happy=no]) | ||
|
|
||
| AS_IF([test "x$musa_happy" = "xyes"], [ | ||
| AC_CHECK_LIB([musart], [musaGetDeviceCount], | ||
| [], | ||
| [musa_happy=no]) | ||
| ]) | ||
| AS_IF([test "x$musa_happy" = "xyes"], [ | ||
| AC_CHECK_LIB([musa], [muMemGetAddressRange], | ||
| [], | ||
| [musa_happy=no]) | ||
| ]) | ||
| AS_IF([test "x$musa_happy" = "xyes"], [ | ||
| AC_CHECK_DECLS( | ||
| [MU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD], | ||
| [AC_LINK_IFELSE( | ||
| [AC_LANG_PROGRAM( | ||
| [[#include <musa.h>]], | ||
| [[int fd = -1; | ||
| return (int)muMemGetHandleForAddressRange( | ||
| &fd, 0, 0, | ||
| MU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD, | ||
| 0);]])], | ||
| [AC_DEFINE( | ||
| [HAVE_MUSA_DMABUF], [1], | ||
| [MUSA supports DMA-BUF export])], | ||
| [])], | ||
| [], | ||
| [[#include <musa.h>]]) | ||
| ]) | ||
| AS_IF([test "x$musa_happy" = "xyes"], [ | ||
| AC_LINK_IFELSE( | ||
|
superleo marked this conversation as resolved.
Resolved
|
||
| [AC_LANG_PROGRAM( | ||
| [[#include <stddef.h> | ||
| #include <musa.h> | ||
| #include <musa_runtime_api.h>]], | ||
| [[int count = 0; | ||
| int device = 0; | ||
| void *address = 0; | ||
| MUdeviceptr base = 0; | ||
| size_t size = 0; | ||
| size_t pitch = 0; | ||
| musaMemPool_t runtime_pool = 0; | ||
| musaStream_t runtime_stream = 0; | ||
| musaEvent_t event = 0; | ||
| char pci_bus_id[64]; | ||
| MUmemoryPool driver_pool = 0; | ||
| MUstream driver_stream = 0; | ||
| unsigned memory_type = 0; | ||
| unsigned is_managed = 0; | ||
| musaGetDeviceCount(&count); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. musaMalloc is in the link probe now. The probe structure was also reworked (mandatory vs. optional symbols) — see the separate thread about the single large probe. @svc-nvidia-pr-review |
||
| musaGetDevice(&device); | ||
| musaSetDevice(device); | ||
| musaDeviceGetPCIBusId(pci_bus_id, | ||
| sizeof(pci_bus_id), | ||
| device); | ||
| muPointerGetAttribute( | ||
| &memory_type, | ||
| MU_POINTER_ATTRIBUTE_MEMORY_TYPE, | ||
| (MUdeviceptr)address); | ||
| muPointerGetAttribute( | ||
| &is_managed, MU_POINTER_ATTRIBUTE_IS_MANAGED, | ||
| (MUdeviceptr)address); | ||
| muPointerGetAttribute( | ||
| &device, MU_POINTER_ATTRIBUTE_DEVICE_ORDINAL, | ||
| (MUdeviceptr)address); | ||
| musaGetErrorString(musaSuccess); | ||
| musaGetLastError(); | ||
| muMemGetAddressRange(&base, &size, | ||
| (MUdeviceptr)address); | ||
| musaMalloc(&address, size); | ||
| musaFree(address); | ||
| musaMallocManaged(&address, size, 0); | ||
| musaMallocPitch(&address, &pitch, size, 1); | ||
| musaMallocAsync(&address, size, runtime_stream); | ||
| musaMallocFromPoolAsync(&address, size, | ||
| runtime_pool, | ||
| runtime_stream); | ||
| musaHostRegister(address, size, 0); | ||
| musaHostUnregister(address); | ||
| musaStreamCreateWithFlags(&runtime_stream, 0); | ||
| musaEventCreateWithFlags(&event, 0); | ||
| musaMemcpy(address, address, size, | ||
| musaMemcpyDeviceToDevice); | ||
| musaMemcpyAsync(address, address, size, | ||
| musaMemcpyDeviceToDevice, | ||
| runtime_stream); | ||
| musaEventRecord(event, runtime_stream); | ||
| musaEventQuery(event); | ||
| if (muEventQuery((MUevent)event) == | ||
| MUSA_ERROR_NOT_READY) { | ||
| count = 0; | ||
| } | ||
| musaEventDestroy(event); | ||
| musaStreamSynchronize(runtime_stream); | ||
| musaStreamDestroy(runtime_stream); | ||
| musaFree(address); | ||
| musaFreeAsync(address, runtime_stream); | ||
| musaFreeHost(address); | ||
| muMemAlloc_v2(&base, size); | ||
| muMemAllocPitch_v2(&base, &pitch, size, 1, 1); | ||
| muMemAllocManaged(&base, size, 0); | ||
| muMemAllocAsync(&base, size, driver_stream); | ||
| muMemAllocFromPoolAsync(&base, size, | ||
| driver_pool, | ||
| driver_stream); | ||
| muMemFreeAsync(base, driver_stream); | ||
| muMemFree_v2(base); | ||
| muMemFree(base); | ||
| return count < 0;]])], | ||
| [], | ||
| [musa_happy=no]) | ||
| ]) | ||
|
|
||
| CPPFLAGS="$save_CPPFLAGS" | ||
| LDFLAGS="$save_LDFLAGS" | ||
| LIBS="$save_LIBS" | ||
|
|
||
| AS_IF([test "x$musa_happy" = "xyes"], [ | ||
| AC_DEFINE([HAVE_MUSA], [1], [Enable MUSA support]) | ||
| AC_SUBST([MUSA_CPPFLAGS]) | ||
| AC_SUBST([MUSA_LDFLAGS]) | ||
| AC_SUBST([MUSA_LIBS]) | ||
| AC_SUBST([MUSA_RPATH]) | ||
| AC_SUBST([MUSA_ROOT]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @svc-nvidia-pr-review ,We prefer no rpath: verified that the built libuct_musa.so /libucm_musa.so carry no RUNPATH and load fine both via the system loader configuration and via an explicit LD_LIBRARY_PATH. Since the SDK location can differ between build and deployment hosts, baking the build-time path into the modules seemed more likely to cause problems than to fix them. |
||
| ], [ | ||
| AS_IF([test "x$with_musa" != "xguess"], [ | ||
| AC_MSG_ERROR([MUSA support was requested but MUSA headers and libraries were not found]) | ||
| ], [ | ||
| AC_MSG_WARN([MUSA headers and libraries not found]) | ||
| ]) | ||
| ]) | ||
| ]) | ||
|
|
||
| musa_checked=yes | ||
| AM_CONDITIONAL([HAVE_MUSA], [test "x$musa_happy" = "xyes"]) | ||
| ]) | ||
| ]) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # | ||
| # Copyright (C) MThreads 2026. ALL RIGHTS RESERVED. | ||
| # See file LICENSE for terms. | ||
| # | ||
|
|
||
| if HAVE_MUSA | ||
| module_LTLIBRARIES = libucm_musa.la | ||
| libucm_musa_la_CPPFLAGS = $(BASE_CPPFLAGS) $(MUSA_CPPFLAGS) | ||
| libucm_musa_la_CFLAGS = $(BASE_CFLAGS) $(MUSA_CFLAGS) $(LT_CFLAGS) | ||
| libucm_musa_la_LIBADD = ../libucm.la $(MUSA_LIBS) | ||
| libucm_musa_la_LDFLAGS = $(UCM_MODULE_LDFLAGS) \ | ||
| $(patsubst %, -Xlinker %, $(MUSA_LDFLAGS)) \ | ||
| -version-info $(SOVERSION) $(UCX_LT_RELEASE) \ | ||
| $(patsubst %, -Xlinker %, $(MUSA_RPATH)) | ||
|
|
||
| libucm_musa_la_SOURCES = \ | ||
| musamem.c | ||
|
|
||
| include $(top_srcdir)/config/module.am | ||
| endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # | ||
| # Copyright (C) MThreads 2026. ALL RIGHTS RESERVED. | ||
| # See file LICENSE for terms. | ||
| # | ||
|
|
||
| UCX_CHECK_MUSA | ||
| AS_IF([test "x$musa_happy" = "xyes"], | ||
| [ucm_modules="${ucm_modules}:musa"]) | ||
| AC_CONFIG_FILES([src/ucm/musa/Makefile]) |
Uh oh!
There was an error while loading. Please reload this page.