Skip to content

Commit

Permalink
Some code to discuss
Browse files Browse the repository at this point in the history
  • Loading branch information
EuphoricThinking committed Sep 11, 2024
1 parent 29f1b43 commit bf6afc5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/umf/memspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ umf_result_t umfPoolCreateFromMemspace(umf_const_memspace_handle_t hMemspace,
umf_const_mempolicy_handle_t hPolicy,
umf_memory_pool_handle_t *hPool);

void freeme(umf_const_memspace_handle_t memspace);

///
/// \brief Creates new memory provider from memspace and policy.
/// \param hMemspace handle to memspace
Expand Down
8 changes: 8 additions & 0 deletions src/memspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ umf_result_t umfPoolCreateFromMemspace(umf_const_memspace_handle_t memspace,
return ret;
}

void freeme(umf_const_memspace_handle_t memspace) {
void **privs = NULL;
umf_result_t ret = memoryTargetHandlesToPriv(memspace, &privs);
// if (ret != UMF_RESULT_SUCCESS) {
// return ret;
// }
umf_ba_global_free(privs);
}
umf_result_t
umfMemoryProviderCreateFromMemspace(umf_const_memspace_handle_t memspace,
umf_const_mempolicy_handle_t policy,
Expand Down
17 changes: 16 additions & 1 deletion test/memspaces/memspace_highest_capacity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "numa_helpers.hpp"
#include "test_helpers.h"

#include "base_alloc_global.h"

#include <numa.h>
#include <numaif.h>
#include <umf/memspace.h>
Expand All @@ -22,7 +24,20 @@ struct memspaceHighestCapacityProviderTest : ::numaNodesTest {

umf_const_memspace_handle_t hMemspace = umfMemspaceHighestCapacityGet();
// UT_ASSERTne(hMemspace, nullptr);
ASSERT_NE(hMemspace, nullptr); // **SEGFAULT** EQ
//ASSERT_TRUE(false); // **SEGFAULT**
//ASSERT_NE(hMemspace, nullptr); // **SEGFAULT** EQ
if (!(GTEST_OUT_EQ(hMemspace, nullptr))) {
std::cerr << "Here" << std::endl;
// umf_ba_global_free(hMemspace);
// void **privs = NULL;
// umf_result_t ret = memoryTargetHandlesToPriv(hMemspace, &privs);
//umf_ba_global_free((void*)hMemspace); //privs);
//freeme(hMemspace);
umf_result_t ret =
umfMemoryProviderCreateFromMemspace(hMemspace, nullptr, &hProvider);
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
GTEST_FAIL() << "HERE";
}

umf_result_t ret =
umfMemoryProviderCreateFromMemspace(hMemspace, nullptr, &hProvider);
Expand Down

0 comments on commit bf6afc5

Please sign in to comment.