Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
demo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Georgiana Mania
demo
Commits
d9e2acfa
Commit
d9e2acfa
authored
1 month ago
by
Georgiana Mania
Browse files
Options
Downloads
Patches
Plain Diff
add Dmitry's solution
parent
0ca092d6
Branches
release-0.5.1
Tags
v0.5.1
1 merge request
!3
Master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.cpp
+33
-0
33 additions, 0 deletions
main.cpp
with
33 additions
and
0 deletions
main.cpp
+
33
−
0
View file @
d9e2acfa
...
...
@@ -173,6 +173,38 @@ void scenario_4(double* array, int nblocks, int nlev, int nproma, bool print=tru
}
void
scenario_4b
(
double
*
array
,
int
nblocks
,
int
nlev
,
int
nproma
,
bool
print
=
true
)
{
if
(
print
)
std
::
cout
<<
"scenario 4b (Dmitry's solution): view(array, nproma, nlev, nblocks); d_view(jc, jk, jb) ----- "
<<
std
::
endl
;
Kokkos
::
View
<
double
***
,
Kokkos
::
HostSpace
,
Kokkos
::
MemoryUnmanaged
>
view
(
array
,
nproma
,
nlev
,
nblocks
);
using
space_t
=
Kokkos
::
DefaultExecutionSpace
::
memory_space
;
auto
d_view_tmp
=
Kokkos
::
create_mirror_view_and_copy
(
space_t
(),
view
);
Kokkos
::
View
<
double
***
,
space_t
>
d_view
(
"d_view"
,
nproma
,
nlev
,
nblocks
);
Kokkos
::
deep_copy
(
d_view_tmp
,
view
);
Kokkos
::
deep_copy
(
d_view
,
d_view_tmp
);
timer
.
reset
();
for
(
int
jb
=
0
;
jb
<
nblocks
;
++
jb
)
Kokkos
::
parallel_for
(
""
,
Kokkos
::
RangePolicy
<>
(
0
,
nproma
),
KOKKOS_LAMBDA
(
const
int
jc
)
{
for
(
int
jk
=
0
;
jk
<
nlev
;
++
jk
)
{
int
p
=
jc
*
nlev
*
nblocks
+
jk
*
nblocks
+
jb
;
d_view
(
jc
,
jk
,
jb
)
=
p
;
// printf("%f ", d_view(jb, jk, jc));
}
});
Kokkos
::
fence
();
if
(
print
)
printf
(
"Time = %f ms
\n\n
"
,
timer
.
seconds
()
*
1000
);
Kokkos
::
deep_copy
(
d_view_tmp
,
d_view
);
Kokkos
::
deep_copy
(
view
,
d_view_tmp
);
validate
(
array
,
nblocks
,
nlev
,
nproma
);
}
#if defined(KOKKOS_ENABLE_CUDA) or defined(KOKKOS_ENABLE_HIP)
#define gpu 1
using
Layout
=
Kokkos
::
LayoutLeft
;
...
...
@@ -346,6 +378,7 @@ int main() {
scenario_2b
(
array
,
nblocks
,
nlev
,
nproma
);
scenario_3
(
array
,
nblocks
,
nlev
,
nproma
);
scenario_4
(
array
,
nblocks
,
nlev
,
nproma
);
scenario_4b
(
array
,
nblocks
,
nlev
,
nproma
);
scenario_5
(
array
,
nblocks
,
nlev
,
nproma
);
scenario_6
(
array
,
nblocks
,
nlev
,
nproma
);
...
...
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