Commit e45c249e authored by Matthieu Dorier's avatar Matthieu Dorier

added optional timers activated with --enable-timers and corrected --enable-sizecheck

parent a9e5850a
......@@ -90,7 +90,13 @@ AC_ARG_ENABLE([sizecheck],
AS_HELP_STRING([--enable-sizecheck], [Adds a header in regions to keep track of region sizes (may degrade performance) @<:@default=no@:>@]),
[AS_CASE(${enableval}, [yes], [AC_DEFINE([USE_SIZECHECK_HEADERS], 1, [Enable sizecheck])], [no], [],
[AC_MSG_ERROR([bad value ${enableval} for --enable-sizecheck])])],
[enable_sizecheck=yes])
[enable_sizecheck=no])
AC_ARG_ENABLE([timers],
AS_HELP_STRING([--enable-timers], [Print detailed timers from each function on stdout @<:@default=no@:>@]),
[AS_CASE(${enableval}, [yes], [AC_DEFINE([ENABLE_TIMING], 1, [Enable timers])], [no], [],
[AC_MSG_ERROR([bad value ${enableval} for --enable-timers])])],
[enable_timers=no])
AC_CONFIG_FILES([Makefile maint/bake-client.pc maint/bake-server.pc])
AC_OUTPUT
This diff is collapsed.
......@@ -35,16 +35,17 @@ int main(int argc, char **argv)
int fd;
char* local_region;
int region_fd;
uint64_t check_size;
uint64_t size;
if(argc != 5)
if(argc != 6)
{
fprintf(stderr, "Usage: bake-copy-from <server addr> <mplex id> <identifier file> <output file>\n");
fprintf(stderr, " Example: ./bake-copy-from tcp://localhost:1234 3 /tmp/bb-copy-rid.0GjOlu /tmp/output.dat\n");
fprintf(stderr, "Usage: bake-copy-from <server addr> <mplex id> <identifier file> <output file> <size>\n");
fprintf(stderr, " Example: ./bake-copy-from tcp://localhost:1234 3 /tmp/bb-copy-rid.0GjOlu /tmp/output.dat 256\n");
return(-1);
}
svr_addr_str = argv[1];
mplex_id = atoi(argv[2]);
size = atol(argv[5]);
/* initialize Margo using the transport portion of the server
* address (i.e., the part before the first : character if present)
......@@ -110,6 +111,8 @@ int main(int argc, char **argv)
}
close(region_fd);
#ifdef USE_SIZECHECK_HEADERS
uint64_t check_size;
ret = bake_get_size(bph, rid, &check_size);
if(ret != 0)
{
......@@ -120,6 +123,15 @@ int main(int argc, char **argv)
margo_finalize(mid);
return(-1);
}
if(check_size != size) {
fprintf(stderr, "Error: incorrect size provided\n");
bake_provider_handle_release(bph);
margo_addr_free(mid, svr_addr);
bake_client_finalize(bcl);
margo_finalize(mid);
return(-1);
}
#endif
fd = open(argv[4], O_RDWR|O_TRUNC|O_CREAT, S_IRUSR|S_IWUSR);
if(fd < 0)
......@@ -132,7 +144,7 @@ int main(int argc, char **argv)
return(-1);
}
ret = ftruncate(fd, check_size);
ret = ftruncate(fd, size);
if(ret < 0)
{
perror("ftruncate");
......@@ -144,7 +156,7 @@ int main(int argc, char **argv)
return(-1);
}
local_region = mmap(NULL, check_size, PROT_WRITE, MAP_SHARED, fd, 0);
local_region = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fd, 0);
if(local_region == MAP_FAILED)
{
perror("mmap");
......@@ -163,11 +175,11 @@ int main(int argc, char **argv)
rid,
0,
local_region,
check_size,
size,
&bytes_read);
if(ret != 0)
{
munmap(local_region, check_size);
munmap(local_region, size);
close(fd);
bake_provider_handle_release(bph);
margo_addr_free(mid, svr_addr);
......@@ -177,7 +189,7 @@ int main(int argc, char **argv)
return(-1);
}
munmap(local_region, check_size);
munmap(local_region, size);
close(fd);
bake_provider_handle_release(bph);
margo_addr_free(mid, svr_addr);
......
......@@ -193,6 +193,7 @@ int main(int argc, char **argv)
return(-1);
}
#ifdef USE_SIZECHECK_HEADERS
/* safety check size */
ret = bake_get_size(bph, rid, &check_size);
if(ret != 0)
......@@ -204,17 +205,18 @@ int main(int argc, char **argv)
fprintf(stderr, "Error: bake_get_size()\n");
return(-1);
}
bake_provider_handle_release(bph);
margo_addr_free(mid, svr_addr);
bake_client_finalize(bcl);
margo_finalize(mid);
if(check_size != statbuf.st_size)
{
fprintf(stderr, "Error: size mismatch!\n");
return(-1);
}
#endif
bake_provider_handle_release(bph);
margo_addr_free(mid, svr_addr);
bake_client_finalize(bcl);
margo_finalize(mid);
sprintf(region_file, "/tmp/bb-copy-rid.XXXXXX");
region_fd = mkstemp(region_file);
......
This diff is collapsed.
/*
* (C) 2015 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __BAKE_TIMING_H
#define __BAKE_TIMING_H
#define _GNU_SOURCE
#include <math.h>
#include "bake-config.h"
#ifdef ENABLE_TIMING
#define TIMERS_INITIALIZE(...) \
static const char* __timer_names[] = { __VA_ARGS__, NULL }; \
double* __timer_values = alloca(sizeof(__timer_values[0])*sizeof(__timer_names)/sizeof(__timer_names[1])); \
{ unsigned i = 0; for(i=0; i < sizeof(__timer_names)/sizeof(__timer_names[1]); i++) __timer_values[i] = NAN; } \
ABT_timer __timer; \
do { \
ABT_timer_create(&__timer); \
ABT_timer_start(__timer); \
} while(0)
#define TIMERS_FINALIZE() \
ABT_timer_stop(__timer); \
ABT_timer_free(&__timer); \
printf("TIMER %s: ", __FUNCTION__); \
do { unsigned i = 0; \
while(__timer_names[i] != NULL) { \
printf("%s=%f ", __timer_names[i], __timer_values[i]); \
i += 1; \
} \
printf("\n"); \
fflush(stdout); \
} while(0)
#define TIMERS_END_STEP(num) \
do { \
ABT_timer_stop_and_read(__timer, &__timer_values[num]); \
ABT_timer_start(__timer); \
} while(0);
#else
#define TIMERS_INITIALIZE(...)
#define TIMERS_FINALIZE()
#define TIMERS_END_STEP(num)
#endif
#endif
......@@ -33,7 +33,7 @@ fi
RID2=`echo "$CPOUT" | grep -o -P '/tmp.*$'`
# Reading from provider 1
run_to 10 src/bake-copy-from $svr1 1 $RID1 $TMPBASE/foo1-out.dat
run_to 10 src/bake-copy-from $svr1 1 $RID1 $TMPBASE/foo1-out.dat 27
if [ $? -ne 0 ]; then
run_to 10 src/bake-shutdown $svr1
wait
......@@ -44,7 +44,7 @@ cat $TMPBASE/foo1-out.dat
sleep 1
# Reading from provider 2
run_to 10 src/bake-copy-from $svr1 2 $RID2 $TMPBASE/foo2-out.dat
run_to 10 src/bake-copy-from $svr1 2 $RID2 $TMPBASE/foo2-out.dat 28
if [ $? -ne 0 ]; then
run_to 10 src/bake-shutdown $svr1
wait
......
......@@ -33,7 +33,7 @@ fi
RID2=`echo "$CPOUT" | grep -o -P '/tmp.*$'`
# Reading from target 1
run_to 10 src/bake-copy-from $svr1 1 $RID1 $TMPBASE/foo1-out.dat
run_to 10 src/bake-copy-from $svr1 1 $RID1 $TMPBASE/foo1-out.dat 25
if [ $? -ne 0 ]; then
run_to 10 src/bake-shutdown $svr1
wait
......@@ -44,7 +44,7 @@ cat $TMPBASE/foo1-out.dat
sleep 1
# Reading from target 2
run_to 10 src/bake-copy-from $svr1 1 $RID2 $TMPBASE/foo2-out.dat
run_to 10 src/bake-copy-from $svr1 1 $RID2 $TMPBASE/foo2-out.dat 26
if [ $? -ne 0 ]; then
run_to 10 src/bake-shutdown $svr1
wait
......
......@@ -21,7 +21,7 @@ if [ $? -ne 0 ]; then
fi
RID=`echo "$CPOUT" | grep -o -P '/tmp.*$'`
run_to 10 src/bake-copy-from $svr1 1 $RID $TMPBASE/foo-out.dat
run_to 10 src/bake-copy-from $svr1 1 $RID $TMPBASE/foo-out.dat 12
if [ $? -ne 0 ]; then
run_to 10 src/bake-shutdown $svr1
wait
......
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