Skip to content

Commit

Permalink
Merge pull request #6 from dfvankomen/master
Browse files Browse the repository at this point in the history
Simple Bug Fixes for dvec.h and enuts.h
  • Loading branch information
dfvankomen committed Mar 31, 2024
2 parents 0ecc874 + 3b71afd commit 6468d48
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CMakeLists-NonLibraryDefs.txt
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)
9 changes: 8 additions & 1 deletion ODE/include/enuts.h
Expand Up @@ -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();
Expand Down Expand Up @@ -2883,4 +2890,4 @@ namespace ts
*/
template<typename T>
void sync_blk_padding(const ot::Mesh* pMesh, const T* const dgWVec,std::vector<ts::BlockTimeStep<T>>& bVec, unsigned int blk, unsigned int bVecIndex,unsigned int dof=1);
}
}
13 changes: 10 additions & 3 deletions include/dvec.h
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 All @@ -207,9 +214,6 @@ namespace ot
template<typename T,typename I>
void DVector<T,I>::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;
Expand All @@ -231,6 +235,9 @@ namespace ot
MPI_Abort(m_comm,0);
}

if(!(pMesh->isActive()))
return;

m_data_ptr = ptr;
return;
}
Expand Down

0 comments on commit 6468d48

Please sign in to comment.