coremark.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. Original Author: Shay Gal-on
  13. */
  14. /* Topic: Description
  15. This file contains declarations of the various benchmark functions.
  16. */
  17. /* Configuration: TOTAL_DATA_SIZE
  18. Define total size for data algorithms will operate on
  19. */
  20. #ifndef TOTAL_DATA_SIZE
  21. #define TOTAL_DATA_SIZE 2 * 1000
  22. #endif
  23. #define SEED_ARG 0
  24. #define SEED_FUNC 1
  25. #define SEED_VOLATILE 2
  26. #define MEM_STATIC 0
  27. #define MEM_MALLOC 1
  28. #define MEM_STACK 2
  29. #include "core_portme.h"
  30. #if HAS_STDIO
  31. #include <stdio.h>
  32. #endif
  33. #if HAS_PRINTF
  34. #define ee_printf printf
  35. #endif
  36. /* Actual benchmark execution in iterate */
  37. void *iterate(void *pres);
  38. /* Typedef: secs_ret
  39. For machines that have floating point support, get number of seconds as
  40. a double. Otherwise an unsigned int.
  41. */
  42. #if HAS_FLOAT
  43. typedef double secs_ret;
  44. #else
  45. typedef ee_u32 secs_ret;
  46. #endif
  47. #if MAIN_HAS_NORETURN
  48. #define MAIN_RETURN_VAL
  49. #define MAIN_RETURN_TYPE void
  50. #else
  51. #define MAIN_RETURN_VAL 0
  52. #define MAIN_RETURN_TYPE int
  53. #endif
  54. void start_time(void);
  55. void stop_time(void);
  56. CORE_TICKS get_time(void);
  57. secs_ret time_in_secs(CORE_TICKS ticks);
  58. /* Misc useful functions */
  59. ee_u16 crcu8(ee_u8 data, ee_u16 crc);
  60. ee_u16 crc16(ee_s16 newval, ee_u16 crc);
  61. ee_u16 crcu16(ee_u16 newval, ee_u16 crc);
  62. ee_u16 crcu32(ee_u32 newval, ee_u16 crc);
  63. ee_u8 check_data_types(void);
  64. void * portable_malloc(ee_size_t size);
  65. void portable_free(void *p);
  66. ee_s32 parseval(char *valstring);
  67. /* Algorithm IDS */
  68. #define ID_LIST (1 << 0)
  69. #define ID_MATRIX (1 << 1)
  70. #define ID_STATE (1 << 2)
  71. #define ALL_ALGORITHMS_MASK (ID_LIST | ID_MATRIX | ID_STATE)
  72. #define NUM_ALGORITHMS 3
  73. /* list data structures */
  74. typedef struct list_data_s
  75. {
  76. ee_s16 data16;
  77. ee_s16 idx;
  78. } list_data;
  79. typedef struct list_head_s
  80. {
  81. struct list_head_s *next;
  82. struct list_data_s *info;
  83. } list_head;
  84. /*matrix benchmark related stuff */
  85. #define MATDAT_INT 1
  86. #if MATDAT_INT
  87. typedef ee_s16 MATDAT;
  88. typedef ee_s32 MATRES;
  89. #else
  90. typedef ee_f16 MATDAT;
  91. typedef ee_f32 MATRES;
  92. #endif
  93. typedef struct MAT_PARAMS_S
  94. {
  95. int N;
  96. MATDAT *A;
  97. MATDAT *B;
  98. MATRES *C;
  99. } mat_params;
  100. /* state machine related stuff */
  101. /* List of all the possible states for the FSM */
  102. typedef enum CORE_STATE
  103. {
  104. CORE_START = 0,
  105. CORE_INVALID,
  106. CORE_S1,
  107. CORE_S2,
  108. CORE_INT,
  109. CORE_FLOAT,
  110. CORE_EXPONENT,
  111. CORE_SCIENTIFIC,
  112. NUM_CORE_STATES
  113. } core_state_e;
  114. /* Helper structure to hold results */
  115. typedef struct RESULTS_S
  116. {
  117. /* inputs */
  118. ee_s16 seed1; /* Initializing seed */
  119. ee_s16 seed2; /* Initializing seed */
  120. ee_s16 seed3; /* Initializing seed */
  121. void * memblock[4]; /* Pointer to safe memory location */
  122. ee_u32 size; /* Size of the data */
  123. ee_u32 iterations; /* Number of iterations to execute */
  124. ee_u32 execs; /* Bitmask of operations to execute */
  125. struct list_head_s *list;
  126. mat_params mat;
  127. /* outputs */
  128. ee_u16 crc;
  129. ee_u16 crclist;
  130. ee_u16 crcmatrix;
  131. ee_u16 crcstate;
  132. ee_s16 err;
  133. /* ultithread specific */
  134. core_portable port;
  135. } core_results;
  136. /* Multicore execution handling */
  137. #if (MULTITHREAD > 1)
  138. ee_u8 core_start_parallel(core_results *res);
  139. ee_u8 core_stop_parallel(core_results *res);
  140. #endif
  141. /* list benchmark functions */
  142. list_head *core_list_init(ee_u32 blksize, list_head *memblock, ee_s16 seed);
  143. ee_u16 core_bench_list(core_results *res, ee_s16 finder_idx);
  144. /* state benchmark functions */
  145. void core_init_state(ee_u32 size, ee_s16 seed, ee_u8 *p);
  146. ee_u16 core_bench_state(ee_u32 blksize,
  147. ee_u8 *memblock,
  148. ee_s16 seed1,
  149. ee_s16 seed2,
  150. ee_s16 step,
  151. ee_u16 crc);
  152. /* matrix benchmark functions */
  153. ee_u32 core_init_matrix(ee_u32 blksize,
  154. void * memblk,
  155. ee_s32 seed,
  156. mat_params *p);
  157. ee_u16 core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc);