Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
La programmation parallèle pour les gens
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
baptiste.coudray
La programmation parallèle pour les gens
Commits
f283c608
Verified
Commit
f283c608
authored
3 years ago
by
baptiste.coudray
Browse files
Options
Downloads
Patches
Plain Diff
Refactored code
parent
d989c412
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
futhark_mpi/dispatch.c
+38
-38
38 additions, 38 deletions
futhark_mpi/dispatch.c
futhark_mpi/dispatch.h
+11
-11
11 additions, 11 deletions
futhark_mpi/dispatch.h
game_of_life/benchmark/main.c
+1
-1
1 addition, 1 deletion
game_of_life/benchmark/main.c
game_of_life/main.c
+1
-1
1 addition, 1 deletion
game_of_life/main.c
with
51 additions
and
51 deletions
futhark_mpi/dispatch.c
+
38
−
38
View file @
f283c608
...
...
@@ -33,6 +33,22 @@
#define CHUNK_DATA_TAG 8
#define ROOT_RANK 0
struct
futhark_opaque_envelope_1d_t
{
struct
futhark_i8_1d
*
v0
;
struct
futhark_i8_1d
*
v1
;
};
struct
futhark_opaque_envelope_2d_t
{
struct
futhark_i8_2d
*
v0
;
struct
futhark_i8_2d
*
v1
;
struct
futhark_i8_2d
*
v2
;
struct
futhark_i8_2d
*
v3
;
struct
futhark_i8_2d
*
v4
;
struct
futhark_i8_2d
*
v5
;
struct
futhark_i8_2d
*
v6
;
struct
futhark_i8_2d
*
v7
;
};
struct
dispatch_context
{
int
my_rank
;
int
world_size
;
...
...
@@ -223,22 +239,6 @@ extern void dispatch_context_print(struct dispatch_context *dc) {
dc
->
data_dimensions
[
0
],
dc
->
data_dimensions
[
1
],
dc
->
data_dimensions
[
2
]);
}
struct
futhark_opaque_envelope_1d_t
{
struct
futhark_i8_1d
*
v0
;
struct
futhark_i8_1d
*
v1
;
};
struct
futhark_opaque_envelope_2d_t
{
struct
futhark_i8_2d
*
v0
;
struct
futhark_i8_2d
*
v1
;
struct
futhark_i8_2d
*
v2
;
struct
futhark_i8_2d
*
v3
;
struct
futhark_i8_2d
*
v4
;
struct
futhark_i8_2d
*
v5
;
struct
futhark_i8_2d
*
v6
;
struct
futhark_i8_2d
*
v7
;
};
static
envelope_t
get_inner_envelope_1d
(
struct
dispatch_context
*
dc
,
struct
futhark_context
*
fc
,
int
thickness
)
{
struct
futhark_u8_1d
*
fut_chunk_data
=
futhark_new_u8_1d
(
fc
,
dc
->
chunk_info
->
data
,
dc
->
chunk_info
->
dimensions
[
1
]
*
dc
->
type
);
...
...
@@ -279,8 +279,6 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int
thickness_y
=
min
(
thickness
,
dc
->
active_domain
.
dimensions
[
0
]);
int
thickness_x
=
min
(
thickness
,
dc
->
active_domain
.
dimensions
[
1
]);
struct
futhark_opaque_envelope_2d_t
*
fut_inner_envelope
;
futhark_context_sync
(
fc
);
...
...
@@ -366,11 +364,12 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
return
inner_envelope
;
}
static
uint8_t
*
chunk_info_to_futhark
(
struct
dispatch_context
*
dc
,
uint8_t
*
out
,
chunk_info_t
*
ci
,
char
*
fut_type
)
{
static
uint8_t
*
chunk_info_to_futhark_struct
(
chunk_info_t
*
ci
,
struct
dispatch_context
*
dc
,
uint8_t
*
out
,
char
*
futhark_type
)
{
*
out
++
=
'b'
;
*
out
++
=
2
;
*
out
++
=
dc
->
n_dimensions
;
memcpy
(
out
,
fut_type
,
4
);
memcpy
(
out
,
fut
hark
_type
,
4
);
out
+=
4
;
int64_t
dimensions64
[
3
];
...
...
@@ -382,6 +381,8 @@ static uint8_t *chunk_info_to_futhark(struct dispatch_context *dc, uint8_t *out,
memcpy
(
out
,
&
dimensions64
[
1
],
1
*
sizeof
(
int64_t
));
}
else
if
(
dc
->
n_dimensions
==
2
)
{
memcpy
(
out
,
dimensions64
,
2
*
sizeof
(
int64_t
));
}
else
{
memcpy
(
out
,
dimensions64
,
3
*
sizeof
(
int64_t
));
}
out
+=
dc
->
n_dimensions
*
sizeof
(
int64_t
);
memcpy
(
out
,
ci
->
data
,
ci
->
count
*
dc
->
type
);
...
...
@@ -391,18 +392,18 @@ static uint8_t *chunk_info_to_futhark(struct dispatch_context *dc, uint8_t *out,
static
void
*
futhark_outer_envelope_1d_new
(
struct
dispatch_context
*
dc
,
struct
futhark_context
*
fc
,
envelope_t
*
outer_envelope
,
void
*
f
(
struct
futhark_context
*
,
const
void
*
),
char
*
fut_type
)
{
void
*
f
(
struct
futhark_context
*
,
const
void
*
),
char
*
fut
hark
_type
)
{
int64_t
size_0
=
7
+
1
*
sizeof
(
int64_t
)
+
outer_envelope
->
east
.
count
*
dc
->
type
;
int64_t
size_1
=
7
+
1
*
sizeof
(
int64_t
)
+
outer_envelope
->
west
.
count
*
dc
->
type
;
void
*
opaque_struct
=
calloc
(
size_0
*
size_1
,
sizeof
(
uint8_t
));
uint8_t
*
o
ut
=
(
uint8_t
*
)
opaque_struct
;
uint8_t
*
o
paque_struct8
=
(
uint8_t
*
)
opaque_struct
;
// East
o
ut
=
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
east
,
fut
_type
);
o
paque_struct8
=
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
east
,
dc
,
opaque_struct8
,
futhark
_type
);
// West
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
west
,
fut
_type
);
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
west
,
dc
,
opaque_struct8
,
futhark
_type
);
void
*
fut_opaque_struct
=
f
(
fc
,
opaque_struct
);
futhark_context_sync
(
fc
);
...
...
@@ -413,8 +414,7 @@ futhark_outer_envelope_1d_new(struct dispatch_context *dc, struct futhark_contex
static
void
*
futhark_outer_envelope_2d_new
(
struct
dispatch_context
*
dc
,
struct
futhark_context
*
fc
,
envelope_t
*
outer_envelope
,
void
*
f
(
struct
futhark_context
*
,
const
void
*
),
char
*
fut_type
)
{
void
*
f
(
struct
futhark_context
*
,
const
void
*
),
char
*
futhark_type
)
{
int64_t
size_0
=
7
+
2
*
sizeof
(
int64_t
)
+
outer_envelope
->
east
.
count
*
dc
->
type
;
int64_t
size_1
=
7
+
2
*
sizeof
(
int64_t
)
+
outer_envelope
->
north
.
count
*
dc
->
type
;
...
...
@@ -427,16 +427,16 @@ futhark_outer_envelope_2d_new(struct dispatch_context *dc, struct futhark_contex
void
*
opaque_struct
=
calloc
(
size_0
+
size_1
+
size_2
+
size_3
+
size_4
+
size_5
+
size_6
+
size_7
,
sizeof
(
uint8_t
));
uint8_t
*
o
ut
=
(
uint8_t
*
)
opaque_struct
;
uint8_t
*
o
paque_struct8
=
(
uint8_t
*
)
opaque_struct
;
o
ut
=
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
east
,
fut
_type
);
o
ut
=
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
north
,
fut
_type
);
o
ut
=
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
north_east
,
fut
_type
);
o
ut
=
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
north_west
,
fut
_type
);
o
ut
=
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
south
,
fut
_type
);
o
ut
=
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
south_east
,
fut
_type
);
o
ut
=
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
south_west
,
fut
_type
);
chunk_info_to_futhark
(
dc
,
out
,
&
outer_envelope
->
west
,
fut
_type
);
o
paque_struct8
=
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
east
,
dc
,
opaque_struct8
,
futhark
_type
);
o
paque_struct8
=
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
north
,
dc
,
opaque_struct8
,
futhark
_type
);
o
paque_struct8
=
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
north_east
,
dc
,
opaque_struct8
,
futhark
_type
);
o
paque_struct8
=
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
north_west
,
dc
,
opaque_struct8
,
futhark
_type
);
o
paque_struct8
=
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
south
,
dc
,
opaque_struct8
,
futhark
_type
);
o
paque_struct8
=
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
south_east
,
dc
,
opaque_struct8
,
futhark
_type
);
o
paque_struct8
=
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
south_west
,
dc
,
opaque_struct8
,
futhark
_type
);
chunk_info_to_futhark
_struct
(
&
outer_envelope
->
west
,
dc
,
opaque_struct8
,
futhark
_type
);
void
*
fut_opaque_struct
=
f
(
fc
,
opaque_struct
);
futhark_context_sync
(
fc
);
...
...
@@ -447,12 +447,12 @@ futhark_outer_envelope_2d_new(struct dispatch_context *dc, struct futhark_contex
extern
void
*
futhark_outer_envelope_new
(
struct
dispatch_context
*
dc
,
struct
futhark_context
*
fc
,
envelope_t
*
outer_envelope
,
void
*
f
(
struct
futhark_context
*
,
const
void
*
),
char
*
fut_type
)
{
char
*
fut
hark
_type
)
{
switch
(
dc
->
n_dimensions
)
{
case
1
:
return
futhark_outer_envelope_1d_new
(
dc
,
fc
,
outer_envelope
,
f
,
fut_type
);
return
futhark_outer_envelope_1d_new
(
dc
,
fc
,
outer_envelope
,
f
,
fut
hark
_type
);
case
2
:
return
futhark_outer_envelope_2d_new
(
dc
,
fc
,
outer_envelope
,
f
,
fut_type
);
return
futhark_outer_envelope_2d_new
(
dc
,
fc
,
outer_envelope
,
f
,
fut
hark
_type
);
default:
return
NULL
;
}
...
...
This diff is collapsed.
Click to expand it.
futhark_mpi/dispatch.h
+
11
−
11
View file @
f283c608
...
...
@@ -4,16 +4,16 @@
#include
"../game_of_life/gol.h"
#include
"chunk_info.h"
#define FUT_I8 " i8"
#define FUT_U8 " i8"
#define FUT_I16 " i16"
#define FUT_U16 " i16"
#define FUT_I32 " i32"
#define FUT_U32 " i32"
#define FUT_I64 " i64"
#define FUT_U64 " i64"
#define FUT_F32 " f32"
#define FUT_F64 " f64"
#define FUT
HARK
_I8 " i8"
#define FUT
HARK
_U8 " i8"
#define FUT
HARK
_I16 " i16"
#define FUT
HARK
_U16 " i16"
#define FUT
HARK
_I32 " i32"
#define FUT
HARK
_U32 " i32"
#define FUT
HARK
_I64 " i64"
#define FUT
HARK
_U64 " i64"
#define FUT
HARK
_F32 " f32"
#define FUT
HARK
_F64 " f64"
struct
dispatch_context
;
...
...
@@ -38,7 +38,7 @@ extern envelope_t get_outer_envelope(struct dispatch_context *dc, struct futhark
extern
void
*
futhark_outer_envelope_new
(
struct
dispatch_context
*
dc
,
struct
futhark_context
*
fc
,
envelope_t
*
outer_envelope
,
void
*
f
(
struct
futhark_context
*
,
const
void
*
),
char
*
fut_type
);
void
*
f
(
struct
futhark_context
*
,
const
void
*
),
char
*
fut
hark
_type
);
extern
chunk_info_t
get_chunk_info
(
struct
dispatch_context
*
dc
);
...
...
This diff is collapsed.
Click to expand it.
game_of_life/benchmark/main.c
+
1
−
1
View file @
f283c608
...
...
@@ -33,7 +33,7 @@ void compute_next_chunk_board(struct dispatch_context *dc, struct futhark_contex
struct
futhark_opaque_envelope_2d_i8
*
fut_outer_envelope
=
futhark_outer_envelope_new
(
dc
,
fc
,
&
outer_envelope
,
futhark_restore_opaque_envelope_2d_i8
,
FUT_I8
);
FUT
HARK
_I8
);
struct
futhark_i8_2d
*
fut_chunk_board
=
futhark_new_i8_2d
(
fc
,
ci
->
data
,
ci
->
dimensions
[
0
],
ci
->
dimensions
[
1
]);
struct
futhark_i8_2d
*
fut_next_chunk_board
;
...
...
This diff is collapsed.
Click to expand it.
game_of_life/main.c
+
1
−
1
View file @
f283c608
...
...
@@ -33,7 +33,7 @@ void compute_next_chunk_board(struct dispatch_context *dc, struct futhark_contex
struct
futhark_opaque_envelope_2d_i8
*
fut_outer_envelope
=
futhark_outer_envelope_new
(
dc
,
fc
,
&
outer_envelope
,
futhark_restore_opaque_envelope_2d_i8
,
FUT_I8
);
FUT
HARK
_I8
);
struct
futhark_i8_2d
*
fut_chunk_board
=
futhark_new_i8_2d
(
fc
,
ci
->
data
,
ci
->
dimensions
[
0
],
ci
->
dimensions
[
1
]);
struct
futhark_i8_2d
*
fut_next_chunk_board
;
...
...
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