codes-workload-test.c 3.23 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * Copyright (C) 2013 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
 */

/* SUMMARY:
 *
 * This is a test harness for the codes workload API.  It sets up two LP
 * types: clients (which consume operations from the workload generator) and
 * servers (which service operations submitted by clients).
 *
 */

#include <string.h>
#include <assert.h>
#include <ross.h>

#include "codes/lp-io.h"
#include "codes/codes.h"
#include "codes/codes-workload.h"
22
#include "codes/configuration.h"
23
24
25
26
27
28
29
30
31
32
33
#include "codes-workload-test-svr-lp.h"
#include "codes-workload-test-cn-lp.h"

#define NUM_SERVERS 16  /* number of servers */
#define NUM_CLIENTS 48  /* number of clients */

const tw_optdef app_opt[] = {
    TWOPT_GROUP("CODES Workload Test Model"),
    TWOPT_END()
};

34
35
36
37
38
static int num_clients_per_lp = -1;

void workload_set_params()
{
    config_lpgroups_t paramconf;
Jonathan Jenkins's avatar
Jonathan Jenkins committed
39
40
    char io_kernel_meta_path[MAX_NAME_LENGTH_WKLD];
    char bgp_config_file[MAX_NAME_LENGTH_WKLD];
41
42
43
    
    configuration_get_lpgroups(&config, "PARAMS", &paramconf);

Jonathan Jenkins's avatar
Jonathan Jenkins committed
44
    configuration_get_value(&config, "PARAMS", "workload_type", workload_type, MAX_NAME_LENGTH_WKLD);
45
46
    if(strcmp(workload_type,"bgp_io_workload") == 0)
    {
47
48
49
50
51
52
        strcpy(bgparams.io_kernel_path,"");
        strcpy(bgparams.io_kernel_def_path, "");
	    bgparams.num_cns = NUM_CLIENTS;

        configuration_get_value(&config, "PARAMS", "io_kernel_meta_path", io_kernel_meta_path, MAX_NAME_LENGTH_WKLD);
        strcpy(bgparams.io_kernel_meta_path, io_kernel_meta_path);
53
        
54
55
        configuration_get_value(&config, "PARAMS", "bgp_config_file", bgp_config_file, MAX_NAME_LENGTH_WKLD);
        strcpy(bgparams.bgp_config_file, bgp_config_file);
56
57
58
    }
}

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
int main(
    int argc,
    char **argv)
{
    int nprocs;
    int rank;
    int lps_per_proc;
    int i;
    int ret;
    lp_io_handle handle;

    g_tw_ts_end = 60*60*24*365;

    tw_opt_add(app_opt);
    tw_init(&argc, &argv);
 
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
  
    if((NUM_SERVERS + NUM_CLIENTS) % nprocs)
    {
        fprintf(stderr, "Error: number of server LPs (%d total) is not evenly divisible by the number of MPI processes (%d)\n", NUM_SERVERS+NUM_CLIENTS, nprocs);
        exit(-1);
    }

84
85
86
87
88
89
    if(argc < 2)
    {
        printf("\n Usage: mpirun <args> --sync=2/3 mapping_file_name.conf (optional --nkp) ");
        exit(-1);
    }

90
91
    lps_per_proc = (NUM_SERVERS+NUM_CLIENTS) / nprocs;

92
93
94
95
96
    num_clients_per_lp = NUM_CLIENTS / nprocs;

    configuration_load(argv[2], MPI_COMM_WORLD, &config);


97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
    tw_define_lps(lps_per_proc, 512, 0);

    for(i=0; i<lps_per_proc; i++)
    {
        if((rank*lps_per_proc + i) < NUM_CLIENTS)
            tw_lp_settype(i, &client_lp);
        else
            tw_lp_settype(i, &svr_lp);
    }

    cn_set_params(NUM_CLIENTS, NUM_SERVERS);

    g_tw_lookahead = 100;

    ret = lp_io_prepare("codes-workload-test-results", LP_IO_UNIQ_SUFFIX, &handle, MPI_COMM_WORLD);
    if(ret < 0)
    {
       return(-1); 
    }

117
    workload_set_params();
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
    tw_run();

    ret = lp_io_flush(handle, MPI_COMM_WORLD);
    assert(ret == 0);

    tw_end();

    return 0;
}

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 * End:
 *
 * vim: ft=c ts=8 sts=4 sw=4 expandtab
 */