OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [example/] [coremark/] [coremark.h] - Blame information for rev 73

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zero_gravi
/*
2
Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
3
 
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
 
8
    http://www.apache.org/licenses/LICENSE-2.0
9
 
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
 
16
Original Author: Shay Gal-on
17
*/
18
 
19
/* Topic: Description
20 38 zero_gravi
        This file contains  declarations of the various benchmark functions.
21 2 zero_gravi
*/
22
 
23
/* Configuration: TOTAL_DATA_SIZE
24 38 zero_gravi
        Define total size for data algorithms will operate on
25 2 zero_gravi
*/
26 38 zero_gravi
#ifndef TOTAL_DATA_SIZE
27
#define TOTAL_DATA_SIZE 2 * 1000
28 2 zero_gravi
#endif
29
 
30 38 zero_gravi
#define SEED_ARG      0
31
#define SEED_FUNC     1
32 2 zero_gravi
#define SEED_VOLATILE 2
33
 
34
#define MEM_STATIC 0
35
#define MEM_MALLOC 1
36 38 zero_gravi
#define MEM_STACK  2
37 2 zero_gravi
 
38
#include "core_portme.h"
39
 
40
#if HAS_STDIO
41
#include <stdio.h>
42
#endif
43
#if HAS_PRINTF
44
#define ee_printf printf
45
#endif
46
 
47
/* Actual benchmark execution in iterate */
48
void *iterate(void *pres);
49
 
50
/* Typedef: secs_ret
51 38 zero_gravi
        For machines that have floating point support, get number of seconds as
52
   a double. Otherwise an unsigned int.
53 2 zero_gravi
*/
54
#if HAS_FLOAT
55
typedef double secs_ret;
56
#else
57
typedef ee_u32 secs_ret;
58
#endif
59
 
60
#if MAIN_HAS_NORETURN
61 38 zero_gravi
#define MAIN_RETURN_VAL
62 2 zero_gravi
#define MAIN_RETURN_TYPE void
63
#else
64 38 zero_gravi
#define MAIN_RETURN_VAL  0
65 2 zero_gravi
#define MAIN_RETURN_TYPE int
66 38 zero_gravi
#endif
67 2 zero_gravi
 
68 38 zero_gravi
void       start_time(void);
69
void       stop_time(void);
70 2 zero_gravi
CORE_TICKS get_time(void);
71 38 zero_gravi
secs_ret   time_in_secs(CORE_TICKS ticks);
72 2 zero_gravi
 
73
/* Misc useful functions */
74
ee_u16 crcu8(ee_u8 data, ee_u16 crc);
75
ee_u16 crc16(ee_s16 newval, ee_u16 crc);
76
ee_u16 crcu16(ee_u16 newval, ee_u16 crc);
77
ee_u16 crcu32(ee_u32 newval, ee_u16 crc);
78 38 zero_gravi
ee_u8  check_data_types(void);
79
void * portable_malloc(ee_size_t size);
80
void   portable_free(void *p);
81 2 zero_gravi
ee_s32 parseval(char *valstring);
82
 
83
/* Algorithm IDS */
84 38 zero_gravi
#define ID_LIST             (1 << 0)
85
#define ID_MATRIX           (1 << 1)
86
#define ID_STATE            (1 << 2)
87
#define ALL_ALGORITHMS_MASK (ID_LIST | ID_MATRIX | ID_STATE)
88
#define NUM_ALGORITHMS      3
89 2 zero_gravi
 
90
/* list data structures */
91 38 zero_gravi
typedef struct list_data_s
92
{
93
    ee_s16 data16;
94
    ee_s16 idx;
95 2 zero_gravi
} list_data;
96
 
97 38 zero_gravi
typedef struct list_head_s
98
{
99
    struct list_head_s *next;
100
    struct list_data_s *info;
101 2 zero_gravi
} list_head;
102
 
103
/*matrix benchmark related stuff */
104
#define MATDAT_INT 1
105
#if MATDAT_INT
106
typedef ee_s16 MATDAT;
107
typedef ee_s32 MATRES;
108
#else
109
typedef ee_f16 MATDAT;
110
typedef ee_f32 MATRES;
111
#endif
112
 
113 38 zero_gravi
typedef struct MAT_PARAMS_S
114
{
115
    int     N;
116
    MATDAT *A;
117
    MATDAT *B;
118
    MATRES *C;
119 2 zero_gravi
} mat_params;
120
 
121
/* state machine related stuff */
122
/* List of all the possible states for the FSM */
123 38 zero_gravi
typedef enum CORE_STATE
124
{
125
    CORE_START = 0,
126
    CORE_INVALID,
127
    CORE_S1,
128
    CORE_S2,
129
    CORE_INT,
130
    CORE_FLOAT,
131
    CORE_EXPONENT,
132
    CORE_SCIENTIFIC,
133
    NUM_CORE_STATES
134
} core_state_e;
135 2 zero_gravi
 
136
/* Helper structure to hold results */
137 38 zero_gravi
typedef struct RESULTS_S
138
{
139
    /* inputs */
140
    ee_s16              seed1;       /* Initializing seed */
141
    ee_s16              seed2;       /* Initializing seed */
142
    ee_s16              seed3;       /* Initializing seed */
143
    void *              memblock[4]; /* Pointer to safe memory location */
144
    ee_u32              size;        /* Size of the data */
145
    ee_u32              iterations;  /* Number of iterations to execute */
146
    ee_u32              execs;       /* Bitmask of operations to execute */
147
    struct list_head_s *list;
148
    mat_params          mat;
149
    /* outputs */
150
    ee_u16 crc;
151
    ee_u16 crclist;
152
    ee_u16 crcmatrix;
153
    ee_u16 crcstate;
154
    ee_s16 err;
155
    /* ultithread specific */
156
    core_portable port;
157 2 zero_gravi
} core_results;
158
 
159
/* Multicore execution handling */
160 38 zero_gravi
#if (MULTITHREAD > 1)
161 2 zero_gravi
ee_u8 core_start_parallel(core_results *res);
162
ee_u8 core_stop_parallel(core_results *res);
163
#endif
164
 
165
/* list benchmark functions */
166
list_head *core_list_init(ee_u32 blksize, list_head *memblock, ee_s16 seed);
167 38 zero_gravi
ee_u16     core_bench_list(core_results *res, ee_s16 finder_idx);
168 2 zero_gravi
 
169
/* state benchmark functions */
170 38 zero_gravi
void   core_init_state(ee_u32 size, ee_s16 seed, ee_u8 *p);
171
ee_u16 core_bench_state(ee_u32 blksize,
172
                        ee_u8 *memblock,
173
                        ee_s16 seed1,
174
                        ee_s16 seed2,
175
                        ee_s16 step,
176
                        ee_u16 crc);
177 2 zero_gravi
 
178
/* matrix benchmark functions */
179 38 zero_gravi
ee_u32 core_init_matrix(ee_u32      blksize,
180
                        void *      memblk,
181
                        ee_s32      seed,
182
                        mat_params *p);
183 2 zero_gravi
ee_u16 core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.