coremark.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. Author : Shay Gal-On, EEMBC
  3. This file is part of EEMBC(R) and CoreMark(TM), which are Copyright (C) 2009
  4. All rights reserved.
  5. EEMBC CoreMark Software is a product of EEMBC and is provided under the terms of the
  6. CoreMark License that is distributed with the official EEMBC COREMARK Software release.
  7. If you received this EEMBC CoreMark Software without the accompanying CoreMark License,
  8. you must discontinue use and download the official release from www.coremark.org.
  9. Also, if you are publicly displaying scores generated from the EEMBC CoreMark software,
  10. make sure that you are in compliance with Run and Reporting rules specified in the accompanying readme.txt file.
  11. EEMBC
  12. 4354 Town Center Blvd. Suite 114-200
  13. El Dorado Hills, CA, 95762
  14. */
  15. /* Topic: Description
  16. This file contains declarations of the various benchmark functions.
  17. */
  18. /* Configuration: TOTAL_DATA_SIZE
  19. Define total size for data algorithms will operate on
  20. */
  21. #ifndef COREMARK_H
  22. #define COREMARK_H
  23. #ifndef TOTAL_DATA_SIZE
  24. #define TOTAL_DATA_SIZE 2*1000
  25. #endif
  26. #define SEED_ARG 0
  27. #define SEED_FUNC 1
  28. #define SEED_VOLATILE 2
  29. #define MEM_STATIC 0
  30. #define MEM_MALLOC 1
  31. #define MEM_STACK 2
  32. #include "core_portme.h"
  33. #if HAS_STDIO
  34. #include <stdio.h>
  35. #endif
  36. #if HAS_PRINTF
  37. #define ee_printf printf
  38. #endif
  39. /* Actual benchmark execution in iterate */
  40. void* iterate(void* pres);
  41. /* Typedef: secs_ret
  42. For machines that have floating point support, get number of seconds as a double.
  43. Otherwise an unsigned int.
  44. */
  45. #if HAS_FLOAT
  46. typedef double secs_ret;
  47. #else
  48. typedef ee_u32 secs_ret;
  49. #endif
  50. #if MAIN_HAS_NORETURN
  51. #define MAIN_RETURN_VAL
  52. #define MAIN_RETURN_TYPE void
  53. #else
  54. #define MAIN_RETURN_VAL 0
  55. #define MAIN_RETURN_TYPE int
  56. #endif
  57. void start_time(void);
  58. void stop_time(void);
  59. CORE_TICKS get_time(void);
  60. void start_instret(void);
  61. void stop_instret(void);
  62. CORE_TICKS get_instret(void);
  63. secs_ret time_in_secs(CORE_TICKS ticks);
  64. /* Misc useful functions */
  65. ee_u16 crcu8(ee_u8 data, ee_u16 crc);
  66. ee_u16 crc16(ee_s16 newval, ee_u16 crc);
  67. ee_u16 crcu16(ee_u16 newval, ee_u16 crc);
  68. ee_u16 crcu32(ee_u32 newval, ee_u16 crc);
  69. ee_u8 check_data_types();
  70. void* portable_malloc(ee_size_t size);
  71. void portable_free(void* p);
  72. ee_s32 parseval(char* valstring);
  73. /* Algorithm IDS */
  74. #define ID_LIST (1<<0)
  75. #define ID_MATRIX (1<<1)
  76. #define ID_STATE (1<<2)
  77. #define ALL_ALGORITHMS_MASK (ID_LIST|ID_MATRIX|ID_STATE)
  78. #define NUM_ALGORITHMS 3
  79. /* list data structures */
  80. typedef struct list_data_s {
  81. ee_s16 data16;
  82. ee_s16 idx;
  83. } list_data;
  84. typedef struct list_head_s {
  85. struct list_head_s* next;
  86. struct list_data_s* info;
  87. } list_head;
  88. /*matrix benchmark related stuff */
  89. #define MATDAT_INT 1
  90. #if MATDAT_INT
  91. typedef ee_s16 MATDAT;
  92. typedef ee_s32 MATRES;
  93. #else
  94. typedef ee_f16 MATDAT;
  95. typedef ee_f32 MATRES;
  96. #endif
  97. typedef struct MAT_PARAMS_S {
  98. int N;
  99. MATDAT* A;
  100. MATDAT* B;
  101. MATRES* C;
  102. } mat_params;
  103. /* state machine related stuff */
  104. /* List of all the possible states for the FSM */
  105. typedef enum CORE_STATE {
  106. CORE_START = 0,
  107. CORE_INVALID,
  108. CORE_S1,
  109. CORE_S2,
  110. CORE_INT,
  111. CORE_FLOAT,
  112. CORE_EXPONENT,
  113. CORE_SCIENTIFIC,
  114. NUM_CORE_STATES
  115. } core_state_e ;
  116. /* Helper structure to hold results */
  117. typedef struct RESULTS_S {
  118. /* inputs */
  119. ee_s16 seed1; /* Initializing seed */
  120. ee_s16 seed2; /* Initializing seed */
  121. ee_s16 seed3; /* Initializing seed */
  122. void* memblock[4]; /* Pointer to safe memory location */
  123. ee_u32 size; /* Size of the data */
  124. ee_u32 iterations; /* Number of iterations to execute */
  125. ee_u32 execs; /* Bitmask of operations to execute */
  126. struct list_head_s* list;
  127. mat_params mat;
  128. /* outputs */
  129. ee_u16 crc;
  130. ee_u16 crclist;
  131. ee_u16 crcmatrix;
  132. ee_u16 crcstate;
  133. ee_s16 err;
  134. /* ultithread specific */
  135. core_portable port;
  136. } core_results;
  137. /* Multicore execution handling */
  138. #if (MULTITHREAD>1)
  139. ee_u8 core_start_parallel(core_results* res);
  140. ee_u8 core_stop_parallel(core_results* res);
  141. #endif
  142. /* list benchmark functions */
  143. list_head* core_list_init(ee_u32 blksize, list_head* memblock, ee_s16 seed);
  144. ee_u16 core_bench_list(core_results* res, ee_s16 finder_idx);
  145. /* state benchmark functions */
  146. void core_init_state(ee_u32 size, ee_s16 seed, ee_u8* p);
  147. ee_u16 core_bench_state(ee_u32 blksize, ee_u8* memblock,
  148. ee_s16 seed1, ee_s16 seed2, ee_s16 step, ee_u16 crc);
  149. /* matrix benchmark functions */
  150. ee_u32 core_init_matrix(ee_u32 blksize, void* memblk, ee_s32 seed, mat_params* p);
  151. ee_u16 core_bench_matrix(mat_params* p, ee_s16 seed, ee_u16 crc);
  152. #endif