Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
986729ea
Commit
986729ea
authored
9 years ago
by
Peter W. Draper
Browse files
Options
Downloads
Patches
Plain Diff
Add code to dump METIS graph
parent
c123d484
No related branches found
No related tags found
1 merge request
!61
METIS fixes
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/debug.c
+89
-2
89 additions, 2 deletions
src/debug.c
src/debug.h
+6
-0
6 additions, 0 deletions
src/debug.h
src/engine.c
+5
-0
5 additions, 0 deletions
src/engine.c
with
100 additions
and
2 deletions
src/debug.c
+
89
−
2
View file @
986729ea
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2013 Matthieu Schaller (matthieu.schaller@durham.ac.uk),
* Pedro Gonnet (pedro.gonnet@durham.ac.uk).
* Copyright (c) 2013- 2015:
* Matthieu Schaller (matthieu.schaller@durham.ac.uk),
* Pedro Gonnet (pedro.gonnet@durham.ac.uk),
* Peter W. Draper (p.w.draper@durham.ac.uk).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
...
...
@@ -20,8 +22,10 @@
#include
<stdio.h>
#include
"config.h"
#include
"const.h"
#include
"part.h"
#include
"debug.h"
/**
* @brief Looks for the particle with the given id and prints its information to
...
...
@@ -98,3 +102,86 @@ void printParticle_single(struct part *p) {
p
->
rho_dh
,
p
->
density
.
div_v
,
p
->
u
,
p
->
force
.
u_dt
,
p
->
force
.
balsara
,
p
->
force
.
POrho2
,
p
->
force
.
v_sig
,
p
->
dt
);
}
#ifdef HAVE_METIS
/**
* @brief Dump the METIS graph in standard format to stdout
*
* @param nvtxs the number of vertices
* @param ncon the number vertex weights
* @param xadj first part of adjacency info
* @param adjncy second part of adjacency info
* @param vwgt weights of vertices
* @param vsize size of vertices
* @param adjwgt weights of edges
*/
void
printMETISGraph
(
idx_t
nvtxs
,
idx_t
ncon
,
idx_t
*
xadj
,
idx_t
*
adjncy
,
idx_t
*
vwgt
,
idx_t
*
vsize
,
idx_t
*
adjwgt
)
{
idx_t
i
;
idx_t
j
;
int
hasvwgt
=
0
;
int
hasewgt
=
0
;
int
hasvsize
=
0
;
/* Check for vwgt, vsize and adjwgt values. */
if
(
vwgt
)
{
for
(
i
=
0
;
i
<
nvtxs
*
ncon
;
i
++
)
{
if
(
vwgt
[
i
]
!=
1
)
{
hasvwgt
=
1
;
break
;
}
}
}
if
(
vsize
)
{
for
(
i
=
0
;
i
<
nvtxs
;
i
++
)
{
if
(
vsize
[
i
]
!=
1
)
{
hasvsize
=
1
;
break
;
}
}
}
if
(
adjwgt
)
{
for
(
i
=
0
;
i
<
xadj
[
nvtxs
];
i
++
)
{
if
(
adjwgt
[
i
]
!=
1
)
{
hasewgt
=
1
;
break
;
}
}
}
/* Write the header line. */
printf
(
"METIS: "
);
printf
(
"%"
PRIDX
" %"
PRIDX
,
nvtxs
,
xadj
[
nvtxs
]
/
2
);
if
(
hasvwgt
||
hasvsize
||
hasewgt
)
{
printf
(
" %d%d%d"
,
hasvsize
,
hasvwgt
,
hasewgt
);
if
(
hasvwgt
)
{
printf
(
" %d"
,
(
int
)
ncon
);
}
}
/* Write the rest of the graph. */
for
(
i
=
0
;
i
<
nvtxs
;
i
++
)
{
printf
(
"
\n
METIS: "
);
if
(
hasvsize
)
{
printf
(
" %"
PRIDX
,
vsize
[
i
]);
}
if
(
hasvwgt
)
{
for
(
j
=
0
;
j
<
ncon
;
j
++
)
{
printf
(
" %"
PRIDX
,
vwgt
[
i
*
ncon
+
j
]);
}
}
for
(
j
=
xadj
[
i
];
j
<
xadj
[
i
+
1
];
j
++
)
{
printf
(
" %"
PRIDX
,
adjncy
[
j
]
+
1
);
if
(
hasewgt
)
{
printf
(
" %"
PRIDX
,
adjwgt
[
j
]);
}
}
}
printf
(
"
\n
"
);
}
#endif
This diff is collapsed.
Click to expand it.
src/debug.h
+
6
−
0
View file @
986729ea
...
...
@@ -27,4 +27,10 @@ void printParticle(struct part *parts, long long int i, int N);
void
printgParticle
(
struct
gpart
*
parts
,
long
long
int
i
,
int
N
);
void
printParticle_single
(
struct
part
*
p
);
#ifdef HAVE_METIS
#include
"metis.h"
void
printMETISGraph
(
idx_t
nvtxs
,
idx_t
ncon
,
idx_t
*
xadj
,
idx_t
*
adjncy
,
idx_t
*
vwgt
,
idx_t
*
vsize
,
idx_t
*
adjwgt
);
#endif
#endif
/* SWIFT_DEBUG_H */
This diff is collapsed.
Click to expand it.
src/engine.c
+
5
−
0
View file @
986729ea
...
...
@@ -540,11 +540,16 @@ void engine_repartition(struct engine *e) {
/* Call METIS. */
idx_t
one
=
1
,
idx_nr_cells
=
nr_cells
,
idx_nr_nodes
=
nr_nodes
;
idx_t
objval
;
/* Dump graph in METIS format */
printMETISGraph
(
idx_nr_cells
,
one
,
offsets
,
inds
,
weights_v
,
NULL
,
weights_e
);
if
(
METIS_PartGraphRecursive
(
&
idx_nr_cells
,
&
one
,
offsets
,
inds
,
weights_v
,
NULL
,
weights_e
,
&
idx_nr_nodes
,
NULL
,
NULL
,
options
,
&
objval
,
nodeIDs
)
!=
METIS_OK
)
error
(
"Call to METIS_PartGraphKway failed."
);
/* Dump the 3d array of cell IDs. */
/* printf( "engine_repartition: nodeIDs = reshape( [" );
for ( i = 0 ; i < cdim[0]*cdim[1]*cdim[2] ; i++ )
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment