Monday, July 16, 2012

Patch metis-4.0 error: conflicting types for __log2

Origin post found here: http://leembong.blogspot.com/2012/02/how-to-patch-metis-40-error-conflicting.html#!/2012/02/how-to-patch-metis-40-error-conflicting.html


METIS is a set of serial programs for partitioning graphs, partitioning finite element meshes, and producing fill reducing orderings for sparse matrices. The algorithms implemented in METIS are based on the multilevel recursive-bisection, multilevel k-way, and multi-constraint partitioning schemes. I give a patch for metis-4.0 software, compilation fails with gcc 4.4.x

make a patch file:
--------------------- metis-4.0.patch--------------------

diff -rupN metis-4.0/Lib/kmetis.c metis-4.0.NEW/Lib/kmetis.c
--- metis-4.0/Lib/kmetis.c 1998-11-30 17:26:47.000000000 +0100
+++ metis-4.0.NEW/Lib/kmetis.c 2010-04-29 17:49:55.000000000 +0200
@@ -66,7 +66,7 @@ void METIS_WPartGraphKway(int *nvtxs, id
     ctrl.dbglvl = options[OPTION_DBGLVL];
   }
   ctrl.optype = OP_KMETIS;
-  ctrl.CoarsenTo = amax((*nvtxs)/(40*log2(*nparts)), 20*(*nparts));
+  ctrl.CoarsenTo = amax((*nvtxs)/(40*log2_function(*nparts)), 20*(*nparts));
   ctrl.maxvwgt = 1.5*((graph.vwgt ? idxsum(*nvtxs, graph.vwgt) : (*nvtxs))/ctrl.CoarsenTo);
 
   InitRandom(-1);
diff -rupN metis-4.0/Lib/kvmetis.c metis-4.0.NEW/Lib/kvmetis.c
--- metis-4.0/Lib/kvmetis.c 1998-11-30 17:26:47.000000000 +0100
+++ metis-4.0.NEW/Lib/kvmetis.c 2010-04-29 17:49:55.000000000 +0200
@@ -66,7 +66,7 @@ void METIS_WPartGraphVKway(int *nvtxs, i
     ctrl.dbglvl = options[OPTION_DBGLVL];
   }
   ctrl.optype = OP_KVMETIS;
-  ctrl.CoarsenTo = amax((*nvtxs)/(40*log2(*nparts)), 20*(*nparts));
+  ctrl.CoarsenTo = amax((*nvtxs)/(40*log2_function(*nparts)), 20*(*nparts));
   ctrl.maxvwgt = 1.5*((graph.vwgt ? idxsum(*nvtxs, graph.vwgt) : (*nvtxs))/ctrl.CoarsenTo);
 
   InitRandom(-1);
diff -rupN metis-4.0/Lib/mkmetis.c metis-4.0.NEW/Lib/mkmetis.c
--- metis-4.0/Lib/mkmetis.c 1998-11-30 17:26:48.000000000 +0100
+++ metis-4.0.NEW/Lib/mkmetis.c 2010-04-29 17:49:55.000000000 +0200
@@ -47,7 +47,7 @@ void METIS_mCPartGraphKway(int *nvtxs, i
     ctrl.dbglvl = options[OPTION_DBGLVL];
   }
   ctrl.optype = OP_KMETIS;
-  ctrl.CoarsenTo = amax((*nvtxs)/(20*log2(*nparts)), 30*(*nparts));
+  ctrl.CoarsenTo = amax((*nvtxs)/(20*log2_function(*nparts)), 30*(*nparts));
 
   ctrl.nmaxvwgt = 1.5/(1.0*ctrl.CoarsenTo);
 
diff -rupN metis-4.0/Lib/proto.h metis-4.0.NEW/Lib/proto.h
--- metis-4.0/Lib/proto.h 1998-11-30 17:26:50.000000000 +0100
+++ metis-4.0.NEW/Lib/proto.h 2010-04-29 17:49:55.000000000 +0200
@@ -459,7 +459,7 @@ double drand48();
 void srand48(long);
 int ispow2(int);
 void InitRandom(int);
-int log2(int);
+int log2_function(int);
 
 
 
diff -rupN metis-4.0/Lib/rename.h metis-4.0.NEW/Lib/rename.h
--- metis-4.0/Lib/rename.h 1998-11-30 17:26:50.000000000 +0100
+++ metis-4.0.NEW/Lib/rename.h 2010-04-29 17:49:55.000000000 +0200
@@ -410,7 +410,8 @@
 #define RandomPermute   __RandomPermute
 #define ispow2    __ispow2
 #define InitRandom   __InitRandom
-#define log2    __log2
+/* Correction bug Nadir SOUALEM*/
+#define log2_function    __log2_function
 
 
 
diff -rupN metis-4.0/Lib/util.c metis-4.0.NEW/Lib/util.c
--- metis-4.0/Lib/util.c 1998-11-30 17:26:50.000000000 +0100
+++ metis-4.0.NEW/Lib/util.c 2010-04-29 17:49:55.000000000 +0200
@@ -507,9 +507,9 @@ void InitRandom(int seed)
 }
 
 /*************************************************************************
-* This function returns the log2(x)
+* This function returns the log2_function(x)
 **************************************************************************/
-int log2(int a)
+int log2_function(int a)
 {
   int i; 
 
 
---------------------------------------------------------------------- 


command:

nsoualem@gold: -> cd metis-4.0
nsoualem@gold: -> patch -p1 < metis-4.0.patch

No comments:

Post a Comment