Skip to content

Commit

Permalink
working gtensor int test for cuda
Browse files Browse the repository at this point in the history
  • Loading branch information
bd4 committed Jul 2, 2024
1 parent e574d68 commit bfa3c32
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
36 changes: 36 additions & 0 deletions integration_tests/gtensor.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bats

setup_file() {
export IPROF=$THAPI_INSTALL_DIR/bin/iprof

bdir=build-$GTENSOR_DEVICE

(cd integration_tests/gtensor;
cmake -S . -B $bdir -DGTENSOR_DEVICE=$GTENSOR_DEVICE -DTHAPI_PATH=$THAPI_INSTALL_DIR \
&& cmake --build $bdir)

export THAPI_TEST_BIN=$(pwd)/integration_tests/gtensor/$bdir/axpy_start_stop
export LD_LIBRARY_PATH=$THAPI_INSTALL_DIR/lib:$LD_LIBRARY_PATH
}

teardown_file() {
rm -rf $THAPI_HOME/thapi-traces
}

@test "axpy-${GTENSOR_DEVICE}-trace-from-start" {
$IPROF --debug 0 $THAPI_TEST_BIN $TEST_ARGS
# NOTE: gtensor kernel names are complex, but all start with gt::, look it up rather
# than hard coding and making it fragile. Includes quotes.
kernel_name=$($IPROF -r -j | jq '.device.data | keys[]' | grep 'gt::')
write_count=$($IPROF -r -j | jq ".device.data | .[${kernel_name}].call")
# 0th call, plus 5 odd calls
[ $write_count -eq 6 ]
}

@test "axpy-${GTENSOR_DEVICE}-no-trace-from-start" {
$IPROF --no-trace-from-start --debug 0 $THAPI_TEST_BIN $TEST_ARGS
kernel_name=$($IPROF -r -j | jq '.device.data | keys[]' | grep 'gt::')
write_count=$($IPROF -r -j | jq ".device.data | .[${kernel_name}].call")
# 5 odd calls, does not include 0 since profiling should be disabled at start
[ $write_count -eq 5 ]
}
7 changes: 5 additions & 2 deletions integration_tests/gtensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif()

set(THAPI_PATH "/opt/thapi" CACHE STRING "Path to thapi installation")

message(STATUS "${PROJECT_NAME}: THAIP_PATH=${THAPI_PATH}")
message(STATUS "${PROJECT_NAME}: THAPI_PATH=${THAPI_PATH}")

# add dependencies
include(cmake/CPM.cmake)
Expand All @@ -19,10 +19,13 @@ CPMFindPackage(NAME gtensor
OPTIONS "GTENSOR_ENABLE_BLAS ON"
"GTENSOR_ENABLE_SOLVER ON")

find_package(PkgConfig REQUIRED)
pkg_check_modules(LTTNG_CTL REQUIRED lttng-ctl)

add_library(thapi_ctl INTERFACE IMPORTED)
target_include_directories(thapi_ctl INTERFACE "${THAPI_PATH}/include")
target_link_libraries(thapi_ctl INTERFACE "${THAPI_PATH}/lib/libthapi-ctl.so")
target_link_libraries(thapi_ctl INTERFACE "lttng-ctl")
target_link_libraries(thapi_ctl INTERFACE ${LTTNG_CTL_LDFLAGS})

add_executable(axpy_start_stop)
target_gtensor_sources(axpy_start_stop PRIVATE axpy_start_stop.cxx)
Expand Down

0 comments on commit bfa3c32

Please sign in to comment.