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
0aa243e6
Commit
0aa243e6
authored
2 months ago
by
Panos Adamidis
Browse files
Options
Downloads
Patches
Plain Diff
Adding scenario_1c with a 2D view and default layout
parent
3949a1db
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Adding scenario_1c with a 2D view and default layout
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.cpp
+40
-2
40 additions, 2 deletions
main.cpp
with
40 additions
and
2 deletions
main.cpp
+
40
−
2
View file @
0aa243e6
...
...
@@ -15,7 +15,8 @@ Kokkos::Timer timer;
// constexpr int nlev = 90;
// constexpr int nproma = 55000;
// #define ENABLE_CHECK_BOUNDS
//#define ENABLE_CHECK_BOUNDS
//#define ENABLE_CHECK_BOUNDS_2D
static
void
validate
(
double
*
array
,
int
nblocks
,
int
nlev
,
int
nproma
)
{
for
(
int
i
=
0
;
i
<
nblocks
*
nlev
*
nproma
;
++
i
)
{
...
...
@@ -29,6 +30,12 @@ KOKKOS_INLINE_FUNCTION void check_bounds(int i1, int i2, int i3, int n1, int n2,
#endif
}
KOKKOS_INLINE_FUNCTION
void
check_bounds_2d
(
int
i1
,
int
i2
,
int
n1
,
int
n2
)
{
#ifdef ENABLE_CHECK_BOUNDS_2D
assert
(
i1
>=
0
&&
i2
>=
0
&&
i1
<
n1
&&
i2
<
n2
);
#endif
}
void
scenario_1
(
double
*
array
,
int
nblocks
,
int
nlev
,
int
nproma
,
bool
print
=
true
)
{
if
(
print
)
std
::
cout
<<
"scenario 1: Default layout; view(array, nblocks, nlev, nproma); d_view(jb, jk, jc) ----- "
...
...
@@ -83,6 +90,33 @@ void scenario_1b(double* array, int nblocks, int nlev, int nproma) {
}
void
scenario_1c
(
double
*
array
,
int
nblocks
,
int
nlev
,
int
nproma
)
{
std
::
cout
<<
"scenario 1c: Default layout; view(array, ncells, nlev); d_view(jc, jk) ----- "
<<
std
::
endl
;
int
ncells
=
nblocks
*
nproma
;
Kokkos
::
View
<
double
**
,
Kokkos
::
MemoryUnmanaged
>
d_view
(
array
,
ncells
,
nlev
);
timer
.
reset
();
Kokkos
::
parallel_for
(
""
,
Kokkos
::
RangePolicy
<>
(
0
,
ncells
),
KOKKOS_LAMBDA
(
const
int
jc
)
{
for
(
int
jk
=
0
;
jk
<
nlev
;
++
jk
)
{
#if defined(DEMO_DEVICE)
int
p
=
jk
*
ncells
+
jc
;
#else
int
p
=
jc
*
nlev
+
jk
;
#endif
check_bounds_2d
(
jc
,
jk
,
d_view
.
extent
(
0
),
d_view
.
extent
(
1
));
d_view
(
jc
,
jk
)
=
p
;
}
});
Kokkos
::
fence
();
printf
(
"Time = %f ms
\n\n
"
,
timer
.
seconds
()
*
1000
);
}
void
scenario_2
(
double
*
array
,
int
nblocks
,
int
nlev
,
int
nproma
,
bool
print
=
true
)
{
if
(
print
)
std
::
cout
<<
"scenario 2: Right layout; view(array, nproma, nlev, nblocks); d_view(jc, jk, jb) ----- "
<<
std
::
endl
;
...
...
@@ -455,6 +489,10 @@ int main() {
std
::
function
<
void
(
double
*
,
int
,
int
,
int
)
>
s_1b
=
scenario_1b
;
openacc_calls
(
array
,
nblocks
,
nlev
,
nproma
,
s_1b
);
memset
(
array
,
0.0
,
sizeof
(
array
));
std
::
function
<
void
(
double
*
,
int
,
int
,
int
)
>
s_1c
=
scenario_1c
;
openacc_calls
(
array
,
nblocks
,
nlev
,
nproma
,
s_1c
);
memset
(
array
,
0.0
,
sizeof
(
array
));
std
::
function
<
void
(
double
*
,
int
,
int
,
int
)
>
s_7b
=
scenario_7b
;
openacc_calls
(
array
,
nblocks
,
nlev
,
nproma
,
s_7b
);
...
...
@@ -477,4 +515,4 @@ int main() {
Kokkos
::
finalize
();
return
0
;
}
\ No newline at end of file
}
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