Skip to content

Commit

Permalink
feat(minor): put calloc behind definition, settable by CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
dfvankomen committed Mar 31, 2024
1 parent 159a8ed commit 3b71afd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists-NonLibraryDefs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ option(WITH_CUDA " build dendro with cuda " OFF)
option(BUILD_WITH_PETSC " build dendro with PETSC " OFF)
option(USE_FD_INTERP_FOR_UNZIP "use FD style interpolation for unzip" OFF)
option(MPIX_CUDA_AWARE_SUPPORT "use FD style interpolation for unzip" OFF)
option(DVEC_ZERO_ALLOC "Make the memory allocation of dvec on CPU initialize as zeros" OFF)

# option(KWAY "K parameter for alltoallv_kway" 128)
set(KWAY
Expand Down Expand Up @@ -207,4 +208,8 @@ if(USE_FD_INTERP_FOR_UNZIP)
add_definitions(-DUSE_FD_INTERP_FOR_UNZIP)
endif()

if(DVEC_ZERO_ALLOC)
add_definitions(-DDVEC_ZERO_ALLOC)
endif()

add_definitions(-DMATVEC_PROFILE)
7 changes: 7 additions & 0 deletions include/dvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,15 @@ namespace ot
#ifdef __CUDACC__
m_data_ptr = GPUDevice::host_malloc<T>(m_size);
#else

#ifdef DVEC_ZERO_ALLOC
m_data_ptr = (T*) calloc(m_size, sizeof(T));
#else
m_data_ptr = (T*) malloc(sizeof(T)*m_size);
#endif
// end DVEC_ZERO_ALLOC
#endif
// end __CUDACC__ if

}else if(m_vec_loc == DVEC_LOC::DEVICE)
{
Expand Down

0 comments on commit 3b71afd

Please sign in to comment.