From ff4b7a094ece097efe8f44d6b2aac1d8b8bf2424 Mon Sep 17 00:00:00 2001 From: Ivan Zinchenko Date: Fri, 6 Feb 2026 10:13:32 +0300 Subject: [PATCH] Modify dedup algo --- .github/workflows/vtkm.yml | 25 ------------------ .github/workflows/vtpc.yml | 54 -------------------------------------- lab/vtld/cpu_utils.c | 26 +++++++++++------- lab/vtld/makefile | 2 +- 4 files changed, 17 insertions(+), 90 deletions(-) delete mode 100644 .github/workflows/vtkm.yml delete mode 100644 .github/workflows/vtpc.yml diff --git a/.github/workflows/vtkm.yml b/.github/workflows/vtkm.yml deleted file mode 100644 index efccba9..0000000 --- a/.github/workflows/vtkm.yml +++ /dev/null @@ -1,25 +0,0 @@ -# name: Test VT Kernel Module - -# on: -# push: -# branches: -# - main -# pull_request: -# paths: -# - 'lab/vtkm/**' - -# jobs: -# build: -# runs-on: ubuntu-latest -# defaults: -# run: -# working-directory: ./lab/vtkm -# steps: -# - uses: actions/checkout@v4 -# - name: Clang Format -# run: | -# find . -path ./build -prune -o \ -# \( -iname '*.c' -o -iname '*.h' -o -iname '*.cpp' -o -iname '*.hpp' \) \ -# -exec clang-format --style=file --dry-run --verbose {} \; -# - name: Build -# run: make diff --git a/.github/workflows/vtpc.yml b/.github/workflows/vtpc.yml deleted file mode 100644 index db0afe4..0000000 --- a/.github/workflows/vtpc.yml +++ /dev/null @@ -1,54 +0,0 @@ -# name: Test VT Page Cache - -# on: -# push: -# branches: -# - main -# pull_request: -# paths: -# - 'lab/vtpc/**' - -# jobs: -# build: -# strategy: -# matrix: -# cmake_build_type: -# - Asan -# - Release -# runs-on: ubuntu-latest -# container: -# image: silkeh/clang:latest -# defaults: -# run: -# working-directory: ./lab/vtpc -# steps: -# - name: Checkout -# uses: actions/checkout@v4 - -# - name: Clang Format -# run: | -# find . -path ./build -prune -o \ -# \( -iname '*.c' -o -iname '*.h' -o -iname '*.cpp' -o -iname '*.hpp' \) \ -# -exec clang-format --style=file --dry-run --verbose {} \; - -# - name: Configure -# run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} - -# - name: Build -# run: cmake --build build - -# - name: Clang Tidy -# if: matrix.cmake_build_type == 'Release' -# run: | -# find . -path ./build -prune -o \ -# \( -iname '*.c' -o -iname '*.h' -o -iname '*.cpp' -o -iname '*.hpp' \) -exec \ -# clang-tidy -p ./build {} \; - -# - name: Test Basic -# run: ./build/test/test_basic - -# - name: Test Sequential -# run: ./build/test/test_seq - -# - name: Test Random -# run: ./build/test/test_random diff --git a/lab/vtld/cpu_utils.c b/lab/vtld/cpu_utils.c index 676454d..4fe0139 100644 --- a/lab/vtld/cpu_utils.c +++ b/lab/vtld/cpu_utils.c @@ -1,14 +1,7 @@ #include "cpu_utils.h" -#include #include -static int cmp_int32(const void* a, const void* b) { - int32_t ia = *(const int32_t*)a; - int32_t ib = *(const int32_t*)b; - return (ia > ib) - (ia < ib); -} - long dedup_run( long size, long max_value, @@ -30,17 +23,30 @@ long dedup_run( if (!arr) { return -1; } + int32_t* dedup = malloc((size_t)size * sizeof(int32_t)); + if (!dedup) { + free(arr); + return -1; + } for (long i = 0; i < size; ++i) { arr[i] = (int32_t)(rand_r(seed) % max_value); } - qsort(arr, (size_t)size, sizeof(int32_t), cmp_int32); long unique = 0; for (long i = 0; i < size; ++i) { - if (i == 0 || arr[i] != arr[i - 1]) { - ++unique; + int32_t value = arr[i]; + int found = 0; + for (long j = 0; j < unique; ++j) { + if (dedup[j] == value) { + found = 1; + break; + } + } + if (!found) { + dedup[unique++] = value; } } free(arr); + free(dedup); results[r] = unique; } diff --git a/lab/vtld/makefile b/lab/vtld/makefile index 901d0b2..986e0b9 100644 --- a/lab/vtld/makefile +++ b/lab/vtld/makefile @@ -1,5 +1,5 @@ CC=gcc -CFLAGS=-O0 -std=c11 +CFLAGS=-O0 all: cpu_dedup cpu_dedup_pthreads ema_replace_str ema_replace_str_pthreads