Skip to content

Commit

Permalink
OMP no default in Linux Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed Apr 9, 2019
1 parent 46606f3 commit 1ee15ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ tuo.exe
*.gcov
.coveralls.yml
build-*
tuo-*
tuo-omp
tuo-debug.exe
tuodebug.exe
Expand Down
8 changes: 6 additions & 2 deletions make/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ ${warning "VERSION is not set (USING NO VERSION instead), use make VERSION=vX.XX
endif
endif

CPPFLAGS := -Wall -Werror -std=gnu++11 -Ofast -DNDEBUG -DNQUEST -DTYRANT_OPTIMIZER_VERSION='"$(VERSION)"' -fopenmp
LDFLAGS := -lboost_system -lboost_thread -lboost_filesystem -lboost_regex -lboost_timer -lpthread -lgomp

CPPFLAGSOMP := -Wall -Werror -std=gnu++11 -Ofast -DNDEBUG -DNQUEST -DTYRANT_OPTIMIZER_VERSION='"$(VERSION)"' -fopenmp
LDFLAGSOMP := -lboost_system -lboost_thread -lboost_filesystem -lboost_regex -lboost_timer -lpthread -lgomp

CPPFLAGS := -Wall -Werror -std=gnu++11 -Ofast -DNDEBUG -DNQUEST -DTYRANT_OPTIMIZER_VERSION='"$(VERSION)"'
LDFLAGS := -lboost_system -lboost_thread -lboost_filesystem -lboost_regex -lboost_timer -lpthread

all: $(MAIN)

Expand Down
8 changes: 3 additions & 5 deletions tyrant_optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,8 +1076,8 @@ class Process
bool compare_stop{false};
unsigned trials[c_num_threads] = {0};
long double successes [c_num_threads] = {.0};
const long double max_possible = max_possible_score[(size_t)optimization_mode];
const long double prob =1-confidence_level;
const long double max_possible = max_possible_score[(size_t)optimization_mode];
const long double prob =1-confidence_level;
omp_lock_t locks[c_num_threads];
for(unsigned i =0; i < c_num_threads;++i)
omp_init_lock(&locks[i]);
Expand All @@ -1088,6 +1088,7 @@ class Process
{
SimulationData* sim = threads_data.at(omp_get_thread_num());
sim->set_decks(this->your_decks, this->enemy_decks);
const long double sim_accum = std::accumulate(sim->factors.begin(), sim->factors.end(),.0);
#pragma omp for reduction(VecPlus:results) schedule(runtime)
for(unsigned i =0; i < thread_num_iterations;++i) {
#pragma omp cancellation point for
Expand All @@ -1096,11 +1097,9 @@ class Process
results =sim->evaluate(); //calculate single sim
else
results =merge(results,sim->evaluate()); //calculate single sim

long double score_accum_d = 0.0;
for(unsigned j=0; j < results.size(); ++j)
score_accum_d+=results[j].points * sim->factors[j];
long double sim_accum = std::accumulate(sim->factors.begin(), sim->factors.end(),.0);
score_accum_d /= sim_accum*max_possible;
omp_set_lock(&locks[omp_get_thread_num()]);
trials[omp_get_thread_num()]++;
Expand Down Expand Up @@ -1135,7 +1134,6 @@ class Process
}
}
}
//todo parallel?
#pragma omp for schedule(runtime)
for( unsigned i =0; i< results.size();++i)
evaluated_results.first[i] =results[i]; //+?
Expand Down

0 comments on commit 1ee15ae

Please sign in to comment.