Commit 214f1e9d authored by Kaiyuan Hou's avatar Kaiyuan Hou
Browse files

add test program strided

parent 61640192
......@@ -5,7 +5,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
bin_PROGRAMS = src/provider/mochio-server
check_PROGRAMS = tests/simple
check_PROGRAMS = tests/simple \
tests/strided
src_provider_mochio_server_SOURCES = src/provider/server.c
src_provider_mochio_server_LDADD = lib/libmochio-provider.la
......@@ -28,13 +29,15 @@ noinst_HEADERS = include/io_stats.h \
include/calc-request.h \
include/file_stats.h
TESTS = tests/simple
TESTS = ${check_PROGRAMS}
tests_simple_SOURCES = tests/simple.c
tests_strided_SOURCES = tests/strided.c
# hack/trick to force linking with C++
# but all symbols are extern C so it should not be needed
#nodist_EXTRA_tests_simple_SOURCES = dummy.cc
tests_simple_LDADD = lib/libmochio-client.la
tests_strided_LDADD = lib/libmochio-client.la
pkgconfigdir = $(libdir)/pkgconfig
......
#include <string.h>
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <mochio.h>
#include <mpi.h>
#define VERBOSE 1
#define NSTRIDE 10
#define SSIZE 1024
int main(int argc, char **argv) {
int ret = 0;
int i, j;
int rank, np;
mochio_client_t client=NULL;
struct mochio_stats stats;
struct iovec write_vec, read_vec;
client = mochio_init(MPI_COMM_WORLD, argv[1]);
unsigned char *buf;
off_t offsets[NSTRIDE];
uint64_t lens[NSTRIDE];
char *filename;
#if 0
printf("delete:\n");
mochio_delete(client, filename);
#endif
MPI_Init(&argc, &argv);
if (argc == 3)
filename = argv[2];
else
filename = "dummy";
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &np);
printf("stat:");
mochio_stat(client, filename, &stats);
printf("got blocksize %ld stripe_count: %d stripe_size: %d from provider\n",
stats.blocksize, stats.stripe_count, stats.stripe_size);
printf("init write\n");
buf = (unsigned char*)malloc(NSTRIDE * SSIZE);
for(i = 0; i < NSTRIDE * SSIZE; i++){
buf[i] = rank + 1;
}
for(i = 0; i < NSTRIDE; i++){
offsets[i] = SSIZE * (i * np + rank);
lens[i] = SSIZE;
}
write_vec.iov_base = buf;
write_vec.iov_len = NSTRIDE * SSIZE;
printf("writing\n");
mochio_write(client, filename, 1, &write_vec, NSTRIDE, offsets, lens);
printf("flushing\n");
mochio_flush(client, filename);
printf("init read\n");
for(i = 0; i < NSTRIDE * SSIZE; i++){
buf[i] = 0;
}
offsets[0] = rank * NSTRIDE * SSIZE;
lens[0] = NSTRIDE * SSIZE;
read_vec.iov_base = buf;
read_vec.iov_len = NSTRIDE * SSIZE;
printf("reading\n");
mochio_read(client, filename, 1, &read_vec, 1, offsets, lens);
for(i = 0; i < NSTRIDE * SSIZE; i++){
j = (i / SSIZE) % np + 1;
if (buf[i] != j){
printf("Rank %d, Error: Expected: buf[%d] = %d got: %d\n", rank, i, j, buf[i]);
ret -= -1;
break;
}
}
free(buf);
#if VERBOSE
mochio_statistics(client);
#endif
mochio_finalize(client);
MPI_Finalize();
return ret;
}
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