-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add kaHIP k-way partitioning #231
Conversation
It looks like currently if you have both parmetis and kahip, and as for kway, kahip will be used, and there is no way to get parmetis. Please allow the use of both. In the call to op_partition, you can specify both combinations, so it's just a matter of propagating this information into op_partition_kway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some compilation issues when I have Parmetis and kahip. Goes through OK if I only have KaHIP.
makefiles/dependencies/kahip.mk
Outdated
KAHIP_DEF ?= -DHAVE_KAHIP | ||
|
||
ifdef KAHIP_INSTALL_PATH | ||
KAHIP_INC_PATH := -I$(KAHIP_INSTALL_PATH)/parallel/parallel_src/interface \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be -I$(KAHIP_INSTALL_PATH)/include
if the kahip library is properly "installed" i.e. during compilation you have -DCMAKE_INSTALL_PREFIX=somedir
then during OP2 make config you have KAHIP_INSTALL_PATH=somedir
makefiles/dependencies/kahip.mk
Outdated
ifdef KAHIP_INSTALL_PATH | ||
KAHIP_INC_PATH := -I$(KAHIP_INSTALL_PATH)/parallel/parallel_src/interface \ | ||
-I$(KAHIP_INSTALL_PATH)/interface | ||
KAHIP_LIB_PATH := -L$(KAHIP_INSTALL_PATH)/build/parallel/parallel_src \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with LIB_PATH - should be -L$(KAHIP_INSTALL_PATH)/lib
op2/src/mpi/op_mpi_part_core.cpp
Outdated
#ifdef HAVE_KAHIP | ||
#include <parhip_interface.h> | ||
|
||
typedef idxtype idx_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting a compile time error with gcc 9 if I also have ParMetis installed:
In file included from src/mpi/op_mpi_part_core.cpp:73:
/home/shared/software/kahip-ompi401/include/parhip_interface.h:15:28: error: conflicting declaration ‘typedef long long unsigned int idxtype’
15 | typedef unsigned long long idxtype;
| ^~~~~~~
src/mpi/op_mpi_part_core.cpp:65:15: note: previous declaration as ‘typedef idx_t idxtype’
65 | typedef idx_t idxtype;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into the same issue yesterday, looks like ParMETIS defines idx_t
while ParHIP defines idxtype
, which is distinct. As long as only one of the two are installed, we can use typedef
to set the type as necessary but with both installed we're forced to choose between the types at runtime.
The interface for the two k-way partition functions are very similar apart from this type issue so I'm reluctant to define another op_partition_kway
just for the ParHIP version. But I've yet to find an elegant solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a tough one... My first idea, while being wasteful, but at least compact, would be to pass the parmetis-style arrays to a function, and allocate new ones with kahip types, convert them, then call kahip. Which is indeed ugly! But the fundamental issue is that even if both use 64 bits, kahip uses unsigned, whereas parmetis signed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we define a generic op_partition_kway_generic
outside the scope of extern "C"
, then call this from op_partition_kway
. Afaik this remains C-compatible if we just expose the signature of op_partition_kway
with extern "C"
, and keep the body outside?
Yes, that is a good idea! this is already a cpp file, and we don’t really need extern “C” for op_partition_kway, just op_partition itself. So you can go ahead and template it!
… On 2022. Jul 20., at 13:50, mgsium ***@***.***> wrote:
@mgsium commented on this pull request.
In op2/src/mpi/op_mpi_part_core.cpp <#231 (comment)>:
> @@ -68,6 +68,14 @@ typedef int idx_t;
#endif
#endif
+// kaHIP header
+#ifdef HAVE_KAHIP
+#include <parhip_interface.h>
+
+typedef idxtype idx_t;
Could we define a generic op_partition_kway_generic outside the scope of extern "C", then call this from op_partition_kway. Afaik this remains C-compatible if we just expose the signature of op_partition_kway with extern "C", and keep the body outside?
—
Reply to this email directly, view it on GitHub <#231 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAJWVVKFZBKXAYKWLETVFBDVU7RW3ANCNFSM53TWZXLQ>.
You are receiving this because you commented.
|
I think some overloading is still necessary because the two partition functions don't take the same arguments. The best I could think of was: /*******************************************************************************
* Generic wrapper for kway-partition functions
*******************************************************************************/
template <class T>
void do_partition(T *vtxdist, T *xadj, T *adjncy, T *wgtflag, T *numflag,
T *ncon, T *nparts,real_t *tpwgts, real_t *ubvec, T *options,
T *edgecut, T *part, MPI_Comm *comm) {}
#ifdef HAVE_PARMETIS
template<> void do_partition<idx_t>(idx_t *vtxdist, idx_t *xadj, idx_t *adjncy,
idx_t *wgtflag, idx_t *numflag, idx_t *ncon, idx_t *nparts,real_t *tpwgts,
real_t *ubvec, idx_t *options, idx_t *edgecut, idx_t *part, MPI_Comm *comm) {
ParMETIS_V3_PartKway( vtxdist, xadj, adjncy, NULL, NULL, wgtflag, numflag, ncon,
nparts, tpwgts, ubvec, options, edgecut, part, comm);
}
#endif
#ifdef HAVE_KAHIP
template<> void do_partition<idxtype>(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,
idxtype *wgtflag, idxtype *numflag, idxtype *ncon, idxtype *nparts, real_t *tpwgts,
real_t *ubvec, idxtype *options, idxtype *edgecut, idxtype *part, MPI_Comm *comm) {
double imb = 0.03;
ParHIPPartitionKWay( vtxdist, xadj, adjncy, NULL, NULL, (int*) nparts, &imb,
false, 1, ULTRAFASTMESH, (int*) edgecut, part, comm);
}
#endif The long argument list is a little ugly (although it can be made a little better by omitting the names of unused arguments). |
Could you not template the whole op_partition_kway function?
i.e.
template <bool use_kahip, typename indextype>
void op_partition_kway() {
then use indextype throughout
}
… On 2022. Jul 20., at 19:33, mgsium ***@***.***> wrote:
I think some overloading is still necessary because the two partition functions don't take the same arguments. The best I could think of was:
/*******************************************************************************
* Generic wrapper for kway-partition functions
*******************************************************************************/
template <class T>
void do_partition(T *vtxdist, T *xadj, T *adjncy, T *wgtflag, T *numflag,
T *ncon, T *nparts,real_t *tpwgts, real_t *ubvec, T *options,
T *edgecut, T *part, MPI_Comm *comm) {}
#ifdef HAVE_PARMETIS
template<> void do_partition<idx_t>(idx_t *vtxdist, idx_t *xadj, idx_t *adjncy,
idx_t *wgtflag, idx_t *numflag, idx_t *ncon, idx_t *nparts,real_t *tpwgts,
real_t *ubvec, idx_t *options, idx_t *edgecut, idx_t *part, MPI_Comm *comm) {
ParMETIS_V3_PartKway( vtxdist, xadj, adjncy, NULL, NULL, wgtflag, numflag, ncon,
nparts, tpwgts, ubvec, options, edgecut, part, comm);
}
#endif
#ifdef HAVE_KAHIP
template<> void do_partition<idxtype>(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,
idxtype *wgtflag, idxtype *numflag, idxtype *ncon, idxtype *nparts, real_t *tpwgts,
real_t *ubvec, idxtype *options, idxtype *edgecut, idxtype *part, MPI_Comm *comm) {
double imb = 0.03;
ParHIPPartitionKWay( vtxdist, xadj, adjncy, NULL, NULL, (int*) nparts, &imb,
false, 1, ULTRAFASTMESH, (int*) edgecut, part, comm);
}
#endif
The long argument list is a little ugly (although it can be made a little better by omitting the names of unused arguments).
Not an ideal solution but it feels less cumbersome than overloading op_partition_kway.
—
Reply to this email directly, view it on GitHub <#231 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAJWVVI2IWZ775QWPUUKAWLVVAZ7NANCNFSM53TWZXLQ>.
You are receiving this because you commented.
|
I'm doing that too, but there's still the problem of choosing whether to call the kahip or parmetis function at runtime. |
On second thoughts, #ifdef HAVE_PARMETIS
void do_partition(idx_t *vtxdist, idx_t *xadj, ...) {
ParMETIS_V3_PartKway( vtxdist, xadj, adjncy, NULL, NULL, wgtflag, numflag, ncon,
nparts, tpwgts, ubvec, options, edgecut, part, comm);
}
#endif
#ifdef HAVE_KAHIP
void do_partition(idxtype *vtxdist, idxtype *xadj, ...) {
double imb = 0.03;
ParHIPPartitionKWay( vtxdist, xadj, adjncy, NULL, NULL, (int*) nparts, &imb,
false, 1, ULTRAFASTMESH, (int*) edgecut, part, comm);
}
#endif |
let's see :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiles and works!
Great! I'll just change the include and library paths and that should be it |
@reguly thanks for following up on this. Seems @mgsium has completed the work in record time ! @mgsium I assume this is now working with the Makefile system in the master branch ? Thanks. |
The Makefiles look good to me. |
@gihanmudalige I updated the docs and ran clang-format on the changes. I've been using the Makefile to build and test so all should be good there. |
No description provided.