diff --git a/CMakeLists-NonLibraryDefs.txt b/CMakeLists-NonLibraryDefs.txt index 8128c6b..88f5387 100644 --- a/CMakeLists-NonLibraryDefs.txt +++ b/CMakeLists-NonLibraryDefs.txt @@ -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 @@ -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) diff --git a/ODE/include/enuts.h b/ODE/include/enuts.h index 3a29384..e69835f 100644 --- a/ODE/include/enuts.h +++ b/ODE/include/enuts.h @@ -766,6 +766,13 @@ namespace ts m_uiBVec.clear(); + // deallocate m_uiStVec, which is based on the number of stages + for (unsigned int i = 0; i < m_uiNumStages; i++) { + m_uiStVec[i].destroy_vector(); + } + m_uiStVec.clear(); + + m_uiBlkTimeLevMinMax.clear(); m_uiActiveBlkIDs.clear(); @@ -2883,4 +2890,4 @@ namespace ts */ template void sync_blk_padding(const ot::Mesh* pMesh, const T* const dgWVec,std::vector>& bVec, unsigned int blk, unsigned int bVecIndex,unsigned int dof=1); -} \ No newline at end of file +} diff --git a/include/dvec.h b/include/dvec.h index d33bedf..694e303 100644 --- a/include/dvec.h +++ b/include/dvec.h @@ -186,8 +186,15 @@ namespace ot #ifdef __CUDACC__ m_data_ptr = GPUDevice::host_malloc(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) { @@ -207,9 +214,6 @@ namespace ot template void DVector::set_vec_ptr(T*& ptr, const ot::Mesh* pMesh, DVEC_TYPE type, DVEC_LOC loc, unsigned int dof, bool allocate_ghost) { - if(!(pMesh->isActive())) - return; - m_dof = dof; m_comm = pMesh->getMPICommunicator(); m_vec_type = type; @@ -231,6 +235,9 @@ namespace ot MPI_Abort(m_comm,0); } + if(!(pMesh->isActive())) + return; + m_data_ptr = ptr; return; }