-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementations for methods for machine_views and associated modules (#…
…1429) * initial commit for machine view adjacent modules * Formatting * Tests for new machine_view.cc functions * formatting * Minor Test correction * formatting * PR fixes * PR Fixes --------- Co-authored-by: Pietro Max Marsella <[email protected]>
- Loading branch information
Showing
8 changed files
with
216 additions
and
19 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
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
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
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,74 @@ | ||
#include "doctest/doctest.h" | ||
#include "pcg/machine_view.h" | ||
#include "pcg/strided_rectangle.h" | ||
#include "pcg/strided_rectangle_side.h" | ||
|
||
TEST_SUITE(FF_TEST_SUITE) { | ||
TEST_CASE("MachineView general util functions") { | ||
StridedRectangle rect{{StridedRectangleSide{num_points_t{7}, 5}, | ||
StridedRectangleSide{num_points_t{10}, 2}}}; | ||
gpu_id_t start(1); | ||
MachineView mv{device_id_t{start}, rect}; | ||
SUBCASE("num_dims") { | ||
CHECK(num_dims(mv) == 2); | ||
} | ||
SUBCASE("num_devices") { | ||
CHECK(num_devices(mv) == 7 * 10); | ||
} | ||
SUBCASE("get_device_type") { | ||
CHECK(get_device_type(mv) == DeviceType::GPU); | ||
} | ||
} | ||
|
||
TEST_CASE("MachineView make_1d_machine_view - GPU") { | ||
StridedRectangle rect{{StridedRectangleSide{num_points_t{7}, 5}}}; | ||
device_id_t start_gpu{gpu_id_t{1}}; | ||
MachineView gpu_mv{start_gpu, rect}; | ||
|
||
SUBCASE("make_1d_machine_view(gpu_id_t start, gpu_id_t stop, int stride)") { | ||
MachineView result = | ||
make_1d_machine_view(start_gpu, device_id_t{gpu_id_t(1 + 7 * 5)}, 5); | ||
MachineView correct = gpu_mv; | ||
CHECK(result == correct); | ||
} | ||
SUBCASE("make_1d_machine_view(gpu_id_t start, num_points_t num_points, int " | ||
"stride)") { | ||
MachineView result = make_1d_machine_view(start_gpu, num_points_t{7}, 5); | ||
MachineView correct = gpu_mv; | ||
CHECK(result == correct); | ||
} | ||
SUBCASE("make_1d_machine_view(gpu_id_t start, side_size_t interval_size, " | ||
"int stride)") { | ||
MachineView result = make_1d_machine_view( | ||
start_gpu, get_side_size(rect.sides.at(ff_dim_t{0})), 5); | ||
MachineView correct = gpu_mv; | ||
CHECK(result == correct); | ||
} | ||
} | ||
|
||
TEST_CASE("MachineView make_1d_machine_view - CPU") { | ||
StridedRectangle rect{{StridedRectangleSide{num_points_t{11}, 4}}}; | ||
device_id_t start_cpu{cpu_id_t{2}}; | ||
MachineView cpu_mv{start_cpu, rect}; | ||
|
||
SUBCASE("make_1d_machine_view(cpu_id_t start, cpu_id_t stop, int stride)") { | ||
MachineView result = | ||
make_1d_machine_view(start_cpu, device_id_t{cpu_id_t(2 + 11 * 4)}, 4); | ||
MachineView correct = cpu_mv; | ||
CHECK(result == correct); | ||
} | ||
SUBCASE("make_1d_machine_view(cpu_id_t start, num_points_t num_points, int " | ||
"stride)") { | ||
MachineView result = make_1d_machine_view(start_cpu, num_points_t{11}, 4); | ||
MachineView correct = cpu_mv; | ||
CHECK(result == correct); | ||
} | ||
SUBCASE("make_1d_machine_view(cpu_id_t start, side_size_t interval_size, " | ||
"int stride)") { | ||
MachineView result = make_1d_machine_view( | ||
start_cpu, get_side_size(rect.sides.at(ff_dim_t{0})), 4); | ||
MachineView correct = cpu_mv; | ||
CHECK(result == correct); | ||
} | ||
} | ||
} |
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,37 @@ | ||
#include "doctest/doctest.h" | ||
#include "pcg/strided_rectangle.h" | ||
#include "pcg/strided_rectangle_side.h" | ||
|
||
TEST_SUITE(FF_TEST_SUITE) { | ||
TEST_CASE("get_side_size(StridedRectangleSide)") { | ||
StridedRectangleSide side{num_points_t{7}, 5}; | ||
|
||
CHECK(get_side_size(side) == side_size_t{7 * 5}); | ||
} | ||
TEST_CASE("strided_side_from_size_and_stride") { | ||
StridedRectangleSide correct{num_points_t{10}, 3}; | ||
StridedRectangleSide result = | ||
strided_side_from_size_and_stride(side_size_t{10 * 3}, 3); | ||
CHECK(result == correct); | ||
} | ||
|
||
TEST_CASE("StridedRectangle - helper functions") { | ||
|
||
StridedRectangleSide s0{num_points_t{7}, 5}; | ||
StridedRectangleSide s1{num_points_t{10}, 2}; | ||
StridedRectangleSide s2{num_points_t{8}, 1}; | ||
StridedRectangle rect{{s0, s1, s2}}; | ||
|
||
SUBCASE("get_num_dims") { | ||
CHECK(get_num_dims(rect) == 3); | ||
} | ||
SUBCASE("get_num_points") { | ||
CHECK(get_num_points(rect) == num_points_t{7 * 8 * 10}); | ||
} | ||
SUBCASE("get_side_at_idx") { | ||
CHECK(get_side_at_idx(rect, ff_dim_t{0}) == s0); | ||
CHECK(get_side_at_idx(rect, ff_dim_t{1}) == s1); | ||
CHECK(get_side_at_idx(rect, ff_dim_t{2}) == s2); | ||
} | ||
} | ||
} |