### Start Benchmark Timer Source: https://github.com/eembc/coremark/blob/main/docs/html/index/Functions.html Marks the beginning of the timed portion of the benchmark. This function should be called immediately before the code segment to be timed. ```c void start_time( void ) ``` -------------------------------- ### Implement Platform Timing Interface Source: https://context7.com/eembc/coremark/llms.txt Defines the required interface for benchmarking time measurement. Includes POSIX-based implementation examples using clock_gettime for high-resolution timing. ```c void start_time(void); void stop_time(void); CORE_TICKS get_time(void); secs_ret time_in_secs(CORE_TICKS ticks); void start_time(void) { clock_gettime(CLOCK_REALTIME, &start_time_val); } void stop_time(void) { clock_gettime(CLOCK_REALTIME, &stop_time_val); } CORE_TICKS get_time(void) { return (CORE_TICKS)((stop_time_val.tv_sec - start_time_val.tv_sec) * 1000 + (stop_time_val.tv_nsec - start_time_val.tv_nsec) / 1000000); } ``` -------------------------------- ### Timer Functions Source: https://github.com/eembc/coremark/blob/main/docs/html/files/linux/core_portme-c.html Defines functions for starting, stopping, and retrieving time measurements for the benchmark. ```APIDOC ## TIMER_RES_DIVIDER ### Description Divider to trade off timer resolution and total time that can be measured. Use lower values to increase resolution, but make sure that overflow does not occur. If there are issues with the return value overflowing, increase this value. ## start_time ### Description This function will be called right before starting the timed portion of the benchmark. Implementation may be capturing a system timer or zeroing system parameters. ### Signature ```c void start_time(void) ``` ## stop_time ### Description This function will be called right after ending the timed portion of the benchmark. Implementation may be capturing a system timer or other system parameters. ### Signature ```c void stop_time(void) ``` ## get_time ### Description Return an abstract “ticks” number that signifies time on the system. The actual value returned may be cpu cycles, milliseconds, or any other value, as long as it can be converted to seconds by `time_in_secs`. This methodology accommodates any hardware or simulated platform. ### Signature ```c CORE_TICKS get_time(void) ``` ## time_in_secs ### Description Convert the value returned by `get_time` to seconds. The `secs_ret` type is used to accommodate systems with no support for floating point. Default implementation is implemented by the `EE_TICKS_PER_SEC` macro. ### Signature ```c secs_ret time_in_secs(CORE_TICKS ticks) ``` ``` -------------------------------- ### CoreMark Utility and Portability Functions Source: https://github.com/eembc/coremark/blob/main/docs/html/index/Functions.html Utility functions for getting seeds and time, and portability functions for memory management and initialization/finalization. ```APIDOC ## CoreMark Utility and Portability Functions ### Description Provides utility functions for obtaining benchmark seeds and timing, as well as portability functions for platform-specific operations like memory allocation and initialization. ### Functions #### `get_seed` - **Description**: Retrieves a seed value for the benchmark. - **Parameters**: None. - **Returns**: `ee_s16` - A seed value. #### `get_time` - **Description**: Gets the current time. - **Returns**: `ee_u32` - The current time value. #### `time_in_secs` - **Description**: Gets the current time in seconds. - **Returns**: `u32` - The current time in seconds. #### `portable_init` - **Description**: Initializes the portable layer. - **Parameters**: None. #### `portable_fini` - **Description**: Finalizes the portable layer. - **Parameters**: None. #### `portable_malloc` - **Description**: Allocates memory using the portable layer. - **Parameters**: - `size` (size_t) - Required - The size of memory to allocate. - **Returns**: `void *` - Pointer to the allocated memory. #### `portable_free` - **Description**: Frees previously allocated memory. - **Parameters**: - `ptr` (void *) - Required - Pointer to the memory to free. #### `core_start_parallel` - **Description**: Starts benchmarking in a parallel context. - **Parameters**: None. #### `core_stop_parallel` - **Description**: Stops benchmarking in a parallel context. - **Parameters**: None. #### `start_time` - **Description**: Records the start time for timing purposes. - **Parameters**: None. #### `stop_time` - **Description**: Records the stop time for timing purposes. - **Parameters**: None. #### `crc*` - **Description**: Calculates CRC checksums (specific function signature not detailed). - **Parameters**: Varies based on specific CRC function. - **Returns**: Varies based on specific CRC function. ``` -------------------------------- ### Timing Functions - Platform Timing Interface Source: https://context7.com/eembc/coremark/llms.txt Provides platform-specific timing functions required for accurate benchmark measurement, including starting and stopping timers, getting elapsed time in ticks, and converting ticks to seconds. ```APIDOC ## Timing Functions - Platform Timing Interface ### Description Implement platform-specific timing functions for accurate benchmark measurement. ### Functions - **start_time()**: Called before benchmark execution to start timing. - **stop_time()**: Called after benchmark execution to stop timing. - **get_time()**: Returns the elapsed time in platform-specific ticks. - **time_in_secs(CORE_TICKS ticks)**: Converts ticks to seconds. ### POSIX Implementation Example ```c #include "coremark.h" #include static struct timespec start_time_val, stop_time_val; void start_time(void) { clock_gettime(CLOCK_REALTIME, &start_time_val); } void stop_time(void) { clock_gettime(CLOCK_REALTIME, &stop_time_val); } CORE_TICKS get_time(void) { return (CORE_TICKS)( (stop_time_val.tv_sec - start_time_val.tv_sec) * 1000 + (stop_time_val.tv_nsec - start_time_val.tv_nsec) / 1000000 ); } secs_ret time_in_secs(CORE_TICKS ticks) { return ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC; } ``` ``` -------------------------------- ### CoreMark Timing Functions Source: https://github.com/eembc/coremark/blob/main/docs/html/files/linux/core_portme-c.html Functions for starting, stopping, and retrieving time measurements within the CoreMark benchmark. ```APIDOC ## start_time ### Description This function will be called right before starting the timed portion of the benchmark. ### Method void ### Endpoint N/A (Function) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ## stop_time ### Description This function will be called right after ending the timed portion of the benchmark. ### Method void ### Endpoint N/A (Function) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ## get_time ### Description Return an abstract “ticks” number that signifies time on the system. ### Method CORE_TICKS ### Endpoint N/A (Function) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (CORE_TICKS) An abstract time value in ticks. #### Response Example N/A ## time_in_secs ### Description Convert the value returned by get_time to seconds. ### Method secs_ret ### Endpoint N/A (Function) ### Parameters #### Path Parameters - **ticks** (CORE_TICKS) - Required - The time value in ticks to convert. ### Request Example N/A ### Response #### Success Response (secs_ret) The time converted to seconds. #### Response Example N/A ``` -------------------------------- ### CoreMark Portable Memory Management Source: https://context7.com/eembc/coremark/llms.txt Demonstrates portable memory allocation functions (`portable_malloc`, `portable_free`) for CoreMark, supporting different memory strategies like heap (malloc/free), static arrays, and stack allocation. Examples show how to configure and use these methods based on `MEM_METHOD`. ```c #include "coremark.h" // Portable memory allocation (wraps platform-specific implementation) void *portable_malloc(ee_size_t size); void portable_free(void *p); // Memory method configuration in core_portme.h: // MEM_MALLOC - Use malloc/free (default for POSIX) // MEM_STATIC - Use static array (for constrained systems) // MEM_STACK - Allocate on stack // Static memory example: #if (MEM_METHOD == MEM_STATIC) ee_u8 static_memblk[TOTAL_DATA_SIZE]; // 2000 bytes default results[0].memblock[0] = (void *)static_memblk; #endif // Stack memory example: #if (MEM_METHOD == MEM_STACK) ee_u8 stack_memblock[TOTAL_DATA_SIZE * MULTITHREAD] for (i = 0; i < MULTITHREAD; i++) { results[i].memblock[0] = stack_memblock + i * TOTAL_DATA_SIZE; } #endif // Heap memory example: #if (MEM_METHOD == MEM_MALLOC) for (i = 0; i < MULTITHREAD; i++) { results[i].memblock[0] = portable_malloc(TOTAL_DATA_SIZE); } // ... run benchmark ... for (i = 0; i < MULTITHREAD; i++) { portable_free(results[i].memblock[0]); } #endif ``` -------------------------------- ### COREMARK Parallel Execution Functions Source: https://github.com/eembc/coremark/blob/main/docs/html/search/FunctionsC.html Information on functions related to starting and stopping parallel execution within COREMARK. ```APIDOC ## COREMARK Parallel Execution Functions ### Description Functions to manage the initiation and termination of parallel processing threads or tasks. ### Endpoints - `core_start_parallel` - `core_stop_parallel` ### Usage Used to control the parallel execution capabilities of the benchmark, allowing for performance testing across multiple cores or threads. ``` -------------------------------- ### CoreMark Multithread Parallel Execution API Source: https://context7.com/eembc/coremark/llms.txt Implements the API for parallel execution in CoreMark, supporting multithreaded benchmarking on multi-core processors. It includes functions to start and stop parallel execution using pthreads and demonstrates how to integrate this into the main execution loop. ```c #include "coremark.h" #if (MULTITHREAD > 1) // Start parallel benchmark execution // Returns: 0 on success for pthread, 1 for fork ee_u8 core_start_parallel(core_results *res); // Stop parallel execution and gather results ee_u8 core_stop_parallel(core_results *res); #endif // Pthread implementation: #if USE_PTHREAD ee_u8 core_start_parallel(core_results *res) { return (ee_u8)pthread_create(&(res->port.thread), NULL, iterate, (void *)res); } ee_u8 core_stop_parallel(core_results *res) { void *retval; return (ee_u8)pthread_join(res->port.thread, &retval); } #endif // Main execution loop with parallel support: start_time(); #if (MULTITHREAD > 1) for (i = 0; i < default_num_contexts; i++) { results[i].iterations = results[0].iterations; core_start_parallel(&results[i]); } for (i = 0; i < default_num_contexts; i++) { core_stop_parallel(&results[i]); } #else iterate(&results[0]); #endif stop_time(); ``` -------------------------------- ### Parallel Execution Functions Source: https://github.com/eembc/coremark/blob/main/docs/html/files/linux/core_portme-c.html Functions to manage the start and stop of parallel execution contexts for the benchmark. ```APIDOC ## core_start_parallel ### Description Start benchmarking in a parallel context. Three implementations are provided: using pthreads, using fork and shared memory, and using fork and sockets. Other implementations using MCAPI or other standards can easily be devised. ## core_stop_parallel ### Description Stop a parallel context execution of coremark, and gather the results. ``` -------------------------------- ### CoreMark Result Reporting Format (C) Source: https://context7.com/eembc/coremark/llms.txt Demonstrates the standard C code structure for reporting CoreMark benchmark results. It includes examples for basic reporting, memory parameters, and parallel execution, adhering to EEMBC standards. The output format is designed for clarity and reproducibility. ```c // Standard result reporting format: // CoreMark 1.0 : N / C [/ P] [/ M] // // N - Iterations per second // C - Compiler version and flags // P - Memory parameters (optional, required for CoreMark/MHz) // M - Parallel method and context count (if used) // Example outputs: ee_printf("CoreMark 1.0 : %f / %s %s", default_num_contexts * results[0].iterations / time_in_secs(total_time), COMPILER_VERSION, COMPILER_FLAGS); // With memory location: ee_printf(" / %s", MEM_LOCATION); // e.g., "Heap", "Code in flash, data in TCRAM" // With parallel execution: ee_printf(" / %d:%s", default_num_contexts, PARALLEL_METHOD); // e.g., "4:PThreads" // Complete example output: // CoreMark 1.0 : 3864.73 / GCC10.2.0 -O2 -DPERFORMANCE_RUN=1 / Heap / 4:PThreads // CoreMark/MHz reporting (for frequency-independent comparison): // CoreMark/MHz 1.0 : 1.47 / GCC 4.1.2 -O2 / DDR3(Heap) 30:1 Memory 1:1 Cache ``` -------------------------------- ### Multithread Parallel Execution API Source: https://context7.com/eembc/coremark/llms.txt API for implementing parallel execution in multi-core benchmarking using pthreads or fork. Includes functions to start and stop parallel execution. ```APIDOC ## Multithread Parallel Execution API Implement parallel execution for multi-core benchmarking using pthreads or fork. ### Description This section describes the API for managing parallel execution in CoreMark, enabling benchmarks to run across multiple cores using either pthreads or the fork system call. It includes functions to initiate and terminate parallel processing. ### Method Function calls for thread creation and management. ### Endpoint N/A (API functions) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c #include "coremark.h" #if (MULTITHREAD > 1) // Start parallel benchmark execution // Returns: 0 on success for pthread, 1 for fork ee_u8 core_start_parallel(core_results *res); // Stop parallel execution and gather results ee_u8 core_stop_parallel(core_results *res); #endif // Pthread implementation: #if USE_PTHREAD ee_u8 core_start_parallel(core_results *res) { return (ee_u8)pthread_create(&(res->port.thread), NULL, iterate, (void *)res); } ee_u8 core_stop_parallel(core_results *res) { void *retval; return (ee_u8)pthread_join(res->port.thread, &retval); } #endif // Main execution loop with parallel support: start_time(); #if (MULTITHREAD > 1) for (i = 0; i < default_num_contexts; i++) { results[i].iterations = results[0].iterations; core_start_parallel(&results[i]); } for (i = 0; i < default_num_contexts; i++) { core_stop_parallel(&results[i]); } #else iterate(&results[0]); #endif stop_time(); ``` ### Response #### Success Response (0) - **status** (u8) - Indicates success (0 for pthread, 1 for fork). #### Response Example ```json { "status": 0 } ``` ``` -------------------------------- ### CoreMark Build and Run Configurations (Makefile) Source: https://github.com/eembc/coremark/blob/main/docs/html/search/BuildTargetsP.html This snippet details the various build and run configurations available for the CoreMark benchmark. It includes pre-build, post-build, pre-load, post-load, pre-run, and post-run steps, with specific makefile configurations for Linux and PIC32 architectures. ```makefile # Example snippet for port_postbuild configuration # This would typically involve commands to finalize the build process # For Linux: # include linux/core_portme.mak # For PIC32: # include PIC32/core_portme.mak ``` ```makefile # Example snippet for port_postload configuration # This would typically involve commands to load the compiled binary onto the target # For Linux: # include linux/core_portme.mak # For PIC32: # include PIC32/core_portme.mak ``` ```makefile # Example snippet for port_postrun configuration # This would typically involve commands to clean up after the benchmark run # For Linux: # include linux/core_portme.mak # For PIC32: # include PIC32/core_portme.mak ``` ```makefile # Example snippet for port_prebuild configuration # This would typically involve commands to prepare for the build process # For Linux: # include linux/core_portme.mak # For PIC32: # include PIC32/core_portme.mak ``` ```makefile # Example snippet for port_preload configuration # This would typically involve commands to prepare the target for loading # For Linux: # include linux/core_portme.mak # For PIC32: # include PIC32/core_portme.mak ``` ```makefile # Example snippet for port_prerun configuration # This would typically involve commands to set up the environment before running the benchmark # For Linux: # include linux/core_portme.mak # For PIC32: # include PIC32/core_portme.mak ``` -------------------------------- ### Initialize State Machine Source: https://github.com/eembc/coremark/blob/main/docs/html/index/General.html Prepares the input data for the state machine benchmark by setting the size, seed, and memory pointer. ```C void core_init_state(ee_u32 size, ee_s16 seed, ee_u8 *p); ``` -------------------------------- ### Main Entry Routine Source: https://github.com/eembc/coremark/blob/main/docs/html/index/Functions.html The main entry point for the CoreMark benchmark execution. ```APIDOC ## main ### Description Main entry routine for the benchmark. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters None (when MAIN_HAS_NOARGC is defined) ### Request Example ```c #if MAIN_HAS_NOARGC int main(void) #else int main(int argc, char *argv[]) #endif { // Benchmark execution starts here return MAIN_RETURN_TYPE; } ``` ### Response #### Success Response (200) - **MAIN_RETURN_TYPE** - The return type of the main function (typically int). #### Response Example ``` [Return value of main] ``` ``` -------------------------------- ### Implement Portable Initialization Function Source: https://github.com/eembc/coremark/blob/main/barebones_porting.md Initializes hardware peripherals and performs sanity checks on data type sizes to ensure the environment meets CoreMark requirements. ```C void portable_init(core_portable *p, int *argc, char *argv[]) { stdio_init(); cache_init(); timer_config(); if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) { ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n"); } if (sizeof(ee_u32) != 4) { ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n"); } p->portable_id = 1; } ``` -------------------------------- ### Compile CoreMark with GCC Source: https://context7.com/eembc/coremark/llms.txt Demonstrates how to compile the CoreMark benchmark suite manually using GCC by linking the required source files and setting performance flags. ```bash gcc -O2 -o coremark.exe \ core_list_join.c \ core_main.c \ core_matrix.c \ core_state.c \ core_util.c \ simple/core_portme.c \ -DPERFORMANCE_RUN=1 \ -DITERATIONS=1000 ./coremark.exe > run1.log ``` -------------------------------- ### CoreMark Main Entry Routine Source: https://github.com/eembc/coremark/blob/main/docs/html/files/core_main-c.html The main function serves as the entry point for the CoreMark benchmark. It handles initialization of seeds, memory allocation, benchmark execution and timing, and result reporting. It accepts arguments for seeding and iteration control, with an option for automatic iteration determination. ```c #if MAIN_HAS_NOARGC MAIN_RETURN_TYPE main( void ) #else MAIN_RETURN_TYPE main( int argc, char *argv[] ) #endif { // ... implementation details ... return 0; } ``` -------------------------------- ### Get Compile-Time Undeterminable Values Source: https://github.com/eembc/coremark/blob/main/docs/html/index/Functions.html Retrieves values that cannot be determined at compile time. This is useful for dynamic configuration or runtime parameters. ```c // Get a values that cannot be determined at compile time. ``` -------------------------------- ### Portable Initialization Source: https://github.com/eembc/coremark/blob/main/docs/html/index/Functions.html Initializes platform-specific components for the benchmark. It takes a pointer to the portable context, and pointers to the argument count and argument vector. ```c void portable_init( core_portable *p, int *argc, char *argv[][ ]) ``` -------------------------------- ### Bare-Metal System Configuration Source: https://context7.com/eembc/coremark/llms.txt Configure CoreMark for microcontrollers and embedded systems without an operating system by defining necessary macros in `core_portme.h` and implementing required functions in `core_portme.c`. ```APIDOC ## Porting to Bare-Metal Systems Configure CoreMark for microcontrollers and embedded systems without an operating system. ### Description This section details the necessary configurations for running CoreMark on bare-metal systems, focusing on the `core_portme.h` header and `core_portme.c` implementation files. ### Method Configuration via C preprocessor macros and function implementations. ### Endpoint N/A (Configuration files) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // core_portme.h configuration for bare-metal: #define HAS_FLOAT 1 // 0 if no FPU #define HAS_TIME_H 0 // No standard time.h #define USE_CLOCK 0 // No clock() function #define HAS_STDIO 1 // printf available (via UART) #define HAS_PRINTF 1 // printf implemented #define MAIN_HAS_NOARGC 1 // No command line arguments #define COMPILER_VERSION "GCC"__VERSION__ #define COMPILER_FLAGS "-O2 -mcpu=cortex-m4" // Timer configuration: #define CLOCKS_PER_SEC 100 // Timer runs at 100Hz #define GETMYTIME(_t) (*_t = barebones_clock()) #define MYTIMEDIFF(fin, ini) ((fin) - (ini)) #define TIMER_RES_DIVIDER 1 #define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER) // core_portme.c implementation: extern void timer_config(void); extern void stdio_init(void); extern unsigned long get_100Hz_value(void); CORETIMETYPE barebones_clock() { return get_100Hz_value(); } void portable_init(core_portable *p, int *argc, char *argv[]) { stdio_init(); // Initialize UART for printf timer_config(); // Initialize hardware timer if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) { ee_printf("ERROR! Please define ee_ptr_int to hold a pointer!\n"); } if (sizeof(ee_u32) != 4) { ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n"); } p->portable_id = 1; } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Get System Time Source: https://github.com/eembc/coremark/blob/main/docs/html/index/Functions.html Returns an abstract 'ticks' number representing the current system time. This is used for timing benchmark execution. ```c CORE_TICKS get_time( void ) ``` -------------------------------- ### Initialize Portable Settings (C) Source: https://github.com/eembc/coremark/blob/main/docs/html/files/linux/core_portme-h.html The 'portable_init' function is responsible for target-specific initialization code. It also includes checks for common mistakes and can be used to set 'default_num_contexts' from the command line via argc/argv. ```c void portable_init( core_portable * p, int * argc, char * argv[] ) ``` -------------------------------- ### Configure CoreMark for Bare-Metal Systems Source: https://context7.com/eembc/coremark/llms.txt This snippet shows the configuration for running CoreMark on bare-metal embedded systems without an operating system. It defines macros for hardware features, compiler versions, and timer settings, along with essential initialization functions for I/O and timers. ```c #define HAS_FLOAT 1 // 0 if no FPU #define HAS_TIME_H 0 // No standard time.h #define USE_CLOCK 0 // No clock() function #define HAS_STDIO 1 // printf available (via UART) #define HAS_PRINTF 1 // printf implemented #define MAIN_HAS_NOARGC 1 // No command line arguments #define COMPILER_VERSION "GCC"__VERSION__ #define COMPILER_FLAGS "-O2 -mcpu=cortex-m4" // Timer configuration: #define CLOCKS_PER_SEC 100 // Timer runs at 100Hz #define GETMYTIME(_t) (*_t = barebones_clock()) #define MYTIMEDIFF(fin, ini) ((fin) - (ini)) #define TIMER_RES_DIVIDER 1 #define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER) // core_portme.c implementation: extern void timer_config(void); extern void stdio_init(void); extern unsigned long get_100Hz_value(void); CORETIMETYPE barebones_clock() { return get_100Hz_value(); } void portable_init(core_portable *p, int *argc, char *argv[]) { stdio_init(); // Initialize UART for printf timer_config(); // Initialize hardware timer if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) { ee_printf("ERROR! Please define ee_ptr_int to hold a pointer!\n"); } if (sizeof(ee_u32) != 4) { ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n"); } p->portable_id = 1; } ``` -------------------------------- ### Initialization and Finalization Source: https://github.com/eembc/coremark/blob/main/docs/html/index/Functions.html Functions for initializing and finalizing the CoreMark benchmark execution environment. ```APIDOC ## portable_init ### Description Target specific initialization code. Tests for some common mistakes. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters - **p** (core_portable *) - Pointer to the portable structure. - **argc** (int *) - Pointer to the argument count. - **argv** (char *[]) - Array of command-line arguments. ### Request Example ```c core_portable my_portable; int arg_count = 1; char* arg_values[] = {"program_name"}; portable_init(&my_portable, &arg_count, arg_values); ``` ### Response None ## portable_fini ### Description Target specific final code. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters - **p** (core_portable *) - Pointer to the portable structure. ### Request Example ```c portable_fini(&my_portable); ``` ### Response None ``` -------------------------------- ### CRC Utility Functions Source: https://context7.com/eembc/coremark/llms.txt Utilize CRC functions for data validation and result verification. This includes functions for different data sizes and examples of CRC accumulation and seeding. ```APIDOC ## CRC Utility Functions Use the CRC functions for data validation and result verification. ### Description This section describes the CRC utility functions available for ensuring data integrity and verifying benchmark results. It covers functions for various data types and provides examples for calculating CRC checksums. ### Method Function calls for CRC calculation. ### Endpoint N/A (Utility functions) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c #include "coremark.h" // CRC functions for different data sizes: ee_u16 crcu8(ee_u8 data, ee_u16 crc); // CRC of 8-bit value ee_u16 crc16(ee_s16 newval, ee_u16 crc); // CRC of signed 16-bit value ee_u16 crcu16(ee_u16 newval, ee_u16 crc);// CRC of unsigned 16-bit value ee_u16 crcu32(ee_u32 newval, ee_u16 crc);// CRC of 32-bit value // Check data type sizes at runtime: ee_u8 check_data_types(void); // Returns error count // Example CRC accumulation: ee_u16 crc = 0; crc = crc16(result1, crc); crc = crc16(result2, crc); crc = crcu32(count, crc); // Seed CRC calculation for validation: ee_u16 seedcrc = 0; seedcrc = crc16(seed1, seedcrc); // 0x0 or 0x3415 seedcrc = crc16(seed2, seedcrc); // 0x0 or 0x3415 seedcrc = crc16(seed3, seedcrc); // 0x66 seedcrc = crc16(size, seedcrc); // 2000 or 666 // Known seedcrc values: // 0x8a02 - Performance run (0,0,0x66, size 2000) // 0x7b05 - Validation run (0x3415,0x3415,0x66, size 2000) // 0x4eaf - Profile run (8,8,8, size 400) // 0xe9f5 - 2K performance run (0,0,0x66, size 666) ``` ### Response #### Success Response (200) - **crc_value** (u16) - The calculated CRC checksum. #### Response Example ```json { "crc_value": 42390 } ``` ``` -------------------------------- ### CoreMark Build Configuration (Makefile) Source: https://github.com/eembc/coremark/blob/main/docs/html/search/GeneralL.html Makefile snippets for configuring the CoreMark build process on different platforms. These files specify build flags and targets. ```makefile # LFLAGS_END ``` ```makefile # LOAD ``` -------------------------------- ### Initialize Matrix Benchmark Data Source: https://context7.com/eembc/coremark/llms.txt Sets up matrix data structures (A, B, and C) within a memory block for the matrix multiplication benchmark. It returns the dimension of the generated NxN matrices. ```c #include "coremark.h" ee_u32 core_init_matrix(ee_u32 blksize, void *memblk, ee_s32 seed, mat_params *p); mat_params mat; ee_u8 memblock[2000]; ee_s32 seed = 0 | (0 << 16); ee_u32 N = core_init_matrix(666, memblock, seed, &mat); ``` -------------------------------- ### CoreMark CRC Utility Functions for Data Validation Source: https://context7.com/eembc/coremark/llms.txt Provides CRC functions to ensure data integrity and verify benchmark results. This snippet includes declarations for CRC calculations on various data types (8-bit, 16-bit, 32-bit) and examples of seeding the CRC calculation for different run types. ```c #include "coremark.h" // CRC functions for different data sizes: ee_u16 crcu8(ee_u8 data, ee_u16 crc); // CRC of 8-bit value ee_u16 crc16(ee_s16 newval, ee_u16 crc); // CRC of signed 16-bit value ee_u16 crcu16(ee_u16 newval, ee_u16 crc);// CRC of unsigned 16-bit value ee_u16 crcu32(ee_u32 newval, ee_u16 crc);// CRC of 32-bit value // Check data type sizes at runtime: ee_u8 check_data_types(void); // Returns error count // Example CRC accumulation: ee_u16 crc = 0; crc = crc16(result1, crc); crc = crc16(result2, crc); crc = crcu32(count, crc); // Seed CRC calculation for validation: ee_u16 seedcrc = 0; seedcrc = crc16(seed1, seedcrc); // 0x0 or 0x3415 seedcrc = crc16(seed2, seedcrc); // 0x0 or 0x3415 seedcrc = crc16(seed3, seedcrc); // 0x66 seedcrc = crc16(size, seedcrc); // 2000 or 666 // Known seedcrc values: // 0x8a02 - Performance run (0,0,0x66, size 2000) // 0x7b05 - Validation run (0x3415,0x3415,0x66, size 2000) // 0x4eaf - Profile run (8,8,8, size 400) // 0xe9f5 - 2K performance run (0,0,0x66, size 666) ``` -------------------------------- ### CoreMark Build Configuration Source: https://github.com/eembc/coremark/blob/main/docs/html/index/General.html Flags and options for configuring the CoreMark build process. ```APIDOC ## CoreMark Build Configuration ### Description This section outlines the flags and options used to configure the build process for CoreMark, including compiler selection and options. ### Flags - **`OUTFLAG`**: Use this flag to define compiler options. - **`RUN`**: Flag related to execution. - **`OPATH`**: Path for output files. - **`PORT_SRCS`**: Source files for the port. - **`PORT_OBJS`**: Object files for the port. - **`PERL`**: Perl script related flag. ### Compiler Flags - **`MEM_METHOD`**: Defines the memory allocation method. - **`MULTITHREAD`**: Flag to enable multithreading support. ### Makefiles - **`linux/core_portme.mak`**: Makefile for Linux. - **`PIC32/core_portme.mak`**: Makefile for PIC32. ### Usage Examples - **Defining Compiler**: `make =` - **Defining Compiler Options**: `make OUTFLAG="-O2 -Wall"` ``` -------------------------------- ### CoreMark Initialization and Finalization Source: https://github.com/eembc/coremark/blob/main/docs/html/files/linux/core_portme-c.html Provides functions for platform-specific initialization and finalization of the CoreMark benchmark environment. ```APIDOC ## portable_init ### Description Target specific initialization code. Test for some common mistakes. ### Method void ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ## portable_fini ### Description Target specific final code. ### Method void ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` -------------------------------- ### Initialize Search and Loading States Source: https://github.com/eembc/coremark/blob/main/docs/html/search/ConfigurationsT.html This JavaScript snippet handles the visibility of loading elements and initializes the search functionality. It relies on the SearchResults class to process queries against the documentation index. ```javascript document.getElementById("Loading").style.display="none"; document.getElementById("NoMatches").style.display="none"; var searchResults = new SearchResults("searchResults", "HTML"); searchResults.Search(); ``` -------------------------------- ### core_init_state - Initialize State Machine Data Source: https://context7.com/eembc/coremark/llms.txt Initializes the input data buffer for the state machine benchmark with predetermined test patterns, including integers, floats, scientific notation, and error patterns. ```APIDOC ## core_init_state - Initialize State Machine Data ### Description Initialize input data for the state machine benchmark with predetermined test patterns. ### Method N/A (Function Signature) ### Endpoint N/A (C Function) ### Parameters #### Function Parameters - **size** (ee_u32) - Size of input buffer - **seed** (ee_s16) - Runtime seed for pattern selection - **p** (ee_u8 *) - Pointer to input buffer ### Input Patterns - Integer patterns: "5012", "1234", "-874", "+122" - Float patterns: "35.54400", ".1234500", "-110.700", "+0.64400" - Scientific patterns: "5.500e+3", "-.123e-2", "-87e+832", "+0.6e-12" - Error patterns: "T0.3e-1F", "-T.T++Tq", "1T3.4e4z", "34.0e-T^" ### Example Initialized Buffer "5012,1234,-874,35.54400,.1234500,5.500e+3,T0.3e-1F,..." ``` -------------------------------- ### Main Benchmark Entry Source: https://github.com/eembc/coremark/blob/main/docs/html/index/Functions.html The main entry routine for the CoreMark benchmark. It handles the overall execution flow of the benchmark. ```c #if MAIN_HAS_NOARGC MAIN_RETURN_TYPE main( void ) #endif ``` -------------------------------- ### Initialization and Finalization Functions Source: https://github.com/eembc/coremark/blob/main/docs/html/files/linux/core_portme-c.html Functions for platform-specific initialization and finalization routines. ```APIDOC ## portable_init ### Description Target specific initialization code. Tests for some common mistakes. ### Signature ```c void portable_init(core_portable *p, int *argc, char *argv[]) ``` ## portable_fini ### Description Target specific final code. ### Signature ```c void portable_fini(core_portable *p) ``` ``` -------------------------------- ### Manage CoreMark State Transitions Source: https://github.com/eembc/coremark/blob/main/docs/html/index/General.html Handles the state machine transitions for the benchmark. It takes current instructions and a transition counter to determine the next state. ```C enum CORE_STATE core_state_transition(ee_u8 **instr, ee_u32 *transition_count); ``` -------------------------------- ### CoreMark Benchmarking Functions Source: https://github.com/eembc/coremark/blob/main/docs/html/index/General.html API functions for initializing state, performing matrix benchmarks, and state machine benchmarks. ```APIDOC ## CoreMark Benchmarking Functions API ### Description This section describes the CoreMark API functions used for initializing benchmark states, running matrix-based benchmarks, and state machine benchmarks. ### Functions #### `core_init_state` - **Description**: Initializes the input data for the state machine. - **Parameters**: - `size` (ee_u32) - Required - The size of the data to initialize. - `seed` (ee_s16) - Required - The seed for initialization. - `p` (ee_u8 *) - Required - Pointer to the memory buffer for initialization. #### `core_bench_matrix` - **Description**: Executes the matrix benchmark. - **Parameters**: - `p` (mat_params *) - Required - Pointer to matrix parameters. - `seed` (ee_s16) - Required - The seed for the benchmark. - `crc` (ee_u16) - Required - The CRC value for the benchmark. - **Return**: `ee_u16` representing the benchmark result. #### `core_bench_state` - **Description**: Executes the state machine benchmark. - **Parameters**: - `blksize` (ee_u32) - Required - The block size for the state machine. - `memblock` (ee_u8 *) - Required - Pointer to the memory block. - `seed1` (ee_s16) - Required - The first seed. - `seed2` (ee_s16) - Required - The second seed. - `step` (ee_s16) - Required - The step value. - `crc` (ee_u16) - Required - The CRC value for the benchmark. - **Return**: `ee_u16` representing the benchmark result. ``` -------------------------------- ### Platform Portable Interface Source: https://github.com/eembc/coremark/blob/main/docs/html/index/General.html Defines the interface for platform-specific memory management and initialization. These functions must be implemented to port CoreMark to a new architecture. ```C void portable_fini(core_portable *p); void portable_free(void *p); void portable_init(core_portable *p, int *argc, char *argv[]); void *portable_malloc(size_t size); ``` -------------------------------- ### Initialize CoreMark State Machine Data Source: https://github.com/eembc/coremark/blob/main/docs/html/files/core_state-c.html Initializes the input data for the state machine. The 'seed' parameter influences the patterns of interspersed strings, and it's crucial that this seed is not determined at compile time. ```c void core_init_state( ee_u32 size, ee_s16 seed, ee_u8 * p ) ``` -------------------------------- ### Initialize List - C Source: https://github.com/eembc/coremark/blob/main/docs/html/files/core_list_join-c.html Initializes a linked list with specified block size, memory block, and seed. This function sets up the foundational structure for list operations. ```C list_head *core_list_init( ee_u32 blksize, list_head *memblock, ee_s16 seed ) ``` -------------------------------- ### Run Benchmark Iterations Source: https://github.com/eembc/coremark/blob/main/docs/html/index/Functions.html Executes the benchmark for a specified number of iterations. This allows for performance testing over a defined workload. ```c // Run the benchmark for a specified number of iterations. ``` -------------------------------- ### CoreMark Main Function Source: https://github.com/eembc/coremark/blob/main/docs/html/files/core_main-c.html Documentation for the main function of the CoreMark benchmark. ```APIDOC ## main ### Description Main entry routine for the benchmark. This function is responsible for initializing seeds, memory, running and timing the benchmark, and reporting results. ### Method N/A (C function) ### Endpoint N/A (C function) ### Parameters #### Arguments - **first seed** (Any value) - Description: The first seed for initialization. - **second seed** (Must be identical to first for iterations to be identical) - Description: The second seed, must match the first for identical iterations. - **third seed** (Any value, should be at least an order of magnitude less then the input size, but bigger then 32) - Description: A third seed value. - **Iterations** (Special, if set to 0, iterations will be automatically determined such that the benchmark will run between 10 to 100 secs) - Description: Number of iterations for the benchmark. If 0, iterations are auto-determined. ### Request Example N/A (C function) ### Response #### Success Response (0) - **Return Type** (int) - Description: Typically returns 0 on successful execution. #### Response Example N/A (C function) ``` -------------------------------- ### Configure CoreMark Build Flags Source: https://github.com/eembc/coremark/blob/main/README.md Commands to execute CoreMark performance, validation, and profile-guided optimization runs using make. These commands set specific compiler flags (XCFLAGS) and rebuild the project to ensure consistent benchmark conditions. ```Makefile make XCFLAGS="-DPERFORMANCE_RUN=1" REBUILD=1 run1.log make XCFLAGS="-DVALIDATION_RUN=1" REBUILD=1 run2.log make XCFLAGS="-DTOTAL_DATA_SIZE=1200 -DPROFILE_RUN=1" REBUILD=1 run3.log ``` -------------------------------- ### core_bench_state - Execute State Machine Benchmark Source: https://context7.com/eembc/coremark/llms.txt Runs the state machine benchmark, which parses numeric strings, identifies their format, injects and undoes corruption, and returns a CRC of state counts. ```APIDOC ## core_bench_state - Execute State Machine Benchmark ### Description Run the state machine benchmark that parses numeric strings and identifies their format. ### Method N/A (Function Signature) ### Endpoint N/A (C Function) ### Parameters #### Function Parameters - **blksize** (ee_u32) - Size of input buffer - **memblock** (ee_u8 *) - Pointer to initialized input data - **seed1** (ee_s16) - Corruption seed (for first XOR pass) - **seed2** (ee_s16) - Restoration seed (for second XOR pass) - **step** (ee_s16) - Corruption interval - **crc** (ee_u16) - Initial CRC value ### Returns - **ee_u16** - CRC of final and transition counts ### Benchmark Operation 1. Parse input and count state transitions. 2. Inject corruption (XOR with `seed1` at `step` intervals). 3. Parse corrupted input. 4. Undo corruption (XOR with `seed2`, typically equal to `seed1`). 5. Return CRC of all state counts. ### State Machine States (Moore Machine) - `CORE_START` (0) - `CORE_INVALID` - `CORE_S1` - `CORE_S2` - `CORE_INT` - `CORE_FLOAT` - `CORE_EXPONENT` - `CORE_SCIENTIFIC` - `NUM_CORE_STATES` ``` -------------------------------- ### Initialize Search Results and UI Cleanup Source: https://github.com/eembc/coremark/blob/main/docs/html/search/ConfigurationS.html This script hides the loading and no-matches indicators after the page content is ready. It then triggers the SearchResults object to perform a search operation based on the current HTML context. ```javascript document.getElementById("Loading").style.display="none"; document.getElementById("NoMatches").style.display="none"; var searchResults = new SearchResults("searchResults", "HTML"); searchResults.Search(); ```