Skip to content

Commit

Permalink
Adding multi-thread support
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-87 committed Jul 19, 2019
1 parent 30709b5 commit e34bbd4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/algorithm/Isomorph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../model/include/Hypergraphe.hh"
#include "../model/include/HyperVertex.hh"
#include "../model/include/HyperEdge.hh"
#include <thread>
#include <boost/graph/isomorphism.hpp>
#include <gecode/search.hh>

Expand All @@ -29,7 +30,16 @@ Isomorph::runAlgorithme() {
IsomorphSpace * is = new IsomorphSpace(_ptrHypergrapheAbstraitA, _ptrHypergrapheAbstraitB);
is->postConstraints();

Gecode::DFS<IsomorphSpace> ensembleSolution( is );
unsigned int nbrThreadsSupported( std::thread::hardware_concurrency() );

if( nbrThreadsSupported <= 0 ) {
nbrThreadsSupported = 1;
};

Gecode::Search::Options opt;
opt.threads = nbrThreadsSupported;

Gecode::DFS<IsomorphSpace> ensembleSolution(is, opt);

if( ensembleSolution.next() ) ret = true;
else ret = false;
Expand Down
17 changes: 17 additions & 0 deletions src/algorithm/IsomorphSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ IsomorphSpace::postConstraints() {
Gecode::branch(*this, _varEdge, Gecode::INT_VAR_SIZE_MIN(), Gecode::INT_VAL_SPLIT_MIN());
}


#if GECODE_VERSION_NUMBER > 500100

Gecode::Space*
IsomorphSpace::copy() {
return new IsomorphSpace(*this);
}

IsomorphSpace::IsomorphSpace(IsomorphSpace& p) :
Gecode::Space(p) {
_varEdge.update(*this, p._varEdge);
}

#else

Gecode::Space*
IsomorphSpace::copy(bool share) {
return new IsomorphSpace(share, *this);
Expand All @@ -84,3 +99,5 @@ IsomorphSpace::IsomorphSpace(bool share, IsomorphSpace& p) :
Gecode::Space(share, p) {
_varEdge.update(*this, share, p._varEdge);
}

#endif
10 changes: 9 additions & 1 deletion src/algorithm/include/IsomorphSpace.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ public:

void postConstraints();

#if GECODE_VERSION_NUMBER > 500100

Gecode::Space * copy();

IsomorphSpace(IsomorphSpace& p);

#else

Gecode::Space * copy(bool share);

IsomorphSpace(bool share, IsomorphSpace& p);


#endif


Gecode::IntVarArray _varEdge;
Expand Down

0 comments on commit e34bbd4

Please sign in to comment.