Skip to content

Commit 6fd62a4

Browse files
committed
MPC: fix integration avoid topo conflict
1 parent 36b7a54 commit 6fd62a4

13 files changed

+70
-95
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,5 @@ endif(NOT DISABLE_UNIT_TESTS)
6969
########################################################################
7070
#Files to install
7171
install(FILES include/mpcalloc.h DESTINATION include/)
72+
73+
install(FILES src/sctk_alloc_posix.h src/sctk_alloc_common.h src/sctk_alloc_to_recode.h src/sctk_alloc_on_node.h DESTINATION include/mpcalloc/)

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ endfunction (cm_export_file)
1111
#################### DEFINE SOURCES #####################
1212
#Message("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
1313
#if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
14-
set(alloc_SRC sctk_alloc_debug.c sctk_allocator.c sctk_alloc_posix.c sctk_alloc_topology.c sctk_alloc_light_mm_source.c sctk_alloc_common.c sctk_alloc_numa_stat.c sctk_alloc_on_node.c sctk_alloc_config.c sctk_alloc_hooks.c)
14+
set(alloc_SRC sctk_alloc_debug.c sctk_allocator.c sctk_alloc_posix.c sctk_alloc_topology.c sctk_alloc_light_mm_source.c sctk_alloc_common.c sctk_alloc_numa_stat.c sctk_alloc_on_node.c sctk_alloc_config.c sctk_alloc_hooks.c sctk_alloc_to_recode.c)
1515
#else()
1616
# set(alloc_SRC sctk_allocator.c sctk_alloc_posix.c sctk_alloc_topology.c sctk_alloc_light_mm_source.c sctk_alloc_common.c sctk_alloc_numa_stat.c)
1717
#endif()

src/sctk_alloc_common.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ extern "C"
139139
/** Select the NUMA memory source init function. **/
140140
#define SCTK_DEFAULT_NUMA_MM_SOURCE_ID SCTK_MAX_NUMA_NODE
141141

142-
/************************** MACROS *************************/
143-
//If not in MPC we didn't support internal profiling
144-
145-
#define SCTK_PROFIL_START(x) /** No profiling support **/
146-
#define SCTK_PROFIL_END(x) /** No profiling support **/
147-
148-
149142
/************************** MACROS *************************/
150143
/**
151144
* Macro to align x on required alignment. It internally use a bit per bit AND operation.

src/sctk_alloc_light_mm_source.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void sctk_alloc_force_segment_binding(
253253
// use hwloc to bind the segment
254254
// 0 on HWLOC_MEMBIND_THREAD for windows
255255
if (light_source->nodeset != NULL)
256-
hwloc_set_area_membind_nodeset(mpc_topology_get(), base, size,
256+
hwloc_set_area_membind_nodeset(mpcalloc_topology_get(), base, size,
257257
light_source->nodeset,
258258
HWLOC_MEMBIND_BIND, 0);
259259
}

src/sctk_alloc_numa_stat.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ SCTK_PUBLIC void sctk_alloc_numa_stat_init(struct sctk_alloc_numa_stat_s* stat)
128128
sctk_alloc_numa_stat_open_pagemap();
129129

130130
//check number of nodes
131-
if (mpc_topology_has_numa_nodes())
131+
if (mpcalloc_topology_has_numa_nodes())
132132
{
133-
stat->numa_nodes = mpc_topology_get_numa_node_count();
133+
stat->numa_nodes = mpcalloc_topology_get_numa_node_count();
134134
} else {
135135
stat->numa_nodes = 1;
136136
warning("No NUMA node available\n");
@@ -175,7 +175,7 @@ void sctk_alloc_numa_stat_print(const struct sctk_alloc_numa_stat_s* stat,void *
175175
printf("%-20s : %-10lu (%.01f Mo)\n","Total pages",stat->total_pages,(float)(stat->total_pages * 4) / 1024.0);
176176
printf("%-20s : %-10lu (%.01f Mo / %.01f %%)\n","Total mapped",stat->total_mapped,(float)(stat->total_mapped * 4) / 1024.0,100.0*(float)stat->total_mapped/(float)stat->total_pages);
177177
printf("%-20s : %lu\n","Non mapped",stat->total_pages - stat->total_mapped);
178-
if (mpc_topology_has_numa_nodes())
178+
if (mpcalloc_topology_has_numa_nodes())
179179
for (i = 0 ; i < stat->numa_nodes ; i++)
180180
printf("NUMA %-15d : %-10lu (%.01f Mo / %.01f %%)\n",i,stat->numa_pages[i],(float)(stat->numa_pages[i] * 4) / 1024.0,100.0*(float)stat->numa_pages[i] / (float)stat->total_mapped);
181181
if (stat->numa_pages[SCTK_DEFAULT_NUMA_MM_SOURCE_ID] != 0)
@@ -382,7 +382,7 @@ SCTK_PUBLIC void sctk_alloc_numa_check(bool fatal_on_fail, const char* filename,
382382
assert(min_ratio >= 0 && min_ratio <= 100);
383383

384384
//if not numa node can return immediately
385-
if (mpc_topology_has_numa_nodes() == false)
385+
if (mpcalloc_topology_has_numa_nodes() == false)
386386
return;
387387

388388
//get numa stat

src/sctk_alloc_on_node.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ SCTK_INTERN void sctk_malloc_on_node_init(int numa_nodes)
7373
memset(sctk_global_alloc_on_node_mm_src,0,sizeof(sctk_global_alloc_on_node_mm_src));
7474

7575
//do nothing if not numa node
76-
if ( mpc_topology_has_numa_nodes() == false)
76+
if ( mpcalloc_topology_has_numa_nodes() == false)
7777
return;
7878

7979
//setup allocations chains for all nodes
@@ -153,7 +153,7 @@ void *sctk_malloc_on_node_numa(size_t size, int node) {
153153
struct sctk_alloc_chain *chain;
154154

155155
// check if NUMA is enabled.
156-
if (mpc_topology_has_numa_nodes()) {
156+
if (mpcalloc_topology_has_numa_nodes()) {
157157
// get the good chain
158158
chain = sctk_malloc_on_node_get_chain(node);
159159
assert(chain != NULL);

src/sctk_alloc_posix.c

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ static struct sctk_alloc_chain sctk_global_egg_chain;
9191
/************************* FUNCTION ************************/
9292
#ifdef MPC_check_compatibility
9393
/** Defined in MPC **/
94-
int mpc_topology_get_current_cpu();
94+
int mpcalloc_topology_get_current_cpu();
9595
/** Defined in MPC **/
96-
int mpc_topology_get_numa_node_from_cpu (int cpu);
96+
int mpcalloc_topology_get_numa_node_from_cpu (int cpu);
9797
#endif
9898

9999
/*************************** FUNCTION **********************/
@@ -255,7 +255,7 @@ SCTK_INTERN void sctk_alloc_posix_mmsrc_numa_init_phase_numa(void)
255255

256256
//get number of nodes
257257
SCTK_NO_PDEBUG("Init numa nodes");
258-
nodes = mpc_topology_get_numa_node_count();
258+
nodes = mpcalloc_topology_get_numa_node_count();
259259
assume_m(nodes <= SCTK_MAX_NUMA_NODE,"Caution, you get more node than supported by allocator. Limit is setup by SCTK_MAX_NUMA_NODE macro in sctk_alloc_posix.c.");
260260

261261
//debug
@@ -272,7 +272,7 @@ SCTK_INTERN void sctk_alloc_posix_mmsrc_numa_init_phase_numa(void)
272272
}
273273

274274
//setup malloc on node
275-
sctk_malloc_on_node_init(mpc_topology_get_numa_node_count());
275+
sctk_malloc_on_node_init(mpcalloc_topology_get_numa_node_count());
276276
#endif
277277

278278
//mark NUMA init phase as done.
@@ -307,7 +307,7 @@ int sctk_alloc_posix_source_round_robin(void) {
307307

308308
sctk_alloc_spinlock_lock(&lock);
309309
res = cnt;
310-
cnt = (cnt + 1) % mpc_topology_get_numa_node_count();
310+
cnt = (cnt + 1) % mpcalloc_topology_get_numa_node_count();
311311
sctk_alloc_spinlock_unlock(&lock);
312312
return res;
313313
}
@@ -527,8 +527,6 @@ SCTK_INTERN struct sctk_alloc_chain * sctk_alloc_posix_setup_tls_chain(void)
527527
//debug
528528
SCTK_NO_PDEBUG("sctk_alloc_posix_setup_tls_chain()");
529529

530-
//profiling
531-
SCTK_PROFIL_START(sctk_alloc_posix_setup_tls_chain);
532530

533531
//check errors
534532
assert(sctk_get_tls_chain() == NULL);
@@ -542,8 +540,6 @@ SCTK_INTERN struct sctk_alloc_chain * sctk_alloc_posix_setup_tls_chain(void)
542540
//make it default for current thread
543541
sctk_alloc_posix_set_default_chain(chain);
544542

545-
SCTK_PROFIL_END(sctk_alloc_posix_setup_tls_chain);
546-
547543
//return it
548544
return chain;
549545
}
@@ -552,10 +548,9 @@ SCTK_INTERN struct sctk_alloc_chain * sctk_alloc_posix_setup_tls_chain(void)
552548
SCTK_PUBLIC void * sctk_calloc (size_t nmemb, size_t size)
553549
{
554550
void * ptr;
555-
SCTK_PROFIL_START(sctk_calloc);
551+
556552
ptr = sctk_malloc(nmemb * size);
557553
memset(ptr,0,nmemb * size);
558-
SCTK_PROFIL_END(sctk_calloc);
559554
return ptr;
560555
}
561556

@@ -567,8 +562,6 @@ SCTK_PUBLIC void * sctk_malloc (size_t size)
567562
struct sctk_alloc_chain * local_chain;
568563
void * res;
569564

570-
//profile
571-
SCTK_PROFIL_START(sctk_malloc);
572565

573566
//get TLS
574567
local_chain = sctk_get_tls_chain();
@@ -600,7 +593,7 @@ SCTK_PUBLIC void * sctk_malloc (size_t size)
600593
//done allocation
601594
res = sctk_alloc_chain_alloc(local_chain,size);
602595
SCTK_PTRACE("void * ptr%p = malloc(%ld);//chain = %p",res,size,local_chain);
603-
SCTK_PROFIL_END(sctk_malloc);
596+
604597
return res;
605598
}
606599

@@ -611,8 +604,6 @@ SCTK_PUBLIC void * sctk_memalign(size_t boundary,size_t size)
611604
struct sctk_alloc_chain * local_chain;
612605
void * res;
613606

614-
//profile
615-
SCTK_PROFIL_START(sctk_memalign);
616607

617608
//get TLS
618609
local_chain = sctk_get_tls_chain();
@@ -640,17 +631,17 @@ SCTK_PUBLIC void * sctk_memalign(size_t boundary,size_t size)
640631
//done allocation
641632
res = sctk_alloc_chain_alloc_align(local_chain,boundary,size);
642633
SCTK_PTRACE("void * ptr%p = memalign(%ld,%ld);//chain = %p",res,boundary,size,local_chain);
643-
SCTK_PROFIL_END(sctk_memalign);
634+
644635
return res;
645636
}
646637

647638
/************************* FUNCTION ************************/
648639
SCTK_PUBLIC int sctk_posix_memalign(void **memptr, size_t boundary, size_t size)
649640
{
650-
SCTK_PROFIL_START(sctk_posix_memalign);
641+
651642
assert(memptr != NULL);
652643
*memptr = sctk_memalign(boundary,size);
653-
SCTK_PROFIL_END(sctk_posix_memalign);
644+
654645
if (memptr == NULL)
655646
return ENOMEM;
656647
else
@@ -669,7 +660,7 @@ SCTK_PUBLIC void sctk_free (void * ptr)
669660
static int cnt = 0;
670661
#endif
671662

672-
SCTK_PROFIL_START(sctk_free);
663+
673664
local_chain = sctk_get_tls_chain();
674665

675666
//setup the local chain if not already done
@@ -731,7 +722,7 @@ SCTK_PUBLIC void sctk_free (void * ptr)
731722
SCTK_ALLOC_HOOK(chain_remote_free,chain,local_chain,ptr);
732723
sctk_alloc_rfq_register(&chain->rfq,ptr);
733724
}
734-
SCTK_PROFIL_END(sctk_free);
725+
735726
}
736727

737728
/************************* FUNCTION ************************/
@@ -792,7 +783,6 @@ SCTK_PUBLIC void * sctk_realloc (void * ptr, size_t size)
792783
struct sctk_alloc_macro_bloc * macro_bloc = NULL;
793784
void * res = NULL;
794785

795-
SCTK_PROFIL_START(sctk_realloc);
796786

797787
//trivial cases
798788
if (ptr == NULL)
@@ -852,7 +842,7 @@ SCTK_PUBLIC void * sctk_realloc (void * ptr, size_t size)
852842
}
853843

854844
SCTK_PTRACE("//ptr%p = realloc(ptr%p,%llu); //%p",res,ptr,size);
855-
SCTK_PROFIL_END(sctk_realloc);
845+
856846
return res;
857847
}
858848

@@ -861,7 +851,6 @@ void *sctk_realloc_inter_chain(void *ptr, size_t size) {
861851
sctk_size_t copy_size = size;
862852
void *res = NULL;
863853

864-
SCTK_PROFIL_START(sctk_realloc_inter_chain);
865854

866855
// when using hooking, we need to know the chain
867856
if (SCTK_ALLOC_HAS_HOOK(chain_next_is_realloc)) {
@@ -884,7 +873,6 @@ void *sctk_realloc_inter_chain(void *ptr, size_t size) {
884873
if (ptr != NULL)
885874
sctk_free(ptr);
886875

887-
SCTK_PROFIL_END(sctk_realloc_inter_chain);
888876

889877
return res;
890878
}
@@ -935,10 +923,8 @@ SCTK_INTERN void sctk_alloc_posix_numa_migrate_chain(struct sctk_alloc_chain * c
935923
int old_numa_node = -1;
936924
int new_numa_node = -1;
937925

938-
SCTK_PROFIL_START(sctk_alloc_posix_numa_migrate);
939-
940926
#ifdef MPC_Theads
941-
SCTK_NO_PDEBUG("Migration on %d",mpc_topology_get_current_cpu());
927+
SCTK_NO_PDEBUG("Migration on %d",mpcalloc_topology_get_current_cpu());
942928
#endif
943929

944930
//if NULL nothing to do otherwise remind the current mm source
@@ -964,7 +950,6 @@ SCTK_INTERN void sctk_alloc_posix_numa_migrate_chain(struct sctk_alloc_chain * c
964950
if (old_numa_node != new_numa_node && new_numa_node != SCTK_DEFAULT_NUMA_MM_SOURCE_ID)
965951
sctk_alloc_chain_numa_migrate(chain,new_numa_node,true,true,new_source);
966952

967-
SCTK_PROFIL_END(sctk_alloc_posix_numa_migrate);
968953
}
969954

970955
/************************* FUNCTION ************************/

src/sctk_alloc_posix_export.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,62 +28,60 @@
2828
#include "sctk_alloc_posix.h"
2929
#include "sctk_alloc_debug.h"
3030

31-
32-
3331
/************************* FUNCTION ************************/
3432
void * calloc (size_t nmemb, size_t size)
3533
{
3634
void * res;
37-
SCTK_PROFIL_START(calloc);
35+
3836
SCTK_ALLOC_MMCHECK_DISABLE_REPORT();
3937
res = sctk_calloc(nmemb,size);
4038
SCTK_ALLOC_MMCHECK_ENABLE_REPORT();
4139
SCTK_ALLOC_MMCHECK_REG(res,nmemb*size,true);
42-
SCTK_PROFIL_END(calloc);
40+
4341
return res;
4442
}
4543

4644
/************************* FUNCTION ************************/
4745
void * malloc (size_t size)
4846
{
4947
void * res;
50-
SCTK_PROFIL_START(malloc);
48+
5149
SCTK_ALLOC_MMCHECK_DISABLE_REPORT();
5250
res = sctk_malloc(size);
5351
SCTK_ALLOC_MMCHECK_ENABLE_REPORT();
5452
SCTK_ALLOC_MMCHECK_REG(res,size,false);
55-
SCTK_PROFIL_END(malloc);
53+
5654
return res;
5755
}
5856

5957
/************************* FUNCTION ************************/
6058
void free (void * ptr)
6159
{
62-
SCTK_PROFIL_START(free);
60+
6361
SCTK_ALLOC_MMCHECK_DISABLE_REPORT();
6462
SCTK_ALLOC_MMCHECK_UNREG(ptr);
6563
sctk_free(ptr);
6664
SCTK_ALLOC_MMCHECK_ENABLE_REPORT();
67-
SCTK_PROFIL_END(free);
65+
6866
}
6967

7068
/************************* FUNCTION ************************/
7169
/** @todo do some check at compile time, because, some OS have more parameters in cfree prototype. **/
7270
void cfree(void * ptr)
7371
{
74-
SCTK_PROFIL_START(cfree);
72+
7573
SCTK_ALLOC_MMCHECK_DISABLE_REPORT();
7674
SCTK_ALLOC_MMCHECK_UNREG(ptr);
7775
sctk_free(ptr);
7876
SCTK_ALLOC_MMCHECK_ENABLE_REPORT();
79-
SCTK_PROFIL_END(cfree);
77+
8078
}
8179

8280
/************************* FUNCTION ************************/
8381
void * realloc (void * ptr, size_t size)
8482
{
8583
void * res;
86-
SCTK_PROFIL_START(realloc);
84+
8785
SCTK_ALLOC_MMCHECK_DISABLE_REPORT();
8886
SCTK_ALLOC_MMCHECK_UNREG(ptr);
8987
res = sctk_realloc(ptr,size);
@@ -92,7 +90,7 @@ void * realloc (void * ptr, size_t size)
9290
**/
9391
SCTK_ALLOC_MMCHECK_REG(res,size,true);
9492
SCTK_ALLOC_MMCHECK_ENABLE_REPORT();
95-
SCTK_PROFIL_END(realloc);
93+
9694
return res;
9795
}
9896

@@ -101,7 +99,7 @@ int posix_memalign(void **memptr, size_t boundary, size_t size)
10199
{
102100
int res = 0;
103101

104-
SCTK_PROFIL_START(posix_memalign);
102+
105103

106104
//limit imposed by posix_memalign linux manpage
107105
if (boundary % sizeof(void*) != 0 && sctk_alloc_is_power_of_two(boundary))
@@ -112,7 +110,7 @@ int posix_memalign(void **memptr, size_t boundary, size_t size)
112110
*memptr = sctk_memalign(boundary,size);
113111
}
114112

115-
SCTK_PROFIL_END(posix_memalign);
113+
116114
return res;
117115
}
118116

@@ -121,7 +119,6 @@ void * memalign(size_t boundary,size_t size)
121119
{
122120
void * res;
123121

124-
SCTK_PROFIL_START(memalign);
125122
SCTK_ALLOC_MMCHECK_DISABLE_REPORT();
126123

127124
//limit imposed by posix_memalign linux manpage
@@ -135,7 +132,7 @@ void * memalign(size_t boundary,size_t size)
135132

136133
SCTK_ALLOC_MMCHECK_ENABLE_REPORT();
137134
SCTK_ALLOC_MMCHECK_REG(res,size,false);
138-
SCTK_PROFIL_END(memalign);
135+
139136

140137
return res;
141138
};

src/sctk_alloc_to_recode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323

2424
/************************** HEADERS ************************/
25-
#include <sctk_config.h>
26-
#include <mpc_common_spinlock.h>
25+
2726
#include "sctk_alloc_posix.h"
2827
#include "sctk_alloc_debug.h"
2928
#include "sctk_alloc_posix.h"

0 commit comments

Comments
 (0)