diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 44f2ba2ca0..3381c09bea 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -151,6 +151,66 @@ jobs: working-directory: ${{env.BUILD_DIR}} run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test + Windows-NMake: + name: Windows-NMake + env: + VCPKG_PATH: "${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows" + BUILD_DIR : "${{github.workspace}}/build" + strategy: + matrix: + os: ['windows-2019', 'windows-2022'] + build_type: [Debug, Release] + compiler: [{c: cl, cxx: cl}] + shared_library: ['ON', 'OFF'] + + runs-on: ${{matrix.os}} + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Initialize vcpkg + uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5 + with: + vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289 + vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg + vcpkgJsonGlob: '**/vcpkg.json' + + - name: Install dependencies + run: vcpkg install + + - name: Configure MSVC environment + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + + - name: Configure build + run: > + cmake + -B ${{env.BUILD_DIR}} + -DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}" + -DCMAKE_C_COMPILER=${{matrix.compiler.c}} + -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} + -G "NMake Makefiles" + -DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}} + -DUMF_LINK_HWLOC_STATICALLY=ON + -DUMF_FORMAT_CODE_STYLE=OFF + -DUMF_DEVELOPER_MODE=ON + -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON + -DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON + -DUMF_BUILD_CUDA_PROVIDER=ON + -DUMF_TESTS_FAIL_ON_SKIP=ON + + - name: Build UMF + shell: cmd + run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j %NUMBER_OF_PROCESSORS% + + - name: Run tests + shell: cmd + working-directory: ${{env.BUILD_DIR}} + run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test + + icx: name: ICX env: diff --git a/.github/workflows/reusable_benchmarks.yml b/.github/workflows/reusable_benchmarks.yml index a7c9e5e285..15e6b15f4a 100644 --- a/.github/workflows/reusable_benchmarks.yml +++ b/.github/workflows/reusable_benchmarks.yml @@ -103,7 +103,9 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: repository: intel/llvm - ref: nightly-2025-02-19 + # add preloaded UMF benchmarks + # https://github.com/intel/llvm/pull/17278 + ref: b2f9dab5266d227cc9eb19af1b54c5bdc50221d1 path: sycl-repo fetch-depth: 1 diff --git a/.github/workflows/reusable_dax.yml b/.github/workflows/reusable_dax.yml index 1a41b11c75..4ea5ddac75 100644 --- a/.github/workflows/reusable_dax.yml +++ b/.github/workflows/reusable_dax.yml @@ -31,7 +31,7 @@ env: INSTL_DIR : "${{github.workspace}}/../install-dir" COVERAGE_DIR : "${{github.workspace}}/coverage" COVERAGE_NAME : "exports-coverage-dax" - DAX_TESTS: "./test/umf_test-provider_file_memory ./test/umf_test-provider_devdax_memory" + DAX_TESTS: "./test/test_provider_file_memory ./test/test_provider_devdax_memory" jobs: dax: diff --git a/.github/workflows/reusable_multi_numa.yml b/.github/workflows/reusable_multi_numa.yml index 7c77505516..3c60bebc38 100644 --- a/.github/workflows/reusable_multi_numa.yml +++ b/.github/workflows/reusable_multi_numa.yml @@ -10,7 +10,7 @@ env: BUILD_DIR : "${{github.workspace}}/build" COVERAGE_DIR : "${{github.workspace}}/coverage" COVERAGE_NAME : "exports-coverage-multinuma" - NUMA_TESTS: "./test/umf_test-memspace_numa ./test/umf_test-provider_os_memory_multiple_numa_nodes" + NUMA_TESTS: "./test/test_memspace_numa ./test/test_provider_os_memory_multiple_numa_nodes" jobs: multi_numa: @@ -60,13 +60,13 @@ jobs: # On RHEL, hwloc version is just a little too low. # Skip some tests until we upgrade hwloc and update CMake to properly handle local hwloc installation. # TODO: fix issue #560 - # TODO: add issue for -E umf-init_teardown - it is not clear why it fails + # TODO: add issue for -E test_init_teardown - it is not clear why it fails - name: Run tests (on RHEL) if: matrix.os == 'rhel-9.1' working-directory: ${{github.workspace}}/build run: | - ctest --output-on-failure --test-dir test -E "umf-provider_os_memory_multiple_numa_nodes|umf-init_teardown" - ./test/umf_test-provider_os_memory_multiple_numa_nodes \ + ctest --output-on-failure --test-dir test -E "test_provider_os_memory_multiple_numa_nodes|test_init_teardown" + ./test/test_provider_os_memory_multiple_numa_nodes \ --gtest_filter="-*checkModeLocal/*:*checkModePreferredEmptyNodeset/*:testNuma.checkModeInterleave" - name: Run NUMA tests under valgrind diff --git a/.github/workflows/reusable_proxy_lib.yml b/.github/workflows/reusable_proxy_lib.yml index bb4a3278ef..363e665264 100644 --- a/.github/workflows/reusable_proxy_lib.yml +++ b/.github/workflows/reusable_proxy_lib.yml @@ -59,9 +59,9 @@ jobs: working-directory: ${{env.BUILD_DIR}} run: LD_PRELOAD=./lib/libumf_proxy.so ctest --output-on-failure - - name: Run "./test/umf_test-memoryPool" with proxy library + - name: Run "./test/test_memoryPool" with proxy library working-directory: ${{env.BUILD_DIR}} - run: LD_PRELOAD=./lib/libumf_proxy.so ./test/umf_test-memoryPool + run: LD_PRELOAD=./lib/libumf_proxy.so ./test/test_memoryPool - name: Run "/usr/bin/ls" with proxy library working-directory: ${{env.BUILD_DIR}} diff --git a/benchmark/benchmark.cpp b/benchmark/benchmark.cpp index 60636a559f..7b04f2061e 100644 --- a/benchmark/benchmark.cpp +++ b/benchmark/benchmark.cpp @@ -96,9 +96,7 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, pool_allocator>); UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, disjoint_pool_uniform) ->Apply(&default_multiple_alloc_uniform_size) - ->Apply(&singlethreaded); -// TODO: change to multithreaded -//->Apply(&multithreaded); + ->Apply(&multithreaded); #ifdef UMF_POOL_JEMALLOC_ENABLED UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, jemalloc_pool_fix, @@ -136,6 +134,81 @@ UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, scalable_pool_uniform) #endif +UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, + proxy_pool_fixedprovider, fixed_alloc_size, + pool_allocator>); + +UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, + proxy_pool_fixedprovider) + ->Apply(&default_multiple_alloc_fix_size) + ->Apply(&singlethreaded); + +UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, fixed_provider, + fixed_alloc_size, + provider_allocator); +UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, fixed_provider) + ->Apply(&default_multiple_alloc_fix_size) + ->Apply(&singlethreaded); + +UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, + disjoint_pool_fix_fixedprovider, fixed_alloc_size, + pool_allocator>); +UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, + disjoint_pool_fix_fixedprovider) + ->Apply(&default_multiple_alloc_fix_size) + ->Apply(&multithreaded); + +UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, + disjoint_pool_uniform_fixedprovider, + uniform_alloc_size, + pool_allocator>); +UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, + disjoint_pool_uniform_fixedprovider) + ->Apply(&default_multiple_alloc_uniform_size) + ->Apply(&singlethreaded); +// TODO: change to multithreaded +//->Apply(&multithreaded); + +#ifdef UMF_POOL_JEMALLOC_ENABLED +UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, + jemalloc_pool_fixedprovider, fixed_alloc_size, + pool_allocator>); +UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, jemalloc_pool_fix) + ->Apply(&default_multiple_alloc_fix_size) + ->Apply(&multithreaded); + +UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, + jemalloc_pool_uniform_fixedprovider, + uniform_alloc_size, + pool_allocator>); +UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, jemalloc_pool_uniform) + ->Apply(&default_multiple_alloc_uniform_size) + ->Apply(&multithreaded); + +#endif + +#ifdef UMF_POOL_SCALABLE_ENABLED +UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, + scalable_pool_fix_fixedprovider, fixed_alloc_size, + pool_allocator>); + +UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, + scalable_pool_fix_fixedprovider) + ->Apply(&default_multiple_alloc_fix_size) + ->Apply(&multithreaded); + +UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, + scalable_pool_uniform_fixedprovider, + uniform_alloc_size, + pool_allocator>); + +UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, + scalable_pool_uniform_fixedprovider) + ->Apply(&default_multiple_alloc_uniform_size) + ->Apply(&multithreaded); + +#endif + //BENCHMARK_MAIN(); int main(int argc, char **argv) { if (initAffinityMask()) { diff --git a/benchmark/benchmark_umf.hpp b/benchmark/benchmark_umf.hpp index 5c3b160c7c..cfc9982d2c 100644 --- a/benchmark/benchmark_umf.hpp +++ b/benchmark/benchmark_umf.hpp @@ -19,6 +19,7 @@ #ifdef UMF_POOL_SCALABLE_ENABLED #include #endif +#include #include #ifdef UMF_POOL_JEMALLOC_ENABLED @@ -145,7 +146,9 @@ struct os_provider : public provider_interface { umfOsMemoryProviderParamsDestroy(handle); }; - return {static_cast(raw_params), deleter}; + return {static_cast( + raw_params), + deleter}; } umf_memory_provider_ops_t * @@ -155,6 +158,62 @@ struct os_provider : public provider_interface { static std::string name() { return "os_provider"; } }; +struct fixed_provider : public provider_interface { + private: + char *mem = NULL; + const size_t size = 1024 * 1024 * 1024; // 1GB + public: + virtual void SetUp(::benchmark::State &state) override { + if (state.thread_index() != 0) { + return; + } + + if (!mem) { + mem = new char[size]; + } + + provider_interface::SetUp(state); + } + + virtual void TearDown(::benchmark::State &state) override { + if (state.thread_index() != 0) { + return; + } + + delete[] mem; + mem = nullptr; + + provider_interface::TearDown(state); + } + + provider_interface::params_ptr + getParams(::benchmark::State &state) override { + umf_fixed_memory_provider_params_handle_t raw_params = nullptr; + umfFixedMemoryProviderParamsCreate(&raw_params, mem, size); + if (!raw_params) { + state.SkipWithError("Failed to create fixed provider params"); + return {nullptr, [](void *) {}}; + } + + // Use a lambda as the custom deleter + auto deleter = [](void *p) { + auto handle = + static_cast(p); + umfFixedMemoryProviderParamsDestroy(handle); + }; + + return {static_cast( + raw_params), + deleter}; + } + + umf_memory_provider_ops_t * + getOps([[maybe_unused]] ::benchmark::State &state) override { + return umfFixedMemoryProviderOps(); + } + static std::string name() { return "fixed_provider"; } +}; + template struct proxy_pool : public pool_interface { umf_memory_pool_ops_t * diff --git a/src/critnib/critnib.c b/src/critnib/critnib.c index 62d14af73d..c95637f20c 100644 --- a/src/critnib/critnib.c +++ b/src/critnib/critnib.c @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2023-2024 Intel Corporation + * Copyright (C) 2023-2025 Intel Corporation * * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -133,24 +133,6 @@ struct critnib { struct utils_mutex_t mutex; /* writes/removes */ }; -/* - * atomic load - */ -static void load(void *src, void *dst) { - utils_atomic_load_acquire((word *)src, (word *)dst); -} - -static void load64(uint64_t *src, uint64_t *dst) { - utils_atomic_load_acquire(src, dst); -} - -/* - * atomic store - */ -static void store(void *dst, void *src) { - utils_atomic_store_release((word *)dst, (word)src); -} - /* * internal: is_leaf -- check tagged pointer for leafness */ @@ -192,8 +174,8 @@ struct critnib *critnib_new(void) { goto err_free_critnib; } - VALGRIND_HG_DRD_DISABLE_CHECKING(&c->root, sizeof(c->root)); - VALGRIND_HG_DRD_DISABLE_CHECKING(&c->remove_count, sizeof(c->remove_count)); + utils_annotate_memory_no_check(&c->root, sizeof(c->root)); + utils_annotate_memory_no_check(&c->remove_count, sizeof(c->remove_count)); return c; err_free_critnib: @@ -278,7 +260,7 @@ static struct critnib_node *alloc_node(struct critnib *__restrict c) { struct critnib_node *n = c->deleted_node; c->deleted_node = n->child[0]; - VALGRIND_ANNOTATE_NEW_MEMORY(n, sizeof(*n)); + utils_annotate_memory_new(n, sizeof(*n)); return n; } @@ -303,13 +285,13 @@ static void free_leaf(struct critnib *__restrict c, */ static struct critnib_leaf *alloc_leaf(struct critnib *__restrict c) { if (!c->deleted_leaf) { - return umf_ba_global_alloc(sizeof(struct critnib_leaf)); + return umf_ba_global_aligned_alloc(sizeof(struct critnib_leaf), 8); } struct critnib_leaf *k = c->deleted_leaf; c->deleted_leaf = k->value; - VALGRIND_ANNOTATE_NEW_MEMORY(k, sizeof(*k)); + utils_annotate_memory_new(k, sizeof(*k)); return k; } @@ -334,7 +316,7 @@ int critnib_insert(struct critnib *c, word key, void *value, int update) { return ENOMEM; } - VALGRIND_HG_DRD_DISABLE_CHECKING(k, sizeof(struct critnib_leaf)); + utils_annotate_memory_no_check(k, sizeof(struct critnib_leaf)); k->key = key; k->value = value; @@ -343,10 +325,8 @@ int critnib_insert(struct critnib *c, word key, void *value, int update) { struct critnib_node *n = c->root; if (!n) { - store(&c->root, kn); - + utils_atomic_store_release_ptr((void **)&c->root, kn); utils_mutex_unlock(&c->mutex); - return 0; } @@ -361,7 +341,8 @@ int critnib_insert(struct critnib *c, word key, void *value, int update) { if (!n) { n = prev; - store(&n->child[slice_index(key, n->shift)], kn); + utils_atomic_store_release_ptr( + (void **)&n->child[slice_index(key, n->shift)], kn); utils_mutex_unlock(&c->mutex); @@ -396,7 +377,7 @@ int critnib_insert(struct critnib *c, word key, void *value, int update) { return ENOMEM; } - VALGRIND_HG_DRD_DISABLE_CHECKING(m, sizeof(struct critnib_node)); + utils_annotate_memory_no_check(m, sizeof(struct critnib_node)); for (int i = 0; i < SLNODES; i++) { m->child[i] = NULL; @@ -406,7 +387,7 @@ int critnib_insert(struct critnib *c, word key, void *value, int update) { m->child[slice_index(path, sh)] = n; m->shift = sh; m->path = key & path_mask(sh); - store(parent, m); + utils_atomic_store_release_ptr((void **)parent, m); utils_mutex_unlock(&c->mutex); @@ -427,7 +408,8 @@ void *critnib_remove(struct critnib *c, word key) { goto not_found; } - word del = (utils_atomic_increment(&c->remove_count) - 1) % DELETED_LIFE; + word del = + (utils_atomic_increment_u64(&c->remove_count) - 1) % DELETED_LIFE; free_node(c, c->pending_del_nodes[del]); free_leaf(c, c->pending_del_leaves[del]); c->pending_del_nodes[del] = NULL; @@ -436,7 +418,7 @@ void *critnib_remove(struct critnib *c, word key) { if (is_leaf(n)) { k = to_leaf(n); if (k->key == key) { - store(&c->root, NULL); + utils_atomic_store_release_ptr((void **)&c->root, NULL); goto del_leaf; } @@ -466,7 +448,8 @@ void *critnib_remove(struct critnib *c, word key) { goto not_found; } - store(&n->child[slice_index(key, n->shift)], NULL); + utils_atomic_store_release_ptr( + (void **)&n->child[slice_index(key, n->shift)], NULL); /* Remove the node if there's only one remaining child. */ int ochild = -1; @@ -482,7 +465,7 @@ void *critnib_remove(struct critnib *c, word key) { ASSERTne(ochild, -1); - store(n_parent, n->child[ochild]); + utils_atomic_store_release_ptr((void **)n_parent, n->child[ochild]); c->pending_del_nodes[del] = n; del_leaf: @@ -511,8 +494,8 @@ void *critnib_get(struct critnib *c, word key) { do { struct critnib_node *n; - load64(&c->remove_count, &wrs1); - load(&c->root, &n); + utils_atomic_load_acquire_u64(&c->remove_count, &wrs1); + utils_atomic_load_acquire_ptr((void **)&c->root, (void **)&n); /* * critbit algorithm: dive into the tree, looking at nothing but @@ -520,13 +503,14 @@ void *critnib_get(struct critnib *c, word key) { * going wrong way if our path is missing, but that's ok... */ while (n && !is_leaf(n)) { - load(&n->child[slice_index(key, n->shift)], &n); + utils_atomic_load_acquire_ptr( + (void **)&n->child[slice_index(key, n->shift)], (void **)&n); } /* ... as we check it at the end. */ struct critnib_leaf *k = to_leaf(n); res = (n && k->key == key) ? k->value : NULL; - load64(&c->remove_count, &wrs2); + utils_atomic_load_acquire_u64(&c->remove_count, &wrs2); } while (wrs1 + DELETED_LIFE <= wrs2); return res; @@ -597,7 +581,7 @@ static struct critnib_leaf *find_le(struct critnib_node *__restrict n, /* recursive call: follow the path */ { struct critnib_node *m; - load(&n->child[nib], &m); + utils_atomic_load_acquire_ptr((void **)&n->child[nib], (void **)&m); struct critnib_leaf *k = find_le(m, key); if (k) { return k; @@ -611,7 +595,7 @@ static struct critnib_leaf *find_le(struct critnib_node *__restrict n, */ for (; nib > 0; nib--) { struct critnib_node *m; - load(&n->child[nib - 1], &m); + utils_atomic_load_acquire_ptr((void **)&n->child[nib - 1], (void **)&m); if (m) { n = m; if (is_leaf(n)) { @@ -635,12 +619,12 @@ void *critnib_find_le(struct critnib *c, word key) { void *res; do { - load64(&c->remove_count, &wrs1); + utils_atomic_load_acquire_u64(&c->remove_count, &wrs1); struct critnib_node *n; /* avoid a subtle TOCTOU */ - load(&c->root, &n); + utils_atomic_load_acquire_ptr((void **)&c->root, (void **)&n); struct critnib_leaf *k = n ? find_le(n, key) : NULL; res = k ? k->value : NULL; - load64(&c->remove_count, &wrs2); + utils_atomic_load_acquire_u64(&c->remove_count, &wrs2); } while (wrs1 + DELETED_LIFE <= wrs2); return res; @@ -694,7 +678,7 @@ static struct critnib_leaf *find_ge(struct critnib_node *__restrict n, unsigned nib = slice_index(key, n->shift); { struct critnib_node *m; - load(&n->child[nib], &m); + utils_atomic_load_acquire_ptr((void **)&n->child[nib], (void **)&m); struct critnib_leaf *k = find_ge(m, key); if (k) { return k; @@ -703,7 +687,7 @@ static struct critnib_leaf *find_ge(struct critnib_node *__restrict n, for (; nib < NIB; nib++) { struct critnib_node *m; - load(&n->child[nib + 1], &m); + utils_atomic_load_acquire_ptr((void **)&n->child[nib + 1], (void **)&m); if (m) { n = m; if (is_leaf(n)) { @@ -741,9 +725,9 @@ int critnib_find(struct critnib *c, uintptr_t key, enum find_dir_t dir, } do { - load64(&c->remove_count, &wrs1); + utils_atomic_load_acquire_u64(&c->remove_count, &wrs1); struct critnib_node *n; - load(&c->root, &n); + utils_atomic_load_acquire_ptr((void **)&c->root, (void **)&n); if (dir < 0) { k = find_le(n, key); @@ -751,7 +735,9 @@ int critnib_find(struct critnib *c, uintptr_t key, enum find_dir_t dir, k = find_ge(n, key); } else { while (n && !is_leaf(n)) { - load(&n->child[slice_index(key, n->shift)], &n); + utils_atomic_load_acquire_ptr( + (void **)&n->child[slice_index(key, n->shift)], + (void **)&n); } struct critnib_leaf *kk = to_leaf(n); @@ -761,7 +747,7 @@ int critnib_find(struct critnib *c, uintptr_t key, enum find_dir_t dir, _rkey = k->key; _rvalue = k->value; } - load64(&c->remove_count, &wrs2); + utils_atomic_load_acquire_u64(&c->remove_count, &wrs2); } while (wrs1 + DELETED_LIFE <= wrs2); if (k) { diff --git a/src/ipc_cache.c b/src/ipc_cache.c index cab5fc478d..6d5d39e4f2 100644 --- a/src/ipc_cache.c +++ b/src/ipc_cache.c @@ -232,7 +232,7 @@ umf_result_t umfIpcOpenedCacheGet(ipc_opened_cache_handle_t cache, exit: if (ret == UMF_RESULT_SUCCESS) { - utils_atomic_increment(&entry->ref_count); + utils_atomic_increment_u64(&entry->ref_count); *retEntry = &entry->value; } diff --git a/src/libumf.c b/src/libumf.c index f8f6cc61ff..e357b2583a 100644 --- a/src/libumf.c +++ b/src/libumf.c @@ -24,10 +24,10 @@ umf_memory_tracker_handle_t TRACKER = NULL; -static unsigned long long umfRefCount = 0; +static uint64_t umfRefCount = 0; int umfInit(void) { - if (utils_fetch_and_add64(&umfRefCount, 1) == 0) { + if (utils_fetch_and_add_u64(&umfRefCount, 1) == 0) { utils_log_init(); TRACKER = umfMemoryTrackerCreate(); if (!TRACKER) { @@ -54,7 +54,7 @@ int umfInit(void) { } void umfTearDown(void) { - if (utils_fetch_and_add64(&umfRefCount, -1) == 1) { + if (utils_fetch_and_sub_u64(&umfRefCount, 1) == 1) { #if !defined(_WIN32) && !defined(UMF_NO_HWLOC) umfMemspaceHostAllDestroy(); umfMemspaceHighestCapacityDestroy(); diff --git a/src/pool/pool_disjoint.c b/src/pool/pool_disjoint.c index 9adb1a7a4f..0bd88bd246 100644 --- a/src/pool/pool_disjoint.c +++ b/src/pool/pool_disjoint.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -20,6 +21,7 @@ #include "provider/provider_tracking.h" #include "uthash/utlist.h" #include "utils_common.h" +#include "utils_concurrency.h" #include "utils_log.h" #include "utils_math.h" @@ -34,7 +36,6 @@ // Forward declarations static void bucket_update_stats(bucket_t *bucket, int in_use, int in_pool); static bool bucket_can_pool(bucket_t *bucket); -static void bucket_decrement_pool(bucket_t *bucket); static slab_list_item_t *bucket_get_avail_slab(bucket_t *bucket, bool *from_pool); @@ -316,6 +317,7 @@ static void bucket_free_chunk(bucket_t *bucket, void *ptr, slab_t *slab, assert(slab_it->val != NULL); pool_unregister_slab(bucket->pool, slab_it->val); DL_DELETE(bucket->available_slabs, slab_it); + assert(bucket->available_slabs_num > 0); bucket->available_slabs_num--; destroy_slab(slab_it->val); } @@ -381,10 +383,16 @@ static slab_list_item_t *bucket_get_avail_slab(bucket_t *bucket, // Allocation from existing slab is treated as from pool for statistics. *from_pool = true; if (slab->num_chunks_allocated == 0) { + assert(bucket->chunked_slabs_in_pool > 0); // If this was an empty slab, it was in the pool. // Now it is no longer in the pool, so update count. --bucket->chunked_slabs_in_pool; - bucket_decrement_pool(bucket); + uint64_t size_to_sub = bucket_slab_alloc_size(bucket); + uint64_t old_size = utils_fetch_and_sub_u64( + &bucket->shared_limits->total_size, size_to_sub); + (void)old_size; + assert(old_size >= size_to_sub); + bucket_update_stats(bucket, 1, -1); } } @@ -420,12 +428,6 @@ static void bucket_update_stats(bucket_t *bucket, int in_use, int in_pool) { in_pool * bucket_slab_alloc_size(bucket); } -static void bucket_decrement_pool(bucket_t *bucket) { - bucket_update_stats(bucket, 1, -1); - utils_fetch_and_add64(&bucket->shared_limits->total_size, - -(long long)bucket_slab_alloc_size(bucket)); -} - static bool bucket_can_pool(bucket_t *bucket) { size_t new_free_slabs_in_bucket; @@ -433,23 +435,20 @@ static bool bucket_can_pool(bucket_t *bucket) { // we keep at most params.capacity slabs in the pool if (bucket_max_pooled_slabs(bucket) >= new_free_slabs_in_bucket) { - size_t pool_size = 0; - utils_atomic_load_acquire(&bucket->shared_limits->total_size, - &pool_size); - while (true) { - size_t new_pool_size = pool_size + bucket_slab_alloc_size(bucket); - - if (bucket->shared_limits->max_size < new_pool_size) { - break; - } - - if (utils_compare_exchange(&bucket->shared_limits->total_size, - &pool_size, &new_pool_size)) { - ++bucket->chunked_slabs_in_pool; - - bucket_update_stats(bucket, -1, 1); - return true; - } + + uint64_t size_to_add = bucket_slab_alloc_size(bucket); + size_t previous_size = utils_fetch_and_add_u64( + &bucket->shared_limits->total_size, size_to_add); + + if (previous_size + size_to_add <= bucket->shared_limits->max_size) { + ++bucket->chunked_slabs_in_pool; + bucket_update_stats(bucket, -1, 1); + return true; + } else { + uint64_t old = utils_fetch_and_sub_u64( + &bucket->shared_limits->total_size, size_to_add); + (void)old; + assert(old >= size_to_add); } } @@ -523,7 +522,7 @@ static void disjoint_pool_print_stats(disjoint_pool_t *pool) { utils_mutex_unlock(&bucket->bucket_lock); } - LOG_DEBUG("current pool size: %zu", + LOG_DEBUG("current pool size: %" PRIu64, disjoint_pool_get_limits(pool)->total_size); LOG_DEBUG("suggested setting=;%c%s:%zu,%zu,64K", (char)tolower(name[0]), (name + 1), high_bucket_size, high_peak_slabs_in_use); @@ -864,7 +863,8 @@ umf_result_t disjoint_pool_free(void *pool, void *ptr) { if (disjoint_pool->params.pool_trace > 2) { const char *name = disjoint_pool->params.name; - LOG_DEBUG("freed %s %p to %s, current total pool size: %zu, current " + LOG_DEBUG("freed %s %p to %s, current total pool size: %" PRIu64 + ", current " "pool size for %s: %zu", name, ptr, (to_pool ? "pool" : "provider"), disjoint_pool_get_limits(disjoint_pool)->total_size, name, diff --git a/src/pool/pool_disjoint_internal.h b/src/pool/pool_disjoint_internal.h index 86460509b4..2b5de64bc3 100644 --- a/src/pool/pool_disjoint_internal.h +++ b/src/pool/pool_disjoint_internal.h @@ -102,7 +102,7 @@ typedef struct slab_t { typedef struct umf_disjoint_pool_shared_limits_t { size_t max_size; - size_t total_size; // requires atomic access + uint64_t total_size; // requires atomic access } umf_disjoint_pool_shared_limits_t; typedef struct umf_disjoint_pool_params_t { diff --git a/src/provider/provider_file_memory.c b/src/provider/provider_file_memory.c index f81e4f8d2d..5cc377f320 100644 --- a/src/provider/provider_file_memory.c +++ b/src/provider/provider_file_memory.c @@ -404,8 +404,12 @@ static umf_result_t file_mmap_aligned(file_memory_provider_t *file_provider, "inserted a value to the map of memory mapping (addr=%p, size=%zu)", ptr, extended_size); - file_provider->base_mmap = ptr; - file_provider->size_mmap = extended_size; + // align the new pointer + uintptr_t aligned_ptr = ALIGN_UP_SAFE((uintptr_t)ptr, alignment); + size_t aligned_size = extended_size - (aligned_ptr - (uintptr_t)ptr); + + file_provider->base_mmap = (void *)aligned_ptr; + file_provider->size_mmap = aligned_size; file_provider->offset_mmap = 0; return UMF_RESULT_SUCCESS; diff --git a/src/provider/provider_os_memory.c b/src/provider/provider_os_memory.c index bd5ea9c691..f0cd3abaed 100644 --- a/src/provider/provider_os_memory.c +++ b/src/provider/provider_os_memory.c @@ -934,7 +934,7 @@ static membind_t membindFirst(os_memory_provider_t *provider, void *addr, if (provider->mode == UMF_NUMA_MODE_INTERLEAVE) { assert(provider->part_size != 0); - size_t s = utils_fetch_and_add64(&provider->alloc_sum, size); + size_t s = utils_fetch_and_add_u64(&provider->alloc_sum, size); membind.node = (s / provider->part_size) % provider->nodeset_len; membind.bitmap = provider->nodeset[membind.node]; membind.bind_size = ALIGN_UP(provider->part_size, membind.page_size); diff --git a/src/provider/provider_os_memory_internal.h b/src/provider/provider_os_memory_internal.h index faf0de2473..4a603b1dad 100644 --- a/src/provider/provider_os_memory_internal.h +++ b/src/provider/provider_os_memory_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Intel Corporation + * Copyright (C) 2023-2025 Intel Corporation * * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -58,7 +58,7 @@ typedef struct os_memory_provider_t { int numa_flags; // combination of hwloc flags size_t part_size; - size_t alloc_sum; // sum of all allocations - used for manual interleaving + uint64_t alloc_sum; // sum of all allocations - used for manual interleaving struct { unsigned weight; diff --git a/src/provider/provider_tracking.c b/src/provider/provider_tracking.c index f9a98e87fe..4696bc562d 100644 --- a/src/provider/provider_tracking.c +++ b/src/provider/provider_tracking.c @@ -565,7 +565,7 @@ static umf_result_t trackingGetIpcHandle(void *provider, const void *ptr, return ret; } - cache_value->handle_id = utils_atomic_increment(&IPC_HANDLE_ID); + cache_value->handle_id = utils_atomic_increment_u64(&IPC_HANDLE_ID); cache_value->ipcDataSize = ipcDataSize; int insRes = critnib_insert(p->ipcCache, (uintptr_t)ptr, @@ -703,18 +703,20 @@ static umf_result_t trackingOpenIpcHandle(void *provider, void *providerIpcData, assert(cache_entry != NULL); void *mapped_ptr = NULL; - utils_atomic_load_acquire(&(cache_entry->mapped_base_ptr), &mapped_ptr); + utils_atomic_load_acquire_ptr(&(cache_entry->mapped_base_ptr), + (void **)&mapped_ptr); if (mapped_ptr == NULL) { utils_mutex_lock(&(cache_entry->mmap_lock)); - utils_atomic_load_acquire(&(cache_entry->mapped_base_ptr), &mapped_ptr); + utils_atomic_load_acquire_ptr(&(cache_entry->mapped_base_ptr), + (void **)&mapped_ptr); if (mapped_ptr == NULL) { ret = upstreamOpenIPCHandle(p, providerIpcData, ipcUmfData->baseSize, &mapped_ptr); if (ret == UMF_RESULT_SUCCESS) { // Put to the cache cache_entry->mapped_size = ipcUmfData->baseSize; - utils_atomic_store_release(&(cache_entry->mapped_base_ptr), - mapped_ptr); + utils_atomic_store_release_ptr(&(cache_entry->mapped_base_ptr), + mapped_ptr); } } utils_mutex_unlock(&(cache_entry->mmap_lock)); diff --git a/src/utils/utils_common.h b/src/utils/utils_common.h index 7824e74af2..fff44f390c 100644 --- a/src/utils/utils_common.h +++ b/src/utils/utils_common.h @@ -53,9 +53,6 @@ typedef enum umf_purge_advise_t { #define ASSERT_IS_ALIGNED(value, align) \ DO_WHILE_EXPRS(assert(IS_ALIGNED(value, align))) -#define VALGRIND_ANNOTATE_NEW_MEMORY(p, s) DO_WHILE_EMPTY -#define VALGRIND_HG_DRD_DISABLE_CHECKING(p, s) DO_WHILE_EMPTY - #ifdef _WIN32 /* Windows */ #define __TLS __declspec(thread) diff --git a/src/utils/utils_concurrency.h b/src/utils/utils_concurrency.h index 910c859b0a..0104b86468 100644 --- a/src/utils/utils_concurrency.h +++ b/src/utils/utils_concurrency.h @@ -10,6 +10,8 @@ #ifndef UMF_UTILS_CONCURRENCY_H #define UMF_UTILS_CONCURRENCY_H 1 +#include +#include #include #include @@ -19,7 +21,7 @@ #include "utils_windows_intrin.h" #pragma intrinsic(_BitScanForward64) -#else +#else /* !_WIN32 */ #include #ifndef __cplusplus @@ -27,10 +29,18 @@ #else /* __cplusplus */ #include #define _Atomic(X) std::atomic + +// TODO remove cpp code from this file +using std::memory_order_acq_rel; +using std::memory_order_acquire; +using std::memory_order_relaxed; +using std::memory_order_release; + #endif /* __cplusplus */ -#endif /* _WIN32 */ +#endif /* !_WIN32 */ +#include "utils_common.h" #include "utils_sanitizers.h" #ifdef __cplusplus @@ -79,70 +89,137 @@ void utils_init_once(UTIL_ONCE_FLAG *flag, void (*onceCb)(void)); #if defined(_WIN32) -static __inline unsigned char utils_lssb_index(long long value) { +static inline unsigned char utils_lssb_index(long long value) { unsigned long ret; _BitScanForward64(&ret, value); return (unsigned char)ret; } -static __inline unsigned char utils_mssb_index(long long value) { +static inline unsigned char utils_mssb_index(long long value) { unsigned long ret; _BitScanReverse64(&ret, value); return (unsigned char)ret; } // There is no good way to do atomic_load on windows... -#define utils_atomic_load_acquire(object, dest) \ - do { \ - *(LONG64 *)dest = \ - InterlockedOr64Acquire((LONG64 volatile *)object, 0); \ - } while (0) +static inline void utils_atomic_load_acquire_u64(uint64_t *ptr, uint64_t *out) { + // NOTE: Windows cl complains about direct accessing 'ptr' which is next + // accessed using Interlocked* functions (warning 28112 - disabled) + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + + // On Windows, there is no equivalent to __atomic_load, so we use cmpxchg + // with 0, 0 here. This will always return the value under the pointer + // without writing anything. + LONG64 ret = InterlockedCompareExchange64((LONG64 volatile *)ptr, 0, 0); + *out = *(uint64_t *)&ret; +} + +static inline void utils_atomic_load_acquire_ptr(void **ptr, void **out) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + uintptr_t ret = (uintptr_t)InterlockedCompareExchangePointer(ptr, 0, 0); + *(uintptr_t *)out = ret; +} -#define utils_atomic_store_release(object, desired) \ - InterlockedExchange64((LONG64 volatile *)object, (LONG64)desired) +static inline void utils_atomic_store_release_ptr(void **ptr, void *val) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + InterlockedExchangePointer(ptr, val); +} -#define utils_atomic_increment(object) \ - InterlockedIncrement64((LONG64 volatile *)object) +static inline uint64_t utils_atomic_increment_u64(uint64_t *ptr) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + // return incremented value + return InterlockedIncrement64((LONG64 volatile *)ptr); +} -#define utils_atomic_decrement(object) \ - InterlockedDecrement64((LONG64 volatile *)object) +static inline uint64_t utils_atomic_decrement_u64(uint64_t *ptr) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + // return decremented value + return InterlockedDecrement64((LONG64 volatile *)ptr); +} -#define utils_fetch_and_add64(ptr, value) \ - InterlockedExchangeAdd64((LONG64 *)(ptr), value) +static inline uint64_t utils_fetch_and_add_u64(uint64_t *ptr, uint64_t val) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + // return the value that had previously been in *ptr + return InterlockedExchangeAdd64((LONG64 volatile *)(ptr), val); +} -// NOTE: windows version have different order of args -#define utils_compare_exchange(object, desired, expected) \ - InterlockedCompareExchange64((LONG64 volatile *)object, *expected, *desired) +static inline uint64_t utils_fetch_and_sub_u64(uint64_t *ptr, uint64_t val) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + // return the value that had previously been in *ptr + // NOTE: on Windows there is no *Sub* version of InterlockedExchange + return InterlockedExchangeAdd64((LONG64 volatile *)(ptr), -(LONG64)val); +} + +static inline bool utils_compare_exchange_u64(uint64_t *ptr, uint64_t *expected, + uint64_t *desired) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + LONG64 out = InterlockedCompareExchange64( + (LONG64 volatile *)ptr, *(LONG64 *)desired, *(LONG64 *)expected); + if (out == *(LONG64 *)expected) { + return true; + } + + // else + *expected = out; + return false; +} #else // !defined(_WIN32) #define utils_lssb_index(x) ((unsigned char)__builtin_ctzll(x)) #define utils_mssb_index(x) ((unsigned char)(63 - __builtin_clzll(x))) -#define utils_atomic_load_acquire(object, dest) \ - do { \ - utils_annotate_acquire((void *)object); \ - __atomic_load(object, dest, memory_order_acquire); \ - } while (0) +static inline void utils_atomic_load_acquire_u64(uint64_t *ptr, uint64_t *out) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + ASSERT_IS_ALIGNED((uintptr_t)out, 8); + __atomic_load(ptr, out, memory_order_acquire); + utils_annotate_acquire(ptr); +} -#define utils_atomic_store_release(object, desired) \ - do { \ - __atomic_store_n(object, desired, memory_order_release); \ - utils_annotate_release((void *)object); \ - } while (0) +static inline void utils_atomic_load_acquire_ptr(void **ptr, void **out) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + ASSERT_IS_ALIGNED((uintptr_t)out, 8); + __atomic_load((uintptr_t *)ptr, (uintptr_t *)out, memory_order_acquire); + utils_annotate_acquire(ptr); +} -#define utils_atomic_increment(object) \ - __atomic_add_fetch(object, 1, memory_order_acq_rel) +static inline void utils_atomic_store_release_ptr(void **ptr, void *val) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + utils_annotate_release(ptr); + __atomic_store_n((uintptr_t *)ptr, (uintptr_t)val, memory_order_release); +} -#define utils_atomic_decrement(object) \ - __atomic_sub_fetch(object, 1, memory_order_acq_rel) +static inline uint64_t utils_atomic_increment_u64(uint64_t *val) { + ASSERT_IS_ALIGNED((uintptr_t)val, 8); + // return incremented value + return __atomic_add_fetch(val, 1, memory_order_acq_rel); +} -#define utils_fetch_and_add64(object, value) \ - __atomic_fetch_add(object, value, memory_order_acq_rel) +static inline uint64_t utils_atomic_decrement_u64(uint64_t *val) { + ASSERT_IS_ALIGNED((uintptr_t)val, 8); + // return decremented value + return __atomic_sub_fetch(val, 1, memory_order_acq_rel); +} -#define utils_compare_exchange(object, expected, desired) \ - __atomic_compare_exchange(object, expected, desired, 0 /* strong */, \ - memory_order_acq_rel, memory_order_relaxed) +static inline uint64_t utils_fetch_and_add_u64(uint64_t *ptr, uint64_t val) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + // return the value that had previously been in *ptr + return __atomic_fetch_add(ptr, val, memory_order_acq_rel); +} + +static inline uint64_t utils_fetch_and_sub_u64(uint64_t *ptr, uint64_t val) { + // return the value that had previously been in *ptr + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + return __atomic_fetch_sub(ptr, val, memory_order_acq_rel); +} + +static inline bool utils_compare_exchange_u64(uint64_t *ptr, uint64_t *expected, + uint64_t *desired) { + ASSERT_IS_ALIGNED((uintptr_t)ptr, 8); + return __atomic_compare_exchange(ptr, expected, desired, 0 /* strong */, + memory_order_acq_rel, + memory_order_relaxed); +} #endif // !defined(_WIN32) diff --git a/src/utils/utils_sanitizers.h b/src/utils/utils_sanitizers.h index 3498e4b705..f8896d0ae3 100644 --- a/src/utils/utils_sanitizers.h +++ b/src/utils/utils_sanitizers.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -168,6 +168,24 @@ static inline void utils_annotate_memory_inaccessible(void *ptr, size_t size) { #endif } +static inline void utils_annotate_memory_new(void *ptr, size_t size) { +#ifdef UMF_VG_DRD_ENABLED + ANNOTATE_NEW_MEMORY(ptr, size); +#else + (void)ptr; + (void)size; +#endif +} + +static inline void utils_annotate_memory_no_check(void *ptr, size_t size) { +#ifdef UMF_VG_HELGRIND_ENABLED + VALGRIND_HG_DISABLE_CHECKING(ptr, size); +#else + (void)ptr; + (void)size; +#endif +} + #ifdef __cplusplus } #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ecdde95e12..37f4c809ec 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -45,8 +45,8 @@ function(build_umf_test) "${multiValueArgs}" ${ARGN}) - set(TEST_NAME umf-${ARG_NAME}) - set(TEST_TARGET_NAME umf_test-${ARG_NAME}) + set(TEST_NAME test_${ARG_NAME}) + set(TEST_TARGET_NAME test_${ARG_NAME}) set(LIB_DIRS ${LIB_DIRS} ${LIBHWLOC_LIBRARY_DIRS}) @@ -130,8 +130,8 @@ function(add_umf_test) SRCS ${ARG_SRCS} LIBS ${ARG_LIBS}) - set(TEST_NAME umf-${ARG_NAME}) - set(TEST_TARGET_NAME umf_test-${ARG_NAME}) + set(TEST_NAME test_${ARG_NAME}) + set(TEST_TARGET_NAME test_${ARG_NAME}) add_test( NAME ${TEST_NAME} @@ -408,7 +408,7 @@ if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER) SRCS providers/provider_level_zero.cpp ${UMF_UTILS_DIR}/utils_level_zero.cpp ${BA_SOURCES_FOR_TEST} LIBS ${UMF_UTILS_FOR_TEST}) - target_compile_definitions(umf_test-provider_level_zero_dlopen_global + target_compile_definitions(test_provider_level_zero_dlopen_global PUBLIC USE_DLOPEN=1 OPEN_ZE_LIBRARY_GLOBAL=1) add_umf_test( @@ -416,7 +416,7 @@ if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER) SRCS providers/provider_level_zero.cpp ${UMF_UTILS_DIR}/utils_level_zero.cpp ${BA_SOURCES_FOR_TEST} LIBS ${UMF_UTILS_FOR_TEST}) - target_compile_definitions(umf_test-provider_level_zero_dlopen_local + target_compile_definitions(test_provider_level_zero_dlopen_local PUBLIC USE_DLOPEN=1 OPEN_ZE_LIBRARY_GLOBAL=0) endif() @@ -443,7 +443,7 @@ if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_CUDA_PROVIDER) SRCS providers/provider_cuda.cpp providers/cuda_helpers.cpp ${BA_SOURCES_FOR_TEST} LIBS ${UMF_UTILS_FOR_TEST}) - target_compile_definitions(umf_test-provider_cuda_dlopen_global + target_compile_definitions(test_provider_cuda_dlopen_global PUBLIC USE_DLOPEN=1 OPEN_CU_LIBRARY_GLOBAL=1) add_umf_test( @@ -451,7 +451,7 @@ if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_CUDA_PROVIDER) SRCS providers/provider_cuda.cpp providers/cuda_helpers.cpp ${BA_SOURCES_FOR_TEST} LIBS ${UMF_UTILS_FOR_TEST}) - target_compile_definitions(umf_test-provider_cuda_dlopen_local + target_compile_definitions(test_provider_cuda_dlopen_local PUBLIC USE_DLOPEN=1 OPEN_CU_LIBRARY_GLOBAL=0) else() message( @@ -496,7 +496,7 @@ if(UMF_PROXY_LIB_ENABLED AND UMF_BUILD_SHARED_LIBRARY) NAME proxy_lib_size_threshold SRCS ${BA_SOURCES_FOR_TEST} test_proxy_lib_size_threshold.cpp LIBS ${UMF_UTILS_FOR_TEST} umf_proxy) - set_property(TEST umf-proxy_lib_size_threshold + set_property(TEST test_proxy_lib_size_threshold PROPERTY ENVIRONMENT UMF_PROXY="size.threshold=64") endif() @@ -506,7 +506,7 @@ if(UMF_PROXY_LIB_ENABLED AND UMF_BUILD_SHARED_LIBRARY) SRCS ${BA_SOURCES_FOR_TEST} memoryPoolAPI.cpp malloc_compliance_tests.cpp LIBS ${UMF_UTILS_FOR_TEST} umf_proxy) - target_compile_definitions(umf_test-proxy_lib_memoryPool + target_compile_definitions(test_proxy_lib_memoryPool PUBLIC UMF_PROXY_LIB_ENABLED=1) endif() @@ -530,7 +530,7 @@ function(add_umf_ipc_test) "" ${ARGN}) - set(TEST_NAME umf-${ARG_TEST}) + set(TEST_NAME test_${ARG_TEST}) if(DEFINED ARG_SRC_DIR) set(SRC_DIR ${ARG_SRC_DIR}) @@ -650,7 +650,7 @@ if(LINUX LIBS dl) # append LD_LIBRARY_PATH to the libumf set_property( - TEST umf-init_teardown + TEST test_init_teardown PROPERTY ENVIRONMENT_MODIFICATION "LD_LIBRARY_PATH=path_list_append:${CMAKE_BINARY_DIR}/lib") endif() diff --git a/test/ipc_devdax_prov.sh b/test/ipc_devdax_prov.sh index 7c5ba36752..43f177c713 100755 --- a/test/ipc_devdax_prov.sh +++ b/test/ipc_devdax_prov.sh @@ -1,5 +1,5 @@ # -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -25,10 +25,10 @@ PORT=$(( 1024 + ( $$ % ( 65535 - 1024 )))) UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes" echo "Starting ipc_devdax_prov CONSUMER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_devdax_prov_consumer $PORT & +UMF_LOG=$UMF_LOG_VAL ./test_ipc_devdax_prov_consumer $PORT & echo "Waiting 1 sec ..." sleep 1 echo "Starting ipc_devdax_prov PRODUCER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_devdax_prov_producer $PORT +UMF_LOG=$UMF_LOG_VAL ./test_ipc_devdax_prov_producer $PORT diff --git a/test/ipc_file_prov.sh b/test/ipc_file_prov.sh index b3e3091a8f..629b2cbb79 100755 --- a/test/ipc_file_prov.sh +++ b/test/ipc_file_prov.sh @@ -1,5 +1,5 @@ # -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -20,13 +20,13 @@ UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes" rm -f ${FILE_NAME} echo "Starting ipc_file_prov CONSUMER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_consumer $PORT ${FILE_NAME}_consumer & +UMF_LOG=$UMF_LOG_VAL ./test_ipc_file_prov_consumer $PORT ${FILE_NAME}_consumer & echo "Waiting 1 sec ..." sleep 1 echo "Starting ipc_file_prov PRODUCER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_producer $PORT ${FILE_NAME}_producer +UMF_LOG=$UMF_LOG_VAL ./test_ipc_file_prov_producer $PORT ${FILE_NAME}_producer # remove the SHM file rm -f ${FILE_NAME} diff --git a/test/ipc_file_prov_fsdax.sh b/test/ipc_file_prov_fsdax.sh index 4e908869b7..314d0aa667 100755 --- a/test/ipc_file_prov_fsdax.sh +++ b/test/ipc_file_prov_fsdax.sh @@ -1,5 +1,5 @@ # -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -31,13 +31,13 @@ UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes" rm -f ${FILE_NAME} echo "Starting ipc_file_prov_fsdax CONSUMER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_consumer $PORT $FILE_NAME & +UMF_LOG=$UMF_LOG_VAL ./test_ipc_file_prov_consumer $PORT $FILE_NAME & echo "Waiting 1 sec ..." sleep 1 echo "Starting ipc_file_prov_fsdax PRODUCER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_producer $PORT $FILE_NAME_2 +UMF_LOG=$UMF_LOG_VAL ./test_ipc_file_prov_producer $PORT $FILE_NAME_2 # remove the SHM file rm -f ${FILE_NAME} diff --git a/test/ipc_os_prov_anon_fd.sh b/test/ipc_os_prov_anon_fd.sh index a42d820a25..4e9a0f8327 100755 --- a/test/ipc_os_prov_anon_fd.sh +++ b/test/ipc_os_prov_anon_fd.sh @@ -15,10 +15,10 @@ PORT=$(( 1024 + ( $$ % ( 65535 - 1024 )))) UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes" echo "Starting ipc_os_prov_anon_fd CONSUMER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_os_prov_consumer $PORT & +UMF_LOG=$UMF_LOG_VAL ./test_ipc_os_prov_consumer $PORT & echo "Waiting 1 sec ..." sleep 1 echo "Starting ipc_os_prov_anon_fd PRODUCER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_os_prov_producer $PORT +UMF_LOG=$UMF_LOG_VAL ./test_ipc_os_prov_producer $PORT diff --git a/test/ipc_os_prov_proxy.sh b/test/ipc_os_prov_proxy.sh index 86b95a2356..9bd02dad84 100755 --- a/test/ipc_os_prov_proxy.sh +++ b/test/ipc_os_prov_proxy.sh @@ -1,5 +1,5 @@ # -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -17,10 +17,10 @@ LD_PRELOAD_VAL="../lib/libumf_proxy.so" PORT=$(( 1024 + ( $$ % ( 65535 - 1024 )))) echo "Starting CONSUMER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_os_prov_consumer $PORT & +UMF_LOG=$UMF_LOG_VAL ./test_ipc_os_prov_consumer $PORT & echo "Waiting 1 sec ..." sleep 1 echo "Starting ipc_os_prov_proxy PRODUCER on port $PORT ..." -LD_PRELOAD=$LD_PRELOAD_VAL UMF_LOG=$UMF_LOG_VAL UMF_PROXY=$UMF_PROXY_VAL ./umf_test-ipc_os_prov_proxy $PORT +LD_PRELOAD=$LD_PRELOAD_VAL UMF_LOG=$UMF_LOG_VAL UMF_PROXY=$UMF_PROXY_VAL ./test_ipc_os_prov_proxy $PORT diff --git a/test/ipc_os_prov_shm.sh b/test/ipc_os_prov_shm.sh index efa2de35ae..7bde3c6135 100755 --- a/test/ipc_os_prov_shm.sh +++ b/test/ipc_os_prov_shm.sh @@ -1,5 +1,5 @@ # -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -20,13 +20,13 @@ UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes" rm -f /dev/shm/${SHM_NAME} echo "Starting ipc_os_prov_shm CONSUMER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_os_prov_consumer $PORT & +UMF_LOG=$UMF_LOG_VAL ./test_ipc_os_prov_consumer $PORT & echo "Waiting 1 sec ..." sleep 1 echo "Starting ipc_os_prov_shm PRODUCER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_os_prov_producer $PORT $SHM_NAME +UMF_LOG=$UMF_LOG_VAL ./test_ipc_os_prov_producer $PORT $SHM_NAME # remove the SHM file rm -f /dev/shm/${SHM_NAME} diff --git a/test/providers/ipc_cuda_prov.sh b/test/providers/ipc_cuda_prov.sh index 1e9b6b05d4..bb4be94747 100755 --- a/test/providers/ipc_cuda_prov.sh +++ b/test/providers/ipc_cuda_prov.sh @@ -1,5 +1,5 @@ # -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -15,10 +15,10 @@ PORT=$(( 1024 + ( $$ % ( 65535 - 1024 )))) UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes" echo "Starting ipc_cuda_prov CONSUMER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_cuda_prov_consumer $PORT & +UMF_LOG=$UMF_LOG_VAL ./test_ipc_cuda_prov_consumer $PORT & echo "Waiting 1 sec ..." sleep 1 echo "Starting ipc_cuda_prov PRODUCER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_cuda_prov_producer $PORT +UMF_LOG=$UMF_LOG_VAL ./test_ipc_cuda_prov_producer $PORT diff --git a/test/providers/ipc_level_zero_prov.sh b/test/providers/ipc_level_zero_prov.sh index 4d29677257..cebd909328 100755 --- a/test/providers/ipc_level_zero_prov.sh +++ b/test/providers/ipc_level_zero_prov.sh @@ -15,10 +15,10 @@ PORT=$(( 1024 + ( $$ % ( 65535 - 1024 )))) UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes" echo "Starting ipc_level_zero_prov CONSUMER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_level_zero_prov_consumer $PORT & +UMF_LOG=$UMF_LOG_VAL ./test_ipc_level_zero_prov_consumer $PORT & echo "Waiting 1 sec ..." sleep 1 echo "Starting ipc_level_zero_prov PRODUCER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_level_zero_prov_producer $PORT +UMF_LOG=$UMF_LOG_VAL ./test_ipc_level_zero_prov_producer $PORT diff --git a/test/supp/drd-umf_test-disjoint_pool.supp b/test/supp/drd-test_disjoint_pool.supp similarity index 74% rename from test/supp/drd-umf_test-disjoint_pool.supp rename to test/supp/drd-test_disjoint_pool.supp index 24a44b93d4..2a5548d27e 100644 --- a/test/supp/drd-umf_test-disjoint_pool.supp +++ b/test/supp/drd-test_disjoint_pool.supp @@ -1,7 +1,7 @@ { False-positive ConflictingAccess in critnib_insert drd:ConflictingAccess - fun:store + fun:utils_atomic_store_release_ptr fun:critnib_insert ... } diff --git a/test/supp/drd-test_ipc.supp b/test/supp/drd-test_ipc.supp new file mode 100644 index 0000000000..fbdbd0183f --- /dev/null +++ b/test/supp/drd-test_ipc.supp @@ -0,0 +1,34 @@ +{ + Conditional variable destruction false-positive + drd:CondErr + ... + fun:pthread_cond_destroy@* + ... +} + +{ + [false-positive] Double check locking pattern in trackingOpenIpcHandle + drd:ConflictingAccess + fun:utils_atomic_load_acquire_ptr + fun:trackingOpenIpcHandle + fun:umfMemoryProviderOpenIPCHandle + fun:umfOpenIPCHandle + ... +} + +{ + [false-positive] trackingGetIpcHandle + drd:ConflictingAccess + fun:trackingGetIpcHandle + fun:umfMemoryProviderGetIPCHandle + fun:umfGetIPCHandle +} + +{ + [false-positive] trackingGetIpcHandle + drd:ConflictingAccess + fun:memmove + fun:trackingGetIpcHandle + fun:umfMemoryProviderGetIPCHandle + fun:umfGetIPCHandle +} diff --git a/test/supp/drd-umf_test-jemalloc_coarse_devdax.supp b/test/supp/drd-test_jemalloc_coarse_devdax.supp similarity index 85% rename from test/supp/drd-umf_test-jemalloc_coarse_devdax.supp rename to test/supp/drd-test_jemalloc_coarse_devdax.supp index bc4f2295f4..8d8746861c 100644 --- a/test/supp/drd-umf_test-jemalloc_coarse_devdax.supp +++ b/test/supp/drd-test_jemalloc_coarse_devdax.supp @@ -9,7 +9,7 @@ { False-positive ConflictingAccess in critnib_insert drd:ConflictingAccess - fun:store + fun:utils_atomic_store_release_ptr fun:critnib_insert ... } diff --git a/test/supp/drd-umf_test-jemalloc_coarse_file.supp b/test/supp/drd-test_jemalloc_coarse_file.supp similarity index 85% rename from test/supp/drd-umf_test-jemalloc_coarse_file.supp rename to test/supp/drd-test_jemalloc_coarse_file.supp index bc4f2295f4..8d8746861c 100644 --- a/test/supp/drd-umf_test-jemalloc_coarse_file.supp +++ b/test/supp/drd-test_jemalloc_coarse_file.supp @@ -9,7 +9,7 @@ { False-positive ConflictingAccess in critnib_insert drd:ConflictingAccess - fun:store + fun:utils_atomic_store_release_ptr fun:critnib_insert ... } diff --git a/test/supp/drd-umf_test-jemalloc_pool.supp b/test/supp/drd-test_jemalloc_pool.supp similarity index 100% rename from test/supp/drd-umf_test-jemalloc_pool.supp rename to test/supp/drd-test_jemalloc_pool.supp diff --git a/test/supp/drd-umf_test-provider_devdax_memory_ipc.supp b/test/supp/drd-test_provider_devdax_memory_ipc.supp similarity index 92% rename from test/supp/drd-umf_test-provider_devdax_memory_ipc.supp rename to test/supp/drd-test_provider_devdax_memory_ipc.supp index 025834658f..f6f12aa1ea 100644 --- a/test/supp/drd-umf_test-provider_devdax_memory_ipc.supp +++ b/test/supp/drd-test_provider_devdax_memory_ipc.supp @@ -1,6 +1,7 @@ { [false-positive] Double check locking pattern in trackingOpenIpcHandle drd:ConflictingAccess + fun:utils_atomic_store_release_ptr fun:trackingOpenIpcHandle fun:umfMemoryProviderOpenIPCHandle fun:umfOpenIPCHandle diff --git a/test/supp/drd-umf_test-provider_file_memory_ipc.supp b/test/supp/drd-test_provider_file_memory_ipc.supp similarity index 59% rename from test/supp/drd-umf_test-provider_file_memory_ipc.supp rename to test/supp/drd-test_provider_file_memory_ipc.supp index a15d860aa5..72fd6d87cc 100644 --- a/test/supp/drd-umf_test-provider_file_memory_ipc.supp +++ b/test/supp/drd-test_provider_file_memory_ipc.supp @@ -9,12 +9,30 @@ { [false-positive] Double check locking pattern in trackingOpenIpcHandle drd:ConflictingAccess + fun:utils_atomic_store_release_ptr fun:trackingOpenIpcHandle fun:umfMemoryProviderOpenIPCHandle fun:umfOpenIPCHandle ... } +{ + [false-positive] trackingGetIpcHandle + drd:ConflictingAccess + fun:trackingGetIpcHandle + fun:umfMemoryProviderGetIPCHandle + fun:umfGetIPCHandle +} + +{ + [false-positive] trackingGetIpcHandle + drd:ConflictingAccess + fun:memmove + fun:trackingGetIpcHandle + fun:umfMemoryProviderGetIPCHandle + fun:umfGetIPCHandle +} + { False-positive ConflictingAccess in jemalloc drd:ConflictingAccess diff --git a/test/supp/drd-umf_test-provider_os_memory.supp b/test/supp/drd-test_provider_os_memory.supp similarity index 92% rename from test/supp/drd-umf_test-provider_os_memory.supp rename to test/supp/drd-test_provider_os_memory.supp index 025834658f..f6f12aa1ea 100644 --- a/test/supp/drd-umf_test-provider_os_memory.supp +++ b/test/supp/drd-test_provider_os_memory.supp @@ -1,6 +1,7 @@ { [false-positive] Double check locking pattern in trackingOpenIpcHandle drd:ConflictingAccess + fun:utils_atomic_store_release_ptr fun:trackingOpenIpcHandle fun:umfMemoryProviderOpenIPCHandle fun:umfOpenIPCHandle diff --git a/test/supp/drd-umf_test-scalable_coarse_devdax.supp b/test/supp/drd-test_scalable_coarse_devdax.supp similarity index 100% rename from test/supp/drd-umf_test-scalable_coarse_devdax.supp rename to test/supp/drd-test_scalable_coarse_devdax.supp diff --git a/test/supp/drd-umf_test-scalable_coarse_file.supp b/test/supp/drd-test_scalable_coarse_file.supp similarity index 100% rename from test/supp/drd-umf_test-scalable_coarse_file.supp rename to test/supp/drd-test_scalable_coarse_file.supp diff --git a/test/supp/drd-umf_test-scalable_pool.supp b/test/supp/drd-test_scalable_pool.supp similarity index 100% rename from test/supp/drd-umf_test-scalable_pool.supp rename to test/supp/drd-test_scalable_pool.supp diff --git a/test/supp/drd-umf_test-ipc.supp b/test/supp/drd-umf_test-ipc.supp deleted file mode 100644 index 76844585d1..0000000000 --- a/test/supp/drd-umf_test-ipc.supp +++ /dev/null @@ -1,7 +0,0 @@ -{ - Conditional variable destruction false-positive - drd:CondErr - ... - fun:pthread_cond_destroy@* - ... -} diff --git a/test/supp/helgrind-umf_test-disjoint_pool.supp b/test/supp/helgrind-test_disjoint_pool.supp similarity index 95% rename from test/supp/helgrind-umf_test-disjoint_pool.supp rename to test/supp/helgrind-test_disjoint_pool.supp index 929674e8e5..65dfdd2c78 100644 --- a/test/supp/helgrind-umf_test-disjoint_pool.supp +++ b/test/supp/helgrind-test_disjoint_pool.supp @@ -31,7 +31,7 @@ { False-positive Race in critnib_insert Helgrind:Race - fun:store + fun:utils_atomic_store_release_ptr fun:critnib_insert ... } diff --git a/test/supp/helgrind-test_ipc.supp b/test/supp/helgrind-test_ipc.supp new file mode 100644 index 0000000000..04f3a91993 --- /dev/null +++ b/test/supp/helgrind-test_ipc.supp @@ -0,0 +1,53 @@ +{ + False-positive race in critnib_insert (lack of instrumentation) + Helgrind:Race + fun:utils_atomic_store_release_ptr + fun:critnib_insert + ... +} + +{ + False-positive race in critnib_find (lack of instrumentation) + Helgrind:Race + fun:find_predecessor + fun:find_le + fun:critnib_find + ... +} + +{ + [false-positive] Double check locking pattern in trackingOpenIpcHandle + Helgrind:Race + fun:utils_atomic_store_release_ptr + fun:trackingOpenIpcHandle + fun:umfMemoryProviderOpenIPCHandle + fun:umfOpenIPCHandle + ... +} + +{ + [false-positive] Double check locking pattern in trackingOpenIpcHandle + Helgrind:Race + fun:utils_atomic_load_acquire_ptr + fun:trackingOpenIpcHandle + fun:umfMemoryProviderOpenIPCHandle + fun:umfOpenIPCHandle + ... +} + +{ + [false-positive] umfMemoryProviderGetIPCHandle + Helgrind:Race + fun:trackingGetIpcHandle + fun:umfMemoryProviderGetIPCHandle + fun:umfGetIPCHandle +} + +{ + [false-positive] umfMemoryProviderGetIPCHandle + Helgrind:Race + fun:memmove + fun:trackingGetIpcHandle + fun:umfMemoryProviderGetIPCHandle + fun:umfGetIPCHandle +} diff --git a/test/supp/helgrind-umf_test-jemalloc_coarse_devdax.supp b/test/supp/helgrind-test_jemalloc_coarse_devdax.supp similarity index 82% rename from test/supp/helgrind-umf_test-jemalloc_coarse_devdax.supp rename to test/supp/helgrind-test_jemalloc_coarse_devdax.supp index ac8969c5ae..2f4980f519 100644 --- a/test/supp/helgrind-umf_test-jemalloc_coarse_devdax.supp +++ b/test/supp/helgrind-test_jemalloc_coarse_devdax.supp @@ -9,7 +9,7 @@ { False-positive Race in critnib_insert Helgrind:Race - fun:store + fun:utils_atomic_store_release_ptr fun:critnib_insert ... } diff --git a/test/supp/helgrind-umf_test-jemalloc_coarse_file.supp b/test/supp/helgrind-test_jemalloc_coarse_file.supp similarity index 82% rename from test/supp/helgrind-umf_test-jemalloc_coarse_file.supp rename to test/supp/helgrind-test_jemalloc_coarse_file.supp index ac8969c5ae..2f4980f519 100644 --- a/test/supp/helgrind-umf_test-jemalloc_coarse_file.supp +++ b/test/supp/helgrind-test_jemalloc_coarse_file.supp @@ -9,7 +9,7 @@ { False-positive Race in critnib_insert Helgrind:Race - fun:store + fun:utils_atomic_store_release_ptr fun:critnib_insert ... } diff --git a/test/supp/helgrind-umf_test-jemalloc_pool.supp b/test/supp/helgrind-test_jemalloc_pool.supp similarity index 100% rename from test/supp/helgrind-umf_test-jemalloc_pool.supp rename to test/supp/helgrind-test_jemalloc_pool.supp diff --git a/test/supp/helgrind-umf_test-provider_os_memory.supp b/test/supp/helgrind-test_provider_devdax_memory_ipc.supp similarity index 91% rename from test/supp/helgrind-umf_test-provider_os_memory.supp rename to test/supp/helgrind-test_provider_devdax_memory_ipc.supp index d6401e8ee7..4bc776f432 100644 --- a/test/supp/helgrind-umf_test-provider_os_memory.supp +++ b/test/supp/helgrind-test_provider_devdax_memory_ipc.supp @@ -1,6 +1,7 @@ { [false-positive] Double check locking pattern in trackingOpenIpcHandle Helgrind:Race + fun:utils_atomic_store_release_ptr fun:trackingOpenIpcHandle fun:umfMemoryProviderOpenIPCHandle fun:umfOpenIPCHandle diff --git a/test/supp/helgrind-umf_test-provider_file_memory_ipc.supp b/test/supp/helgrind-test_provider_file_memory_ipc.supp similarity index 52% rename from test/supp/helgrind-umf_test-provider_file_memory_ipc.supp rename to test/supp/helgrind-test_provider_file_memory_ipc.supp index cdc0bd8df4..de22665f51 100644 --- a/test/supp/helgrind-umf_test-provider_file_memory_ipc.supp +++ b/test/supp/helgrind-test_provider_file_memory_ipc.supp @@ -1,6 +1,17 @@ { [false-positive] Double check locking pattern in trackingOpenIpcHandle Helgrind:Race + fun:utils_atomic_store_release_ptr + fun:trackingOpenIpcHandle + fun:umfMemoryProviderOpenIPCHandle + fun:umfOpenIPCHandle + ... +} + +{ + [false-positive] Double check locking pattern in trackingOpenIpcHandle + Helgrind:Race + fun:utils_atomic_load_acquire_ptr fun:trackingOpenIpcHandle fun:umfMemoryProviderOpenIPCHandle fun:umfOpenIPCHandle @@ -10,7 +21,7 @@ { False-positive race in critnib_insert (lack of instrumentation) Helgrind:Race - fun:store + fun:utils_atomic_store_release_ptr fun:critnib_insert ... } @@ -40,3 +51,20 @@ fun:tbb_pool_finalize ... } + +{ + [false-positive] trackingGetIpcHandle + Helgrind:Race + fun:trackingGetIpcHandle + fun:umfMemoryProviderGetIPCHandle + fun:umfGetIPCHandle +} + +{ + [false-positive] trackingGetIpcHandle + Helgrind:Race + fun:memmove + fun:trackingGetIpcHandle + fun:umfMemoryProviderGetIPCHandle + fun:umfGetIPCHandle +} diff --git a/test/supp/helgrind-umf_test-provider_devdax_memory_ipc.supp b/test/supp/helgrind-test_provider_os_memory.supp similarity index 91% rename from test/supp/helgrind-umf_test-provider_devdax_memory_ipc.supp rename to test/supp/helgrind-test_provider_os_memory.supp index d6401e8ee7..4bc776f432 100644 --- a/test/supp/helgrind-umf_test-provider_devdax_memory_ipc.supp +++ b/test/supp/helgrind-test_provider_os_memory.supp @@ -1,6 +1,7 @@ { [false-positive] Double check locking pattern in trackingOpenIpcHandle Helgrind:Race + fun:utils_atomic_store_release_ptr fun:trackingOpenIpcHandle fun:umfMemoryProviderOpenIPCHandle fun:umfOpenIPCHandle diff --git a/test/supp/helgrind-umf_test-scalable_coarse_devdax.supp b/test/supp/helgrind-test_scalable_coarse_devdax.supp similarity index 100% rename from test/supp/helgrind-umf_test-scalable_coarse_devdax.supp rename to test/supp/helgrind-test_scalable_coarse_devdax.supp diff --git a/test/supp/helgrind-umf_test-scalable_coarse_file.supp b/test/supp/helgrind-test_scalable_coarse_file.supp similarity index 100% rename from test/supp/helgrind-umf_test-scalable_coarse_file.supp rename to test/supp/helgrind-test_scalable_coarse_file.supp diff --git a/test/supp/helgrind-umf_test-scalable_pool.supp b/test/supp/helgrind-test_scalable_pool.supp similarity index 100% rename from test/supp/helgrind-umf_test-scalable_pool.supp rename to test/supp/helgrind-test_scalable_pool.supp diff --git a/test/supp/helgrind-umf_test-ipc.supp b/test/supp/helgrind-umf_test-ipc.supp deleted file mode 100644 index e46140c197..0000000000 --- a/test/supp/helgrind-umf_test-ipc.supp +++ /dev/null @@ -1,16 +0,0 @@ -{ - False-positive race in critnib_insert (lack of instrumentation) - Helgrind:Race - fun:store - fun:critnib_insert - ... -} - -{ - False-positive race in critnib_find (lack of instrumentation) - Helgrind:Race - fun:find_predecessor - fun:find_le - fun:critnib_find - ... -} diff --git a/test/supp/memcheck-umf_test-jemalloc_coarse_devdax.supp b/test/supp/memcheck-test_jemalloc_coarse_devdax.supp similarity index 100% rename from test/supp/memcheck-umf_test-jemalloc_coarse_devdax.supp rename to test/supp/memcheck-test_jemalloc_coarse_devdax.supp diff --git a/test/supp/memcheck-umf_test-jemalloc_coarse_file.supp b/test/supp/memcheck-test_jemalloc_coarse_file.supp similarity index 100% rename from test/supp/memcheck-umf_test-jemalloc_coarse_file.supp rename to test/supp/memcheck-test_jemalloc_coarse_file.supp diff --git a/test/supp/memcheck-umf_test-jemalloc_pool.supp b/test/supp/memcheck-test_jemalloc_pool.supp similarity index 100% rename from test/supp/memcheck-umf_test-jemalloc_pool.supp rename to test/supp/memcheck-test_jemalloc_pool.supp diff --git a/test/supp/memcheck-umf_test-scalable_pool.supp b/test/supp/memcheck-test_scalable_pool.supp similarity index 100% rename from test/supp/memcheck-umf_test-scalable_pool.supp rename to test/supp/memcheck-test_scalable_pool.supp diff --git a/test/test_valgrind.sh b/test/test_valgrind.sh index 954a3a56bb..ea156e620b 100755 --- a/test/test_valgrind.sh +++ b/test/test_valgrind.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -16,7 +16,7 @@ function print_usage() { echo "Where:" echo echo "tests_examples - (optional) list of tests or examples to be run (paths relative to the build directory)." - echo " If it is empty, all tests (./test/umf_test-*) and examples (./examples/umf_example_*)" + echo " If it is empty, all tests (./test/test_*) and examples (./examples/umf_example_*)" echo " found in will be run." } @@ -37,8 +37,8 @@ if [ ! -f $WORKSPACE/README.md ]; then exit 1 fi -if [ $(ls -1 ${BUILD_DIR}/test/umf_test-* 2>/dev/null | wc -l) -eq 0 ]; then - echo -e "error: UMF tests ./test/umf_test-* not found in the build directory: ${BUILD_DIR}\n" +if [ $(ls -1 ${BUILD_DIR}/test/test_* 2>/dev/null | wc -l) -eq 0 ]; then + echo -e "error: UMF tests ./test/test_* not found in the build directory: ${BUILD_DIR}\n" print_usage exit 1 fi @@ -74,7 +74,7 @@ echo "Working directory: $(pwd)" echo "Running: \"valgrind $OPTION\" for the following tests:" ANY_TEST_FAILED=0 -PATH_TESTS="./test/umf_test-*" +PATH_TESTS="./test/test_*" PATH_EXAMPLES="./examples/umf_example_*" rm -f ${PATH_TESTS}.log ${PATH_TESTS}.err ${PATH_EXAMPLES}.log ${PATH_EXAMPLES}.err @@ -100,7 +100,7 @@ for test in $TESTS; do # skip tests incompatible with valgrind FILTER="" case $test in - ./test/umf_test-disjointPool) + ./test/test_disjointPool) if [ "$TOOL" = "helgrind" ]; then # skip because of the assert in helgrind: # Helgrind: hg_main.c:308 (lockN_acquire_reader): Assertion 'lk->kind == LK_rdwr' failed. @@ -108,40 +108,40 @@ for test in $TESTS; do continue; fi ;; - ./test/umf_test-ipc_os_prov_*) + ./test/test_ipc_os_prov_*) echo "- SKIPPED" continue; # skip testing helper binaries used by the ipc_os_prov_* tests ;; - ./test/umf_test-ipc_devdax_prov_*) + ./test/test_ipc_devdax_prov_*) echo "- SKIPPED" continue; # skip testing helper binaries used by the ipc_devdax_prov_* tests ;; - ./test/umf_test-ipc_file_prov_*) + ./test/test_ipc_file_prov_*) echo "- SKIPPED" continue; # skip testing helper binaries used by the ipc_file_prov_* tests ;; - ./test/umf_test-memspace_host_all) + ./test/test_memspace_host_all) FILTER='--gtest_filter="-*allocsSpreadAcrossAllNumaNodes"' ;; - ./test/umf_test-provider_os_memory) + ./test/test_provider_os_memory) FILTER='--gtest_filter="-osProviderTest/umfIpcTest*"' ;; - ./test/umf_test-provider_os_memory_config) + ./test/test_provider_os_memory_config) FILTER='--gtest_filter="-*protection_flag_none:*protection_flag_read:*providerConfigTestNumaMode*"' ;; - ./test/umf_test-memspace_highest_capacity) + ./test/test_memspace_highest_capacity) FILTER='--gtest_filter="-*highestCapacityVerify*"' ;; - ./test/umf_test-provider_os_memory_multiple_numa_nodes) + ./test/test_provider_os_memory_multiple_numa_nodes) FILTER='--gtest_filter="-testNuma.checkModeInterleave*:testNumaNodesAllocations/testNumaOnEachNode.checkNumaNodesAllocations*:testNumaNodesAllocations/testNumaOnEachNode.checkModePreferred*:testNumaNodesAllocations/testNumaOnEachNode.checkModeInterleaveSingleNode*:testNumaNodesAllocationsAllCpus/testNumaOnEachCpu.checkModePreferredEmptyNodeset*:testNumaNodesAllocationsAllCpus/testNumaOnEachCpu.checkModeLocal*"' ;; - ./test/umf_test-memspace_highest_bandwidth) + ./test/test_memspace_highest_bandwidth) FILTER='--gtest_filter="-*allocLocalMt*"' ;; - ./test/umf_test-memspace_lowest_latency) + ./test/test_memspace_lowest_latency) FILTER='--gtest_filter="-*allocLocalMt*"' ;; - ./test/umf_test-memoryPool) + ./test/test_memoryPool) FILTER='--gtest_filter="-*allocMaxSize*"' ;; ./examples/umf_example_ipc_ipcapi_*)