Skip to content

Commit f0db772

Browse files
gnurizenclaude
andcommitted
Add realistic CUDA API function names to test stack traces
- Add fake cuLaunchKernel, cuGraphLaunch, cudaLaunchKernel, cudaGraphLaunch functions that appear in the call stack when the profiler captures samples - Use __attribute__((noinline)) to prevent compiler from inlining these - Use random kernel names for graph kernels instead of hardcoded "graph_kernel" - Add cuda_runtime.h include for runtime API types Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8b7bc8d commit f0db772

File tree

2 files changed

+915
-194
lines changed

2 files changed

+915
-194
lines changed

test/CMakeLists.txt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
cmake_minimum_required(VERSION 3.18)
2+
project(parcagpu_test C)
3+
4+
# CUDA include paths
5+
if(NOT DEFINED CUDA_ROOT)
6+
set(CUDA_ROOT "/usr/local/cuda" CACHE PATH "CUDA installation directory")
7+
endif()
8+
9+
set(CUDA_INCLUDE_DIRS
10+
"${CUDA_ROOT}/include"
11+
"${CUDA_ROOT}/extras/CUPTI/include"
12+
)
13+
14+
# Mock CUPTI library
15+
add_library(cupti SHARED mock_cupti.c)
16+
target_include_directories(cupti PRIVATE ${CUDA_INCLUDE_DIRS})
17+
set_target_properties(cupti PROPERTIES
18+
C_STANDARD 11
19+
C_STANDARD_REQUIRED ON
20+
POSITION_INDEPENDENT_CODE ON
21+
)
22+
23+
# Detect CUDA major version from CUPTI library
24+
execute_process(
25+
COMMAND bash -c "ls ${CUDA_ROOT}/lib64/libcupti.so.* 2>/dev/null | grep -oE 'libcupti\\.so\\.[0-9]+$' | head -1 | grep -oE '[0-9]+$'"
26+
OUTPUT_VARIABLE CUDA_MAJOR_VERSION
27+
OUTPUT_STRIP_TRAILING_WHITESPACE
28+
)
29+
if(NOT CUDA_MAJOR_VERSION)
30+
set(CUDA_MAJOR_VERSION "12")
31+
endif()
32+
message(STATUS "Detected CUDA major version: ${CUDA_MAJOR_VERSION}")
33+
34+
# Create versioned symlink matching installed CUDA
35+
add_custom_command(TARGET cupti POST_BUILD
36+
COMMAND ${CMAKE_COMMAND} -E create_symlink
37+
$<TARGET_FILE_NAME:cupti>
38+
${CMAKE_CURRENT_BINARY_DIR}/libcupti.so.${CUDA_MAJOR_VERSION}
39+
)
40+
41+
# Test executable
42+
add_executable(test_cupti_prof test_cupti_prof.c)
43+
target_include_directories(test_cupti_prof PRIVATE ${CUDA_INCLUDE_DIRS})
44+
target_compile_options(test_cupti_prof PRIVATE
45+
-D_POSIX_C_SOURCE=199309L
46+
-Wall
47+
-Wextra
48+
)
49+
target_link_libraries(test_cupti_prof PRIVATE dl pthread)
50+
set_target_properties(test_cupti_prof PROPERTIES
51+
C_STANDARD 11
52+
C_STANDARD_REQUIRED ON
53+
)
54+
55+
# Installation
56+
install(TARGETS cupti test_cupti_prof
57+
RUNTIME DESTINATION bin
58+
LIBRARY DESTINATION lib
59+
)

0 commit comments

Comments
 (0)