Skip to content

Commit 956abc9

Browse files
committed
feat: add MetaX GPU examples and documentation
New examples: - examples/metax_example.cpp: Basic MetaX MCPTI profiling - examples/metax_benchmark.cpp: Multi-stream benchmark with analysis - python/examples/metax_profiling.py: Python API for MetaX GPUs Build system: - Add MetaX examples to CMakeLists.txt - Use find_library() for mcpti and mcruntime linking Documentation: - Add MetaX MCPTI profiling section to README - Include C++ and Python API examples - Document captured event types
1 parent 6d36299 commit 956abc9

6 files changed

Lines changed: 955 additions & 8 deletions

File tree

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,77 @@ profiler.export_perfetto("metal_trace.json")
406406
- `Game Performance` - Frame rate and GPU time
407407
- `Animation Hitches` - Animation performance
408408

409+
**Output:**
410+
411+
#### MetaX GPU Profiling with MCPTI
412+
413+
TraceSmith supports MetaX GPUs (C500, C550, etc.) using the MCPTI (MACA Profiling Tools Interface), which provides an API compatible with NVIDIA CUPTI.
414+
415+
**Build with MetaX support:**
416+
417+
```bash
418+
cmake -DTRACESMITH_ENABLE_MACA=ON ..
419+
make -j4
420+
```
421+
422+
**C++ API:**
423+
424+
```cpp
425+
#include <tracesmith/tracesmith.hpp>
426+
427+
// Check MetaX GPU availability
428+
if (tracesmith::isMACAAvailable()) {
429+
std::cout << "MetaX devices: " << tracesmith::getMACADeviceCount() << std::endl;
430+
}
431+
432+
// Create MCPTI profiler
433+
auto profiler = tracesmith::createProfiler(tracesmith::PlatformType::MACA);
434+
435+
// Configure
436+
tracesmith::ProfilerConfig config;
437+
config.capture_kernels = true;
438+
config.capture_memcpy = true;
439+
profiler->initialize(config);
440+
441+
// Capture events
442+
profiler->startCapture();
443+
// ... GPU code using MACA runtime ...
444+
profiler->stopCapture();
445+
446+
// Get events
447+
std::vector<tracesmith::TraceEvent> events;
448+
profiler->getEvents(events);
449+
```
450+
451+
**Python API:**
452+
453+
```python
454+
import tracesmith as ts
455+
456+
# Check MetaX availability
457+
if ts.is_maca_available():
458+
print(f"MetaX devices: {ts.get_maca_device_count()}")
459+
460+
# Create profiler
461+
profiler = ts.create_profiler(ts.PlatformType.MACA)
462+
profiler.initialize(ts.ProfilerConfig())
463+
464+
profiler.start_capture()
465+
# ... GPU code ...
466+
profiler.stop_capture()
467+
468+
events = profiler.get_events()
469+
```
470+
471+
**MCPTI Captured Events:**
472+
473+
| Event Type | Description |
474+
|------------|-------------|
475+
| KernelLaunch/Complete | Kernel execution timing |
476+
| MemcpyH2D/D2H/D2D | Memory transfers |
477+
| MemsetDevice | Memory initialization |
478+
| StreamSync/DeviceSync | Synchronization events |
479+
409480
**Output:**
410481
- SBT file with parsed GPU events
411482
- Optional: Raw `.trace` file (use `--keep-trace`) for viewing in Instruments

examples/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,35 @@ if(TRACESMITH_ENABLE_METAL AND APPLE)
268268
)
269269
endif()
270270

271+
# ----------------------------------------------------------------------------
272+
# MetaX MACA Examples (requires MetaX GPU)
273+
# ----------------------------------------------------------------------------
274+
if(TRACESMITH_ENABLE_MACA)
275+
# MetaX basic example
276+
add_executable(metax_example
277+
metax_example.cpp
278+
)
279+
280+
target_link_libraries(metax_example PRIVATE
281+
tracesmith-common
282+
tracesmith-format
283+
tracesmith-capture
284+
tracesmith-state
285+
)
286+
287+
# MetaX benchmark example
288+
add_executable(metax_benchmark
289+
metax_benchmark.cpp
290+
)
291+
292+
target_link_libraries(metax_benchmark PRIVATE
293+
tracesmith-common
294+
tracesmith-format
295+
tracesmith-capture
296+
tracesmith-state
297+
)
298+
endif()
299+
271300
# ----------------------------------------------------------------------------
272301
# Goal Validation Example - Validates all project goals from PLANNING.md
273302
# ----------------------------------------------------------------------------
@@ -380,5 +409,10 @@ if(TRACESMITH_ENABLE_METAL AND APPLE)
380409
message(STATUS " Metal examples (Apple GPU):")
381410
message(STATUS " - metal_example (Apple Metal profiling)")
382411
endif()
412+
if(TRACESMITH_ENABLE_MACA)
413+
message(STATUS " MetaX examples (MetaX GPU):")
414+
message(STATUS " - metax_example (MetaX MCPTI profiling)")
415+
message(STATUS " - metax_benchmark (MetaX benchmark with multi-stream)")
416+
endif()
383417
message(STATUS " Python examples:")
384418
message(STATUS " - python_example.py (Python API demonstration)")

0 commit comments

Comments
 (0)