Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions include/umf/providers/provider_coarse.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define UMF_COARSE_PROVIDER_H

#include <stdbool.h>
#include <string.h>

#include <umf/memory_provider.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -98,6 +100,15 @@ umf_memory_provider_ops_t *umfCoarseMemoryProviderOps(void);
coarse_memory_provider_stats_t
umfCoarseMemoryProviderGetStats(umf_memory_provider_handle_t provider);

/// @brief Create default params for the coarse memory provider
static inline coarse_memory_provider_params_t
umfCoarseMemoryProviderParamsDefault(void) {
coarse_memory_provider_params_t coarse_memory_provider_params;
memset(&coarse_memory_provider_params, 0,
sizeof(coarse_memory_provider_params));
return coarse_memory_provider_params;
}

#ifdef __cplusplus
}
#endif
Expand Down
23 changes: 19 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
endif()

if(UMF_BUILD_LIBUMF_POOL_DISJOINT
AND UMF_BUILD_LIBUMF_POOL_JEMALLOC
AND UMF_POOL_JEMALLOC_ENABLED
AND UMF_POOL_SCALABLE_ENABLED
AND (NOT UMF_DISABLE_HWLOC))
add_umf_test(
Expand All @@ -177,7 +177,7 @@ if(UMF_BUILD_LIBUMF_POOL_DISJOINT
LIBS disjoint_pool jemalloc_pool ${JEMALLOC_LIBRARIES})
endif()

if(UMF_BUILD_LIBUMF_POOL_JEMALLOC AND (NOT UMF_DISABLE_HWLOC))
if(UMF_POOL_JEMALLOC_ENABLED AND (NOT UMF_DISABLE_HWLOC))
add_umf_test(
NAME jemalloc_pool
SRCS pools/jemalloc_pool.cpp malloc_compliance_tests.cpp
Expand All @@ -190,8 +190,7 @@ if(UMF_POOL_SCALABLE_ENABLED AND (NOT UMF_DISABLE_HWLOC))
endif()

if(LINUX AND (NOT UMF_DISABLE_HWLOC)) # OS-specific functions are implemented
# only for
# Linux now
# only for Linux now
if(PkgConfig_FOUND)
pkg_check_modules(LIBNUMA numa)
endif()
Expand Down Expand Up @@ -257,6 +256,22 @@ if(LINUX AND (NOT UMF_DISABLE_HWLOC)) # OS-specific functions are implemented
NAME provider_file_memory
SRCS provider_file_memory.cpp
LIBS ${UMF_UTILS_FOR_TEST})

# This test requires Linux-only file memory provider
if(UMF_POOL_JEMALLOC_ENABLED)
add_umf_test(
NAME jemalloc_coarse_file
SRCS pools/jemalloc_coarse_file.cpp malloc_compliance_tests.cpp
LIBS jemalloc_pool)
endif()

# This test requires Linux-only file memory provider
if(UMF_POOL_SCALABLE_ENABLED)
add_umf_test(
NAME scalable_coarse_file SRCS pools/scalable_coarse_file.cpp
malloc_compliance_tests.cpp)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND UMF_BUILD_FUZZTESTS)
add_subdirectory(fuzz)
endif()
Expand Down
16 changes: 16 additions & 0 deletions test/pools/jemalloc_coarse_file.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Intel Corporation
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "umf/pools/pool_jemalloc.h"

#include "pool_coarse_file.hpp"

auto coarseParams = umfCoarseMemoryProviderParamsDefault();
auto fileParams = umfFileMemoryProviderParamsDefault(FILE_PATH);

INSTANTIATE_TEST_SUITE_P(jemallocCoarseFileTest, umfPoolTest,
::testing::Values(poolCreateExtParams{
umfJemallocPoolOps(), nullptr,
umfFileMemoryProviderOps(), &fileParams,
&coarseParams}));
19 changes: 19 additions & 0 deletions test/pools/pool_coarse_file.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2024 Intel Corporation
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef UMF_TEST_POOL_COARSE_FILE_HPP
#define UMF_TEST_POOL_COARSE_FILE_HPP 1

#include "umf/providers/provider_coarse.h"
#include "umf/providers/provider_file_memory.h"

#include "pool.hpp"
#include "poolFixtures.hpp"

using umf_test::test;
using namespace umf_test;

#define FILE_PATH ((char *)"/tmp/file_provider")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why hard-coding this path? can't we use something like for dax (UMF_TESTS_FSDAX_PATH)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ops, race condition ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remember

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: #821


#endif /* UMF_TEST_POOL_COARSE_FILE_HPP */
16 changes: 16 additions & 0 deletions test/pools/scalable_coarse_file.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Intel Corporation
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "umf/pools/pool_scalable.h"

#include "pool_coarse_file.hpp"

auto coarseParams = umfCoarseMemoryProviderParamsDefault();
auto fileParams = umfFileMemoryProviderParamsDefault(FILE_PATH);

INSTANTIATE_TEST_SUITE_P(scalableCoarseFileTest, umfPoolTest,
::testing::Values(poolCreateExtParams{
umfScalablePoolOps(), nullptr,
umfFileMemoryProviderOps(), &fileParams,
&coarseParams}));
34 changes: 34 additions & 0 deletions test/supp/drd-umf_test-jemalloc_coarse_file.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
False-positive ConflictingAccess in libjemalloc.so
drd:ConflictingAccess
obj:*/libjemalloc.so*
...
fun:mallocx
...
}

{
False-positive ConflictingAccess in libjemalloc.so
drd:ConflictingAccess
obj:*/libjemalloc.so*
...
fun:op_free
...
}

{
False-positive ConflictingAccess in libjemalloc.so
drd:ConflictingAccess
obj:*/libjemalloc.so*
...
fun:__nptl_deallocate_tsd
...
}

{
False-positive ConflictingAccess in critnib_insert
drd:ConflictingAccess
fun:store
fun:critnib_insert
...
}
49 changes: 49 additions & 0 deletions test/supp/drd-umf_test-scalable_coarse_file.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
False-positive ConflictingAccess in libtbbmalloc.so
drd:ConflictingAccess
obj:*/libtbbmalloc.so*
}

{
False-positive ConflictingAccess in libtbbmalloc.so
drd:ConflictingAccess
obj:*/libtbbmalloc.so*
...
fun:tbb_malloc
...
}

{
False-positive ConflictingAccess in libtbbmalloc.so
drd:ConflictingAccess
obj:*/libtbbmalloc.so*
...
fun:tbb_aligned_malloc
...
}

{
False-positive ConflictingAccess in libtbbmalloc.so
drd:ConflictingAccess
obj:*/libtbbmalloc.so*
...
fun:tbb_free
...
}

{
False-positive ConflictingAccess in libtbbmalloc.so
drd:ConflictingAccess
obj:*/libtbbmalloc.so*
...
fun:__nptl_deallocate_tsd
...
}

{
False-positive ConflictingAccess in _Z22pow2AlignedAllocHelperP17umf_memory_pool_t
drd:ConflictingAccess
fun:memset
fun:_Z22pow2AlignedAllocHelperP17umf_memory_pool_t
...
}
34 changes: 34 additions & 0 deletions test/supp/helgrind-umf_test-jemalloc_coarse_file.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
False-positive Race in libjemalloc.so
Helgrind:Race
obj:*/libjemalloc.so*
...
fun:mallocx
...
}

{
False-positive Race in libjemalloc.so
Helgrind:Race
obj:*/libjemalloc.so*
...
fun:op_free
...
}

{
False-positive Race in libjemalloc.so
Helgrind:Race
obj:*/libjemalloc.so*
...
fun:__nptl_deallocate_tsd
...
}

{
False-positive Race in critnib_insert
Helgrind:Race
fun:store
fun:critnib_insert
...
}
49 changes: 49 additions & 0 deletions test/supp/helgrind-umf_test-scalable_coarse_file.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
False-positive Race in libtbbmalloc.so
Helgrind:Race
obj:*/libtbbmalloc.so*
}

{
False-positive Race in libtbbmalloc.so
Helgrind:Race
obj:*/libtbbmalloc.so*
...
fun:tbb_malloc
...
}

{
False-positive Race in libtbbmalloc.so
Helgrind:Race
obj:*/libtbbmalloc.so*
...
fun:tbb_aligned_malloc
...
}

{
False-positive Race in libtbbmalloc.so
Helgrind:Race
obj:*/libtbbmalloc.so*
...
fun:tbb_free
...
}

{
False-positive Race in libtbbmalloc.so
Helgrind:Race
obj:*/libtbbmalloc.so*
...
fun:__nptl_deallocate_tsd
...
}

{
False-positive Race in _Z22pow2AlignedAllocHelperP17umf_memory_pool_t
Helgrind:Race
fun:memset
fun:_Z22pow2AlignedAllocHelperP17umf_memory_pool_t
...
}
Loading