Skip to content

Commit

Permalink
Print system memory also
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorySchwing committed Aug 11, 2021
1 parent 95b07d0 commit c0c2110
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions MainSimpleParallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
#include <memory>
#include "simpleParallel/ConnectednessTest.h"
#include "simpleParallel/ParallelB1.h"
#include <unistd.h>


//#include "simpleParallel/COO.h"
//#include "simpleParallel/CSR.h"
//#include "gpu/COO.cuh"

unsigned long long getTotalSystemMemory()
{
long pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGE_SIZE);
return pages * page_size;
}

int main(int argc, char *argv[])
{
Expand Down Expand Up @@ -46,10 +54,9 @@ int main(int argc, char *argv[])
long long treeSize = ParallelB1::CalculateSpaceForDesiredNumberOfLevels(numberOfLevels);
long long sizeOfSingleGraph = sizeof(g);
long long totalMem = sizeOfSingleGraph * treeSize;
std::cout << "You are about to allocate " << totalMem << " bytes (total)" << std::endl;
std::cout << "You are about to allocate " << double(totalMem)/1024 << " KB (total)" << std::endl;
std::cout << "You are about to allocate " << double(totalMem)/1024/1024 << " MB (total)" << std::endl;
std::cout << "You are about to allocate " << double(totalMem)/1024/1024/1024 << " GB (total)" << std::endl;
long long memAvail = getTotalSystemMemory();
std::cout << "You are about to allocate " << double(totalMem)/1024/1024/1024 << " GB" << std::endl;
std::cout << "Your system has " << double(memAvail)/1024/1024/1024 << " GB available" << std::endl;
do
{
std::cout << '\n' << "Press a key to continue...; ctrl-c to terminate";
Expand Down

0 comments on commit c0c2110

Please sign in to comment.