Skip to content

Commit

Permalink
Patch error in the use of the macro SCOTCH_5 and SCOTCH_5 (a macro se…
Browse files Browse the repository at this point in the history
…t to 0 is considered as defined, thus #ifdef SCOTCH_6 returns 1 even if SCOTCH_6=0 leading to livelock during renumbering).
  • Loading branch information
Algiane committed Mar 16, 2017
1 parent 45bcdc5 commit c2cc825
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 44 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ PROJECT (mmg)
###############################################################################
SET (CMAKE_RELEASE_VERSION_MAJOR "5" )
SET (CMAKE_RELEASE_VERSION_MINOR "2" )
SET (CMAKE_RELEASE_VERSION_PATCH "2" )
SET (CMAKE_RELEASE_DATE "Mar 1, 2017" )
SET (CMAKE_RELEASE_VERSION_PATCH "3" )
SET (CMAKE_RELEASE_DATE "Mar 17, 2017" )

SET (CMAKE_RELEASE_VERSION
"${CMAKE_RELEASE_VERSION_MAJOR}.${CMAKE_RELEASE_VERSION_MINOR}.${CMAKE_RELEASE_VERSION_PATCH}")
Expand Down
72 changes: 39 additions & 33 deletions src/common/librnbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
int _MMG5_kPartBoxCompute(SCOTCH_Graph graf, int vertNbr, int boxVertNbr,
SCOTCH_Num *permVrtTab,MMG5_pMesh mesh) {
int boxNbr, vertIdx;
#ifdef SCOTCH_5
SCOTCH_Num logMaxVal, SupMaxVal, InfMaxVal, maxVal;
#endif
char s[200];
SCOTCH_Num *sortPartTb;
SCOTCH_Strat strat ;
Expand All @@ -69,11 +67,12 @@ int _MMG5_kPartBoxCompute(SCOTCH_Graph graf, int vertNbr, int boxVertNbr,

/* Initializing SCOTCH functions */
CHECK_SCOTCH(SCOTCH_stratInit(&strat), "scotch_stratInit", 0) ;
#ifdef SCOTCH_6
CHECK_SCOTCH(SCOTCH_archCmplt(&arch, boxNbr), "scotch_archCmplt", 0) ;
#else
CHECK_SCOTCH(SCOTCH_archVcmplt(&arch), "scotch_archVcmplt", 0) ;
#endif
if ( SCOTCH_6 ) {
CHECK_SCOTCH(SCOTCH_archCmplt(&arch, boxNbr), "scotch_archCmplt", 0) ;
}
else {
CHECK_SCOTCH(SCOTCH_archVcmplt(&arch), "scotch_archVcmplt", 0) ;
}
sprintf(s, "m{vert=%d,low=r{job=t,map=t,poli=S,sep=m{vert=80,low=h{pass=10}f{bal=0.0005,move=80},asc=f{bal=0.005,move=80}}}}", vertNbr / boxVertNbr);
CHECK_SCOTCH(SCOTCH_stratGraphMap(&strat, s), "scotch_stratGraphMap", 0) ;

Expand All @@ -84,41 +83,41 @@ int _MMG5_kPartBoxCompute(SCOTCH_Graph graf, int vertNbr, int boxVertNbr,
CHECK_SCOTCH(SCOTCH_graphMap(&graf, &arch, &strat, sortPartTb), "scotch_graphMap", 0);


#ifdef SCOTCH_6
// Looking for the max value in sortPartTb and computing sortPartTb as
// followed :
// - sortPartTb[2i] is the box value
// - sortPartTb[2i+1] is the vertex number
maxVal = sortPartTb[0];
#endif
if ( SCOTCH_6 ) {
// Looking for the max value in sortPartTb and computing sortPartTb as
// followed :
// - sortPartTb[2i] is the box value
// - sortPartTb[2i+1] is the vertex number
maxVal = sortPartTb[0];
}
for (vertIdx = vertNbr - 1 ; vertIdx >= 0 ; vertIdx--) {
sortPartTb[2*vertIdx] = sortPartTb[vertIdx];
sortPartTb[2*vertIdx+1] = vertIdx + 1;
#ifdef SCOTCH_5
if (sortPartTb[vertIdx] > maxVal)
maxVal = sortPartTb[vertIdx];
#endif
if ( SCOTCH_5 ) {
if (sortPartTb[vertIdx] > maxVal)
maxVal = sortPartTb[vertIdx];
}
}

#ifdef SCOTCH_5
// Determining the log of MaxVal
logMaxVal = 0;
while ( maxVal > 0) {
logMaxVal++;
maxVal >>= 1;
}
if ( SCOTCH_5 ) {
// Determining the log of MaxVal
logMaxVal = 0;
while ( maxVal > 0) {
logMaxVal++;
maxVal >>= 1;
}

// Infering the interval in which box values will be
InfMaxVal = logMaxVal << logMaxVal;
SupMaxVal = (logMaxVal << (logMaxVal + 1)) - 1;
// Infering the interval in which box values will be
InfMaxVal = logMaxVal << logMaxVal;
SupMaxVal = (logMaxVal << (logMaxVal + 1)) - 1;

// Increasing box values until they are in the previous interval
for (vertIdx = 0 ; vertIdx < vertNbr ; vertIdx++) {
while (!(sortPartTb[2*vertIdx] >= InfMaxVal && sortPartTb[2*vertIdx] <= SupMaxVal)) {
sortPartTb[2*vertIdx] <<= 1;
// Increasing box values until they are in the previous interval
for (vertIdx = 0 ; vertIdx < vertNbr ; vertIdx++) {
while (!(sortPartTb[2*vertIdx] >= InfMaxVal && sortPartTb[2*vertIdx] <= SupMaxVal)) {
sortPartTb[2*vertIdx] <<= 1;
}
}
}
#endif

// Sorting the tabular, which contains box values and vertex numbers
_SCOTCHintSort2asc1(sortPartTb, vertNbr);
Expand Down Expand Up @@ -191,6 +190,13 @@ int _MMG5_scotchCall(MMG5_pMesh mesh, MMG5_pSol met)
#ifdef USE_SCOTCH
/*check enough vertex to renum*/
if ( mesh->info.renum && (mesh->np/2. > _MMG5_BOXSIZE) && mesh->np>100000 ) {

if ( (SCOTCH_5 && SCOTCH_6 ) || ( (!SCOTCH_5) && (!SCOTCH_6) ) ) {
printf(" ## Error: fail to determine scotch version.\n");
printf(" No renumbering.\n");
return 1;
}

/* renumbering begin */
if ( mesh->info.imprim > 5 )
fprintf(stdout," -- RENUMBERING. \n");
Expand Down
6 changes: 4 additions & 2 deletions src/common/librnbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

#define SCOTCH_5 TOSTRING(SCOTCH_VERSION)=='5.0'||TOSTRING(SCOTCH_VERSION)=='5.1'||TOSTRING(SCOTCH_VERSION)=='5'
#define SCOTCH_6 TOSTRING(SCOTCH_VERSION)=='6'
#define SCOTCH_5 (!strcmp(TOSTRING(SCOTCH_VERSION),"5.0") || \
!strcmp(TOSTRING(SCOTCH_VERSION),"5.1") || !strcmp(TOSTRING(SCOTCH_VERSION),"5"))

#define SCOTCH_6 !strcmp(TOSTRING(SCOTCH_VERSION),"6")

#define CHECK_SCOTCH(t,m,e) if(0!=t){perror(m);return(e);}

Expand Down
4 changes: 2 additions & 2 deletions src/common/mmgcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ extern "C" {
#include "eigenv.h"
#include "libmmgcommon.h"

#define MG_VER "5.2.2"
#define MG_REL "Mar 1, 2017"
#define MG_VER "5.2.3"
#define MG_REL "Mar 17, 2017"
#define MG_CPY "Copyright (c) IMB-LJLL, 2004-"
#define MG_STR "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"

Expand Down
11 changes: 6 additions & 5 deletions src/mmg3d/librnbg_3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ int _MMG5_biPartBoxCompute(SCOTCH_Graph graf, int vertNbr, int boxVertNbr, SCOTC

/* Initializing SCOTCH functions */
CHECK_SCOTCH(SCOTCH_stratInit(&strat), "scotch_stratInit", 0) ;
#ifdef SCOTCH_6
CHECK_SCOTCH(SCOTCH_stratGraphMap(&strat, "r{job=t,map=t,poli=S,sep=m{,vert=80,low=h{pass=10}f{bal=0.005,move=0},asc=b{bnd=f{bal=0.05,move=0},org=f{bal=0.05,move=0}}}|m{,vert=80,low=h{pass=10}f{bal=0.005,move=0},asc=b{bnd=f{bal=0.05,move=0},org=f{bal=0.05,move=0}}}}"), "scotch_stratGraphMap", 0) ;
#else
CHECK_SCOTCH(SCOTCH_stratGraphMap(&strat, "r{job=t,map=t,poli=S,sep=m{type=h,vert=80,low=h{pass=10}f{bal=0.005,move=0},asc=b{bnd=f{bal=0.05,move=0},org=f{bal=0.05,move=0}}}|m{,vert=80,low=h{pass=10}f{bal=0.005,move=0},asc=b{bnd=f{bal=0.05,move=0},org=f{bal=0.05,move=0}}}}"), "scotch_stratGraphMap", 0) ;
#endif
if ( SCOTCH_6 ) {
CHECK_SCOTCH(SCOTCH_stratGraphMap(&strat, "r{job=t,map=t,poli=S,sep=m{,vert=80,low=h{pass=10}f{bal=0.005,move=0},asc=b{bnd=f{bal=0.05,move=0},org=f{bal=0.05,move=0}}}|m{,vert=80,low=h{pass=10}f{bal=0.005,move=0},asc=b{bnd=f{bal=0.05,move=0},org=f{bal=0.05,move=0}}}}"), "scotch_stratGraphMap", 0) ;
}
else {
CHECK_SCOTCH(SCOTCH_stratGraphMap(&strat, "r{job=t,map=t,poli=S,sep=m{type=h,vert=80,low=h{pass=10}f{bal=0.005,move=0},asc=b{bnd=f{bal=0.05,move=0},org=f{bal=0.05,move=0}}}|m{,vert=80,low=h{pass=10}f{bal=0.005,move=0},asc=b{bnd=f{bal=0.05,move=0},org=f{bal=0.05,move=0}}}}"), "scotch_stratGraphMap", 0) ;
}

_MMG5_ADD_MEM(mesh,vertNbr*sizeof(SCOTCH_Num),"partTab",return(1));
_MMG5_SAFE_CALLOC(partTab,vertNbr,SCOTCH_Num);
Expand Down

0 comments on commit c2cc825

Please sign in to comment.