Skip to content

Commit

Permalink
cmpccxadd: add 40 functional cases
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaan Lu <[email protected]>
  • Loading branch information
jiaanlu committed May 24, 2024
1 parent 8aa595e commit 97bcacc
Show file tree
Hide file tree
Showing 46 changed files with 1,263 additions and 0 deletions.
1 change: 1 addition & 0 deletions BM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Features
* [AMX](amx/README.md)
* [cet(Control flow Enhancement Technology)](cet/README.md)
* [CMPccXADD](cmpccxadd/README.md)
* [cstate](cstate/README.md)
* [DSA](dsa/README.md)
* [FRED](fred/README.md) (in progress)
Expand Down
18 changes: 18 additions & 0 deletions BM/cmpccxadd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 Intel Corporation.
# Jiaan Lu <[email protected]>

CFLAGS = -g

src = $(filter-out cmpxadd.c, $(wildcard *.c))
target = $(patsubst %.c, %, ${src})

.PHONY: all clean

%:%.c
$(CC) ${CFLAGS} $^ -o $@

all: ${target}

clean:
rm -f ${target}
19 changes: 19 additions & 0 deletions BM/cmpccxadd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# CMPccXADD

## Description
CMPccXADD is a new set of instructions in the latest Intel platform
Sierra Forest. This new instruction set includes a semaphore operation
that can compare and add the operands if condition is met, which can
improve database performance.

This test suite provides basic functional check to ensure CMPccXADD works properly.

## Usage
```
make
# To run a specific case
(for example) ./cmpbexadd_above
# To run all cases at once
./runtest_all.sh
```
Test results (PASS or FAIL) will be printed out.
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmpbexadd_above.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputUnsigned output;
uop1 = 2;
uop2 = 1;
uop3 = 3;
output = cmp_be_add(uop1, uop2, uop3);
printf("cmp_be_add - target: *(rax) = 2, rbx = 2, rcx = 3, rflags = 0x202\n");
if (output.rax == 2 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x202) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmpbexadd_below.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputUnsigned output;
uop1 = 1;
uop2 = 2;
uop3 = 3;
output = cmp_be_add(uop1, uop2, uop3);
printf("cmp_be_add - target: *(rax) = 4, rbx = 1, rcx = 3, rflags = 0x297\n");
if (output.rax == 4 && output.rbx == 1 && output.rcx == 3 && output.rflags == 0x297) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmpbexadd_equal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputUnsigned output;
uop1 = 2;
uop2 = 2;
uop3 = 3;
output = cmp_be_add(uop1, uop2, uop3);
printf("cmp_be_add - target: *(rax) = 5, rbx = 2, rcx = 3, rflags = 0x246\n");
if (output.rax == 5 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x246) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmpbxadd_above.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputUnsigned output;
uop1 = 2;
uop2 = 1;
uop3 = 3;
output = cmp_b_add(uop1, uop2, uop3);
printf("cmp_b_add - target: *(rax) = 2, rbx = 2, rcx = 3, rflags = 0x202\n");
if (output.rax == 2 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x202) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmpbxadd_below.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputUnsigned output;
uop1 = 1;
uop2 = 2;
uop3 = 3;
output = cmp_b_add(uop1, uop2, uop3);
printf("cmp_b_add - target: *(rax) = 4, rbx = 1, rcx = 3, rflags = 0x297\n");
if (output.rax == 4 && output.rbx == 1 && output.rcx == 3 && output.rflags == 0x297) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmpbxadd_equal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputUnsigned output;
uop1 = 2;
uop2 = 2;
uop3 = 3;
output = cmp_b_add(uop1, uop2, uop3);
printf("cmp_b_add - target: *(rax) = 2, rbx = 2, rcx = 3, rflags = 0x246\n");
if (output.rax == 2 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x246) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmplexadd_equal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputSigned output;
op1 = -1;
op2 = -1;
op3 = 2;
output = cmp_le_add(op1, op2, op3);
printf("cmp_le_add - target: *(rax) = 1, rbx = -1, rcx = 2, rflags = 0x246\n");
if (output.rax == 1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x246) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmplexadd_less.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputSigned output;
op1 = -1;
op2 = 1;
op3 = 2;
output = cmp_le_add(op1, op2, op3);
printf("cmp_le_add - target: *(rax) = 1, rbx = -1, rcx = 2, rflags = 0x282\n");
if (output.rax == 1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x282) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmplexadd_more.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputSigned output;
op1 = -1;
op2 = -2;
op3 = 2;
output = cmp_le_add(op1, op2, op3);
printf("cmp_le_add - target: *(rax) = -1, rbx = -1, rcx = 2, rflags = 0x202\n");
if (output.rax == -1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x202) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmplxadd_equal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputSigned output;
op1 = -1;
op2 = -1;
op3 = 2;
output = cmp_l_add(op1, op2, op3);
printf("cmp_l_add - target: *(rax) = -1, rbx = -1, rcx = 2, rflags = 0x246\n");
if (output.rax == -1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x246) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmplxadd_less.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputSigned output;
op1 = -1;
op2 = 1;
op3 = 2;
output = cmp_l_add(op1, op2, op3);
printf("cmp_l_add - target: *(rax) = 1, rbx = -1, rcx = 2, rflags = 0x282\n");
if (output.rax == 1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x282) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
27 changes: 27 additions & 0 deletions BM/cmpccxadd/cmplxadd_more.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
* Jiaan Lu <[email protected]>
*
*/

#include <stdio.h>
#include <limits.h>
#include "cmpxadd.c"
void main() {
unsigned long uop1, uop2, uop3;
long op1, op2, op3;
struct OutputSigned output;
op1 = -1;
op2 = -2;
op3 = 2;
output = cmp_l_add(op1, op2, op3);
printf("cmp_l_add - target: *(rax) = -1, rbx = -1, rcx = 2, rflags = 0x202\n");
if (output.rax == -1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x202) {
printf("Test passed\n");
} else {
printf("Test failed\n");
}
}
Loading

0 comments on commit 97bcacc

Please sign in to comment.