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
bdf128dc
Verified
Commit
bdf128dc
authored
2 years ago
by
raphael.bach
Browse files
Options
Downloads
Patches
Plain Diff
Add `fmpi_halo_exchange_1d()`
parent
33fed354
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/fmpi_domain.h
+6
-0
6 additions, 0 deletions
include/fmpi_domain.h
src/fmpi_domain.c
+34
-0
34 additions, 0 deletions
src/fmpi_domain.c
src/fmpi_task.c
+1
-30
1 addition, 30 deletions
src/fmpi_task.c
with
41 additions
and
30 deletions
include/fmpi_domain.h
+
6
−
0
View file @
bdf128dc
...
...
@@ -65,6 +65,12 @@ void fmpi_domain_set_inner(
const
struct
fmpi_ctx
*
ctx
,
const
struct
fmpi_domain
*
domain
,
const
void
*
data
);
/*------------------------------------------------------------------------------
fmpi_halo_exchange_1d()
------------------------------------------------------------------------------*/
int
fmpi_halo_exchange_1d
(
const
struct
fmpi_ctx
*
ctx
,
const
struct
fmpi_domain
*
domain
);
/*==============================================================================
GUARD
==============================================================================*/
...
...
This diff is collapsed.
Click to expand it.
src/fmpi_domain.c
+
34
−
0
View file @
bdf128dc
...
...
@@ -89,6 +89,40 @@ void fmpi_domain_set_inner(
assert
(
data
!=
NULL
);
memcpy
(
domain
->
inner
.
raw
,
data
,
domain
->
inner
.
size
);
}
/*------------------------------------------------------------------------------
fmpi_halo_exchange_1d()
------------------------------------------------------------------------------*/
int
fmpi_halo_exchange_1d
(
const
struct
fmpi_ctx
*
const
ctx
,
const
struct
fmpi_domain
*
const
domain
){
assert
(
ctx
!=
NULL
);
assert
(
domain
!=
NULL
);
const
size_t
idx_1
=
domain
->
halo
.
type
.
size
;
const
size_t
idx_nm2
=
(
domain
->
halo
.
cnt
-
2
)
*
domain
->
halo
.
type
.
size
;
const
size_t
idx_nm1
=
idx_nm2
+
idx_1
;
void
*
const
buf_0
=
domain
->
halo
.
raw
;
const
void
*
const
buf_1
=
(
char
*
)
buf_0
+
idx_1
;
const
void
*
const
buf_nm2
=
(
char
*
)
buf_0
+
idx_nm2
;
void
*
const
buf_nm1
=
(
char
*
)
buf_0
+
idx_nm1
;
const
int
rank
=
ctx
->
mpi
->
rank
;
const
int
left
=
(
rank
!=
0
)
?
(
rank
-
1
)
:
MPI_PROC_NULL
;
const
int
right
=
(
rank
!=
(
ctx
->
mpi
->
size
-
1
))
?
(
rank
+
1
)
:
MPI_PROC_NULL
;
MPI_Datatype
type
=
fmpi_mpi_type
(
domain
->
halo
.
type
.
base
);
MPI_Sendrecv
(
buf_nm2
,
1
,
type
,
right
,
0
,
buf_0
,
1
,
type
,
left
,
0
,
ctx
->
mpi
->
world
,
MPI_STATUS_IGNORE
);
MPI_Sendrecv
(
buf_1
,
1
,
type
,
left
,
1
,
buf_nm1
,
1
,
type
,
right
,
1
,
ctx
->
mpi
->
world
,
MPI_STATUS_IGNORE
);
return
FMPI_SUCCESS
;
}
/*==============================================================================
PRIVATE FUNCTION DEFINITION
==============================================================================*/
...
...
This diff is collapsed.
Click to expand it.
src/fmpi_task.c
+
1
−
30
View file @
bdf128dc
...
...
@@ -128,36 +128,7 @@ int fmpi_task_run_sync(
}
if
(
task
->
stencil
.
type
!=
FMPI_STENCIL_NONE
)
{
fmpi_domain_set_inner
(
ctx
,
&
task
->
domains
[
0
],
task
->
args
.
out
.
raw
);
const
int
rank
=
ctx
->
mpi
->
rank
;
size_t
type_size
=
task
->
domains
[
0
].
inner
.
type
.
size
;
const
size_t
idx_1
=
type_size
;
const
size_t
idx_nm2
=
(
task
->
domains
[
0
].
halo
.
cnt
-
2
)
*
type_size
;
const
size_t
idx_nm1
=
idx_nm2
+
idx_1
;
void
*
const
buf_0
=
task
->
domains
[
0
].
halo
.
raw
;
const
void
*
const
buf_1
=
(
char
*
)
buf_0
+
idx_1
;
const
void
*
const
buf_nm2
=
(
char
*
)
buf_0
+
idx_nm2
;
void
*
const
buf_nm1
=
(
char
*
)
buf_0
+
idx_nm1
;
MPI_Datatype
type
=
fmpi_mpi_type
(
task
->
domains
[
0
].
halo
.
type
.
base
);
if
((
rank
%
2
)
==
0
)
{
int
left
=
(
rank
!=
0
)
?
(
rank
-
1
)
:
MPI_PROC_NULL
;
int
right
=
rank
+
1
;
MPI_Send
(
buf_nm2
,
1
,
type
,
right
,
0
,
ctx
->
mpi
->
world
);
MPI_Recv
(
buf_0
,
1
,
type
,
left
,
1
,
ctx
->
mpi
->
world
,
MPI_STATUS_IGNORE
);
MPI_Send
(
buf_1
,
1
,
type
,
left
,
2
,
ctx
->
mpi
->
world
);
MPI_Recv
(
buf_nm1
,
1
,
type
,
right
,
3
,
ctx
->
mpi
->
world
,
MPI_STATUS_IGNORE
);
}
else
{
int
left
=
rank
-
1
;
int
right
=
(
rank
!=
(
ctx
->
mpi
->
size
-
1
))
?
(
rank
+
1
)
:
MPI_PROC_NULL
;
MPI_Recv
(
buf_0
,
1
,
type
,
left
,
0
,
ctx
->
mpi
->
world
,
MPI_STATUS_IGNORE
);
MPI_Send
(
buf_nm2
,
1
,
type
,
right
,
1
,
ctx
->
mpi
->
world
);
MPI_Recv
(
buf_nm1
,
1
,
type
,
right
,
2
,
ctx
->
mpi
->
world
,
MPI_STATUS_IGNORE
);
MPI_Send
(
buf_1
,
1
,
type
,
left
,
3
,
ctx
->
mpi
->
world
);
}
fmpi_halo_exchange_1d
(
ctx
,
&
task
->
domains
[
0
]);
const
int
err
=
fmpi_futhark_free_data_sync
(
ctx
->
fut
,
task
->
args
.
in
[
0
].
gpu
,
task
->
domains
[
0
].
halo
.
type
.
base
,
task
->
domains
[
0
].
halo
.
dim_cnt
...
...
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