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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
raphael.bach
fmpi
Commits
dd4c9aa4
Verified
Commit
dd4c9aa4
authored
3 years ago
by
raphael.bach
Browse files
Options
Downloads
Patches
Plain Diff
Add `fmpi_partition_block_1d()` in `fmpi_domain` module
parent
b1dbd3af
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/fmpi_domain.c
+44
-11
44 additions, 11 deletions
src/fmpi_domain.c
src/fmpi_task.c
+5
-0
5 additions, 0 deletions
src/fmpi_task.c
with
49 additions
and
11 deletions
src/fmpi_domain.c
+
44
−
11
View file @
dd4c9aa4
...
...
@@ -29,9 +29,22 @@
// Internal
#include
"fmpi_data.h"
#include
"internal/fmpi_ctx.h"
#include
"internal/fmpi_error.h"
#include
"internal/fmpi_mpi.h"
/*==============================================================================
PUBLIC FUNCTION
PRIVATE FUNCTION DECLARATION
==============================================================================*/
/*------------------------------------------------------------------------------
fmpi_partition_block_1d()
------------------------------------------------------------------------------*/
/**
* TODO
*/
static
struct
fmpi_data
*
fmpi_partition_block_1d
(
const
struct
fmpi_ctx
*
ctx
,
const
struct
fmpi_data
*
data
);
/*==============================================================================
PUBLIC FUNCTION DEFINITION
==============================================================================*/
//! @todo Handle creation of domain with data in 2D and 3D
/*------------------------------------------------------------------------------
...
...
@@ -44,29 +57,49 @@ struct fmpi_domain fmpi_new_domain(
const
size_t
proc_cnt
=
(
size_t
)
ctx
->
mpi
->
size
;
struct
fmpi_domain
domain
=
{
.
data
=
data
,
.
parts
=
NULL
,
.
part_cnt
=
proc_cnt
};
domain
.
parts
=
malloc
(
proc_cnt
*
sizeof
(
*
domain
.
parts
)
);
domain
.
parts
=
fmpi_partition_block_1d
(
ctx
,
&
data
);
if
(
domain
.
parts
==
NULL
)
{
FMPI_RAISE_ERROR
(
ctx
->
err_handler
,
"FMPI"
,
"malloc(domain.parts) failed!"
);
FMPI_RAISE_ERROR
(
ctx
->
err_handler
,
"FMPI"
,
"fmpi_partition_block_1d() failed!"
);
}
return
domain
;
}
const
size_t
cnt_per_proc
=
data
.
cnt
/
proc_cnt
;
size_t
rem
=
data
.
cnt
%
proc_cnt
;
/*==============================================================================
PRIVATE FUNCTION DEFINITION
==============================================================================*/
/*------------------------------------------------------------------------------
fmpi_partition_block_1d()
------------------------------------------------------------------------------*/
static
struct
fmpi_data
*
fmpi_partition_block_1d
(
const
struct
fmpi_ctx
*
const
ctx
,
const
struct
fmpi_data
*
const
data
)
{
assert
(
ctx
!=
NULL
);
assert
(
data
!=
NULL
);
const
size_t
proc_cnt
=
(
size_t
)
ctx
->
mpi
->
size
;
struct
fmpi_data
*
parts
=
malloc
(
proc_cnt
*
sizeof
(
*
parts
));
if
(
parts
==
NULL
)
{
FMPI_RAISE_ERROR
(
ctx
->
err_handler
,
"FMPI"
,
"malloc(parts) failed!"
);
return
NULL
;
}
const
size_t
cnt_per_proc
=
data
->
cnt
/
proc_cnt
;
size_t
rem
=
data
->
cnt
%
proc_cnt
;
size_t
offset
=
0
;
for
(
size_t
i
=
0
;
i
<
proc_cnt
;
i
++
)
{
const
size_t
cnt
=
rem
!=
0
?
cnt_per_proc
+
1
:
cnt_per_proc
;
rem
=
rem
!=
0
?
rem
-
1
:
rem
;
const
size_t
size
=
cnt
*
data
.
type_size
;
domain
.
parts
[
i
]
=
(
struct
fmpi_data
){
\
.
type
=
data
.
type
,
.
type_size
=
data
.
type_size
,
const
size_t
size
=
cnt
*
data
->
type_size
;
parts
[
i
]
=
(
struct
fmpi_data
){
\
.
type
=
data
->
type
,
.
type_size
=
data
->
type_size
,
.
cnt
=
cnt
,
.
size
=
size
,
.
dim_len
=
{
cnt
,
1
,
1
},
.
dim_cnt
=
1
,
.
start
=
(
char
*
)
data
.
start
+
offset
.
start
=
(
char
*
)
data
->
start
+
offset
};
offset
+=
size
;
}
return
domain
;
return
parts
;
}
This diff is collapsed.
Click to expand it.
src/fmpi_task.c
+
5
−
0
View file @
dd4c9aa4
...
...
@@ -30,6 +30,7 @@
#include
"fmpi_domain.h"
#include
"fmpi_stencil.h"
#include
"internal/fmpi_ctx.h"
#include
"internal/fmpi_error.h"
#include
"internal/fmpi_futhark.h"
#include
"internal/fmpi_futhark_entry.h"
#include
"internal/fmpi_mpi.h"
...
...
@@ -55,6 +56,10 @@ struct fmpi_task fmpi_task_register(
const
size_t
rank
=
(
size_t
)
ctx
->
mpi
->
rank
;
for
(
size_t
i
=
0
;
i
<
task
.
args
.
cnt
;
i
++
)
{
task
.
domains
[
i
]
=
fmpi_new_domain
(
ctx
,
args
->
in
[
i
]);
if
(
task
.
domains
[
i
].
parts
==
NULL
)
{
FMPI_RAISE_ERROR
(
ctx
->
err_handler
,
"FMPI"
,
"fmpi_new_domain() failed!"
);
continue
;
}
void
*
start
=
fmpi_futhark_new_data
(
ctx
->
fut
,
task
.
domains
[
i
].
parts
[
rank
].
start
,
task
.
domains
[
i
].
data
.
type
,
task
.
domains
[
i
].
data
.
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