|
| 1 | +extern "C" %{ |
| 2 | +/* |
| 3 | + * Copyright (c) 2017-2019 The Universiy of Tennessee and The Universiy |
| 4 | + * of Tennessee Research Foundation. All rights |
| 5 | + * reserved. |
| 6 | + */ |
| 7 | +#include <parsec/data_dist/matrix/matrix.h> |
| 8 | +#include "benchmark_internal.h" |
| 9 | +#include "core_c.h" |
| 10 | + |
| 11 | +%} |
| 12 | + |
| 13 | +descA [ type = "parsec_tiled_matrix_dc_t*" ] |
| 14 | +graph [ type = "task_graph_t" ] |
| 15 | +nb_fields [ type = "int" ] |
| 16 | +time_steps [ type = "int" ] |
| 17 | +graph_idx [ type = "int" ] |
| 18 | +extra_local_memory [ type = "char**" ] |
| 19 | + |
| 20 | +update(t, x, k) |
| 21 | + |
| 22 | +t = 1 .. time_steps-1 |
| 23 | + |
| 24 | +offset = %{ return task_graph_offset_at_timestep(graph, t); %} |
| 25 | +width = %{ return task_graph_width_at_timestep(graph, t); %} |
| 26 | + |
| 27 | +x = offset .. offset+width-1 |
| 28 | +m = t % nb_fields |
| 29 | + |
| 30 | +in_first = %{ return get_in_first(graph, t, x); %} |
| 31 | +in_last = %{ return get_in_last(graph, t, x); %} |
| 32 | +num_args = %{ return get_num_args(graph, t, x, in_first, in_last); %} |
| 33 | + |
| 34 | +k = in_first .. in_last |
| 35 | + |
| 36 | +: descA(m, x) |
| 37 | + |
| 38 | +RW I <- (num_args >= 2)? A benchmark(t-1, k): NULL |
| 39 | + -> (num_args >= 2 && k == in_first)? A1 benchmark(t, x) |
| 40 | + -> (num_args >= 3 && k == in_first + 1)? A2 benchmark(t, x) |
| 41 | + -> (num_args >= 4 && k == in_first + 2)? A3 benchmark(t, x) |
| 42 | + -> (num_args >= 5 && k == in_first + 3)? A4 benchmark(t, x) |
| 43 | + -> (num_args >= 6 && k == in_first + 4)? A5 benchmark(t, x) |
| 44 | + |
| 45 | +BODY |
| 46 | +{ |
| 47 | + //printf("update (%d, %d, %d): in (%d, %d)\n", t, x, k, in_first, in_last); |
| 48 | +} |
| 49 | +END |
| 50 | + |
| 51 | +benchmark(t, x) |
| 52 | + |
| 53 | +t = 0 .. time_steps-1 |
| 54 | + |
| 55 | +offset = %{ return task_graph_offset_at_timestep(graph, t); %} |
| 56 | +width = %{ return task_graph_width_at_timestep(graph, t); %} |
| 57 | + |
| 58 | +x = offset .. offset+width-1 |
| 59 | +m = t % nb_fields |
| 60 | + |
| 61 | +in_first = %{ return get_in_first(graph, t, x); %} |
| 62 | +in_last = %{ return get_in_last(graph, t, x); %} |
| 63 | +num_args = %{ return get_num_args(graph, t, x, in_first, in_last); %} |
| 64 | + |
| 65 | +out_first = %{ return get_out_first(graph, t, x); %} |
| 66 | +out_last = %{ return get_out_last(graph, t, x); %} |
| 67 | +num_args_out = %{ return get_num_args_out(graph, t, x, out_first, out_last); %} |
| 68 | + |
| 69 | +: descA(m, x) |
| 70 | + |
| 71 | +READ A1 <- (t > 0 && num_args >= 2)? I update(t, x, in_first): NULL |
| 72 | +READ A2 <- (t > 0 && num_args >= 3)? I update(t, x, in_first+1): NULL |
| 73 | +READ A3 <- (t > 0 && num_args >= 4)? I update(t, x, in_first+2): NULL |
| 74 | +READ A4 <- (t > 0 && num_args >= 5)? I update(t, x, in_first+3): NULL |
| 75 | +READ A5 <- (t > 0 && num_args >= 6)? I update(t, x, in_first+4): NULL |
| 76 | + |
| 77 | +RW A <- descA(m, x) |
| 78 | + -> (t < time_steps-1 && num_args_out >= 2)? I update(t+1, out_first .. out_last, x) |
| 79 | + -> descA(m, x) |
| 80 | + |
| 81 | +BODY |
| 82 | +{ |
| 83 | + //printf("benchmark (%d, %d): in (%d, %d); out (%d, %d)\n", t, x, in_first, in_last, out_first, out_last); |
| 84 | + CORE_kernel(es, graph, A, A1, A2, A3, A4, A5, num_args, x, t, graph_idx, descA->super.myrank, extra_local_memory); |
| 85 | +} |
| 86 | +END |
| 87 | + |
| 88 | +extern "C" %{ |
| 89 | + |
| 90 | +parsec_taskpool_t* |
| 91 | +parsec_benchmark_New(parsec_tiled_matrix_dc_t *A, task_graph_t graph, int nb_fields, |
| 92 | + int time_steps, int graph_idx, char **extra_local_memory) |
| 93 | +{ |
| 94 | + parsec_taskpool_t* benchmark_taskpool; |
| 95 | + parsec_benchmark_taskpool_t* taskpool = NULL; |
| 96 | + |
| 97 | + taskpool = parsec_benchmark_new(A, graph, nb_fields, time_steps, graph_idx, extra_local_memory); |
| 98 | + benchmark_taskpool = (parsec_taskpool_t*)taskpool; |
| 99 | + |
| 100 | + parsec_matrix_add2arena(&(taskpool->arenas_datatypes[PARSEC_benchmark_DEFAULT_ARENA]), |
| 101 | + parsec_datatype_float_t, matrix_UpperLower, |
| 102 | + 1, A->mb, A->nb, A->mb, |
| 103 | + PARSEC_ARENA_ALIGNMENT_SSE, -1 ); |
| 104 | + |
| 105 | + return benchmark_taskpool; |
| 106 | +} |
| 107 | + |
| 108 | +void parsec_benchmark_Destruct(parsec_taskpool_t *taskpool) |
| 109 | +{ |
| 110 | + parsec_benchmark_taskpool_t *benchmark_taskpool = (parsec_benchmark_taskpool_t *)taskpool; |
| 111 | + parsec_matrix_del2arena(&(benchmark_taskpool->arenas_datatypes[PARSEC_benchmark_DEFAULT_ARENA])); |
| 112 | + parsec_taskpool_free(taskpool); |
| 113 | +} |
| 114 | + |
| 115 | +int parsec_benchmark(parsec_context_t *parsec, |
| 116 | + parsec_tiled_matrix_dc_t *A, task_graph_t graph, int nb_fields, |
| 117 | + int time_steps, int graph_idx, char **extra_local_memory) |
| 118 | +{ |
| 119 | + parsec_taskpool_t *parsec_benchmark = NULL; |
| 120 | + |
| 121 | + parsec_benchmark = parsec_benchmark_New(A, graph, nb_fields, time_steps, graph_idx, extra_local_memory); |
| 122 | + |
| 123 | + if( parsec_benchmark != NULL ){ |
| 124 | + parsec_enqueue(parsec, parsec_benchmark); |
| 125 | + parsec_context_start(parsec); |
| 126 | + parsec_context_wait(parsec); |
| 127 | + parsec_benchmark_Destruct(parsec_benchmark); |
| 128 | + } |
| 129 | + |
| 130 | + return 0; |
| 131 | +} |
| 132 | + |
| 133 | +%} |
0 commit comments