Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fmpi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
raphael.bach
fmpi
Commits
bda86fe4
Verified
Commit
bda86fe4
authored
3 years ago
by
raphael.bach
Browse files
Options
Downloads
Patches
Plain Diff
Duplicate `MPI_COMM_WORLD`
parent
b47e8600
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/internal/fmpi_mpi.h
+1
-0
1 addition, 0 deletions
include/internal/fmpi_mpi.h
src/fmpi_mpi.c
+12
-6
12 additions, 6 deletions
src/fmpi_mpi.c
src/fmpi_reduce.c
+1
-1
1 addition, 1 deletion
src/fmpi_reduce.c
src/fmpi_task.c
+2
-2
2 additions, 2 deletions
src/fmpi_task.c
with
16 additions
and
9 deletions
include/internal/fmpi_mpi.h
+
1
−
0
View file @
bda86fe4
...
...
@@ -50,6 +50,7 @@ typedef struct fmpi_mpi_ctx {
char
cpu_name
[
MPI_MAX_PROCESSOR_NAME
];
//!< TODO
int
cpu_name_length
;
//!< TODO
int
root
;
//!< TODO
MPI_Comm
world
;
int
futhark_err_class
;
//!< TODO
int
futhark_err_code
;
//!< TODO
struct
fmpi_error_handler
err_handler
;
//!< TODO
...
...
This diff is collapsed.
Click to expand it.
src/fmpi_mpi.c
+
12
−
6
View file @
bda86fe4
...
...
@@ -61,18 +61,24 @@ struct fmpi_mpi_ctx * fmpi_mpi_init(
FMPI_RAISE_ERROR
(
err_handler
,
"MPI"
,
"malloc(fmpi_mpi_ctx) failed!"
);
return
NULL
;
}
ctx
->
root
=
FMPI_MPI_ROOT
;
ctx
->
err_handler
=
err_handler
;
ctx
->
root
=
FMPI_MPI_ROOT
;
int
err_id
=
MPI_Init
(
argc
,
argv
);
if
(
fmpi_mpi_check_error
(
ctx
,
err_id
,
"MPI_Init"
)
==
true
)
{
return
ctx
;
}
err_id
=
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
ctx
->
rank
);
err_id
=
MPI_Comm_dup
(
MPI_COMM_WORLD
,
&
ctx
->
world
);
if
(
fmpi_mpi_check_error
(
ctx
,
err_id
,
"MPI_Comm_dup"
)
==
true
)
{
free
(
ctx
);
return
NULL
;
}
err_id
=
MPI_Comm_rank
(
ctx
->
world
,
&
ctx
->
rank
);
fmpi_mpi_check_error
(
ctx
,
err_id
,
"MPI_Comm_rank"
);
err_id
=
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
ctx
->
size
);
err_id
=
MPI_Comm_size
(
ctx
->
world
,
&
ctx
->
size
);
fmpi_mpi_check_error
(
ctx
,
err_id
,
"MPI_Comm_size"
);
// `ctx->size` is used with `malloc()` and `malloc(0)` is implementation-defined.
assert
(
ctx
->
size
>
0
);
...
...
@@ -145,7 +151,7 @@ int fmpi_mpi_world_rank(const struct fmpi_mpi_ctx * const ctx)
{
assert
(
ctx
!=
NULL
);
int
rank
=
-
1
;
int
err_id
=
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
int
err_id
=
MPI_Comm_rank
(
ctx
->
world
,
&
rank
);
if
(
fmpi_mpi_check_error
(
ctx
,
err_id
,
"MPI_Comm_rank"
)
==
true
)
{
return
-
1
;
}
...
...
@@ -170,7 +176,7 @@ void fmpi_mpi_abort(const struct fmpi_mpi_ctx * const ctx)
{
assert
(
ctx
!=
NULL
);
if
(
fmpi_mpi_finalized
(
ctx
)
==
false
)
{
int
err_id
=
MPI_Abort
(
MPI_COMM_WORLD
,
MPI_ERR_UNKNOWN
);
int
err_id
=
MPI_Abort
(
ctx
->
world
,
MPI_ERR_UNKNOWN
);
fmpi_mpi_check_error
(
ctx
,
err_id
,
"MPI_Abort"
);
}
}
...
...
@@ -180,7 +186,7 @@ void fmpi_mpi_abort(const struct fmpi_mpi_ctx * const ctx)
int
fmpi_mpi_world_barrier
(
const
struct
fmpi_mpi_ctx
*
const
ctx
)
{
assert
(
ctx
!=
NULL
);
const
int
err_id
=
MPI_Barrier
(
MPI_COMM_WORLD
);
const
int
err_id
=
MPI_Barrier
(
ctx
->
world
);
if
(
fmpi_mpi_check_error
(
ctx
,
err_id
,
"MPI_Barrier"
)
==
true
)
{
return
-
1
;
}
...
...
This diff is collapsed.
Click to expand it.
src/fmpi_reduce.c
+
1
−
1
View file @
bda86fe4
...
...
@@ -66,7 +66,7 @@ T fmpi_reduce_prod_##T(const struct fmpi_ctx * const ctx, const T * const array)
if(fact_global == NULL) { \
fprintf(stderr, "malloc(fact_global) failed!\n"); \
} \
int err_id = MPI_Gather(array, 1, FMPI_TYPE_MPI_##T, fact_global, 1, FMPI_TYPE_MPI_##T, ctx->mpi->root,
MPI_COMM_WORLD
); \
int err_id = MPI_Gather(array, 1, FMPI_TYPE_MPI_##T, fact_global, 1, FMPI_TYPE_MPI_##T, ctx->mpi->root,
ctx->mpi->world
); \
if(fmpi_mpi_check_error(ctx->mpi, err_id, "MPI_Gather()") == true) { \
free(fact_global); \
} \
...
...
This diff is collapsed.
Click to expand it.
src/fmpi_task.c
+
2
−
2
View file @
bda86fe4
...
...
@@ -187,13 +187,13 @@ int fmpi_task_finalize(
MPI_Reduce
(
MPI_IN_PLACE
,
task
->
args
.
out
.
raw
,
(
int
)
task
->
args
.
out
.
cnt
,
fmpi_mpi_type
(
task
->
args
.
out
.
type
.
base
),
MPI_SUM
,
ctx
->
mpi
->
root
,
MPI_COMM_WORLD
ctx
->
mpi
->
root
,
ctx
->
mpi
->
world
);
}
else
{
MPI_Reduce
(
task
->
args
.
out
.
raw
,
task
->
args
.
out
.
raw
,
(
int
)
task
->
args
.
out
.
cnt
,
fmpi_mpi_type
(
task
->
args
.
out
.
type
.
base
),
MPI_SUM
,
ctx
->
mpi
->
root
,
MPI_COMM_WORLD
ctx
->
mpi
->
root
,
ctx
->
mpi
->
world
);
}
}
...
...
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