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
b47e8600
Verified
Commit
b47e8600
authored
3 years ago
by
raphael.bach
Browse files
Options
Downloads
Patches
Plain Diff
Add `fmpi_task_finalize()`
parent
e746e94c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/array_sum/main.c
+4
-1
4 additions, 1 deletion
examples/array_sum/main.c
include/fmpi_task.h
+14
-0
14 additions, 0 deletions
include/fmpi_task.h
src/fmpi_task.c
+29
-0
29 additions, 0 deletions
src/fmpi_task.c
with
47 additions
and
1 deletion
examples/array_sum/main.c
+
4
−
1
View file @
b47e8600
...
...
@@ -3,6 +3,7 @@
#include
<stdint.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<mpi.h>
// fmpi
#include
<fmpi.h>
// Internal
...
...
@@ -37,7 +38,9 @@ int main(int argc, char * argv[])
fmpi_data_1d_in
(
ctx
,
in
,
in_size
)
);
fmpi_run_task
(
ctx
,
&
array_sum_task
);
printf
(
"rank=%d sum=%ld
\n
"
,
fmpi_world_rank
(
ctx
),
out
);
printf
(
"rank=%d local sum=%ld
\n
"
,
fmpi_world_rank
(
ctx
),
out
);
fmpi_task_finalize
(
ctx
,
&
array_sum_task
,
FMPI_TASK_OP_SUM
);
fmpi_root_printf
(
ctx
,
"global sum=%ld
\n
"
,
out
);
fmpi_exit
(
&
ctx
);
return
EXIT_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
include/fmpi_task.h
+
14
−
0
View file @
b47e8600
...
...
@@ -50,6 +50,13 @@
/*==============================================================================
TYPE
==============================================================================*/
/*------------------------------------------------------------------------------
fmpi_task_op
------------------------------------------------------------------------------*/
typedef
enum
fmpi_task_op
{
FMPI_TASK_OP_NONE
=
0
,
FMPI_TASK_OP_SUM
}
fmpi_task_op
;
/*------------------------------------------------------------------------------
fmpi_task_args
------------------------------------------------------------------------------*/
...
...
@@ -183,6 +190,13 @@ int fmpi_task_run_sync(const struct fmpi_ctx * ctx, const struct fmpi_task * tas
* }
*/
int
fmpi_task_run_async
(
const
struct
fmpi_ctx
*
ctx
,
const
struct
fmpi_task
*
task
);
/*------------------------------------------------------------------------------
fmpi_task_finalize()
------------------------------------------------------------------------------*/
int
fmpi_task_finalize
(
const
struct
fmpi_ctx
*
ctx
,
const
struct
fmpi_task
*
task
,
enum
fmpi_task_op
op
);
/*==============================================================================
MACRO
==============================================================================*/
...
...
This diff is collapsed.
Click to expand it.
src/fmpi_task.c
+
29
−
0
View file @
b47e8600
...
...
@@ -170,3 +170,32 @@ int fmpi_task_run_async(
assert
(
task
!=
NULL
);
return
task
->
func
(
ctx
,
&
task
->
args
);
}
/*------------------------------------------------------------------------------
fmpi_task_finalize()
------------------------------------------------------------------------------*/
int
fmpi_task_finalize
(
const
struct
fmpi_ctx
*
const
ctx
,
const
struct
fmpi_task
*
const
task
,
const
enum
fmpi_task_op
op
){
assert
(
ctx
!=
NULL
);
assert
(
task
!=
NULL
);
if
(
op
==
FMPI_TASK_OP_NONE
)
{
return
0
;
}
if
(
op
==
FMPI_TASK_OP_SUM
)
{
if
(
fmpi_mpi_is_root
(
ctx
->
mpi
))
{
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
);
}
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
);
}
}
return
0
;
}
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