From c2cc8259875b75eb8ab61a54692714e2bb42a1b6 Mon Sep 17 00:00:00 2001 From: Algiane Date: Thu, 16 Mar 2017 14:10:20 +0100 Subject: [PATCH] Patch error in the use of the macro SCOTCH_5 and SCOTCH_5 (a macro set to 0 is considered as defined, thus #ifdef SCOTCH_6 returns 1 even if SCOTCH_6=0 leading to livelock during renumbering). --- CMakeLists.txt | 4 +-- src/common/librnbg.c | 72 +++++++++++++++++++++++------------------- src/common/librnbg.h | 6 ++-- src/common/mmgcommon.h | 4 +-- src/mmg3d/librnbg_3d.c | 11 ++++--- 5 files changed, 53 insertions(+), 44 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43487b7fb..9f42d312f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}") diff --git a/src/common/librnbg.c b/src/common/librnbg.c index 4efcc3307..7d8e21840 100644 --- a/src/common/librnbg.c +++ b/src/common/librnbg.c @@ -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 ; @@ -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) ; @@ -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); @@ -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"); diff --git a/src/common/librnbg.h b/src/common/librnbg.h index 9f2a55d67..b3359f491 100644 --- a/src/common/librnbg.h +++ b/src/common/librnbg.h @@ -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);} diff --git a/src/common/mmgcommon.h b/src/common/mmgcommon.h index f32ac4dae..d43416935 100644 --- a/src/common/mmgcommon.h +++ b/src/common/mmgcommon.h @@ -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 "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" diff --git a/src/mmg3d/librnbg_3d.c b/src/mmg3d/librnbg_3d.c index 414d2184f..98c28b218 100644 --- a/src/mmg3d/librnbg_3d.c +++ b/src/mmg3d/librnbg_3d.c @@ -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);