coremark.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 TOTAL_DATA_SIZE
  22. #define TOTAL_DATA_SIZE 2*1000
  23. #endif
  24. #define SEED_ARG 0
  25. #define SEED_FUNC 1
  26. #define SEED_VOLATILE 2
  27. #define MEM_STATIC 0
  28. #define MEM_MALLOC 1
  29. #define MEM_STACK 2
  30. #include "core_portme.h"
  31. #if HAS_STDIO
  32. #include <stdio.h>
  33. #endif
  34. #if HAS_PRINTF
  35. #define ee_printf printf
  36. #endif
  37. /* Actual benchmark execution in iterate */
  38. void *iterate(void *pres);
  39. /* Typedef: secs_ret
  40. For machines that have floating point support, get number of seconds as a double.
  41. Otherwise an unsigned int.
  42. */
  43. #if HAS_FLOAT
  44. typedef double secs_ret;
  45. #else
  46. typedef ee_u32 secs_ret;
  47. #endif
  48. #if MAIN_HAS_NORETURN
  49. #define MAIN_RETURN_VAL
  50. #define MAIN_RETURN_TYPE void
  51. #else
  52. #define MAIN_RETURN_VAL 0
  53. #define MAIN_RETURN_TYPE int
  54. #endif
  55. void start_time(void);
  56. void stop_time(void);
  57. CORE_TICKS get_time(void);
  58. secs_ret time_in_secs(CORE_TICKS ticks);
  59. /* Misc useful functions */
  60. ee_u16 crcu8(ee_u8 data, ee_u16 crc);
  61. ee_u16 crc16(ee_s16 newval, ee_u16 crc);
  62. ee_u16 crcu16(ee_u16 newval, ee_u16 crc);
  63. ee_u16 crcu32(ee_u32 newval, ee_u16 crc);
  64. ee_u8 check_data_types();
  65. void *portable_malloc(ee_size_t size);
  66. void portable_free(void *p);
  67. ee_s32 parseval(char *valstring);
  68. /* Algorithm IDS */
  69. #define ID_LIST (1<<0)
  70. #define ID_MATRIX (1<<1)
  71. #define ID_STATE (1<<2)
  72. #define ALL_ALGORITHMS_MASK (ID_LIST|ID_MATRIX|ID_STATE)
  73. #define NUM_ALGORITHMS 3
  74. /* list data structures */
  75. typedef struct list_data_s {
  76. ee_s16 data16;
  77. ee_s16 idx;
  78. } list_data;
  79. typedef struct list_head_s {
  80. struct list_head_s *next;
  81. struct list_data_s *info;
  82. } list_head;
  83. /*matrix benchmark related stuff */
  84. #define MATDAT_INT 1
  85. #if MATDAT_INT
  86. typedef ee_s16 MATDAT;
  87. typedef ee_s32 MATRES;
  88. #else
  89. typedef ee_f16 MATDAT;
  90. typedef ee_f32 MATRES;
  91. #endif
  92. typedef struct MAT_PARAMS_S {
  93. int N;
  94. MATDAT *A;
  95. MATDAT *B;
  96. MATRES *C;
  97. } mat_params;
  98. /* state machine related stuff */
  99. /* List of all the possible states for the FSM */
  100. typedef enum CORE_STATE {
  101. CORE_START=0,
  102. CORE_INVALID,
  103. CORE_S1,
  104. CORE_S2,
  105. CORE_INT,
  106. CORE_FLOAT,
  107. CORE_EXPONENT,
  108. CORE_SCIENTIFIC,
  109. NUM_CORE_STATES
  110. } core_state_e ;
  111. /* Helper structure to hold results */
  112. typedef struct RESULTS_S {
  113. /* inputs */
  114. ee_s16 seed1; /* Initializing seed */
  115. ee_s16 seed2; /* Initializing seed */
  116. ee_s16 seed3; /* Initializing seed */
  117. void *memblock[4]; /* Pointer to safe memory location */
  118. ee_u32 size; /* Size of the data */
  119. ee_u32 iterations; /* Number of iterations to execute */
  120. ee_u32 execs; /* Bitmask of operations to execute */
  121. struct list_head_s *list;
  122. mat_params mat;
  123. /* outputs */
  124. ee_u16 crc;
  125. ee_u16 crclist;
  126. ee_u16 crcmatrix;
  127. ee_u16 crcstate;
  128. ee_s16 err;
  129. /* ultithread specific */
  130. core_portable port;
  131. } core_results;
  132. /* Multicore execution handling */
  133. #if (MULTITHREAD>1)
  134. ee_u8 core_start_parallel(core_results *res);
  135. ee_u8 core_stop_parallel(core_results *res);
  136. #endif
  137. /* list benchmark functions */
  138. list_head *core_list_init(ee_u32 blksize, list_head *memblock, ee_s16 seed);
  139. ee_u16 core_bench_list(core_results *res, ee_s16 finder_idx);
  140. /* state benchmark functions */
  141. void core_init_state(ee_u32 size, ee_s16 seed, ee_u8 *p);
  142. ee_u16 core_bench_state(ee_u32 blksize, ee_u8 *memblock,
  143. ee_s16 seed1, ee_s16 seed2, ee_s16 step, ee_u16 crc);
  144. /* matrix benchmark functions */
  145. ee_u32 core_init_matrix(ee_u32 blksize, void *memblk, ee_s32 seed, mat_params *p);
  146. ee_u16 core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc);