@@ -21,6 +21,7 @@ set(WITH_CPU ON CACHE INTERNAL "CPU backend is always enabled")
2121option (WITH_OMPI "Enable OpenMPI backend" OFF )
2222option (WITH_MPICH "Enable MPICH backend" OFF )
2323option (WITH_NCCL "Enable NCCL backend" OFF )
24+ option (WITH_MCCL "Enable MCCL backend" OFF )
2425
2526# =========================================================
2627# --- MISC. BUILD OPTIONS ---
@@ -228,10 +229,31 @@ if(AUTO_DETECT_BACKENDS)
228229 else ()
229230 message (STATUS "No suitable device environment, skipping NCCL detection." )
230231 endif ()
232+
233+ # Detect MCCL Dependencies
234+ if (WITH_METAX)
235+ set (_MCCL_HINTS)
236+ if (DEFINED ENV{MACA_PATH})
237+ list (APPEND _MCCL_HINTS "$ENV{MACA_PATH} " )
238+ endif ()
239+ list (APPEND _MCCL_HINTS /opt/maca)
240+
241+ find_path (AUTO_MCCL_INC NAMES mccl.h HINTS ${_MCCL_HINTS} PATH_SUFFIXES include QUIET )
242+ find_library (AUTO_MCCL_LIB NAMES mccl HINTS ${_MCCL_HINTS} PATH_SUFFIXES lib lib64 QUIET )
243+
244+ if (AUTO_MCCL_INC AND AUTO_MCCL_LIB)
245+ set (WITH_MCCL ON )
246+ message (STATUS "Auto-detected MCCL backend." )
247+ else ()
248+ message (STATUS "MCCL library/headers not found in MetaX paths." )
249+ endif ()
250+ else ()
251+ message (STATUS "No suitable device environment, skipping MCCL detection." )
252+ endif ()
231253endif ()
232254
233255# Fallback: If no backends are enabled or auto-detected, fall back to OpenMPI as the default bootstrap profile.
234- if (NOT WITH_OMPI AND NOT WITH_MPICH AND NOT WITH_NCCL)
256+ if (NOT WITH_OMPI AND NOT WITH_MPICH AND NOT WITH_NCCL AND NOT WITH_MCCL )
235257 set (WITH_OMPI ON )
236258 message (STATUS "No backend specified or detected. Defaulting to `WITH_OMPI=ON`" )
237259endif ()
@@ -349,6 +371,26 @@ if(WITH_NCCL)
349371 include_directories (${NCCL_INC} )
350372endif ()
351373
374+ if (WITH_MCCL)
375+ if (NOT WITH_METAX)
376+ message (FATAL_ERROR "MCCL backend requires MetaX GPU support. Please enable `WITH_METAX`." )
377+ endif ()
378+
379+ set (_MCCL_HINTS)
380+ if (MACA_PATH)
381+ list (APPEND _MCCL_HINTS "${MACA_PATH} " )
382+ endif ()
383+ if (DEFINED ENV{MACA_PATH})
384+ list (APPEND _MCCL_HINTS "$ENV{MACA_PATH} " )
385+ endif ()
386+ list (APPEND _MCCL_HINTS /opt/maca)
387+
388+ find_library (MCCL_LIB NAMES mccl HINTS ${_MCCL_HINTS} PATH_SUFFIXES lib lib64 REQUIRED )
389+ find_path (MCCL_INC NAMES mccl.h HINTS ${_MCCL_HINTS} PATH_SUFFIXES include REQUIRED )
390+
391+ include_directories (${MCCL_INC} )
392+ endif ()
393+
352394# Python is required for code generation.
353395find_package (Python3 REQUIRED )
354396
0 commit comments