Skip to content

Commit

Permalink
Feat: quicksort benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ppodds committed Jun 3, 2022
1 parent b01a4f7 commit 8e83e28
Show file tree
Hide file tree
Showing 11 changed files with 4,787 additions and 0 deletions.
15 changes: 15 additions & 0 deletions benchmark/benchmark-quicksort.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
gem5_path=../gem5

while getopts “a:” flag
do
case $flag in
a) l3_assoc=$OPTARG;;
esac
done

arg="--cpu-type=TimingSimpleCPU --caches --l2cache --l3cache --l3_assoc=${l3_assoc} --l1i_size=32kB --l1d_size=32kB --l2_size=128kB --l3_size=1MB --mem-type=NVMainMemory --nvmain-config=../NVmain/Config/PCM_ISSCC_2012_4GB.config"

gcc quicksort.c -o quicksort

${gem5_path}/build/X86/gem5.opt ${gem5_path}/configs/example/se.py -c quicksort ${arg}
29 changes: 29 additions & 0 deletions benchmark/multiply.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

#define SIZE 300
int main()
{
int size = SIZE;

int A[SIZE][SIZE],B[SIZE][SIZE],C[SIZE][SIZE];
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
A[i][j] = rand() % size + 1;
B[i][j] = rand() % size + 1;
}
}
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
C[i][j] = 0;
for (int k = 0; k< size ; k++)
{
C[i][j] += A[i][k] * B[k][j];
}
}
}

}

Binary file added benchmark/quicksort
Binary file not shown.
35 changes: 35 additions & 0 deletions benchmark/quicksort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

#define SWAP(x,y) {int t; t = x; x = y; y = t;}


void quickSort(int number[], int left, int right) {
if(left < right) {
int s = number[(left+right)/2];
int i = left - 1;
int j = right + 1;

while(1) {
while(number[++i] < s) ;
while(number[--j] > s) ;
if(i >= j)
break;
SWAP(number[i], number[j]);
}

quickSort(number, left, i-1);
quickSort(number, j+1, right);
}
}

int main(){


int arr[1000000];
int size = 1000000;
for (int i = 0; i < size; i++){
arr[i] = rand() % size + 1;
}
quickSort(arr, 0, size-1);

}

Loading

0 comments on commit 8e83e28

Please sign in to comment.