Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 2.8)
project (SHARPSAT)
cmake_minimum_required (VERSION 3.5)
project (SHARPSAT)

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -Wall")

Expand All @@ -26,4 +26,4 @@ find_library(GMPXX_LIB gmpxx)
add_subdirectory(src)

add_executable (sharpSAT src/main.cpp)
target_link_libraries (sharpSAT libsharpSAT ${GMP_LIB} ${GMPXX_LIB})
target_link_libraries (sharpSAT libsharpSAT ${GMP_LIB} ${GMPXX_LIB})
4 changes: 3 additions & 1 deletion setupdev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ mkdir Release
cd Release

cmake -DCMAKE_BUILD_TYPE=Release ../..
# cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGMP_INCLUDE_DIR=C:\gmp\include -DGMP_LIB=C:\gmp\lib\libgmp.a -DGMPXX_LIB=C:\gmp\lib\libgmpxx.a ../..

cd ..
mkdir Debug
cd Debug

cmake -DCMAKE_BUILD_TYPE=Debug ../..
# cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGMP_INCLUDE_DIR=C:\gmp\include -DGMP_LIB=C:\gmp\lib\libgmp.a -DGMPXX_LIB=C:\gmp\lib\libgmpxx.a ../..

cd ..
mkdir Profiling
cd Profiling

cmake -DCMAKE_BUILD_TYPE=Profiling ../..

# cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Profiling -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGMP_INCLUDE_DIR=C:\gmp\include -DGMP_LIB=C:\gmp\lib\libgmp.a -DGMPXX_LIB=C:\gmp\lib\libgmpxx.a ../..
48 changes: 30 additions & 18 deletions src/component_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,46 @@
#include <sys/sysinfo.h>
#include <cstdint>

uint64_t freeram() {

struct sysinfo info;
sysinfo(&info);

return info.freeram *(uint64_t) info.mem_unit;
uint64_t free_ram() {
struct sysinfo info;
sysinfo(&info);
return info.freeram * (uint64_t)info.mem_unit;
}

#elif __APPLE__ && __MACH__

#include <sys/types.h>
#include <sys/sysctl.h>

uint64_t free_ram() {
int mib[2];
int64_t physical_memory;
mib[0] = CTL_HW;
mib[1] = HW_MEMSIZE;
size_t length = sizeof(int64_t);
sysctl(mib, 2, &physical_memory, &length, NULL, 0);
return physical_memory;
}

uint64_t freeram() {
#elif defined(_WIN32)

int mib[2];
int64_t physical_memory;
mib[0] = CTL_HW;
mib[1] = HW_MEMSIZE;
size_t length = sizeof(int64_t);
sysctl(mib, 2, &physical_memory, &length, NULL, 0);
#include <windows.h>

return physical_memory;
uint64_t free_ram() {
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
return memInfo.ullAvailPhys;
}

#else

// If no OS detected, just return 0 or raise a compile error
uint64_t free_ram() {
return 0;
// or #error "No implementation of free_ram() for this platform"
}

#endif


Expand Down Expand Up @@ -69,16 +81,16 @@ void ComponentCache::init(Component &super_comp) {
free_entry_base_slots_.clear();
free_entry_base_slots_.reserve(10000);

uint64_t free_ram = freeram();
uint64_t max_cache_bound = 95 * (free_ram / 100);
uint64_t freeram = free_ram();
uint64_t max_cache_bound = 95 * (freeram / 100);

if (statistics_.maximum_cache_size_bytes_ == 0) {
statistics_.maximum_cache_size_bytes_ = max_cache_bound;
}

if (statistics_.maximum_cache_size_bytes_ > free_ram) {
if (statistics_.maximum_cache_size_bytes_ > freeram) {
cout << endl <<" WARNING: Maximum cache size larger than free RAM available" << endl;
cout << " Free RAM " << free_ram / 1000000 << "MB" << endl;
cout << " Free RAM " << freeram / 1000000 << "MB" << endl;
}

cout << "Maximum cache size:\t"
Expand Down
1 change: 1 addition & 0 deletions src/component_types/difference_packed_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "component.h"

#include <math.h>
#include <cstdint>



Expand Down
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#include <string>

#include <sys/time.h>

#if defined(__linux__) || defined(__APPLE__)
#include <sys/resource.h>
#endif
//#include <sys/resource.h>

using namespace std;

Expand Down