-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from czgdp1807/mdspan_02
Prohibit modification of `std::vector` objects used by `Kokkos::mdspan` constructor
- Loading branch information
Showing
9 changed files
with
200 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <vector> | ||
#include <mdspan/mdspan.hpp> | ||
|
||
int main() { | ||
|
||
std::vector<double> arr1_data = {1.0, 2.0, 3.0, 2.0, 5.0, 7.0, 2.0, 5.0, 7.0}; | ||
|
||
Kokkos::mdspan<double, Kokkos::dextents<int32_t, 2>> arr1{arr1_data.data(), 3, 3}; | ||
|
||
arr1_data[0] = 4.0; | ||
|
||
return 0; | ||
} |
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,31 @@ | ||
#include <vector> | ||
#include <mdspan/mdspan.hpp> | ||
|
||
struct A { | ||
std::vector<double> arr1_data; | ||
}; | ||
|
||
int main1() { | ||
|
||
std::vector<double> arr2_data = {1.0, 2.0, 3.0, 2.0, 5.0, 7.0, 2.0, 5.0, 7.0}; | ||
std::vector<double> arr3_data = {1.0, 2.0, 3.0, 2.0, 5.0, 7.0, 2.0, 5.0, 7.0}; | ||
|
||
Kokkos::mdspan<double, Kokkos::dextents<int32_t, 2>> arr1{arr2_data.data(), 3, 3}; | ||
|
||
arr3_data[0] = 4.0; | ||
arr2_data[0] = 4.0; | ||
|
||
return 0; | ||
} | ||
|
||
int main() { | ||
|
||
struct A aobj; | ||
aobj.arr1_data = {1.0, 2.0, 3.0, 2.0, 5.0, 7.0, 2.0, 5.0, 7.0}; | ||
|
||
Kokkos::mdspan<double, Kokkos::dextents<int32_t, 2>> arr1{aobj.arr1_data.data(), 3, 3}; | ||
|
||
aobj.arr1_data[0] = 4.0; | ||
|
||
return 0; | ||
} |
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 @@ | ||
{ | ||
"basename": "asr-array_01_mdspan-3a0babe", | ||
"cmd": "lc --show-asr --no-color {infile} -o {outfile}", | ||
"infile": "tests/array_01_mdspan.cpp", | ||
"infile_hash": "89f0c42a5270d3e994901c745aeb9d6b6d005eb466f53abc3c6b0684", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": null, | ||
"stdout_hash": null, | ||
"stderr": "asr-array_01_mdspan-3a0babe.stderr", | ||
"stderr_hash": "75fae36610809dcd01894bb09490f3b174e656cf490f47aa38aa5caf", | ||
"returncode": 1 | ||
} |
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 @@ | ||
arr1_data is marked as read only. |
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 @@ | ||
{ | ||
"basename": "asr-array_02_mdspan-a54a3c5", | ||
"cmd": "lc --show-asr --no-color {infile} -o {outfile}", | ||
"infile": "tests/array_02_mdspan.cpp", | ||
"infile_hash": "0a58aca0631849d0d9f53e91255e409d79d6e8df0db2ce820f0f5d15", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": null, | ||
"stdout_hash": null, | ||
"stderr": "asr-array_02_mdspan-a54a3c5.stderr", | ||
"stderr_hash": "c335fe2f02049228933225c455954d7fb45ed1e5b318fafe53932c96", | ||
"returncode": 1 | ||
} |
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 @@ | ||
arr2_data is marked as read only. |
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