Skip to content

Commit

Permalink
ckp
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisHeimbigner committed Aug 17, 2023
1 parent adb696a commit 0d1f20d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
6 changes: 6 additions & 0 deletions nczarr_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ IF(ENABLE_TESTS)
TARGET_INCLUDE_DIRECTORIES(tst_chunkcases PUBLIC ../libnczarr)
add_sh_test(nczarr_test run_chunkcases)

if(LARGE_FILE_TESTS)
BUILD_BIN_TEST(test_readcaching})
BUILD_BIN_TEST(test_writecaching})
add_sh_test(nczarr_test run_cachetest)
ENDIF()

add_sh_test(nczarr_test run_purezarr)
add_sh_test(nczarr_test run_interop)
add_sh_test(nczarr_test run_misc)
Expand Down
8 changes: 5 additions & 3 deletions nczarr_test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ ut_projections_SOURCES = ut_projections.c ${commonsrc}
ut_chunking_SOURCES = ut_chunking.c ${commonsrc}
tst_fillonlyz_SOURCES = tst_fillonlyz.c ${tstcommonsrc}

check_PROGRAMS += test_readcaching test_writecaching
TESTS += test_readcaching test_writecaching

check_PROGRAMS += tst_zchunks tst_zchunks2 tst_zchunks3 tst_fillonlyz test_quantize tst_notzarr

TESTS += run_ut_chunk.sh
Expand Down Expand Up @@ -69,6 +66,11 @@ TESTS += run_nulls.sh
TESTS += run_notzarr.sh
TESTS += run_external.sh

if LARGE_FILE_TESTS
check_PROGRAMS += test_writecaching test_readcaching
TESTS += run_cachetest.sh
endif

endif #BUILD_UTILITIES

if BUILD_UTILITIES
Expand Down
18 changes: 9 additions & 9 deletions nczarr_test/test_readcaching.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#include "netcdf.h"

#include <stdlib.h>
#include <stdio.h>

#include <unistd.h>
#include <sys/resource.h>

#if defined(__APPLE__) && defined(__MACH__)
#include <mach/mach.h>
#endif

#include "netcdf.h"

#define filename "file://tmp_cachetest.zarr#mode=zarr,file"
#define chunkSize (size_t)(1<<17) /* 128k */
#define numCells (size_t)(50 * chunkSize)
#define numSteps (size_t)360

static float var[numCells];

size_t getPeakRSS(void)
{
struct rusage rusage;
Expand All @@ -34,11 +40,6 @@ nce(int istat)
int
main(void)
{
const char *filename = "file://tmp_readcaching.zarr#mode=zarr,file";
const size_t chunkSize = 262144; // 256k
const size_t numCells = 50 * chunkSize;
const size_t numSteps = 360;

printf("read: chunkSize=%zu, numCells=%zu, numSteps=%zu, filename=%s\n", chunkSize, numCells, numSteps, filename);

int ncId;
Expand All @@ -58,7 +59,6 @@ main(void)
printf("set chunk cache: size=%zu, nelems=%zu, preemption=%g\n", size, nelems, preemption);

{
float* var = calloc(sizeof(float),numCells);
for (size_t i = 0; i < numCells; ++i) var[i] = 0.0f;
for (size_t i = 0; i < numSteps; ++i)
{
Expand Down
21 changes: 10 additions & 11 deletions nczarr_test/test_writecaching.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#include "netcdf.h"

#include <stdlib.h>
#include <stdio.h>

#include <unistd.h>
#include <sys/resource.h>

#if defined(__APPLE__) && defined(__MACH__)
#include <mach/mach.h>
#endif

#include "netcdf.h"

#define filename "file://tmp_cachetest.zarr#mode=zarr,file"
#define chunkSize ((size_t)(1<<17)) /* 128k */
#define numCells ((size_t)(50 * chunkSize))
#define numSteps ((size_t)360)

static float var[numCells];

size_t getPeakRSS(void)
{
struct rusage rusage;
Expand All @@ -34,11 +39,6 @@ nce(int istat)
int
main(void)
{
const char *filename = "file://tmp_writecaching.zarr#mode=zarr,file";
const size_t chunkSize = 262144; // 256k
const size_t numCells = 50 * chunkSize;
const size_t numSteps = 360;

printf("write: chunkSize=%zu, numCells=%zu, numSteps=%zu, filename=%s\n", chunkSize, numCells, numSteps, filename);

int ncId;
Expand Down Expand Up @@ -72,7 +72,6 @@ main(void)
nce(nc_enddef(ncId));

{
float* var = calloc(sizeof(float),numCells);
for (size_t i = 0; i < numCells; ++i) var[i] = 0.0f;
for (size_t i = 0; i < numSteps; ++i)
{
Expand All @@ -92,7 +91,7 @@ main(void)
printf("*** Failed: used: %luMB expected: < 100MB\n",mbused);
return (1);
} else {
printf("*** Passed: used: %luMB (< 100MB\)n",mbused);
printf("*** Passed: used: %luMB (< 100MB)\n",mbused);
return 0;
}
}
Expand Down

0 comments on commit 0d1f20d

Please sign in to comment.