coremark.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. #include <rtthread.h>
  31. #if HAS_STDIO
  32. #include <stdio.h>
  33. #endif
  34. #if HAS_PRINTF
  35. #if(HAS_FLOAT)
  36. #define ee_printf printf
  37. #else
  38. #define ee_printf rt_kprintf
  39. #endif
  40. #endif
  41. /* Actual benchmark execution in iterate */
  42. void *iterate(void *pres);
  43. /* Typedef: secs_ret
  44. For machines that have floating point support, get number of seconds as a double.
  45. Otherwise an unsigned int.
  46. */
  47. #if HAS_FLOAT
  48. typedef double secs_ret;
  49. #else
  50. typedef ee_u32 secs_ret;
  51. #endif
  52. #if MAIN_HAS_NORETURN
  53. #define MAIN_RETURN_VAL
  54. #define MAIN_RETURN_TYPE void
  55. #else
  56. #define MAIN_RETURN_VAL 0
  57. #define MAIN_RETURN_TYPE int
  58. #endif
  59. void start_time(void);
  60. void stop_time(void);
  61. CORE_TICKS get_time(void);
  62. secs_ret time_in_secs(CORE_TICKS ticks);
  63. /* Misc useful functions */
  64. ee_u16 crcu8(ee_u8 data, ee_u16 crc);
  65. ee_u16 crc16(ee_s16 newval, ee_u16 crc);
  66. ee_u16 crcu16(ee_u16 newval, ee_u16 crc);
  67. ee_u16 crcu32(ee_u32 newval, ee_u16 crc);
  68. ee_u8 check_data_types(void);
  69. void *portable_malloc(ee_size_t size);
  70. void portable_free(void *p);
  71. ee_s32 parseval(char *valstring);
  72. /* Algorithm IDS */
  73. #define ID_LIST (1<<0)
  74. #define ID_MATRIX (1<<1)
  75. #define ID_STATE (1<<2)
  76. #define ALL_ALGORITHMS_MASK (ID_LIST|ID_MATRIX|ID_STATE)
  77. #define NUM_ALGORITHMS 3
  78. /* list data structures */
  79. typedef struct list_data_s {
  80. ee_s16 data16;
  81. ee_s16 idx;
  82. } list_data;
  83. typedef struct list_head_s {
  84. struct list_head_s *next;
  85. struct list_data_s *info;
  86. } list_head;
  87. /*matrix benchmark related stuff */
  88. #define MATDAT_INT 1
  89. #if MATDAT_INT
  90. typedef ee_s16 MATDAT;
  91. typedef ee_s32 MATRES;
  92. #else
  93. typedef ee_f16 MATDAT;
  94. typedef ee_f32 MATRES;
  95. #endif
  96. typedef struct MAT_PARAMS_S {
  97. int N;
  98. MATDAT *A;
  99. MATDAT *B;
  100. MATRES *C;
  101. } mat_params;
  102. /* state machine related stuff */
  103. /* List of all the possible states for the FSM */
  104. typedef enum CORE_STATE {
  105. CORE_START=0,
  106. CORE_INVALID,
  107. CORE_S1,
  108. CORE_S2,
  109. CORE_INT,
  110. CORE_FLOAT,
  111. CORE_EXPONENT,
  112. CORE_SCIENTIFIC,
  113. NUM_CORE_STATES
  114. } core_state_e ;
  115. /* Helper structure to hold results */
  116. typedef struct RESULTS_S {
  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, ee_u8 *memblock,
  147. ee_s16 seed1, ee_s16 seed2, ee_s16 step, ee_u16 crc);
  148. /* matrix benchmark functions */
  149. ee_u32 core_init_matrix(ee_u32 blksize, void *memblk, ee_s32 seed, mat_params *p);
  150. ee_u16 core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc);