Skip to content

Commit

Permalink
add cubin_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
FindHao committed Mar 20, 2022
1 parent 5167e2e commit 710d77b
Show file tree
Hide file tree
Showing 8 changed files with 667 additions and 22 deletions.
6 changes: 6 additions & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ cd ${source_path}/drcctprof_clients
./build_clean.sh ; ./build.sh
cp -r ./DrCCTProf/build ${install_path}/drcctprof

cd ${source_path}/cubin_filter
rm -rf ${source_path}/cubin_filter/build
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${install_path}/cubin_filter
make -j 16
make install -j 4

cd ${source_path}
# cp -rf ./bin ${install_path}/
Expand Down
12 changes: 9 additions & 3 deletions bin/build_debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ echo $install_path

cd ${source_path}/gpu-patch
make clean
make PREFIX=${install_path}/gpu-patch CUDA_PATH=$CUDA_PATH install -j 12
# make install -j 4
make PREFIX=${install_path}/gpu-patch CUDA_PATH=$CUDA_PATH install -j 4

cd ${source_path}/redshow
make clean
Expand All @@ -52,8 +51,15 @@ cd ${source_path}/drcctprof_clients
./build_clean.sh ; ./build_debug.sh
cp -r ./DrCCTProf/build_debug ${install_path}/drcctprof-debug

cd ${source_path}/cubin_filter
rm -rf ${source_path}/cubin_filter/build
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${install_path}/cubin_filter
make -j 16
make install -j 4

cd ${source_path}
# cp -rf ./bin ${install_path}/
mkdir ${install_path}/bin
ln -s ${source_path}/bin/gpupunk ${install_path}/bin/gpupunk
ln -s ${source_path}/bin/gpupunk ${install_path}/bin/gpupunk

59 changes: 40 additions & 19 deletions bin/gpupunk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export GPUPUNK_WITH_DRRUN=1
export GPUPUNK_WITH_HPCRUN=0
# with detail log
export GPUPUNK_VERBOSE=0

# filter cubins
export GPUPUNK_CUBIN_FILTER=1
usage() {
cat <<EOF
Usage:
Expand All @@ -46,11 +47,15 @@ Usage:
GPUPUNK_SANITIZER_APPROX_LEVEL
GPUPUNK_SANITIZER_DEFAULT_TYPE
GPUPUNK_SANITIZER_KERNEL_SAMPLING_FREQUENCY
GPUPUNK_SANITIZER_BLOCK_SAMPLEING_FREQUENCY
GPUPUNK_SANITIZER_WHITELIST
GPUPUNK_SANITIZER_BLACKLIST
gputrigger/include/control-knob.h
-w <whitelist.txt>
kernel whitelist for instrumentation.
-cubin_filter [yes|no|y|n]
default is yes. This option will enable cubin filter.
EOF
exit 0
}
Expand Down Expand Up @@ -103,6 +108,17 @@ while test "x$1" != x; do
fi
shift
;;
-cubin_filter)
if [ $1 == "no" ] || [ $1 == "n" ]; then
export GPUPUNK_CUBIN_FILTER=0
else
if [ $1 != "yes" ] && [ $1 != "y" ]; then
echo "wrong argument pattern for -cubin_filter"
exit -1
fi
fi
shift
;;
-v)
export GPUPUNK_VERBOSE=1
;;
Expand Down Expand Up @@ -147,26 +163,31 @@ else
export GPUPUNK_REDIRECT=/dev/null
fi

if [ $GPUPUNK_WITH_HPCRUN -eq 1 ]; then
if [ -z $HPCTOOLKIT_PATH ]; then
echo "HPCTOOLKIT_PATH is not set."
exit -1
fi
MEASUREMENTS=gpupunk-measurements
DATABASE=gpupunk-database
echo "Make sure $MEASUREMENTS and $DATABASE is clean"
rm -rf $MEASUREMENTS
rm -rf $DATABASE
HPCRUN=${HPCTOOLKIT_PATH}/bin/hpcrun
echo "$GPUPUNK_LAUNCHER $HPCRUN -e gpu=nvidia -o $MEASUREMENTS $GPUPUNK_EXEC $GPUPUNK_ARGS &>> $GPUPUNK_REDIRECT"
$GPUPUNK_LAUNCHER $HPCRUN -e gpu=nvidia -o $MEASUREMENTS $GPUPUNK_EXEC $GPUPUNK_ARGS &>>$GPUPUNK_REDIRECT
HPCSTRUCT=${HPCTOOLKIT_PATH}/bin/hpcstruct
$HPCSTRUCT -j 12 $MEASUREMENTS &>>$GPUPUNK_REDIRECT
rm ./cubins ./structs
ln -s $MEASUREMENTS/cubins ./
ln -s $MEASUREMENTS/structs ./
if [ $GPUPUNK_CUBIN_FILTER -eq 1 ]; then
rm -rf ./cubins
LD_PRELOAD=${GPUPUNK_PATH}/cubin_filter/libcubin_filter.so $GPUPUNK_EXEC $GPUPUNK_ARGS &>>$GPUPUNK_REDIRECT
fi

# if [ $GPUPUNK_WITH_HPCRUN -eq 1 ]; then
# if [ -z $HPCTOOLKIT_PATH ]; then
# echo "HPCTOOLKIT_PATH is not set."
# exit -1
# fi
# MEASUREMENTS=gpupunk-measurements
# DATABASE=gpupunk-database
# echo "Make sure $MEASUREMENTS and $DATABASE is clean"
# rm -rf $MEASUREMENTS
# rm -rf $DATABASE
# HPCRUN=${HPCTOOLKIT_PATH}/bin/hpcrun
# echo "$GPUPUNK_LAUNCHER $HPCRUN -e gpu=nvidia -o $MEASUREMENTS $GPUPUNK_EXEC $GPUPUNK_ARGS &>> $GPUPUNK_REDIRECT"
# $GPUPUNK_LAUNCHER $HPCRUN -e gpu=nvidia -o $MEASUREMENTS $GPUPUNK_EXEC $GPUPUNK_ARGS &>>$GPUPUNK_REDIRECT
# HPCSTRUCT=${HPCTOOLKIT_PATH}/bin/hpcstruct
# $HPCSTRUCT -j 12 $MEASUREMENTS &>>$GPUPUNK_REDIRECT
# rm ./cubins ./structs
# ln -s $MEASUREMENTS/cubins ./
# ln -s $MEASUREMENTS/structs ./
# fi

if [ $GPUPUNK_WITH_DRRUN -eq 1 ]; then
# DRRUN="${DRCCTPROF_PATH}/bin64/drrun -dumpcore_mask 0x837f -t drcctlib_cpu_gpu_memory --"
DRRUN="${DRCCTPROF_PATH}/bin64/drrun -t drcctlib_cpu_gpu_memory --"
Expand Down
61 changes: 61 additions & 0 deletions cubin_filter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
cmake_minimum_required(VERSION 3.10)
project(cubin_filter)
include(CheckLanguage)
check_language(CUDA)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS " -Wall -Wextra")

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Default build type: RelWithDebInfo" FORCE)
endif ()

if (${CMAKE_VERSION} VERSION_LESS "3.17.0")
find_package(CUDA REQUIRED)
set(CUDAToolkit_NVCC_EXECUTABLE ${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc)
set(CUDAToolkit_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR})
if (${CUDA_VERSION} LESS 11.2)
message(FATAL_ERROR "CUDAToolkit mush be newer or equal to 11.2. Your version is " ${CUDA_VERSION})
endif ()
else ()
find_package(CUDAToolkit REQUIRED)
if (NOT CMAKE_CUDA_COMPILER)
if (NOT ${CUDAToolkit_NVCC_EXECUTABLE} AND UNIX AND EXISTS "/usr/local/cuda/bin/nvcc")
set(CUDAToolkit_NVCC_EXECUTABLE "/usr/local/cuda/bin/nvcc")
set(CMAKE_CUDA_COMPILER ${CUDAToolkit_NVCC_EXECUTABLE})
message(WARNING "CMAKE_CUDA_COMPILER guessed: " ${CUDAToolkit_NVCC_EXECUTABLE} "\n"
"Please fix your cuda installation: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#mandatory-post")
endif ()
endif ()
if (${CUDAToolkit_VERSION} LESS 11.2)
message(FATAL_ERROR "CUDAToolkit mush be newer or equal to 11.2. Your version is " ${CUDAToolkit_VERSION})
endif ()
endif ()
enable_language(CUDA)


set(SANITIZER_PATH ${CUDAToolkit_TARGET_DIR}/compute-sanitizer)

include_directories(${SANITIZER_PATH}/include/
${CUDAToolkit_TARGET_DIR}/include/
${CMAKE_CURRENT_LIST_DIR}/include/
${CMAKE_CURRENT_LIST_DIR}/src/
)
message(INFO ${SANITIZER_PATH} ${CUDAToolkit_NVCC_EXECUTABLE})
add_link_options(-L${SANITIZER_PATH} -fPIC -shared)

aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/ cubin_filter_src)
file(GLOB cubin_filter_head CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/*.h" )


add_library(cubin_filter SHARED ${cubin_filter_src} )

target_link_libraries(cubin_filter PUBLIC
-lsanitizer-public
-lmbedcrypto
)


install(TARGETS cubin_filter DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES ${cubin_filter_head} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/)
Loading

0 comments on commit 710d77b

Please sign in to comment.