diff --git a/src/coreComponents/LvArray b/src/coreComponents/LvArray index 145bb1c530a..c506d0d307c 160000 --- a/src/coreComponents/LvArray +++ b/src/coreComponents/LvArray @@ -1 +1 @@ -Subproject commit 145bb1c530a68afa7d446e21c7a90b9c6a987d1f +Subproject commit c506d0d307cb1a5ddfa71a43c83b89dbd3caf6d8 diff --git a/src/coreComponents/common/LifoStorageCommon.hpp b/src/coreComponents/common/LifoStorageCommon.hpp index 6fec8404332..0189e7cc1ed 100644 --- a/src/coreComponents/common/LifoStorageCommon.hpp +++ b/src/coreComponents/common/LifoStorageCommon.hpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -38,7 +37,7 @@ #include "common/TimingMacros.hpp" #include "common/FixedSizeDequeWithMutexes.hpp" #include "common/MultiMutexesLock.hpp" - +#include "LvArray/src/system.hpp" namespace geos { @@ -155,7 +154,7 @@ class LifoStorageCommon static int computeNumberOfBufferOnHost( int percent, size_t bufferSize, int maxNumberOfBuffers, int numberOfBuffersToStoreOnDevice ) { GEOS_ERROR_IF( percent > 100, "Error, percentage of memory should be smallerer than -100, check lifoOnHost (should be greater that -100)" ); - size_t free = sysconf( _SC_AVPHYS_PAGES ) * sysconf( _SC_PAGESIZE ); + size_t free = LvArray::system::getAvailableMemoryOnHost(); int numberOfBuffersToStoreOnHost = std::max( 1, std::min( ( int )( 0.01 * percent * free / bufferSize ), maxNumberOfBuffers - numberOfBuffersToStoreOnDevice ) ); double freeGB = ( ( double ) free ) / ( 1024.0 * 1024.0 * 1024.0 ) / MpiWrapper::nodeCommSize(); LIFO_LOG_RANK( " LIFO : available memory on host " << freeGB << " GB" ); diff --git a/src/coreComponents/common/LifoStorageCuda.hpp b/src/coreComponents/common/LifoStorageCuda.hpp index 9345db2615d..b3c1fd590bc 100644 --- a/src/coreComponents/common/LifoStorageCuda.hpp +++ b/src/coreComponents/common/LifoStorageCuda.hpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "common/FixedSizeDeque.hpp" @@ -30,6 +29,7 @@ #include "common/FixedSizeDequeWithMutexes.hpp" #include "common/MultiMutexesLock.hpp" #include "common/LifoStorageCommon.hpp" +#include "LvArray/src/system.hpp" namespace geos { @@ -147,8 +147,7 @@ class LifoStorageCuda : public LifoStorageCommon< T, INDEX_TYPE > static int computeNumberOfBufferOnDevice( int percent, size_t bufferSize, int maxNumberOfBuffers ) { GEOS_ERROR_IF( percent > 100, "Error, percentage of memory should be smaller than 100, check lifoOnDevice (should be greater than -100)" ); - size_t free, total; - GEOS_ERROR_IF( cudaSuccess != cudaMemGetInfo( &free, &total ), "Error getting CUDA device available memory" ); + size_t free = LvArray::system::getAvailableMemoryOnDevice(); double freeGB = ( ( double ) free ) / ( 1024.0 * 1024.0 * 1024.0 ); LIFO_LOG_RANK( " LIFO : available memory on device " << freeGB << " GB" ); return std::min( ( int )( 0.01 * percent * free / bufferSize ), maxNumberOfBuffers );