From cc56e8997aac95f4cf560897de9c5fbc71a860e5 Mon Sep 17 00:00:00 2001 From: Huanzhi Pu Date: Mon, 3 Mar 2025 18:06:38 -0500 Subject: [PATCH 1/2] add cupbop test functionality (update CI workflow to use actions/cache@v3) --- .github/workflows/ci.yml | 14 ++++++------ ci/regression.sh.in | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 393ba7f2c..501b9b365 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Cache Toolchain Directory id: cache-toolchain - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: tools key: ${{ runner.os }}-toolchain-v0.1 @@ -36,7 +36,7 @@ jobs: - name: Cache Third Party Directory id: cache-thirdparty - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: third_party key: ${{ runner.os }}-thirdparty-v0.1 @@ -79,7 +79,7 @@ jobs: - name: Cache Toolchain Directory id: cache-toolchain - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: tools key: ${{ runner.os }}-toolchain-v0.1 @@ -88,7 +88,7 @@ jobs: - name: Cache Third Party Directory id: cache-thirdparty - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: third_party key: ${{ runner.os }}-thirdparty-v0.1 @@ -117,7 +117,7 @@ jobs: strategy: fail-fast: false matrix: - name: [regression, opencl, cache, config1, config2, debug, scope, stress, synthesis, vm, vector] + name: [regression, opencl, cache, config1, config2, debug, scope, stress, synthesis, vm, vector, cupbop] xlen: [32, 64] steps: @@ -130,7 +130,7 @@ jobs: - name: Cache Toolchain Directory id: cache-toolchain - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: tools key: ${{ runner.os }}-toolchain-v0.1 @@ -139,7 +139,7 @@ jobs: - name: Cache Third Party Directory id: cache-thirdparty - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: third_party key: ${{ runner.os }}-thirdparty-v0.1 diff --git a/ci/regression.sh.in b/ci/regression.sh.in index 94ac4651f..407d097a5 100755 --- a/ci/regression.sh.in +++ b/ci/regression.sh.in @@ -403,6 +403,48 @@ vector() echo "vector tests done!" } +cupbop() { + + echo "begin cupbop tests..." + + if [ "$XLEN" == "32" ]; then + echo "cupbop tests skipped for 32-bit" + return + fi + + + echo "downloading cupbop binaries..." + CUPBOP_URL="https://www.dropbox.com/scl/fi/qxiofb0ejfxoog9m7tmae/cupbop.zip?rlkey=kcboy03c08xcn6yizd4nv8h88&st=7yuqftef&dl=1" + + wget -O cupbop.zip "${CUPBOP_URL}" || curl -L -o cupbop.zip "${CUPBOP_URL}" + unzip -o cupbop.zip -d tests/ + rm cupbop.zip + + echo "building simx runtime..." + make -C runtime/simx + + PERF_CLASS=2 + VORTEX_RUNTIME_DIR="runtime" + CUPBOP_RUNTIME_DIR="tests/cupbop/runtime" + + tests=("bfs" "nn") + tests_args=("./graph20.txt" "./filelist.txt -r 10 -lat 30 -lng 90") + + for i in "${!tests[@]}"; do + test="${tests[$i]}" + args="${tests_args[$i]}" + echo "running test: $test" + ( + cd "tests/cupbop/$test" || exit + chmod +x "./host_${XLEN}.out" + LD_LIBRARY_PATH="../../../${CUPBOP_RUNTIME_DIR}:../../../${VORTEX_RUNTIME_DIR}/simx:../../../${VORTEX_RUNTIME_DIR}:${LD_LIBRARY_PATH}" \ + ./host_${XLEN}.out ${args} + ) + done + + echo "cupbop tests done!" +} + show_usage() { echo "Vortex Regression Test" @@ -459,6 +501,9 @@ while [ "$1" != "" ]; do --vector ) tests+=("vector") ;; + --cupbop ) + tests+=("cupbop") + ;; --all ) tests=() tests+=("unittest") @@ -475,6 +520,7 @@ while [ "$1" != "" ]; do tests+=("stress") tests+=("synthesis") tests+=("vector") + tests+=("cupbop") ;; -h | --help ) show_usage From aaeb7ba644088ec605e6650eebe904db919559c9 Mon Sep 17 00:00:00 2001 From: tinebp Date: Sat, 3 May 2025 21:34:10 -0700 Subject: [PATCH 2/2] extending divergence test coverage --- sim/common/util.cpp | 19 +++++++++++++++++++ sim/common/util.h | 3 +++ tests/regression/diverge/kernel.cpp | 17 +++++++++++++++++ tests/regression/diverge/main.cpp | 8 ++++++++ 4 files changed, 47 insertions(+) diff --git a/sim/common/util.cpp b/sim/common/util.cpp index 8cd67bb33..ff22817b9 100644 --- a/sim/common/util.cpp +++ b/sim/common/util.cpp @@ -12,6 +12,8 @@ // limitations under the License. #include "util.h" +#include +#include #include // return file extension @@ -36,4 +38,21 @@ void aligned_free(void *ptr) { // retreive the stored unaligned address and use it to free the allocation void* unaligned_addr = ((void**)ptr)[-1]; free(unaligned_addr); +} + +std::string vortex::resolve_file_path(const std::string& filename, const std::string& searchPaths) { + std::ifstream ifs(filename); + if (!ifs) { + std::stringstream ss(searchPaths); + std::string path; + while (std::getline(ss, path, ',')) { + if (!path.empty()) { + std::string filePath = path + "/" + filename; + std::ifstream ifs(filePath); + if (ifs) + return filePath; + } + } + } + return filename; } \ No newline at end of file diff --git a/sim/common/util.h b/sim/common/util.h index fd234d279..c4b47ac49 100644 --- a/sim/common/util.h +++ b/sim/common/util.h @@ -17,6 +17,7 @@ #include #include #include +#include template void unused(Args&&...) {} @@ -94,4 +95,6 @@ public: } }; +std::string resolve_file_path(const std::string& filename, const std::string& searchPaths); + } \ No newline at end of file diff --git a/tests/regression/diverge/kernel.cpp b/tests/regression/diverge/kernel.cpp index 70b27fa79..522a31b23 100644 --- a/tests/regression/diverge/kernel.cpp +++ b/tests/regression/diverge/kernel.cpp @@ -5,6 +5,14 @@ // Parallel Selection sort +struct key_t { + uint32_t user = 0; +}; + +static __attribute__((noinline)) void hacker(key_t* key, uint32_t task_id) { + key->user = task_id; +} + void kernel_body(kernel_arg_t* __UNIFORM__ arg) { int32_t* src_ptr = (int32_t*)arg->src_addr; int32_t* dst_ptr = (int32_t*)arg->dst_addr; @@ -13,6 +21,15 @@ void kernel_body(kernel_arg_t* __UNIFORM__ arg) { int value = src_ptr[task_id]; + key_t key; + uint32_t samples = arg->num_points; + while (samples--) { + hacker(&key, task_id); + if ((key.user & 0x1) == 0) { + value += 1; + } + } + // none taken if (task_id >= 0x7fffffff) { value = 0; diff --git a/tests/regression/diverge/main.cpp b/tests/regression/diverge/main.cpp index d858b1729..bca9a1fc0 100644 --- a/tests/regression/diverge/main.cpp +++ b/tests/regression/diverge/main.cpp @@ -78,6 +78,14 @@ void gen_ref_data(std::vector& ref_data, const std::vector& src_data, for (int i = 0; i < (int)size; ++i) { int value = src_data.at(i); + key_t key; + uint32_t samples = size; + while (samples--) { + if ((i & 0x1) == 0) { + value += 1; + } + } + // none taken if (i >= 0x7fffffff) { value = 0;