diff --git a/addCopyrights.dat b/addCopyrights.dat index edb91dd8a..835e48c25 100644 --- a/addCopyrights.dat +++ b/addCopyrights.dat @@ -13900,3 +13900,6 @@ D src/utility/strings.H src/utility/findKeyAndValue.H D src/utility/strings.C src/utility/findKeyAndValue.H D src/utility/strings.H src/utility/AS_UTL_decodeRange.H D src/utility/strings.C src/utility/splitToWords.H +D src/utility/arrays.H src/utility/AS_UTL_alloc.H +D src/utility/system.C src/utility/timeAndSize.C +D src/utility/system.H src/utility/timeAndSize.H diff --git a/src/AS_global.C b/src/AS_global.C index bc8897c8f..be0c75d48 100644 --- a/src/AS_global.C +++ b/src/AS_global.C @@ -40,8 +40,7 @@ #include "AS_UTL_stackTrace.H" #include "files.H" - -#include "timeAndSize.H" +#include "system.H" #ifdef X86_GCC_LINUX #include diff --git a/src/AS_global.H b/src/AS_global.H index 65f843016..d268cf8d5 100644 --- a/src/AS_global.H +++ b/src/AS_global.H @@ -110,7 +110,7 @@ int AS_configure(int argc, char **argv); #endif -#include "AS_UTL_alloc.H" +#include "arrays.H" diff --git a/src/bogart/AS_BAT_OverlapCache.C b/src/bogart/AS_BAT_OverlapCache.C index fdf3d6e7a..c0d68453e 100644 --- a/src/bogart/AS_BAT_OverlapCache.C +++ b/src/bogart/AS_BAT_OverlapCache.C @@ -49,6 +49,8 @@ #include "AS_BAT_Unitig.H" // sizeof(ufNode) #include "AS_BAT_Logging.H" +#include "system.H" + #include uint64 ovlCacheMagic = 0x65686361436c766fLLU; //0102030405060708LLU; diff --git a/src/correction/readConsensus.C b/src/correction/readConsensus.C index 1af8ba9d0..cf382a89a 100644 --- a/src/correction/readConsensus.C +++ b/src/correction/readConsensus.C @@ -28,6 +28,7 @@ */ #include "AS_global.H" +#include "system.H" #include "sweatShop.H" //#include @@ -43,8 +44,6 @@ #include "AS_UTL_reverseComplement.H" -#include "timeAndSize.H" // getTime(); - // This uses the RED/OEA framework to generate corrected reads. It probably isn't worth keeping. diff --git a/src/main.mk b/src/main.mk index 9bd2a859d..a7b09d3f3 100644 --- a/src/main.mk +++ b/src/main.mk @@ -32,19 +32,17 @@ SOURCES := AS_global.C \ utility/files-memoryMapped.C \ \ utility/strings.C \ + utility/system.C \ \ utility/AS_UTL_reverseComplement.C \ utility/AS_UTL_stackTrace.C \ \ - utility/AS_UTL_alloc.C \ - \ utility/hexDump.C \ utility/md5.C \ utility/mt19937ar.C \ utility/objectStore.C \ utility/speedCounter.C \ utility/sweatShop.C \ - utility/timeAndSize.C \ \ correction/computeGlobalScore.C \ correction/falconConsensus.C \ diff --git a/src/meryl-san/meryl-san.H b/src/meryl-san/meryl-san.H index c8306051e..c698d49ee 100644 --- a/src/meryl-san/meryl-san.H +++ b/src/meryl-san/meryl-san.H @@ -24,13 +24,13 @@ #include "AS_global.H" #include "files.H" +#include "system.H" #include "kMer.H" #include "bitPackedFile.H" #include "libmeryl-san.H" #include "speedCounter.H" -#include "timeAndSize.H" #define PERSONALITY_MERGE 0xff diff --git a/src/meryl-san/simple.C b/src/meryl-san/simple.C index 638774d60..0b7a35b27 100644 --- a/src/meryl-san/simple.C +++ b/src/meryl-san/simple.C @@ -21,6 +21,7 @@ #include "AS_global.H" #include "files.H" +#include "system.H" #include "kMer.H" #include "bitPackedFile.H" @@ -31,7 +32,6 @@ #include "speedCounter.H" #include "speedCounter.H" -#include "timeAndSize.H" #include diff --git a/src/overlapInCore/overlapPair.C b/src/overlapInCore/overlapPair.C index b7a2583f1..c7800ec3e 100644 --- a/src/overlapInCore/overlapPair.C +++ b/src/overlapInCore/overlapPair.C @@ -32,6 +32,7 @@ */ #include "AS_global.H" +#include "system.H" #include @@ -44,8 +45,6 @@ #include "AS_UTL_reverseComplement.H" -#include "timeAndSize.H" // getTime(); - // The process will load BATCH_SIZE overlaps into memory, then load all the reads referenced by // those overlaps. Once all data is loaded, compute threads are spawned. Each thread will reserve // THREAD_SIZE overlaps to compute. A small THREAD_SIZE relative to BATCH_SIZE will result in diff --git a/src/utility/AS_UTL_alloc.C b/src/utility/AS_UTL_alloc.C deleted file mode 100644 index c6272e5d1..000000000 --- a/src/utility/AS_UTL_alloc.C +++ /dev/null @@ -1,68 +0,0 @@ - -/****************************************************************************** - * - * This file is part of canu, a software program that assembles whole-genome - * sequencing reads into contigs. - * - * This software is based on: - * 'Celera Assembler' (http://wgs-assembler.sourceforge.net) - * the 'kmer package' (http://kmer.sourceforge.net) - * both originally distributed by Applera Corporation under the GNU General - * Public License, version 2. - * - * Canu branched from Celera Assembler at its revision 4587. - * Canu branched from the kmer project at its revision 1994. - * - * Modifications by: - * - * File 'README.licenses' in the root directory of this distribution contains - * full conditions and disclaimers for each license. - */ - -#include "AS_UTL_alloc.H" - - - - -#if !defined(__CYGWIN__) && !defined(_WIN32) -#include -#endif - -#ifdef HW_PHYSMEM - -uint64 -getPhysicalMemorySize(void) { - uint64 physMemory = 0; - - int mib[2] = { CTL_HW, HW_PHYSMEM }; - size_t len = sizeof(uint64); - - errno = 0; - - if (sysctl(mib, 2, &physMemory, &len, NULL, 0) != 0) - fprintf(stderr, "getPhysicalMemorySize()-- sysctl() failed to return CTL_HW, HW_PHYSMEM: %s\n", strerror(errno)), exit(1); - - if (len != sizeof(uint64)) { -#ifdef HW_MEMSIZE - mib[1] = HW_MEMSIZE; - len = sizeof(uint64); - if (sysctl(mib, 2, &physMemory, &len, NULL, 0) != 0 || len != sizeof(uint64)) -#endif - fprintf(stderr, "getPhysicalMemorySize()-- sysctl() failed to return CTL_HW, HW_PHYSMEM: %s\n", strerror(errno)), exit(1); - } - - return(physMemory); -} - -#else - -uint64 -getPhysicalMemorySize(void) { - uint64 physPages = sysconf(_SC_PHYS_PAGES); - uint64 pageSize = sysconf(_SC_PAGESIZE); - uint64 physMemory = physPages * pageSize; - - return(physMemory); -} - -#endif diff --git a/src/utility/AS_UTL_alloc.H b/src/utility/arrays.H similarity index 95% rename from src/utility/AS_UTL_alloc.H rename to src/utility/arrays.H index 4650a955e..321e615d8 100644 --- a/src/utility/AS_UTL_alloc.H +++ b/src/utility/arrays.H @@ -19,14 +19,8 @@ * full conditions and disclaimers for each license. */ -#ifndef AS_UTL_ALLOC_H -#define AS_UTL_ALLOC_H - -#include "AS_global.H" - - -uint64 getPhysicalMemorySize(void); - +#ifndef ARRAYS_H +#define ARRAYS_H const uint32 resizeArray_doNothing = 0x00; @@ -143,4 +137,4 @@ resizeArrayPair(T1*& array1, T2*& array2, uint64 arrayLen, LL &arrayMax, LL newM } -#endif // AS_UTL_ALLOC_H +#endif // ARRAYS_H diff --git a/src/utility/speedCounter.H b/src/utility/speedCounter.H index ca1faffc7..ab8290daa 100644 --- a/src/utility/speedCounter.H +++ b/src/utility/speedCounter.H @@ -39,7 +39,7 @@ #define SPEEDCOUNTER_H #include "AS_global.H" -#include "timeAndSize.H" +#include "system.H" class speedCounter { public: diff --git a/src/utility/sweatShop.C b/src/utility/sweatShop.C index 1eba32a96..a71c70deb 100644 --- a/src/utility/sweatShop.C +++ b/src/utility/sweatShop.C @@ -20,7 +20,7 @@ */ #include "sweatShop.H" -#include "timeAndSize.H" +#include "system.H" #include // pthread scheduling stuff diff --git a/src/utility/timeAndSize.C b/src/utility/system.C similarity index 69% rename from src/utility/timeAndSize.C rename to src/utility/system.C index a4b14ae54..d14b2389f 100644 --- a/src/utility/timeAndSize.C +++ b/src/utility/system.C @@ -25,6 +25,10 @@ #include #include +#if !defined(__CYGWIN__) && !defined(_WIN32) +#include +#endif + double @@ -127,3 +131,43 @@ getProcessSizeLimit(void) { return(sz); } + + +#ifdef HW_PHYSMEM + +uint64 +getPhysicalMemorySize(void) { + uint64 physMemory = 0; + + int mib[2] = { CTL_HW, HW_PHYSMEM }; + size_t len = sizeof(uint64); + + errno = 0; + + if (sysctl(mib, 2, &physMemory, &len, NULL, 0) != 0) + fprintf(stderr, "getPhysicalMemorySize()-- sysctl() failed to return CTL_HW, HW_PHYSMEM: %s\n", strerror(errno)), exit(1); + + if (len != sizeof(uint64)) { +#ifdef HW_MEMSIZE + mib[1] = HW_MEMSIZE; + len = sizeof(uint64); + if (sysctl(mib, 2, &physMemory, &len, NULL, 0) != 0 || len != sizeof(uint64)) +#endif + fprintf(stderr, "getPhysicalMemorySize()-- sysctl() failed to return CTL_HW, HW_PHYSMEM: %s\n", strerror(errno)), exit(1); + } + + return(physMemory); +} + +#else + +uint64 +getPhysicalMemorySize(void) { + uint64 physPages = sysconf(_SC_PHYS_PAGES); + uint64 pageSize = sysconf(_SC_PAGESIZE); + uint64 physMemory = physPages * pageSize; + + return(physMemory); +} + +#endif diff --git a/src/utility/timeAndSize.H b/src/utility/system.H similarity index 96% rename from src/utility/timeAndSize.H rename to src/utility/system.H index b30b5eec5..f76bece3c 100644 --- a/src/utility/timeAndSize.H +++ b/src/utility/system.H @@ -36,3 +36,5 @@ double getProcessTime(void); uint64 getProcessSize(void); uint64 getProcessSizeLimit(void); + +uint64 getPhysicalMemorySize(void);