Commit 49e8ab89 authored by Huihuo Zheng's avatar Huihuo Zheng
Browse files

organize test programs

parent b2968518
......@@ -137,7 +137,11 @@ void create_mmap(char *path, H5Dio_mmap &f) {
::pwrite(fh, &a, 1, ss);
fsync(fh);
close(fh);
#ifdef __APPLE__
f.fd = open(f.filename, O_RDWR);
#else
f.fd = open(f.filename, O_RDWR | O_DIRECT);
#endif
f.buf = mmap(NULL, ss, PROT_READ | PROT_WRITE, MAP_SHARED, f.fd, 0);
msync(f.buf, ss, MS_SYNC);
} else {
......
......@@ -7,7 +7,15 @@ HDF5_LIB=-L$(HDF5_ROOT)/lib -lhdf5
%.o: %.cpp
$(CXX) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
all: test_cache read_dataset_cache prepare_dataset
all: read_dataset_cache prepare_dataset
read_dataset_cache: read_dataset_cache.o H5Dio_cache.o ../utils/debug.o ../utils/profiling.o
$(CXX) $(CFLAGS) -o $@ read_dataset_cache.o H5Dio_cache.o ../utils/debug.o ../utils/profiling.o $(HDF5_LIB) -lpthread
prepare_dataset: prepare_dataset.o
$(CXX) $(CFLAGS) -o $@ $< $(HDF5_LIB)
test: test_mmap test_cache test_mmap_mem
test_mmap: test_mmap.o
$(CXX) $(CFLAGS) -o $@ $<
test_cache: test_cache.o ../utils/profiling.o
......@@ -15,9 +23,6 @@ test_cache: test_cache.o ../utils/profiling.o
test_mmap_mem: test_mmap_mem.o ../utils/profiling.o
$(CXX) $(CFLAGS) -o $@ $< ../utils/profiling.o
read_dataset_cache: read_dataset_cache.o H5Dio_cache.o ../utils/debug.o ../utils/profiling.o
$(CXX) $(CFLAGS) -o $@ read_dataset_cache.o H5Dio_cache.o ../utils/debug.o ../utils/profiling.o $(HDF5_LIB) -lpthread
prepare_dataset: prepare_dataset.o
$(CXX) $(CFLAGS) -o $@ $< $(HDF5_LIB)
clean:
rm -rf *.o read_dataset_cache prepare_dataset
rm -rf *.o read_dataset_cache prepare_dataset test_mmap test_cache test_mmap_mem
/*
This is the test program for studying the cache effect in POSIX I/O.
Normally, when we write data to the files. The system will keep a copy of the data in the
cache. So when we are reading the same data from the files, it actually read from the cache
instead of from the file system.
In order to avoid the cache effect, one can write more than one files, so by the time
reading the first file, the first file is already been pushed out of the cache.
The other way to avoid the cache effect is to separate out the read from the write. In the
benchmark, we do write first, and then do read in an independent run. The benchmarks script
allow us to do this.
Huihuo Zheng
- huihuo.zheng@anl.gov
*/
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <iostream>
#include "stdio.h"
#include "string.h"
......@@ -11,7 +27,6 @@
#include "mpi.h"
using namespace std;
int main(int argc, char **argv) {
int dim = 1024576;
int nbatch = 1024;
int niter = 10;
......@@ -84,7 +99,7 @@ int main(int argc, char **argv) {
tt.stop_clock("read");
if (rank==0) cout << "Read rate: " << sizeof(double)*dim*nbatch/tt["read"].t_iter[it]/1024/1024*nproc << endl;
close(fd);
//remove(fname);
remove(fname);
}
MPI_Finalize();
return 0;
......
/*
This program is to test the memory footprint when using
the memory mapped file.
In principle, when we map the files into a pointer, before accessing
the pointer, the amount of Resident set is the same, whereas the amount
of virtual memory is increased. Then when we start to access the memory
mapped file using the pointer, the amount of resisent set increases.
However, the increase will stop at certain point if it reach to the
maximum capacity of the physical memory of the system.
Huihuo Zheng
*/
#include <iostream>
#include <random>
#include <algorithm>
......@@ -139,7 +154,6 @@ int main(int argc, char **argv) {
msync(buf, size, MS_SYNC);
process_mem_usage(vm, rss);
if (rank==0) cout << "REMAP MSYNC -- VM: " << vm << "; RSS: " << rss << endl;
}
}
if (read)
......
......@@ -38,6 +38,7 @@
/*
Global variable to define information related to the local storage
*/
SSD_CACHE_IO
H5SSD = {
.mspace_total = 137438953472,
......
......@@ -16,6 +16,7 @@ void H5PthreadWait();
void test_mmap_buf();
// The meta data for I/O thread to perform write
typedef struct _thread_data_t {
// we will use the link structure in C to build the list of I/O tasks
char fname[255];
......@@ -33,6 +34,7 @@ typedef struct _thread_data_t {
void check_pthread_data(thread_data_t *pt);
// SSD cache
typedef struct _SSD_CACHE_IO {
int fd;
char fname[255];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment