Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Dynamically target the exact folder where the script is executed
- RUN_DIR="$(pwd)"
- BASE_DIR="/home/michiel/cuda-samples/cpp/3_CUDA_Features"
- COMMON_INC="/home/michiel/cuda-samples/Common"
- LOG_FILE="${RUN_DIR}/turing_benchmark_results.log"
- ARCH_FLAG="-arch=sm_75"
- # Clear out any previous log files
- echo "==================================================" > "$LOG_FILE"
- echo " TURING ARCHITECTURE BENCHMARK LOG " >> "$LOG_FILE"
- echo " Generated on: $(date) " >> "$LOG_FILE"
- echo " Output location: ${LOG_FILE} " >> "$LOG_FILE"
- echo "==================================================" >> "$LOG_FILE"
- echo "" >> "$LOG_FILE"
- # Helper function to compile and run a test
- run_test() {
- local folder_name=$1
- local source_file=$2
- local extra_flags=$3
- local display_name=$4
- echo "[*] Starting Benchmark: ${display_name}..."
- echo "--------------------------------------------------" >> "$LOG_FILE"
- echo " TEST: ${display_name}" >> "$LOG_FILE"
- echo "--------------------------------------------------" >> "$LOG_FILE"
- # Navigate to target directory inside the samples tree
- if cd "${BASE_DIR}/${folder_name}" 2>/dev/null; then
- # Clean any old binaries to guarantee a fresh build
- rm -f "${folder_name}"
- # Compile (Added -diag-suppress 20054 to silence the dynamic shared memory warnings)
- echo " Compiling ${source_file} with ${ARCH_FLAG}..."
- nvcc "${source_file}" -I"${COMMON_INC}" ${ARCH_FLAG} ${extra_flags} -diag-suppress 20054 -o "${folder_name}"
- # Check if compilation succeeded
- if [ -f "${folder_name}" ]; then
- echo " Running binary..."
- # Execute and pipe output straight to our relative log file
- ./"${folder_name}" >> "$LOG_FILE" 2>&1
- echo "" >> "$LOG_FILE"
- echo "[+] ${display_name} completed successfully."
- else
- echo "[-] Error: Compilation failed for ${display_name}." >> "$LOG_FILE"
- echo "[-] Error: Compilation failed for ${display_name}."
- fi
- else
- echo "[-] Error: Directory ${folder_name} not found." >> "$LOG_FILE"
- echo "[-] Error: Directory ${folder_name} not found."
- fi
- echo ""
- }
- # --- TEST 1: FP16 Tensor Cores ---
- run_test "cudaTensorCoreGemm" "cudaTensorCoreGemm.cu" "-lcublas -lcudart" "FP16 Tensor Core GEMM Execution"
- # --- TEST 2: INT8 Tensor Cores (IMMA) ---
- run_test "immaTensorCoreGemm" "immaTensorCoreGemm.cu" "-lcublas -lcudart" "INT8 Integer Tensor Core (IMMA) Execution"
- # --- TEST 3: Asynchronous Global to Shared Memory Copy ---
- run_test "globalToShmemAsyncCopy" "globalToShmemAsyncCopy.cu" "-lcudart" "Asynchronous Memory Pipeline Performance"
- # --- TEST 4: Hardware Warp Cohesion and Atomics ---
- run_test "warpAggregatedAtomicsCG" "warpAggregatedAtomicsCG.cu" "-lcudart" "Cooperative Groups Warp Aggregated Atomics"
- # Complete
- echo "=================================================="
- echo "All tests finished!"
- echo "Your benchmark summary is waiting here: ${LOG_FILE}"
- echo "You can read it using: cat ./turing_benchmark_results.log"
- echo "=================================================="
Advertisement