Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
f402dfd8
Commit
f402dfd8
authored
Oct 4, 2018
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add fill and copy mechanisms
parent
64443540
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!11
Feature/mpi
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mesh/ItemValue.hpp
+20
-0
20 additions, 0 deletions
src/mesh/ItemValue.hpp
src/utils/Array.hpp
+24
-0
24 additions, 0 deletions
src/utils/Array.hpp
with
44 additions
and
0 deletions
src/mesh/ItemValue.hpp
+
20
−
0
View file @
f402dfd8
...
@@ -31,6 +31,16 @@ class ItemValue
...
@@ -31,6 +31,16 @@ class ItemValue
friend
ItemValue
<
std
::
add_const_t
<
DataType
>
,
friend
ItemValue
<
std
::
add_const_t
<
DataType
>
,
item_type
>
;
item_type
>
;
friend
PASTIS_INLINE
ItemValue
<
std
::
remove_const_t
<
DataType
>
,
item_type
>
copy
(
const
ItemValue
<
DataType
,
item_type
>&
source
)
{
ItemValue
<
std
::
remove_const_t
<
DataType
>
,
item_type
>
image
(
source
);
image
.
m_values
=
copy
(
source
.
m_values
);
return
image
;
}
public
:
public
:
PASTIS_FORCEINLINE
PASTIS_FORCEINLINE
const
bool
&
isBuilt
()
const
const
bool
&
isBuilt
()
const
...
@@ -45,6 +55,14 @@ class ItemValue
...
@@ -45,6 +55,14 @@ class ItemValue
return
m_values
.
size
();
return
m_values
.
size
();
}
}
PASTIS_INLINE
void
fill
(
const
DataType
&
data
)
const
{
static_assert
(
not
std
::
is_const
<
DataType
>
(),
"Cannot modify ItemValue of const"
);
m_values
.
fill
(
data
);
}
// Following Kokkos logic, these classes are view and const view does allow
// Following Kokkos logic, these classes are view and const view does allow
// changes in data
// changes in data
PASTIS_FORCEINLINE
PASTIS_FORCEINLINE
...
@@ -59,6 +77,8 @@ class ItemValue
...
@@ -59,6 +77,8 @@ class ItemValue
{
{
static_assert
(
std
::
is_same
<
IndexType
,
ItemId
>
(),
static_assert
(
std
::
is_same
<
IndexType
,
ItemId
>
(),
"ItemValue must be indexed by ItemId"
);
"ItemValue must be indexed by ItemId"
);
static_assert
(
not
std
::
is_const
<
DataType
>
(),
"Cannot modify ItemValue of const"
);
return
m_values
[
i
];
return
m_values
[
i
];
}
}
...
...
This diff is collapsed.
Click to expand it.
src/utils/Array.hpp
+
24
−
0
View file @
f402dfd8
...
@@ -33,6 +33,17 @@ class Array
...
@@ -33,6 +33,17 @@ class Array
return
m_values
[
i
];
return
m_values
[
i
];
}
}
PASTIS_INLINE
void
fill
(
const
DataType
&
data
)
const
{
static_assert
(
not
std
::
is_const
<
DataType
>
(),
"Cannot modify Array of const"
);
parallel_for
(
this
->
size
(),
PASTIS_LAMBDA
(
const
index_type
&
i
){
m_values
[
i
]
=
data
;
});
}
template
<
typename
DataType2
>
template
<
typename
DataType2
>
PASTIS_INLINE
PASTIS_INLINE
Array
&
operator
=
(
const
Array
<
DataType2
>&
array
)
Array
&
operator
=
(
const
Array
<
DataType2
>&
array
)
...
@@ -82,4 +93,17 @@ class Array
...
@@ -82,4 +93,17 @@ class Array
~
Array
()
=
default
;
~
Array
()
=
default
;
};
};
template
<
typename
DataType
>
PASTIS_INLINE
Array
<
std
::
remove_const_t
<
DataType
>>
copy
(
const
Array
<
DataType
>&
array
)
{
Array
<
std
::
remove_const_t
<
DataType
>>
image
(
array
.
size
());
using
index_type
=
typename
Array
<
DataType
>::
index_type
;
parallel_for
(
array
.
size
(),
PASTIS_LAMBDA
(
const
index_type
&
i
){
image
[
i
]
=
array
[
i
];
});
return
image
;
}
#endif // ARRAY_HPP
#endif // ARRAY_HPP
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