[88] | 1 | /* |
---|
| 2 | * $Id: main.cpp 117 2009-05-16 14:42:39Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Special_Register_unit/SelfTest/include/test.h" |
---|
| 9 | |
---|
| 10 | #define NB_PARAMS 2 |
---|
| 11 | |
---|
| 12 | void usage (int argc, char * argv[]) |
---|
| 13 | { |
---|
| 14 | err (_("<Usage> %s name_instance list_params.\n"),argv[0]); |
---|
| 15 | err (_("list_params is :\n")); |
---|
| 16 | err (_(" * nb_front_end (uint32_t)\n")); |
---|
| 17 | err (_(" * nb_context [nb_front_end] (uint32_t)\n")); |
---|
| 18 | err (_(" * nb_inst_reexecute (uint32_t)\n")); |
---|
| 19 | |
---|
| 20 | exit (1); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | #ifndef SYSTEMC |
---|
| 24 | int main (int argc, char * argv[]) |
---|
| 25 | #else |
---|
| 26 | int sc_main (int argc, char * argv[]) |
---|
| 27 | #endif |
---|
| 28 | { |
---|
| 29 | if (argc <= static_cast<int>(2+NB_PARAMS)) |
---|
| 30 | usage (argc, argv); |
---|
| 31 | |
---|
| 32 | uint32_t x = 1; |
---|
| 33 | |
---|
| 34 | string name = argv[x++]; |
---|
| 35 | |
---|
| 36 | uint32_t _nb_front_end = fromString<uint32_t>(argv[x++]); |
---|
| 37 | |
---|
| 38 | if (argc != static_cast<int>(2+NB_PARAMS+_nb_front_end)) |
---|
| 39 | usage (argc, argv); |
---|
| 40 | |
---|
| 41 | uint32_t * _nb_context = new uint32_t [_nb_front_end]; |
---|
| 42 | for (uint32_t i=0; i<_nb_front_end; i++) |
---|
| 43 | _nb_context [i] = fromString<uint32_t>(argv[x++]); |
---|
| 44 | |
---|
| 45 | uint32_t _nb_inst_reexecute = fromString<uint32_t>(argv[x++]); |
---|
| 46 | |
---|
| 47 | bool *** _implement_group = new bool ** [_nb_front_end]; |
---|
| 48 | for (uint32_t i=0; i<_nb_front_end; i++) |
---|
| 49 | { |
---|
| 50 | _implement_group [i] = new bool * [_nb_context[i]]; |
---|
| 51 | for (uint32_t j=0; j<_nb_context[i]; j++) |
---|
| 52 | { |
---|
| 53 | _implement_group [i][j] = new bool [NB_GROUP]; |
---|
| 54 | |
---|
| 55 | for (uint32_t k=0; k<NB_GROUP; k++) |
---|
| 56 | _implement_group [i][j][k] = false; |
---|
| 57 | |
---|
| 58 | _implement_group [i][j][GROUP_SYSTEM_AND_CONTROL] = true; |
---|
| 59 | _implement_group [i][j][GROUP_DCACHE ] = true; |
---|
| 60 | } |
---|
| 61 | } |
---|
| 62 | |
---|
[117] | 63 | uint32_t num_thread = 0; |
---|
| 64 | uint32_t ** _translate_num_context_to_num_thread = new uint32_t * [_nb_front_end]; |
---|
| 65 | for (uint32_t i=0; i<_nb_front_end; i++) |
---|
| 66 | { |
---|
| 67 | _translate_num_context_to_num_thread [i] = new uint32_t [_nb_context[i]]; |
---|
| 68 | for (uint32_t j=0; j<_nb_context[i]; j++) |
---|
| 69 | _translate_num_context_to_num_thread [i][j] = num_thread ++; |
---|
| 70 | } |
---|
| 71 | |
---|
[88] | 72 | int _return = EXIT_SUCCESS; |
---|
| 73 | try |
---|
| 74 | { |
---|
| 75 | morpheo::behavioural::core::multi_ooo_engine::ooo_engine::special_register_unit::Parameters * param = new morpheo::behavioural::core::multi_ooo_engine::ooo_engine::special_register_unit::Parameters |
---|
| 76 | ( |
---|
| 77 | _nb_front_end , |
---|
| 78 | _nb_context , |
---|
| 79 | _nb_inst_reexecute , |
---|
| 80 | _implement_group , |
---|
[117] | 81 | _translate_num_context_to_num_thread, |
---|
[88] | 82 | true //is_toplevel |
---|
| 83 | ); |
---|
| 84 | |
---|
| 85 | msg(_("%s"),param->print(0).c_str()); |
---|
| 86 | |
---|
| 87 | test (name,param); |
---|
[115] | 88 | |
---|
| 89 | delete param; |
---|
[88] | 90 | } |
---|
| 91 | catch (morpheo::ErrorMorpheo & error) |
---|
| 92 | { |
---|
| 93 | msg (_("<%s> :\n%s"),name.c_str(), error.what ()); |
---|
| 94 | _return = EXIT_FAILURE; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | try |
---|
| 98 | { |
---|
| 99 | if (_return == EXIT_SUCCESS) |
---|
| 100 | TEST_OK("Special_Register_unit : no error"); |
---|
| 101 | else |
---|
| 102 | TEST_KO("Special_Register_unit : a lot of error"); |
---|
| 103 | } |
---|
| 104 | catch (morpheo::ErrorMorpheo & error) |
---|
| 105 | { |
---|
| 106 | // msg (_("<%s> :\n%s"),name.c_str(), error.what ()); |
---|
| 107 | _return = EXIT_FAILURE; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | for (uint32_t i=0; i<_nb_front_end; i++) |
---|
| 111 | { |
---|
[117] | 112 | delete [] _translate_num_context_to_num_thread [i]; |
---|
| 113 | } |
---|
| 114 | delete [] _translate_num_context_to_num_thread; |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | for (uint32_t i=0; i<_nb_front_end; i++) |
---|
| 118 | { |
---|
[88] | 119 | for (uint32_t j=0; j<_nb_context[i]; j++) |
---|
| 120 | delete [] _implement_group [i][j]; |
---|
| 121 | delete [] _implement_group [i]; |
---|
| 122 | } |
---|
| 123 | delete [] _implement_group; |
---|
| 124 | |
---|
| 125 | delete [] _nb_context; |
---|
| 126 | |
---|
| 127 | return (_return); |
---|
| 128 | } |
---|