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
96d63367
Verified
Commit
96d63367
authored
3 years ago
by
baptiste.coudray
Browse files
Options
Downloads
Patches
Plain Diff
Renamed variable
parent
f5b7ae2d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lattice_boltzmann/main.c
+21
-18
21 additions, 18 deletions
lattice_boltzmann/main.c
with
21 additions
and
18 deletions
lattice_boltzmann/main.c
+
21
−
18
View file @
96d63367
...
...
@@ -41,18 +41,26 @@ convert_chunk_with_envelope(struct futhark_context *fc, const void *data, int64_
return
futhark_new_f32_4d
(
fc
,
data
,
dim0
,
dim1
,
dim2
,
NB_VALUES
);
}
void
compute_next_lbm
(
struct
dispatch_context
*
dc
,
struct
futhark_context
*
fc
,
chunk_info_t
*
ci
)
{
double
compute_next_lbm
(
struct
dispatch_context
*
dc
,
struct
futhark_context
*
fc
,
chunk_info_t
*
ci
)
{
struct
futhark_f32_4d
*
fut_chunk_with_envelope
=
get_chunk_with_envelope
(
dc
,
fc
,
1
,
convert_chunk_with_envelope
);
struct
futhark_f32_4d
*
fut_next_chunk_lbm
;
// Warmup
futhark_entry_next_chunk_lbm
(
fc
,
&
fut_next_chunk_lbm
,
fut_chunk_with_envelope
);
futhark_context_sync
(
fc
);
double
start
=
MPI_Wtime
();
for
(
int
i
=
0
;
i
<
N_ITERATIONS
;
++
i
)
{
futhark_entry_next_chunk_lbm
(
fc
,
&
fut_next_chunk_lbm
,
fut_chunk_with_envelope
);
futhark_context_sync
(
fc
);
}
futhark_values_f32_4d
(
fc
,
fut_next_chunk_lbm
,
ci
->
data
);
futhark_context_sync
(
fc
);
double
finish
=
MPI_Wtime
();
futhark_free_f32_4d
(
fc
,
fut_chunk_with_envelope
);
futhark_free_f32_4d
(
fc
,
fut_next_chunk_lbm
);
return
finish
-
start
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -75,7 +83,7 @@ int main(int argc, char *argv[]) {
#endif
char
device
[
4
]
=
{
0
};
snprintf
(
device
,
sizeof
(
device
),
"#%d"
,
my_rank
%
nb_devices
);
futhark_context_config_set_device
(
fut_config
,
device
);
futhark_context_config_set_device
(
fut_config
,
"AMD"
);
#endif
struct
futhark_context
*
fut_context
=
futhark_context_new
(
fut_config
);
...
...
@@ -83,30 +91,25 @@ int main(int argc, char *argv[]) {
// https://stackoverflow.com/a/33624425
int
count
=
1
;
int
array_of_
blocklengths
[]
=
{
NB_VALUES
};
MPI_Aint
array_of_
displacements
[]
=
{
offsetof
(
struct
lbm_values
,
values
)};
MPI_Datatype
array_of_
types
[]
=
{
MPI_FLOAT
};
MPI_Datatype
tmp_type
,
my_mpi
_type
;
int
block
_
lengths
[]
=
{
NB_VALUES
};
MPI_Aint
displacements
[]
=
{
offsetof
(
struct
lbm_values
,
values
)};
MPI_Datatype
types
[]
=
{
MPI_FLOAT
};
MPI_Datatype
tmp_type
,
lbm
_type
;
MPI_Aint
lb
,
extent
;
MPI_Type_create_struct
(
count
,
array_of_blocklengths
,
array_of_displacements
,
array_of_types
,
&
tmp_type
);
MPI_Type_create_struct
(
count
,
block_lengths
,
displacements
,
types
,
&
tmp_type
);
MPI_Type_get_extent
(
tmp_type
,
&
lb
,
&
extent
);
MPI_Type_create_resized
(
tmp_type
,
lb
,
extent
,
&
my_mpi
_type
);
MPI_Type_commit
(
&
my_mpi
_type
);
MPI_Type_create_resized
(
tmp_type
,
lb
,
extent
,
&
lbm
_type
);
MPI_Type_commit
(
&
lbm
_type
);
struct
dispatch_context
*
disp_context
=
dispatch_context_new
(
lbm_dimensions
,
my_mpi
_type
,
3
);
struct
dispatch_context
*
disp_context
=
dispatch_context_new
(
lbm_dimensions
,
lbm
_type
,
3
);
chunk_info_t
ci
=
get_chunk_info
(
disp_context
);
init_chunk_lbm
(
&
ci
);
for
(
int
i
=
0
;
i
<
N_MEASURES
;
++
i
)
{
double
start
=
MPI_Wtime
();
for
(
int
j
=
0
;
j
<
N_ITERATIONS
;
++
j
)
{
compute_next_lbm
(
disp_context
,
fut_context
,
&
ci
);
}
double
finish
=
MPI_Wtime
();
double
time
=
compute_next_lbm
(
disp_context
,
fut_context
,
&
ci
);
if
(
my_rank
==
ROOT_RANK
)
{
printf
(
"%d;%d;%d;%f
\n
"
,
world_size
,
nb_devices
,
lbm_dimensions
[
0
],
finish
-
start
);
printf
(
"%d;%d;%d;%f
\n
"
,
world_size
,
nb_devices
,
lbm_dimensions
[
0
],
time
);
}
}
...
...
@@ -114,6 +117,6 @@ int main(int argc, char *argv[]) {
futhark_context_config_free
(
fut_config
);
futhark_context_free
(
fut_context
);
MPI_Type_free
(
&
tmp_type
);
MPI_Type_free
(
&
my_mpi
_type
);
MPI_Type_free
(
&
lbm
_type
);
return
MPI_Finalize
();
}
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