Yeah, I jumped the gun on that post. All that’s needed is to edit posix/core_portme.h

```
diff --git a/posix/core_portme.h b/posix/core_portme.h
index e49e474..abf9d6a 100644
--- a/posix/core_portme.h
+++ b/posix/core_portme.h
@@ -112,7 +112,7 @@ typedef unsigned short ee_u16;
typedef signed int ee_s32;
typedef double ee_f32;
typedef unsigned char ee_u8;
-typedef unsigned int ee_u32;
+typedef signed int ee_u32;
typedef uintptr_t ee_ptr_int;
typedef size_t ee_size_t;
/* align an offset to point to a 32b value */
```

BTW, `make PORT_CFLAGS=".."`

doesn’t work. You have to use `make XCFLAGS="..."`

```
make XCFLAGS="-fno-common -funroll-loops -mtune=sifive-7-series -fno-tree-loop-distribute-patterns -falign-functions=8 -falign-jumps=8 -falign-loops=8 -funroll-all-loops"
```

If you’re a purist, you can edit just the loops that are affected instead of changing the typedef.

```
diff --git a/core_matrix.c b/core_matrix.c
index 29fd8ab..3a8a969 100644
--- a/core_matrix.c
+++ b/core_matrix.c
@@ -35,13 +35,13 @@ zero). NxN Matrix C - used for the result.
The actual values for A and B must be derived based on input that is not
available at compile time.
*/
-ee_s16 matrix_test(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B, MATDAT val);
-ee_s16 matrix_sum(ee_u32 N, MATRES *C, MATDAT clipval);
-void matrix_mul_const(ee_u32 N, MATRES *C, MATDAT *A, MATDAT val);
-void matrix_mul_vect(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B);
-void matrix_mul_matrix(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B);
-void matrix_mul_matrix_bitextract(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B);
-void matrix_add_const(ee_u32 N, MATDAT *A, MATDAT val);
+ee_s16 matrix_test(ee_s32 N, MATRES *C, MATDAT *A, MATDAT *B, MATDAT val);
+ee_s16 matrix_sum(ee_s32 N, MATRES *C, MATDAT clipval);
+void matrix_mul_const(ee_s32 N, MATRES *C, MATDAT *A, MATDAT val);
+void matrix_mul_vect(ee_s32 N, MATRES *C, MATDAT *A, MATDAT *B);
+void matrix_mul_matrix(ee_s32 N, MATRES *C, MATDAT *A, MATDAT *B);
+void matrix_mul_matrix_bitextract(ee_s32 N, MATRES *C, MATDAT *A, MATDAT *B);
+void matrix_add_const(ee_s32 N, MATDAT *A, MATDAT val);
#define matrix_test_next(x) (x + 1)
#define matrix_clip(x, y) ((y) ? (x)&0x0ff : (x)&0x0ffff)
@@ -91,7 +91,7 @@ printmatC(MATRES *C, ee_u32 N, char *name)
ee_u16
core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc)
{
- ee_u32 N = p->N;
+ ee_s32 N = p->N;
MATRES *C = p->C;
MATDAT *A = p->A;
MATDAT *B = p->B;
@@ -127,7 +127,7 @@ core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc)
After the last step, matrix A is back to original contents.
*/
ee_s16
-matrix_test(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B, MATDAT val)
+matrix_test(ee_s32 N, MATRES *C, MATDAT *A, MATDAT *B, MATDAT val)
{
ee_u16 crc = 0;
MATDAT clipval = matrix_big(val);
@@ -178,14 +178,14 @@ matrix_test(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B, MATDAT val)
determined at compile time
*/
ee_u32
-core_init_matrix(ee_u32 blksize, void *memblk, ee_s32 seed, mat_params *p)
+core_init_matrix(ee_s32 blksize, void *memblk, ee_s32 seed, mat_params *p)
{
- ee_u32 N = 0;
+ ee_s32 N = 0;
MATDAT *A;
MATDAT *B;
ee_s32 order = 1;
MATDAT val;
- ee_u32 i = 0, j = 0;
+ ee_s32 i = 0, j = 0;
if (seed == 0)
seed = 1;
while (j < blksize)
@@ -235,11 +235,11 @@ core_init_matrix(ee_u32 blksize, void *memblk, ee_s32 seed, mat_params *p)
Otherwise, reset the accumulator and add 10 to the result.
*/
ee_s16
-matrix_sum(ee_u32 N, MATRES *C, MATDAT clipval)
+matrix_sum(ee_s32 N, MATRES *C, MATDAT clipval)
{
MATRES tmp = 0, prev = 0, cur = 0;
ee_s16 ret = 0;
- ee_u32 i, j;
+ ee_s32 i, j;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
@@ -266,9 +266,9 @@ matrix_sum(ee_u32 N, MATRES *C, MATDAT clipval)
This could be used as a scaler for instance.
*/
void
-matrix_mul_const(ee_u32 N, MATRES *C, MATDAT *A, MATDAT val)
+matrix_mul_const(ee_s32 N, MATRES *C, MATDAT *A, MATDAT val)
{
- ee_u32 i, j;
+ ee_s32 i, j;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
@@ -282,9 +282,9 @@ matrix_mul_const(ee_u32 N, MATRES *C, MATDAT *A, MATDAT val)
Add a constant value to all elements of a matrix.
*/
void
-matrix_add_const(ee_u32 N, MATDAT *A, MATDAT val)
+matrix_add_const(ee_s32 N, MATDAT *A, MATDAT val)
{
- ee_u32 i, j;
+ ee_s32 i, j;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
@@ -300,9 +300,9 @@ matrix_add_const(ee_u32 N, MATDAT *A, MATDAT val)
coefficients is applied to the matrix.)
*/
void
-matrix_mul_vect(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B)
+matrix_mul_vect(ee_s32 N, MATRES *C, MATDAT *A, MATDAT *B)
{
- ee_u32 i, j;
+ ee_s32 i, j;
for (i = 0; i < N; i++)
{
C[i] = 0;
@@ -319,9 +319,9 @@ matrix_mul_vect(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B)
scaling.
*/
void
-matrix_mul_matrix(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B)
+matrix_mul_matrix(ee_s32 N, MATRES *C, MATDAT *A, MATDAT *B)
{
- ee_u32 i, j, k;
+ ee_s32 i, j, k;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
@@ -341,9 +341,9 @@ matrix_mul_matrix(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B)
scaling.
*/
void
-matrix_mul_matrix_bitextract(ee_u32 N, MATRES *C, MATDAT *A, MATDAT *B)
+matrix_mul_matrix_bitextract(ee_s32 N, MATRES *C, MATDAT *A, MATDAT *B)
{
- ee_u32 i, j, k;
+ ee_s32 i, j, k;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
diff --git a/coremark.h b/coremark.h
index 9c5e406..49da159 100644
--- a/coremark.h
+++ b/coremark.h
@@ -176,7 +176,7 @@ ee_u16 core_bench_state(ee_u32 blksize,
ee_u16 crc);
/* matrix benchmark functions */
-ee_u32 core_init_matrix(ee_u32 blksize,
+ee_u32 core_init_matrix(ee_s32 blksize,
void * memblk,
ee_s32 seed,
mat_params *p);
```