main.cpp 1.04 KB
Newer Older
perdacherMartin's avatar
perdacherMartin committed
1 2 3 4 5 6 7

#include <string.h>
#include <stdio.h>
#include <omp.h>

#include "util/allocation.h"
#include "util/arguments.h"
perdacherMartin's avatar
perdacherMartin committed
8
#include "util/dataIo.h"
perdacherMartin's avatar
perdacherMartin committed
9 10 11 12
#include "bmeans/blasmeans.h"


int main(int argc, char** argv) {
Martin Perdacher's avatar
Martin Perdacher committed
13
    size_t *members = NULL;
perdacherMartin's avatar
perdacherMartin committed
14 15
    double *x = NULL;
    CUtilTimer timer;
perdacherMartin's avatar
perdacherMartin committed
16
    char filename[] = "";
perdacherMartin's avatar
perdacherMartin committed
17
    double elapsed=0.0;
perdacherMartin's avatar
perdacherMartin committed
18
    bool isBinary = false;
perdacherMartin's avatar
perdacherMartin committed
19

Martin Perdacher's avatar
Martin Perdacher committed
20 21
    size_t threads = 0;
    size_t N=64, K=40, D=20;
perdacherMartin's avatar
perdacherMartin committed
22

perdacherMartin's avatar
perdacherMartin committed
23
    parsing_args(argc,argv, &N, &K, &D, &threads, filename, isBinary);
perdacherMartin's avatar
perdacherMartin committed
24 25 26 27 28

    if ( threads != 0 ){
        omp_set_num_threads(threads);
    }

Martin Perdacher's avatar
Martin Perdacher committed
29 30
    // const int n = 1024 * 1024 * N ;
    const int n = N ;
perdacherMartin's avatar
perdacherMartin committed
31 32 33
    const int d = D ;
    const int k = K ;

Martin Perdacher's avatar
Martin Perdacher committed
34
    members = (size_t *) ddr_alloc(sizeof (size_t) * n);
perdacherMartin's avatar
perdacherMartin committed
35 36
    x = (double*) ddr_alloc(sizeof (double)*n * d);

martin's avatar
martin committed
37
    if ( strcmp(filename,"" ) == 0) {
perdacherMartin's avatar
perdacherMartin committed
38 39 40
        random_init(x,n,d);
    }else{
        read_file(x, n, d, filename, isBinary);
perdacherMartin's avatar
perdacherMartin committed
41 42
    }

perdacherMartin's avatar
perdacherMartin committed
43
    elapsed = blasMeans( members, x, d, k, n, threads);
perdacherMartin's avatar
perdacherMartin committed
44 45 46 47 48 49 50 51

    printf("%d; %d; %d; %f\n", n,d,k,elapsed);

    ddr_free(members);
    ddr_free(x);

    return 0;
}