-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
689 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
source/framework/algorithm/include/lue/framework/algorithm/cell_index.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
#include "lue/framework/algorithm/policy.hpp" | ||
#include "lue/framework/partitioned_array.hpp" | ||
|
||
|
||
namespace lue { | ||
|
||
template<typename Policies, Rank rank> | ||
auto cell_index( | ||
Policies const& policies, | ||
PartitionedArray<policy::InputElementT<Policies, 0>, rank> const& condition, | ||
Index dimension_idx) -> PartitionedArray<policy::OutputElementT<Policies, 0>, rank>; | ||
|
||
} // namespace lue |
29 changes: 29 additions & 0 deletions
29
source/framework/algorithm/include/lue/framework/algorithm/default_policies/cell_index.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#include "lue/framework/algorithm/cell_index.hpp" | ||
|
||
|
||
namespace lue { | ||
namespace policy::cell_index { | ||
|
||
template<typename IndexElement, typename ConditionElement> | ||
using DefaultPolicies = policy::DefaultPolicies< | ||
AllValuesWithinDomain<ConditionElement>, | ||
OutputElements<IndexElement>, | ||
InputElements<ConditionElement>>; | ||
|
||
} // namespace policy::cell_index | ||
|
||
|
||
namespace default_policies { | ||
|
||
template<typename IndexElement, typename ConditionElement, Rank rank> | ||
auto cell_index(PartitionedArray<ConditionElement, rank> const& condition, Index const dimension_idx) | ||
-> PartitionedArray<IndexElement, rank> | ||
{ | ||
using Policies = policy::cell_index::DefaultPolicies<IndexElement, ConditionElement>; | ||
|
||
return cell_index(Policies{}, condition, dimension_idx); | ||
} | ||
|
||
} // namespace default_policies | ||
} // namespace lue |
526 changes: 526 additions & 0 deletions
526
source/framework/algorithm/include/lue/framework/algorithm/definition/cell_index.hpp
Large diffs are not rendered by default.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
source/framework/algorithm/include/lue/framework/algorithm/value_policies/cell_index.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#include "lue/framework/algorithm/cell_index.hpp" | ||
|
||
|
||
namespace lue { | ||
namespace policy::cell_index { | ||
|
||
template<typename IndexElement, typename ConditionElement> | ||
using DefaultValuePolicies = policy::DefaultValuePolicies< | ||
AllValuesWithinDomain<ConditionElement>, | ||
OutputElements<IndexElement>, | ||
InputElements<ConditionElement>>; | ||
|
||
} // namespace policy::cell_index | ||
|
||
|
||
namespace value_policies { | ||
|
||
template<typename IndexElement, typename ConditionElement, Rank rank> | ||
auto cell_index(PartitionedArray<ConditionElement, rank> const& condition, Index const dimension_idx) | ||
-> PartitionedArray<IndexElement, rank> | ||
{ | ||
using Policies = policy::cell_index::DefaultValuePolicies<IndexElement, ConditionElement>; | ||
|
||
return cell_index(Policies{}, condition, dimension_idx); | ||
} | ||
|
||
} // namespace value_policies | ||
} // namespace lue |
13 changes: 13 additions & 0 deletions
13
source/framework/algorithm/src/local_operation/cell_index.cpp.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "lue/framework/algorithm/default_policies/cell_index.hpp" | ||
#include "lue/framework/algorithm/definition/cell_index.hpp" | ||
#include "lue/framework/algorithm/value_policies/cell_index.hpp" | ||
|
||
|
||
namespace lue { | ||
|
||
LUE_INSTANTIATE_CELL_INDEX( | ||
ESC(policy::cell_index::{{ Policies }}<{{ IndexElement }}, {{ ConditionElement }}>), | ||
{{ rank }} | ||
); | ||
|
||
} // namespace lue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
source/framework/python/src/algorithm/local_operation/cell_index.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "lue/framework/algorithm/value_policies/cell_index.hpp" | ||
#include <pybind11/pybind11.h> | ||
|
||
|
||
namespace lue::framework { | ||
namespace { | ||
|
||
using ConditionElement = std::uint8_t; | ||
using IndexElement = std::uint64_t; | ||
|
||
template<Rank rank> | ||
auto cell_index(PartitionedArray<ConditionElement, rank> const& condition, Index const dimension_idx) | ||
-> PartitionedArray<IndexElement, rank> | ||
{ | ||
return value_policies::cell_index<IndexElement>(condition, dimension_idx); | ||
} | ||
|
||
} // Anonymous namespace | ||
|
||
|
||
void bind_cell_index(pybind11::module& module) | ||
{ | ||
module.def("cell_idx", cell_index<2>); | ||
} | ||
|
||
} // namespace lue::framework |
20 changes: 20 additions & 0 deletions
20
source/framework/python/test/algorithm/local_operation/cell_index_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import numpy as np | ||
|
||
import lue.framework as lfr | ||
import lue_test | ||
|
||
|
||
def setUpModule(): | ||
lue_test.start_hpx_runtime() | ||
|
||
|
||
def tearDownModule(): | ||
lue_test.stop_hpx_runtime() | ||
|
||
|
||
class CellIndexTest(lue_test.TestCase): | ||
@lue_test.framework_test_case | ||
def test_overloads(self): | ||
array_shape = (60, 40) | ||
condition = lfr.create_array(array_shape, np.uint8, 1) | ||
lfr.cell_index(condition, 0) |