2
Copyright (C) 2008- The University of Notre Dame
3
This software is distributed under the GNU General Public License.
4
See the file COPYING for details.
7
#include "chirp_matrix.h"
11
#include "timestamp.h"
23
int main( int argc, char *argv[] )
25
auth_register_byname("hostname");
27
debug_config(argv[0]);
30
//debug_flags_set("chirp");
33
printf("use: %s <host> <path> <width> <height> <nhosts> <ops>\n",argv[0]);
38
timestamp_t start, stop;
39
const char *host = argv[1];
40
const char *path = argv[2];
41
int width = atoi(argv[3]);
42
int height = atoi(argv[4]);
43
int nhosts = atoi(argv[5]);
44
int randlimit = atoi(argv[6]);
45
time_t stoptime = time(0) + 3600;
47
double *data = malloc(width*8);
49
struct chirp_matrix *matrix;
51
matrix = chirp_matrix_open(host,path,stoptime);
53
if(chirp_matrix_width(matrix)==width && chirp_matrix_height(matrix)==height && chirp_matrix_nhosts(matrix)==nhosts) {
56
chirp_matrix_close(matrix,stoptime);
57
chirp_matrix_delete(host,path,stoptime);
63
matrix = chirp_matrix_create(host,path,width,height,sizeof(double),nhosts,stoptime);
65
printf("couldn't create matrix: %s\n",strerror(errno));
69
start = timestamp_get();
70
for(i=0;i<height;i++) {
71
chirp_matrix_set_row(matrix,i,data,stoptime);
73
chirp_matrix_fsync(matrix,stoptime);
74
stop = timestamp_get();
75
printf("init %8.0lf cells/sec\n",1000000.0*(height*width)/(stop-start));
79
/*--------------------------------------------------------------------*/
81
start = timestamp_get();
82
for(i=0;i<randlimit;i++) {
83
chirp_matrix_get_row(matrix,rand()%height,data,stoptime);
85
stop = timestamp_get();
86
printf("rowread %8.0lf cells/sec\n",1000000.0*(randlimit*width)/(stop-start));
88
/*--------------------------------------------------------------------*/
90
start = timestamp_get();
91
for(i=0;i<randlimit;i++) {
92
chirp_matrix_set_row(matrix,rand()%height,data,stoptime);
94
chirp_matrix_fsync(matrix,stoptime);
95
stop = timestamp_get();
96
printf("rowwrite %8.0lf cells/sec\n",1000000.0*(randlimit*width)/(stop-start));
98
/*--------------------------------------------------------------------*/
100
start = timestamp_get();
101
for(i=0;i<randlimit;i++) {
102
chirp_matrix_get_col(matrix,rand()%width,data,stoptime);
104
stop = timestamp_get();
105
printf("colread %8.0lf cells/sec\n",1000000.0*(randlimit*height)/(stop-start));
107
/*--------------------------------------------------------------------*/
109
start = timestamp_get();
110
for(i=0;i<randlimit;i++) {
111
chirp_matrix_set_col(matrix,rand()%width,data,stoptime);
113
chirp_matrix_fsync(matrix,stoptime);
114
stop = timestamp_get();
115
printf("colwrite %8.0lf cells/sec\n",1000000.0*(randlimit*height)/(stop-start));
117
/*--------------------------------------------------------------------*/
119
start = timestamp_get();
120
for(i=0;i<randlimit;i++) {
121
chirp_matrix_get(matrix,rand()%width,rand()%height,data,stoptime);
123
stop = timestamp_get();
124
printf("cellread %8.0lf cells/sec\n",1000000.0*randlimit/(stop-start));
126
/*--------------------------------------------------------------------*/
128
start = timestamp_get();
129
for(i=0;i<randlimit;i++) {
130
chirp_matrix_set(matrix,rand()%width,rand()%height,data,stoptime);
132
chirp_matrix_fsync(matrix,stoptime);
133
stop = timestamp_get();
134
printf("cellwrite %8.0lf cells/sec\n",1000000.0*randlimit/(stop-start));
136
/*-------------------------------------------------------------------*/