1/* 2 * Copyright (c) 2007-12 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8 */ 9#include <string.h> 10#include <limits.h> 11#include <barrelfish/barrelfish.h> 12#include <barrelfish/spawn_client.h> 13#include <bench/bench.h> 14#include <omp.h> 15#include <xomp/xomp.h> 16 17#include <flounder/flounder_support_ump.h> 18 19#include "xomptest.h" 20 21static inline cycles_t calculate_time(cycles_t tsc_start, 22 cycles_t tsc_end) 23{ 24 cycles_t result; 25 if (tsc_end < tsc_start) { 26 result = (LONG_MAX - tsc_start) + tsc_end - bench_tscoverhead(); 27 } else { 28 result = (tsc_end - tsc_start - bench_tscoverhead()); 29 } 30 return result; 31} 32 33uint32_t asrc[MAX]; 34uint32_t adst[MAX]; 35 36int main(int argc, 37 char *argv[]) 38{ 39 errval_t err; 40 41 debug_printf("BOMP bench started. (MASTER) %u\n", argc); 42 43 bench_init(); 44 45 debug_printf("Bomp init...\n"); 46 bomp_custom_init(NULL); 47 48 debug_printf("spawning domains...%u\n", BOMP_NTHREADS); 49 backend_span_domain(BOMP_NTHREADS, 0); 50 51 debug_printf("setting threads...%u\n", BOMP_NTHREADS); 52 omp_set_num_threads(BOMP_NTHREADS); 53 54 cycles_t tsc_start, tsc_end; 55 cycles_t result; 56 uint64_t tscperus; 57 bench_ctl_t *ctl; 58 59 err = sys_debug_get_tsc_per_ms(&tscperus); 60 assert(err_is_ok(err)); 61 tscperus /= 1000; 62 63 debug_printf("tsc_perus: %lu\n", tscperus); 64 65 66 debug_printf("BENCHMARK: single loop\n"); 67 debug_printf("=========================================================\n"); 68 ctl = bench_ctl_init(BENCH_MODE_FIXEDRUNS, 1, BENCH_N_RUNS); 69 do { 70 tsc_start = bench_tsc(); 71 do_process_single(asrc, adst); 72 tsc_end = bench_tsc(); 73 result = calculate_time(tsc_start, tsc_end); 74 }while (!bench_ctl_add_run(ctl, &result)); 75 76 bench_ctl_dump_analysis(ctl, 0, "single", tscperus); 77 78 bench_ctl_destroy(ctl); 79 80 debug_printf("=========================================================\n"); 81 82 debug_printf("BENCHMARK: omp loop\n"); 83 debug_printf("=========================================================\n"); 84 ctl = bench_ctl_init(BENCH_MODE_FIXEDRUNS, 1, BENCH_N_RUNS); 85 do { 86 tsc_start = bench_tsc(); 87 do_process(asrc, adst); 88 tsc_end = bench_tsc(); 89 result = calculate_time(tsc_start, tsc_end); 90 }while (!bench_ctl_add_run(ctl, &result)); 91 92 bench_ctl_dump_analysis(ctl, 0, "omp", tscperus); 93 bench_ctl_destroy(ctl); 94 95 debug_printf("=========================================================\n"); 96 97 /* debug_printf("Verifying"); 98 99 for (uint32_t i = 0; i < MAX; ++i) { 100 if (adst[i] != asrc[i]) { 101 USER_PANIC("test failed: data[%u]=%u, expected %u\n", i, adst[i], asrc[i]); 102 } 103 } 104 105 debug_printf("SUCCESSS!!!!!\n");*/ 106 while (1) { 107 messages_wait_and_handle_next(); 108 } 109 110 return 0; 111} 112