diff options
| author | tylov <[email protected]> | 2023-07-11 16:36:55 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-07-11 16:36:55 +0200 |
| commit | afc968975a057f5b2653e3cfa51ef2eff83a8d5b (patch) | |
| tree | f0100b3ae35cd2a77a9648812e6e2ce198676f47 /misc | |
| parent | 8debe47bc014c41b6cf8082dcef4b87e4ef29cfa (diff) | |
| download | STC-modified-afc968975a057f5b2653e3cfa51ef2eff83a8d5b.tar.gz STC-modified-afc968975a057f5b2653e3cfa51ef2eff83a8d5b.zip | |
Internal updates and doc reorg.
Diffstat (limited to 'misc')
| -rw-r--r-- | misc/benchmarks/various/cspan_bench.c | 14 | ||||
| -rw-r--r-- | misc/benchmarks/various/string_bench_STD.cpp | 1 | ||||
| -rw-r--r-- | misc/examples/multidim.c | 1 |
3 files changed, 8 insertions, 8 deletions
diff --git a/misc/benchmarks/various/cspan_bench.c b/misc/benchmarks/various/cspan_bench.c index 6ca7425d..e724bdbd 100644 --- a/misc/benchmarks/various/cspan_bench.c +++ b/misc/benchmarks/various/cspan_bench.c @@ -12,8 +12,8 @@ enum { nz = 64 }; int lx = 15, ly = 10, lz = 5; -int hx = 20, hy = 15, hz = 15; -intptr_t n = 1000000; +int hx = 30, hy = 15, hz = 15; +intptr_t n = 100000; // define the contents of two nx x ny x nz arrays in and out double Vout[nx * ny * nz]; @@ -49,10 +49,10 @@ static void TraditionalForLoop(intptr_t state) for (int s = 0; s < state; ++s) { for (int x = lx; x < hx; ++x) { for (int y = ly; y < hy; ++y) { - for (int z = lz; z < hz; ++z) - { - double d = Vin[nz*(ny*x + y) + z]; - Vout[nz*(ny*x + y) + z] += d; + for (int z = lz; z < hz; ++z) { + int i = nz*(ny*x + y) + z; + double d = Vin[i]; + Vout[i] += d; sum += d; } } @@ -64,13 +64,13 @@ static void TraditionalForLoop(intptr_t state) static void MDRanges_nested_loop(intptr_t state) { + clock_t t = clock(); 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}); // C++23: for (auto [o, i] : std::views::zip(flat(r_out), flat(r_in))) { o = i; } - clock_t t = clock(); double sum = 0; for (intptr_t s = 0; s < state; ++s) { diff --git a/misc/benchmarks/various/string_bench_STD.cpp b/misc/benchmarks/various/string_bench_STD.cpp index 8bb87937..07934948 100644 --- a/misc/benchmarks/various/string_bench_STD.cpp +++ b/misc/benchmarks/various/string_bench_STD.cpp @@ -12,6 +12,7 @@ #include <unordered_map> #define i_static #include <stc/cstr.h> +#include <stc/algo/raii.h> std::vector<std::string> read_file(const char* name) { diff --git a/misc/examples/multidim.c b/misc/examples/multidim.c index df8f485d..43c21443 100644 --- a/misc/examples/multidim.c +++ b/misc/examples/multidim.c @@ -28,7 +28,6 @@ int main() } puts("ss3 = ms3[:, 1:3, 1:3]"); ispan3 ss3 = ms3; - //cspan_slice(&ss3, {c_ALL}, {1,3}, {1,3}); ss3 = cspan_slice(ispan3, &ms3, {c_ALL}, {1,3}, {1,3}); for (int i=0; i != ss3.shape[0]; i++) { |
