~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to chirp/src/chirp_matrix_benchmark.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-05-07 09:05:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110507090500-lqpmdtwndor6e7os
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
5
*/
 
6
 
 
7
#include "chirp_matrix.h"
 
8
 
 
9
#include "auth_all.h"
 
10
#include "debug.h"
 
11
#include "timestamp.h"
 
12
#include "macros.h"
 
13
 
 
14
#include <time.h>
 
15
#include <stdio.h>
 
16
#include <time.h>
 
17
#include <string.h>
 
18
#include <errno.h>
 
19
#include <stdlib.h>
 
20
#include <sys/time.h>
 
21
#include <sys/wait.h>
 
22
 
 
23
int main( int argc, char *argv[] )
 
24
{       
 
25
        auth_register_byname("hostname");
 
26
 
 
27
        debug_config(argv[0]);
 
28
        srand(time(0));
 
29
 
 
30
        //debug_flags_set("chirp");
 
31
 
 
32
        if(argc!=7) {
 
33
                printf("use: %s <host> <path> <width> <height> <nhosts> <ops>\n",argv[0]);
 
34
                return -1;
 
35
        }
 
36
 
 
37
        int i;
 
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;
 
46
 
 
47
        double *data = malloc(width*8);
 
48
 
 
49
        struct chirp_matrix *matrix;
 
50
 
 
51
        matrix = chirp_matrix_open(host,path,stoptime);
 
52
        if(matrix) {
 
53
                if(chirp_matrix_width(matrix)==width && chirp_matrix_height(matrix)==height && chirp_matrix_nhosts(matrix)==nhosts) {
 
54
                        /* ok, continue */
 
55
                } else {
 
56
                        chirp_matrix_close(matrix,stoptime);
 
57
                        chirp_matrix_delete(host,path,stoptime);
 
58
                        matrix = 0;
 
59
                }
 
60
        }
 
61
 
 
62
        if(!matrix) {
 
63
                matrix = chirp_matrix_create(host,path,width,height,sizeof(double),nhosts,stoptime);
 
64
                if(!matrix) {
 
65
                        printf("couldn't create matrix: %s\n",strerror(errno));
 
66
                        return 1;
 
67
                }
 
68
 
 
69
                start = timestamp_get();
 
70
                for(i=0;i<height;i++) {
 
71
                        chirp_matrix_set_row(matrix,i,data,stoptime);
 
72
                }
 
73
                chirp_matrix_fsync(matrix,stoptime);
 
74
                stop = timestamp_get();
 
75
                printf("init      %8.0lf cells/sec\n",1000000.0*(height*width)/(stop-start));
 
76
                sleep(1);
 
77
        }
 
78
 
 
79
        /*--------------------------------------------------------------------*/
 
80
 
 
81
        start = timestamp_get();
 
82
        for(i=0;i<randlimit;i++) {
 
83
                chirp_matrix_get_row(matrix,rand()%height,data,stoptime);
 
84
        }
 
85
        stop = timestamp_get();
 
86
        printf("rowread   %8.0lf cells/sec\n",1000000.0*(randlimit*width)/(stop-start));
 
87
 
 
88
        /*--------------------------------------------------------------------*/
 
89
 
 
90
        start = timestamp_get();
 
91
        for(i=0;i<randlimit;i++) {
 
92
                chirp_matrix_set_row(matrix,rand()%height,data,stoptime);
 
93
        }
 
94
        chirp_matrix_fsync(matrix,stoptime);
 
95
        stop = timestamp_get();
 
96
        printf("rowwrite  %8.0lf cells/sec\n",1000000.0*(randlimit*width)/(stop-start));
 
97
 
 
98
        /*--------------------------------------------------------------------*/
 
99
 
 
100
        start = timestamp_get();
 
101
        for(i=0;i<randlimit;i++) {
 
102
                chirp_matrix_get_col(matrix,rand()%width,data,stoptime);
 
103
        }
 
104
        stop = timestamp_get();
 
105
        printf("colread   %8.0lf cells/sec\n",1000000.0*(randlimit*height)/(stop-start));
 
106
 
 
107
        /*--------------------------------------------------------------------*/
 
108
 
 
109
        start = timestamp_get();
 
110
        for(i=0;i<randlimit;i++) {
 
111
                chirp_matrix_set_col(matrix,rand()%width,data,stoptime);
 
112
        }
 
113
        chirp_matrix_fsync(matrix,stoptime);
 
114
        stop = timestamp_get();
 
115
        printf("colwrite  %8.0lf cells/sec\n",1000000.0*(randlimit*height)/(stop-start));
 
116
 
 
117
        /*--------------------------------------------------------------------*/
 
118
 
 
119
        start = timestamp_get();
 
120
        for(i=0;i<randlimit;i++) {
 
121
                chirp_matrix_get(matrix,rand()%width,rand()%height,data,stoptime);
 
122
        }
 
123
        stop = timestamp_get();
 
124
        printf("cellread  %8.0lf cells/sec\n",1000000.0*randlimit/(stop-start));
 
125
 
 
126
        /*--------------------------------------------------------------------*/
 
127
 
 
128
        start = timestamp_get();
 
129
        for(i=0;i<randlimit;i++) {
 
130
                chirp_matrix_set(matrix,rand()%width,rand()%height,data,stoptime);
 
131
        }
 
132
        chirp_matrix_fsync(matrix,stoptime);
 
133
        stop = timestamp_get();
 
134
        printf("cellwrite %8.0lf cells/sec\n",1000000.0*randlimit/(stop-start));
 
135
 
 
136
        /*-------------------------------------------------------------------*/
 
137
 
 
138
 
 
139
        return 0;
 
140
}