Skip to content

Commit

Permalink
Collect all system/hardware related functions into system.H.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianwalenz committed Jul 21, 2018
1 parent 8076733 commit 9375de2
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 91 deletions.
3 changes: 3 additions & 0 deletions addCopyrights.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions src/AS_global.C
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@

#include "AS_UTL_stackTrace.H"
#include "files.H"

#include "timeAndSize.H"
#include "system.H"

#ifdef X86_GCC_LINUX
#include <fpu_control.h>
Expand Down
2 changes: 1 addition & 1 deletion src/AS_global.H
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int AS_configure(int argc, char **argv);
#endif


#include "AS_UTL_alloc.H"
#include "arrays.H"



Expand Down
2 changes: 2 additions & 0 deletions src/bogart/AS_BAT_OverlapCache.C
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#include "AS_BAT_Unitig.H" // sizeof(ufNode)
#include "AS_BAT_Logging.H"

#include "system.H"

#include <sys/types.h>

uint64 ovlCacheMagic = 0x65686361436c766fLLU; //0102030405060708LLU;
Expand Down
3 changes: 1 addition & 2 deletions src/correction/readConsensus.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/

#include "AS_global.H"
#include "system.H"

#include "sweatShop.H"
//#include <pthread.h>
Expand All @@ -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.

Expand Down
4 changes: 1 addition & 3 deletions src/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion src/meryl-san/meryl-san.H
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/meryl-san/simple.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "AS_global.H"
#include "files.H"
#include "system.H"

#include "kMer.H"
#include "bitPackedFile.H"
Expand All @@ -31,7 +32,6 @@
#include "speedCounter.H"

#include "speedCounter.H"
#include "timeAndSize.H"

#include <algorithm>

Expand Down
3 changes: 1 addition & 2 deletions src/overlapInCore/overlapPair.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/

#include "AS_global.H"
#include "system.H"

#include <pthread.h>

Expand All @@ -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
Expand Down
68 changes: 0 additions & 68 deletions src/utility/AS_UTL_alloc.C

This file was deleted.

12 changes: 3 additions & 9 deletions src/utility/AS_UTL_alloc.H → src/utility/arrays.H
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,4 +137,4 @@ resizeArrayPair(T1*& array1, T2*& array2, uint64 arrayLen, LL &arrayMax, LL newM
}


#endif // AS_UTL_ALLOC_H
#endif // ARRAYS_H
2 changes: 1 addition & 1 deletion src/utility/speedCounter.H
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#define SPEEDCOUNTER_H

#include "AS_global.H"
#include "timeAndSize.H"
#include "system.H"

class speedCounter {
public:
Expand Down
2 changes: 1 addition & 1 deletion src/utility/sweatShop.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

#include "sweatShop.H"
#include "timeAndSize.H"
#include "system.H"

#include <sched.h> // pthread scheduling stuff

Expand Down
44 changes: 44 additions & 0 deletions src/utility/timeAndSize.C → src/utility/system.C
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include <sys/time.h>
#include <sys/resource.h>

#if !defined(__CYGWIN__) && !defined(_WIN32)
#include <sys/sysctl.h>
#endif



double
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/utility/timeAndSize.H → src/utility/system.H
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ double getProcessTime(void);

uint64 getProcessSize(void);
uint64 getProcessSizeLimit(void);

uint64 getPhysicalMemorySize(void);

0 comments on commit 9375de2

Please sign in to comment.