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
68f63eed
Verified
Commit
68f63eed
authored
2 years ago
by
raphael.bach
Browse files
Options
Downloads
Patches
Plain Diff
Add `fmpi_halo_exchange_2d()`
parent
22e93e5f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/fmpi_domain.h
+7
-0
7 additions, 0 deletions
include/fmpi_domain.h
src/fmpi_domain.c
+35
-0
35 additions, 0 deletions
src/fmpi_domain.c
with
42 additions
and
0 deletions
include/fmpi_domain.h
+
7
−
0
View file @
68f63eed
...
@@ -46,6 +46,7 @@ typedef struct fmpi_domain {
...
@@ -46,6 +46,7 @@ typedef struct fmpi_domain {
const
struct
fmpi_data
*
data
;
//!< Data composing the domain.
const
struct
fmpi_data
*
data
;
//!< Data composing the domain.
struct
fmpi_data
inner
;
struct
fmpi_data
inner
;
struct
fmpi_data
halo
;
struct
fmpi_data
halo
;
struct
fmpi_stencil
stencil
;
size_t
part_cnt
;
//!< Number of partitions.
size_t
part_cnt
;
//!< Number of partitions.
}
fmpi_domain
;
}
fmpi_domain
;
/*==============================================================================
/*==============================================================================
...
@@ -71,6 +72,12 @@ void fmpi_domain_set_inner(
...
@@ -71,6 +72,12 @@ void fmpi_domain_set_inner(
int
fmpi_halo_exchange_1d
(
int
fmpi_halo_exchange_1d
(
const
struct
fmpi_ctx
*
ctx
,
const
struct
fmpi_domain
*
domain
const
struct
fmpi_ctx
*
ctx
,
const
struct
fmpi_domain
*
domain
);
);
/*------------------------------------------------------------------------------
fmpi_halo_exchange_2d()
------------------------------------------------------------------------------*/
int
fmpi_halo_exchange_2d
(
const
struct
fmpi_ctx
*
ctx
,
const
struct
fmpi_domain
*
domain
);
/*==============================================================================
/*==============================================================================
GUARD
GUARD
==============================================================================*/
==============================================================================*/
...
...
This diff is collapsed.
Click to expand it.
src/fmpi_domain.c
+
35
−
0
View file @
68f63eed
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include
"fmpi_domain.h"
#include
"fmpi_domain.h"
// C Standard Library
// C Standard Library
#include
<assert.h>
#include
<assert.h>
#include
<limits.h>
// INT_MAX
#include
<stdlib.h>
// size_t, NULL, malloc(), free()
#include
<stdlib.h>
// size_t, NULL, malloc(), free()
#include
<string.h>
// memcpy()
#include
<string.h>
// memcpy()
// Internal
// Internal
...
@@ -80,6 +81,7 @@ struct fmpi_domain fmpi_new_domain(
...
@@ -80,6 +81,7 @@ struct fmpi_domain fmpi_new_domain(
const
size_t
proc_cnt
=
(
size_t
)
ctx
->
mpi
->
size
;
const
size_t
proc_cnt
=
(
size_t
)
ctx
->
mpi
->
size
;
struct
fmpi_domain
domain
=
{
struct
fmpi_domain
domain
=
{
.
data
=
data
,
.
data
=
data
,
.
stencil
=
stencil
,
.
part_cnt
=
proc_cnt
.
part_cnt
=
proc_cnt
};
};
domain
.
inner
=
fmpi_partition_block_1d
(
ctx
,
data
);
domain
.
inner
=
fmpi_partition_block_1d
(
ctx
,
data
);
...
@@ -135,6 +137,39 @@ int fmpi_halo_exchange_1d(
...
@@ -135,6 +137,39 @@ int fmpi_halo_exchange_1d(
);
);
return
FMPI_SUCCESS
;
return
FMPI_SUCCESS
;
}
}
/*------------------------------------------------------------------------------
fmpi_halo_exchange_2d()
------------------------------------------------------------------------------*/
int
fmpi_halo_exchange_2d
(
const
struct
fmpi_ctx
*
const
ctx
,
const
struct
fmpi_domain
*
const
domain
){
assert
(
ctx
!=
NULL
);
assert
(
domain
!=
NULL
);
const
size_t
type_size
=
domain
->
inner
.
type
.
size
;
void
*
const
halo_top
=
domain
->
halo
.
raw
;
const
void
*
const
inner_top
=
(
const
char
*
)
halo_top
+
(
domain
->
halo
.
dim_len
[
0
]
*
domain
->
stencil
.
length
*
type_size
);
const
void
*
const
inner_bottom
=
(
const
char
*
)
inner_top
+
(
domain
->
halo
.
dim_len
[
0
]
*
(
domain
->
inner
.
dim_len
[
1
]
-
1
)
*
type_size
);
void
*
const
halo_bottom
=
(
char
*
)
halo_top
+
(
domain
->
halo
.
dim_len
[
0
]
*
(
domain
->
halo
.
dim_len
[
1
]
-
1
)
*
type_size
);
const
int
rank
=
ctx
->
mpi
->
rank
;
const
int
above
=
(
rank
!=
0
)
?
(
rank
-
1
)
:
MPI_PROC_NULL
;
const
int
under
=
(
rank
!=
(
ctx
->
mpi
->
size
-
1
))
?
(
rank
+
1
)
:
MPI_PROC_NULL
;
assert
(
domain
->
inner
.
dim_len
[
0
]
<=
INT_MAX
);
const
int
cnt
=
(
int
)
domain
->
halo
.
dim_len
[
0
];
MPI_Datatype
type
=
fmpi_mpi_type
(
domain
->
halo
.
type
.
base
);
MPI_Sendrecv
(
inner_top
,
cnt
,
type
,
above
,
0
,
halo_bottom
,
cnt
,
type
,
under
,
0
,
ctx
->
mpi
->
world
,
MPI_STATUS_IGNORE
);
MPI_Sendrecv
(
inner_bottom
,
cnt
,
type
,
under
,
1
,
halo_top
,
cnt
,
type
,
above
,
1
,
ctx
->
mpi
->
world
,
MPI_STATUS_IGNORE
);
return
FMPI_SUCCESS
;
}
/*==============================================================================
/*==============================================================================
PRIVATE FUNCTION DEFINITION
PRIVATE FUNCTION DEFINITION
==============================================================================*/
==============================================================================*/
...
...
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