Skip to content

Commit 9804adf

Browse files
committed
Added option to disable pack buffer memory pools.
Details: - Added a new configure option, --[en|dis]able-packbuf-pools, which will enable or disable the use of internal memory pools for managing buffers used for packing. When disabled, the function specified by the cpp macro BLIS_MALLOC_POOL is called whenever a packing buffer is needed (and BLIS_FREE_POOL is called when the buffer is ready to be released, usually at the end of a loop). When enabled, which was the status quo prior to this commit, a memory pool data structure is created and managed to provide threads with packing buffers. The memory pool minimizes calls to bli_malloc_pool() (i.e., the wrapper that calls BLIS_MALLOC_POOL), but does so through a somewhat more complex mechanism that may incur additional overhead in some (but not all) situations. The new option defaults to --enable-packbuf-pools. - Removed the reinitialization of the memory pools from the level-3 front-ends and replaced it with automatic reinitialization within the pool API's implementation. This required an extra argument to bli_pool_checkout_block() in the form of a requested size, but hides the complexity entirely from BLIS. And since bli_pool_checkout_block() is only ever called within a critical section, this change fixes a potential race condition in which threads using contexts with different cache blocksizes--most likely a heterogeneous environment--can check out pool blocks that are too small for the submatrices it wishes to pack. Thanks to Nisanth Padinharepatt for reporting this potential issue. - Removed several functions in light of the relocation of pool reinit, including bli_membrk_reinit_pools(), bli_memsys_reinit(), bli_pool_reinit_if(), and bli_check_requested_block_size_for_pool(). - Updated the testsuite to print whether the memory pools are enabled or disabled.
1 parent 107801a commit 9804adf

25 files changed

Lines changed: 82 additions & 174 deletions

build/bli_config.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
#define BLIS_ENABLE_PTHREADS
5353
#endif
5454

55+
#if @enable_packbuf_pools@
56+
#define BLIS_ENABLE_PACKBUF_POOLS
57+
#endif
58+
5559
#if @int_type_size@ == 64
5660
#define BLIS_INT_TYPE_SIZE 64
5761
#elif @int_type_size@ == 32

configure

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ print_usage()
9999
echo " --disable-threading is specified, threading will be"
100100
echo " disabled. The default is 'no'."
101101
echo " "
102+
echo " --disable-packbuf-pools, --enable-packbuf-pools"
103+
echo " "
104+
echo " Disable (enabled by default) use of internal memory"
105+
echo " pools for managing packing buffers. When disabled,"
106+
echo " the function specified by BLIS_MALLOC_POOL is called"
107+
echo " on-demand, whenever a packing buffer is needed, and"
108+
echo " the buffer is released via the function specified by"
109+
echo " BLIS_FREE_POOL() when the loop in which it was"
110+
echo " allocated terminates. When enabled, the memory pools"
111+
echo " minimize calls to both BLIS_MALLOC_POOL() and"
112+
echo " BLIS_FREE_POOL(), especially in a multithreaded"
113+
echo " environment, but does so through a mechanism that may"
114+
echo " incur additional overhead in some (but not all)"
115+
echo " situations."
116+
echo " "
102117
echo " -q, --quiet Suppress informational output. By default, configure"
103118
echo " is verbose. (NOTE: -q is not yet implemented)"
104119
echo " "
@@ -502,6 +517,7 @@ main()
502517
enable_verbose='no'
503518
enable_static='yes'
504519
enable_shared='no'
520+
enable_packbuf_pools='yes'
505521
int_type_size=0
506522
blas2blis_int_type_size=32
507523
enable_blas2blis='yes'
@@ -582,6 +598,12 @@ main()
582598
disable-threading)
583599
threading_model='no'
584600
;;
601+
enable-packbuf-pools)
602+
enable_packbuf_pools='yes'
603+
;;
604+
disable-packbuf-pools)
605+
enable_packbuf_pools='no'
606+
;;
585607
int-size=*)
586608
int_type_size=${OPTARG#*=}
587609
;;
@@ -1029,6 +1051,13 @@ main()
10291051
fi
10301052

10311053
# Convert 'yes' and 'no' flags to booleans.
1054+
if [ "x${enable_packbuf_pools}" = "xyes" ]; then
1055+
echo "${script_name}: internal memory pools for packing buffers are enabled."
1056+
enable_packbuf_pools_01=1
1057+
else
1058+
echo "${script_name}: internal memory pools for packing buffers are disabled."
1059+
enable_packbuf_pools_01=0
1060+
fi
10321061
if [ "x${enable_blas2blis}" = "xyes" ]; then
10331062
echo "${script_name}: the BLAS compatibility layer is enabled."
10341063
enable_blas2blis_01=1
@@ -1135,6 +1164,7 @@ main()
11351164
| perl -pe "s/\@kernel_list_defines\@/${kernel_list_defines}/g" \
11361165
| sed -e "s/@enable_openmp@/${enable_openmp_01}/g" \
11371166
| sed -e "s/@enable_pthreads@/${enable_pthreads_01}/g" \
1167+
| sed -e "s/@enable_packbuf_pools@/${enable_packbuf_pools_01}/g" \
11381168
| sed -e "s/@int_type_size@/${int_type_size}/g" \
11391169
| sed -e "s/@blas2blis_int_type_size@/${blas2blis_int_type_size}/g" \
11401170
| sed -e "s/@enable_blas2blis@/${enable_blas2blis_01}/g" \

frame/3/gemm/bli_gemm_front.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ void bli_gemm_front
6262
return;
6363
}
6464

65-
// Reinitialize the memory allocator to accommodate the blocksizes
66-
// in the current context.
67-
bli_memsys_reinit( cntx );
68-
6965
// Alias A, B, and C in case we need to apply transformations.
7066
bli_obj_alias_to( *a, a_local );
7167
bli_obj_alias_to( *b, b_local );

frame/3/hemm/bli_hemm_front.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ void bli_hemm_front
6363
return;
6464
}
6565

66-
// Reinitialize the memory allocator to accommodate the blocksizes
67-
// in the current context.
68-
bli_memsys_reinit( cntx );
69-
7066
// Alias A, B, and C in case we need to apply transformations.
7167
bli_obj_alias_to( *a, a_local );
7268
bli_obj_alias_to( *b, b_local );

frame/3/her2k/bli_her2k_front.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ void bli_her2k_front
6767
return;
6868
}
6969

70-
// Reinitialize the memory allocator to accommodate the blocksizes
71-
// in the current context.
72-
bli_memsys_reinit( cntx );
73-
7470
// Alias A, B, and C in case we need to apply transformations.
7571
bli_obj_alias_to( *a, a_local );
7672
bli_obj_alias_to( *b, b_local );

frame/3/herk/bli_herk_front.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ void bli_herk_front
6363
return;
6464
}
6565

66-
// Reinitialize the memory allocator to accommodate the blocksizes
67-
// in the current context.
68-
bli_memsys_reinit( cntx );
69-
7066
// Alias A and C in case we need to apply transformations.
7167
bli_obj_alias_to( *a, a_local );
7268
bli_obj_alias_to( *c, c_local );

frame/3/symm/bli_symm_front.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ void bli_symm_front
6363
return;
6464
}
6565

66-
// Reinitialize the memory allocator to accommodate the blocksizes
67-
// in the current context.
68-
bli_memsys_reinit( cntx );
69-
7066
// Alias A, B, and C in case we need to apply transformations.
7167
bli_obj_alias_to( *a, a_local );
7268
bli_obj_alias_to( *b, b_local );

frame/3/syr2k/bli_syr2k_front.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ void bli_syr2k_front
6464
return;
6565
}
6666

67-
// Reinitialize the memory allocator to accommodate the blocksizes
68-
// in the current context.
69-
bli_memsys_reinit( cntx );
70-
7167
// Alias A, B, and C in case we need to apply transformations.
7268
bli_obj_alias_to( *a, a_local );
7369
bli_obj_alias_to( *b, b_local );

frame/3/syrk/bli_syrk_front.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ void bli_syrk_front
6161
return;
6262
}
6363

64-
// Reinitialize the memory allocator to accommodate the blocksizes
65-
// in the current context.
66-
bli_memsys_reinit( cntx );
67-
6864
// Alias A and C in case we need to apply transformations.
6965
bli_obj_alias_to( *a, a_local );
7066
bli_obj_alias_to( *c, c_local );

frame/3/trmm/bli_trmm_front.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ void bli_trmm_front
6161
return;
6262
}
6363

64-
// Reinitialize the memory allocator to accommodate the blocksizes
65-
// in the current context.
66-
bli_memsys_reinit( cntx );
67-
6864
// Alias A and B so we can tweak the objects if necessary.
6965
bli_obj_alias_to( *a, a_local );
7066
bli_obj_alias_to( *b, b_local );

0 commit comments

Comments
 (0)