core_portme.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 configuration constants required to execute on
  16. different platforms
  17. */
  18. #ifndef CORE_PORTME_H
  19. #define CORE_PORTME_H
  20. /************************/
  21. /* Data types and settings */
  22. /************************/
  23. /* Configuration : HAS_FLOAT
  24. Define to 1 if the platform supports floating point.
  25. */
  26. #ifndef HAS_FLOAT
  27. #define HAS_FLOAT 1
  28. #endif
  29. /* Configuration : HAS_TIME_H
  30. Define to 1 if platform has the time.h header file,
  31. and implementation of functions thereof.
  32. */
  33. #ifndef HAS_TIME_H
  34. #define HAS_TIME_H 1
  35. #endif
  36. /* Configuration : USE_CLOCK
  37. Define to 1 if platform has the time.h header file,
  38. and implementation of functions thereof.
  39. */
  40. #ifndef USE_CLOCK
  41. #define USE_CLOCK 1
  42. #endif
  43. /* Configuration : HAS_STDIO
  44. Define to 1 if the platform has stdio.h.
  45. */
  46. #ifndef HAS_STDIO
  47. #define HAS_STDIO 0
  48. #endif
  49. /* Configuration : HAS_PRINTF
  50. Define to 1 if the platform has stdio.h and implements the printf
  51. function.
  52. */
  53. #ifndef HAS_PRINTF
  54. #define HAS_PRINTF 0
  55. #endif
  56. /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
  57. Initialize these strings per platform
  58. */
  59. #ifndef COMPILER_VERSION
  60. #ifdef __GNUC__
  61. #define COMPILER_VERSION "GCC"__VERSION__
  62. #else
  63. #define COMPILER_VERSION "Please put compiler version here (e.g. gcc 4.1)"
  64. #endif
  65. #endif
  66. #ifndef COMPILER_FLAGS
  67. #define COMPILER_FLAGS \
  68. "-Os"
  69. #endif
  70. #ifndef MEM_LOCATION
  71. #define MEM_LOCATION "STACK"
  72. #endif
  73. /* Data Types :
  74. To avoid compiler issues, define the data types that need ot be used for
  75. 8b, 16b and 32b in <core_portme.h>.
  76. *Imprtant* :
  77. ee_ptr_int needs to be the data type used to hold pointers, otherwise
  78. coremark may fail!!!
  79. */
  80. typedef signed short ee_s16;
  81. typedef unsigned short ee_u16;
  82. typedef signed int ee_s32;
  83. typedef double ee_f32;
  84. typedef unsigned char ee_u8;
  85. typedef unsigned int ee_u32;
  86. typedef ee_u32 ee_ptr_int;
  87. typedef unsigned int ee_size_t;
  88. #define NULL ((void *)0)
  89. /* align_mem :
  90. This macro is used to align an offset to point to a 32b value. It is
  91. used in the Matrix algorithm to initialize the input memory blocks.
  92. */
  93. #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x)-1) & ~3))
  94. /* Configuration : CORE_TICKS
  95. Define type of return from the timing functions.
  96. */
  97. #define CORETIMETYPE ee_u32
  98. typedef ee_u32 CORE_TICKS;
  99. /* Configuration : SEED_METHOD
  100. Defines method to get seed values that cannot be computed at compile
  101. time.
  102. Valid values :
  103. SEED_ARG - from command line.
  104. SEED_FUNC - from a system function.
  105. SEED_VOLATILE - from volatile variables.
  106. */
  107. #ifndef SEED_METHOD
  108. #define SEED_METHOD SEED_VOLATILE
  109. #endif
  110. /* Configuration : MEM_METHOD
  111. Defines method to get a block of memry.
  112. Valid values :
  113. MEM_MALLOC - for platforms that implement malloc and have malloc.h.
  114. MEM_STATIC - to use a static memory array.
  115. MEM_STACK - to allocate the data block on the stack (NYI).
  116. */
  117. #ifndef MEM_METHOD
  118. #define MEM_METHOD MEM_STACK
  119. #endif
  120. /* Configuration : MULTITHREAD
  121. Define for parallel execution
  122. Valid values :
  123. 1 - only one context (default).
  124. N>1 - will execute N copies in parallel.
  125. Note :
  126. If this flag is defined to more then 1, an implementation for launching
  127. parallel contexts must be defined.
  128. Two sample implementations are provided. Use <USE_PTHREAD> or <USE_FORK>
  129. to enable them.
  130. It is valid to have a different implementation of <core_start_parallel>
  131. and <core_end_parallel> in <core_portme.c>, to fit a particular architecture.
  132. */
  133. #ifndef MULTITHREAD
  134. #define MULTITHREAD 1
  135. #define USE_PTHREAD 0
  136. #define USE_FORK 0
  137. #define USE_SOCKET 0
  138. #endif
  139. /* Configuration : MAIN_HAS_NOARGC
  140. Needed if platform does not support getting arguments to main.
  141. Valid values :
  142. 0 - argc/argv to main is supported
  143. 1 - argc/argv to main is not supported
  144. Note :
  145. This flag only matters if MULTITHREAD has been defined to a value
  146. greater then 1.
  147. */
  148. #ifndef MAIN_HAS_NOARGC
  149. #define MAIN_HAS_NOARGC 1
  150. #endif
  151. /* Configuration : MAIN_HAS_NORETURN
  152. Needed if platform does not support returning a value from main.
  153. Valid values :
  154. 0 - main returns an int, and return value will be 0.
  155. 1 - platform does not support returning a value from main
  156. */
  157. #ifndef MAIN_HAS_NORETURN
  158. #define MAIN_HAS_NORETURN 0
  159. #endif
  160. /* Variable : default_num_contexts
  161. Not used for this simple port, must contain the value 1.
  162. */
  163. extern ee_u32 default_num_contexts;
  164. typedef struct CORE_PORTABLE_S
  165. {
  166. ee_u8 portable_id;
  167. } core_portable;
  168. /* target specific init/fini */
  169. void portable_init(core_portable *p, int *argc, char *argv[]);
  170. void portable_fini(core_portable *p);
  171. #if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) \
  172. && !defined(VALIDATION_RUN)
  173. #if (TOTAL_DATA_SIZE == 1200)
  174. #define PROFILE_RUN 1
  175. #elif (TOTAL_DATA_SIZE == 2000)
  176. #define PERFORMANCE_RUN 1
  177. #else
  178. #define VALIDATION_RUN 1
  179. #endif
  180. #endif
  181. int ee_printf(const char *fmt, ...);
  182. #ifndef ITERATIONS
  183. #define ITERATIONS 10000
  184. #endif
  185. #define CLOCKS_PER_SEC 1000
  186. #endif /* CORE_PORTME_H */