diff options
| author | tylov <[email protected]> | 2023-07-08 14:00:23 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-07-08 14:00:23 +0200 |
| commit | 2d1011251596edee16d3bd6afb0e3c3b9df1157b (patch) | |
| tree | bde4e7fd426ef52678590fb5b2e7e4af63b1fb9b /misc | |
| parent | 3a26c8fe4bce8a3af62042dd0fca5f36221359a9 (diff) | |
| download | STC-modified-2d1011251596edee16d3bd6afb0e3c3b9df1157b.tar.gz STC-modified-2d1011251596edee16d3bd6afb0e3c3b9df1157b.zip | |
Added support for column-major md cspan.
API change: the create function cspan_md(order, array, d1, d2, ...) has the new first argument order, which must be either 'C' or 'F' (C: row-major or Fortran: column-major). The representation of strides was changed.
Diffstat (limited to 'misc')
| -rw-r--r-- | misc/benchmarks/various/cspan_bench.c | 12 | ||||
| -rw-r--r-- | misc/benchmarks/various/string_bench_STC.cpp | 5 | ||||
| -rw-r--r-- | misc/examples/multidim.c | 2 | ||||
| -rw-r--r-- | misc/tests/cspan_test.c | 10 |
4 files changed, 15 insertions, 14 deletions
diff --git a/misc/benchmarks/various/cspan_bench.c b/misc/benchmarks/various/cspan_bench.c index 02ae3237..6ca7425d 100644 --- a/misc/benchmarks/various/cspan_bench.c +++ b/misc/benchmarks/various/cspan_bench.c @@ -28,8 +28,8 @@ static void MDRanges_setup(intptr_t state) for (intptr_t s = 0; s < state; ++s) { - MD3 r_in = cspan_md(Vin, nx, ny, nz); - MD3 r_out = cspan_md(Vout, nx, ny, nz); + MD3 r_in = cspan_md('C', Vin, nx, ny, nz); + MD3 r_out = cspan_md('C', Vout, nx, ny, nz); r_in = cspan_slice(MD3, &r_in, {lx, hx}, {ly, hy}, {lz, hz}); r_out = cspan_slice(MD3, &r_out, {lx, hx}, {ly, hy}, {lz, hz}); @@ -64,8 +64,8 @@ static void TraditionalForLoop(intptr_t state) static void MDRanges_nested_loop(intptr_t state) { - MD3 r_in = cspan_md(Vin, nx, ny, nz); - MD3 r_out = cspan_md(Vout, nx, ny, nz); + MD3 r_in = cspan_md('C', Vin, nx, ny, nz); + MD3 r_out = cspan_md('C', Vout, nx, ny, nz); r_in = cspan_slice(MD3, &r_in, {lx, hx}, {ly, hy}, {lz, hz}); r_out = cspan_slice(MD3, &r_out, {lx, hx}, {ly, hy}, {lz, hz}); @@ -91,8 +91,8 @@ static void MDRanges_nested_loop(intptr_t state) static void MDRanges_loop_over_joined(intptr_t state) { - MD3 r_in = cspan_md(Vin, nx, ny, nz); - MD3 r_out = cspan_md(Vout, nx, ny, nz); + MD3 r_in = cspan_md('C', Vin, nx, ny, nz); + MD3 r_out = cspan_md('C', Vout, nx, ny, nz); r_in = cspan_slice(MD3, &r_in, {lx, hx}, {ly, hy}, {lz, hz}); r_out = cspan_slice(MD3, &r_out, {lx, hx}, {ly, hy}, {lz, hz}); diff --git a/misc/benchmarks/various/string_bench_STC.cpp b/misc/benchmarks/various/string_bench_STC.cpp index ae8e4c38..319b0b19 100644 --- a/misc/benchmarks/various/string_bench_STC.cpp +++ b/misc/benchmarks/various/string_bench_STC.cpp @@ -4,10 +4,11 @@ #include <iostream> #include <iomanip> #include <chrono> -#define i_static +#define i_implement #include <stc/cstr.h> // string -#define i_static +#define i_implement #include <stc/csview.h> // string_view +#include <stc/algo/raii.h> #define i_key_str #include <stc/cvec.h> // vec of cstr with const char* lookup diff --git a/misc/examples/multidim.c b/misc/examples/multidim.c index 2f3ad907..df8f485d 100644 --- a/misc/examples/multidim.c +++ b/misc/examples/multidim.c @@ -14,7 +14,7 @@ int main() ispan ms1 = cspan_from(&v); // View the same data as a 3D array 2 x 3 x 4 - ispan3 ms3 = cspan_md(v.data, 2, 3, 4); + ispan3 ms3 = cspan_md('C', v.data, 2, 3, 4); puts("ms3:"); for (int i=0; i != ms3.shape[0]; i++) { diff --git a/misc/tests/cspan_test.c b/misc/tests/cspan_test.c index 9afa63f5..d266fa38 100644 --- a/misc/tests/cspan_test.c +++ b/misc/tests/cspan_test.c @@ -8,7 +8,7 @@ using_cspan3(intspan, int); CTEST(cspan, subdim) { int array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; - intspan3 m = cspan_md(array, 2, 2, 3); + intspan3 m = cspan_md('C', array, 2, 2, 3); for (size_t i = 0; i < m.shape[0]; ++i) { intspan2 sub_i = cspan_submd3(&m, i); @@ -23,7 +23,7 @@ CTEST(cspan, subdim) { CTEST(cspan, slice) { int array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; - intspan2 m1 = cspan_md(array, 3, 4); + intspan2 m1 = cspan_md('C', array, 3, 4); size_t sum1 = 0; for (size_t i = 0; i < m1.shape[0]; ++i) { @@ -53,7 +53,7 @@ CTEST(cspan, slice2) { c_forrange (i, 10*20*30) cstack_int_push(&stack, i); - intspan3 ms3 = cspan_md(stack.data, 10, 20, 30); + intspan3 ms3 = cspan_md('C', stack.data, 10, 20, 30); ms3 = cspan_slice(intspan3, &ms3, {1,4}, {3,7}, {20,24}); size_t sum = 0; @@ -93,7 +93,7 @@ CTEST_SETUP(cspan_cube) { c_forrange (i, N) cstack_int_push(&_self->stack, i+1); - intspan3 ms3 = cspan_md(_self->stack.data, CUBE, CUBE, CUBE); + intspan3 ms3 = cspan_md('C', _self->stack.data, CUBE, CUBE, CUBE); c_forrange (i, 0, ms3.shape[0], TSIZE) { c_forrange (j, 0, ms3.shape[1], TSIZE) { @@ -114,7 +114,7 @@ CTEST_TEARDOWN(cspan_cube) { CTEST_F(cspan_cube, slice3) { intptr_t n = cstack_int_size(&_self->stack); - //printf("\ntiles: %zi, cells: %zi\n", Tiles_size(&_self->tiles), n); + //printf("\ntiles: %d, cells: %d\n", (int)Tiles_size(&_self->tiles), (int)n); int64_t sum = 0; // iterate each 3d tile in sequence |
