Add wasm tacle-bench targets
This commit is contained in:
BIN
targets/wasm-tacle/kernel/quicksort/generated/default/quicksort.wasm
Executable file
BIN
targets/wasm-tacle/kernel/quicksort/generated/default/quicksort.wasm
Executable file
Binary file not shown.
2788
targets/wasm-tacle/kernel/quicksort/generated/default/quicksort.wat
Normal file
2788
targets/wasm-tacle/kernel/quicksort/generated/default/quicksort.wat
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,66 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: math_private.h
|
||||
|
||||
Author: Unknown
|
||||
|
||||
Function: IEEE754 software library routines.
|
||||
|
||||
Source: Sun Microsystems
|
||||
|
||||
Original name: fdlibm.h
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: See the terms below.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
====================================================
|
||||
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
Permission to use, copy, modify, and distribute this
|
||||
software is freely granted, provided that this notice
|
||||
is preserved.
|
||||
====================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
from: @(#)fdlibm.h 5.1 93/09/24
|
||||
*/
|
||||
|
||||
#ifndef _MATH_PRIVATE_H_
|
||||
#define _MATH_PRIVATE_H_
|
||||
|
||||
/* A union which permits us to convert between a float and a 32 bit
|
||||
int. */
|
||||
|
||||
typedef union {
|
||||
float value;
|
||||
unsigned int word;
|
||||
} quicksort_ieee_float_shape_type;
|
||||
|
||||
/* Get a 32 bit int from a float. */
|
||||
|
||||
#define QUICKSORT_GET_FLOAT_WORD(i, d) \
|
||||
{ \
|
||||
quicksort_ieee_float_shape_type gf_u; \
|
||||
gf_u.value = (d); \
|
||||
(i) = gf_u.word; \
|
||||
}
|
||||
|
||||
/* Set a float from a 32 bit int. */
|
||||
|
||||
#define QUICKSORT_SET_FLOAT_WORD(d, i) \
|
||||
{ \
|
||||
quicksort_ieee_float_shape_type sf_u; \
|
||||
sf_u.word = (i); \
|
||||
(d) = sf_u.value; \
|
||||
}
|
||||
|
||||
#endif /* _MATH_PRIVATE_H_ */
|
||||
@ -0,0 +1,236 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: quicksort
|
||||
|
||||
Author: Matthew R. Guthaus
|
||||
|
||||
Function: quicksort applies a recursive quicksort algorithm to two different
|
||||
input sets.
|
||||
|
||||
Source: MiBench
|
||||
http://wwweb.eecs.umich.edu/mibench
|
||||
|
||||
Original name: qsort
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: GPL
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Include section
|
||||
*/
|
||||
|
||||
#include "quicksort.h"
|
||||
#include "quicksortlibm.h"
|
||||
#include "quicksortstdlib.h"
|
||||
|
||||
/*
|
||||
Forward declaration of functions
|
||||
*/
|
||||
|
||||
// Wasm loop bounds
|
||||
|
||||
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
|
||||
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
|
||||
|
||||
void quicksort_init(void);
|
||||
int quicksort_return(void);
|
||||
void quicksort_str(char *, unsigned long, unsigned long);
|
||||
void quicksort_vec(char *, unsigned long, unsigned long);
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
quicksort_main(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int main(void);
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
|
||||
extern const char *quicksort_input_string[681];
|
||||
char quicksort_strings[681][20];
|
||||
|
||||
extern unsigned int quicksort_input_vector[1000 * 3];
|
||||
struct quicksort_3DVertexStruct quicksort_vectors[1000];
|
||||
|
||||
volatile int quicksort_const_prop_border_i = 0;
|
||||
volatile char quicksort_const_prop_border_c = 0;
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
void
|
||||
quicksort_init(void) {
|
||||
unsigned int i, j;
|
||||
unsigned int x, y, z;
|
||||
unsigned int read_counter = 0;
|
||||
|
||||
/* constant propagation border */
|
||||
__pragma_loopbound(3000, 3000);
|
||||
for (i = 0; i < 3000; i++)
|
||||
quicksort_input_vector[i] += quicksort_const_prop_border_i;
|
||||
|
||||
/* Init arrays */
|
||||
__pragma_loopbound(681, 681);
|
||||
for (i = 0; i < 681; i++) {
|
||||
__pragma_loopbound(1, 20);
|
||||
for (j = 0; j < 20 - 1; j++) {
|
||||
quicksort_strings[i][j] = quicksort_input_string[i][j];
|
||||
quicksort_strings[i][j] += quicksort_const_prop_border_c;
|
||||
|
||||
if (quicksort_input_string[i][j] == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
/* Terminate with '\0' anyways. */
|
||||
quicksort_strings[i][20 - 1] = '\0';
|
||||
}
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++) {
|
||||
x = quicksort_vectors[i].x = quicksort_input_vector[read_counter++];
|
||||
y = quicksort_vectors[i].y = quicksort_input_vector[read_counter++];
|
||||
z = quicksort_vectors[i].z = quicksort_input_vector[read_counter++];
|
||||
|
||||
quicksort_vectors[i].distance = quicksort_sqrt(
|
||||
quicksort_pow(x, 2) + quicksort_pow(y, 2) + quicksort_pow(z, 2));
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
quicksort_return(void) {
|
||||
int checksum = 0;
|
||||
|
||||
checksum += quicksort_strings[42][1] + quicksort_vectors[42].x +
|
||||
quicksort_vectors[42].y + quicksort_vectors[42].z;
|
||||
|
||||
return (checksum);
|
||||
}
|
||||
|
||||
/*
|
||||
Algorithm core functions
|
||||
*/
|
||||
|
||||
void
|
||||
quicksort_str(char *a, unsigned long n, unsigned long es) {
|
||||
unsigned long j;
|
||||
char *pi, *pj, *pn;
|
||||
|
||||
__pragma_loopbound(0, 8);
|
||||
while (n > 1) {
|
||||
if (n > 10)
|
||||
pi = quicksort_pivot_strings(a, n, es);
|
||||
else
|
||||
pi = a + (n >> 1) * es;
|
||||
|
||||
quicksort_swapi(a, pi, es);
|
||||
pi = a;
|
||||
pn = a + n * es;
|
||||
pj = pn;
|
||||
|
||||
__pragma_loopbound(0, 169);
|
||||
while (1) {
|
||||
__pragma_loopbound(1, 26);
|
||||
do
|
||||
pi += es;
|
||||
while ((pi < pn) && (quicksort_compare_strings(pi, a) < 0));
|
||||
|
||||
__pragma_loopbound(1, 23);
|
||||
do
|
||||
pj -= es;
|
||||
while ((pj > a) && (quicksort_compare_strings(pj, a) > 0));
|
||||
|
||||
if (pj < pi)
|
||||
break;
|
||||
quicksort_swapi(pi, pj, es);
|
||||
}
|
||||
quicksort_swapi(a, pj, es);
|
||||
j = (pj - a) / es;
|
||||
n = n - j - 1;
|
||||
|
||||
if (j >= n) {
|
||||
quicksort_str(a, j, es);
|
||||
a += (j + 1) * es;
|
||||
} else {
|
||||
quicksort_str(a + (j + 1) * es, n, es);
|
||||
n = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
quicksort_vec(char *a, unsigned long n, unsigned long es) {
|
||||
unsigned long j;
|
||||
char *pi, *pj, *pn;
|
||||
|
||||
__pragma_loopbound(0, 15);
|
||||
while (n > 1) {
|
||||
if (n > 10)
|
||||
pi = quicksort_pivot_vectors(a, n, es);
|
||||
else
|
||||
pi = a + (n >> 1) * es;
|
||||
|
||||
quicksort_swapi(a, pi, es);
|
||||
pi = a;
|
||||
pn = a + n * es;
|
||||
pj = pn;
|
||||
|
||||
__pragma_loopbound(1, 250);
|
||||
while (1) {
|
||||
__pragma_loopbound(1, 51);
|
||||
do
|
||||
pi += es;
|
||||
while ((pi < pn) && (quicksort_compare_vectors(pi, a) < 0));
|
||||
|
||||
__pragma_loopbound(1, 27);
|
||||
do
|
||||
pj -= es;
|
||||
while ((pj > a) && (quicksort_compare_vectors(pj, a) > 0));
|
||||
|
||||
if (pj < pi)
|
||||
break;
|
||||
|
||||
quicksort_swapi(pi, pj, es);
|
||||
}
|
||||
|
||||
quicksort_swapi(a, pj, es);
|
||||
j = (pj - a) / es;
|
||||
n = n - j - 1;
|
||||
|
||||
if (j >= n) {
|
||||
quicksort_vec(a, j, es);
|
||||
a += (j + 1) * es;
|
||||
} else {
|
||||
quicksort_vec(a + (j + 1) * es, n, es);
|
||||
n = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
quicksort_main(void) {
|
||||
_Pragma("marker recursivecall")
|
||||
_Pragma("flowrestriction 1*quicksort_str <= 521*recursivecall")
|
||||
quicksort_str(*quicksort_strings, 681, sizeof(char[20]));
|
||||
|
||||
_Pragma("marker recursivecall2")
|
||||
_Pragma("flowrestriction 1*quicksort_vec <= 650*recursivecall2")
|
||||
quicksort_vec((char *) quicksort_vectors, 1000,
|
||||
sizeof(struct quicksort_3DVertexStruct));
|
||||
}
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void) {
|
||||
quicksort_init();
|
||||
quicksort_main();
|
||||
|
||||
return (quicksort_return() - 1527923179 != 0);
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
|
||||
#ifndef __QUICKSORT_H
|
||||
#define __QUICKSORT_H
|
||||
|
||||
struct quicksort_3DVertexStruct {
|
||||
unsigned int x, y, z;
|
||||
double distance;
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,56 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: quicksortlibm.c
|
||||
|
||||
Author: Ian Lance Taylor
|
||||
|
||||
Function: IEEE754 software library routines.
|
||||
|
||||
Source: Sun Microsystems and Cygnus
|
||||
|
||||
Original name: Unknown
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: See quicksortlibm.c
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __QUICKSORTLIBM
|
||||
#define __QUICKSORTLIBM
|
||||
|
||||
// The following defines map the math functions to specialized calls
|
||||
#define quicksort_acos quicksort___ieee754_acosf
|
||||
#define quicksort_atan quicksort___atanf
|
||||
#define quicksort_cos quicksort___cosf
|
||||
#define quicksort_fabs quicksort___fabsf
|
||||
#define quicksort_fabsf quicksort___fabsf
|
||||
#define quicksort_isinf quicksort___isinff
|
||||
#define quicksort_pow quicksort___ieee754_powf
|
||||
#define quicksort_sqrt quicksort___ieee754_sqrtf
|
||||
#define quicksort_log10 quicksort___ieee754_log10f
|
||||
#define quicksort_log quicksort___ieee754_logf
|
||||
#define quicksort_sin quicksort___sinf
|
||||
|
||||
float quicksort___atanf(float);
|
||||
float quicksort___copysignf(float, float);
|
||||
float quicksort___cosf(float);
|
||||
float quicksort___fabsf(float);
|
||||
float quicksort___floorf(float);
|
||||
float quicksort___ieee754_acosf(float);
|
||||
float quicksort___ieee754_powf(float, float);
|
||||
int quicksort___ieee754_rem_pio2f(float, float *);
|
||||
float quicksort___ieee754_sqrtf(float);
|
||||
int quicksort___isinff(float);
|
||||
float quicksort___kernel_cosf(float, float);
|
||||
float quicksort___kernel_sinf(float, float, int);
|
||||
int quicksort___kernel_rem_pio2f(float *, float *, int, int, int, const int *);
|
||||
float quicksort___scalbnf(float, int);
|
||||
float quicksort___ieee754_logf(float);
|
||||
float quicksort___ieee754_log10f(float);
|
||||
float quicksort___sinf(float);
|
||||
|
||||
#endif // __QUICKSORTLIBM
|
||||
@ -0,0 +1,134 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: quicksort
|
||||
|
||||
Author: Matthew R. Guthaus
|
||||
|
||||
Function: quicksort applies a recursive quicksort algorithm to two different
|
||||
input sets.
|
||||
|
||||
Source: MiBench
|
||||
http://wwweb.eecs.umich.edu/mibench
|
||||
|
||||
Original name: qsort
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: GPL
|
||||
|
||||
*/
|
||||
|
||||
#include "quicksort.h"
|
||||
|
||||
// Wasm loop bounds
|
||||
|
||||
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
|
||||
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
|
||||
|
||||
int
|
||||
quicksort_strcmp(const char *str1, const char *str2) {
|
||||
__pragma_loopbound(0, 11);
|
||||
while (*str1 && (*str1 == *str2))
|
||||
++str1, ++str2;
|
||||
|
||||
return (*(const unsigned char *) str1 - *(const unsigned char *) str2);
|
||||
}
|
||||
|
||||
int
|
||||
quicksort_compare_strings(const char *elem1, const char *elem2) {
|
||||
int result;
|
||||
|
||||
result = quicksort_strcmp(elem1, elem2);
|
||||
|
||||
return ((result < 0) ? 1 : ((result == 0) ? 0 : -1));
|
||||
}
|
||||
|
||||
int
|
||||
quicksort_compare_vectors(const char *elem1, const char *elem2) {
|
||||
/* D = [ (x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2 ]^(1/2) */
|
||||
/* sort based on distances from the origin... */
|
||||
|
||||
double distance1, distance2;
|
||||
|
||||
distance1 = (*((struct quicksort_3DVertexStruct *) elem1)).distance;
|
||||
distance2 = (*((struct quicksort_3DVertexStruct *) elem2)).distance;
|
||||
|
||||
return ((distance1 > distance2) ? 1 : ((distance1 == distance2) ? 0 : -1));
|
||||
}
|
||||
|
||||
void
|
||||
quicksort_swapi(char *ii, char *ij, unsigned long es) {
|
||||
char *i, *j, c;
|
||||
|
||||
i = (char *) ii;
|
||||
j = (char *) ij;
|
||||
|
||||
__pragma_loopbound(20, 24);
|
||||
do {
|
||||
c = *i;
|
||||
*i++ = *j;
|
||||
*j++ = c;
|
||||
es -= sizeof(char);
|
||||
} while (es != 0);
|
||||
}
|
||||
|
||||
char *
|
||||
quicksort_pivot_strings(char *a, unsigned long n, unsigned long es) {
|
||||
long j;
|
||||
char *pi, *pj, *pk;
|
||||
|
||||
j = n / 6 * es;
|
||||
pi = a + j; /* 1/6 */
|
||||
j += j;
|
||||
pj = pi + j; /* 1/2 */
|
||||
pk = pj + j; /* 5/6 */
|
||||
|
||||
if (quicksort_compare_strings(pi, pj) < 0) {
|
||||
if (quicksort_compare_strings(pi, pk) < 0) {
|
||||
if (quicksort_compare_strings(pj, pk) < 0)
|
||||
return (pj);
|
||||
return (pk);
|
||||
}
|
||||
return (pi);
|
||||
}
|
||||
|
||||
if (quicksort_compare_strings(pj, pk) < 0) {
|
||||
if (quicksort_compare_strings(pi, pk) < 0)
|
||||
return (pi);
|
||||
return (pk);
|
||||
}
|
||||
|
||||
return (pj);
|
||||
}
|
||||
|
||||
char *
|
||||
quicksort_pivot_vectors(char *a, unsigned long n, unsigned long es) {
|
||||
long j;
|
||||
char *pi, *pj, *pk;
|
||||
|
||||
j = n / 6 * es;
|
||||
pi = a + j; /* 1/6 */
|
||||
j += j;
|
||||
pj = pi + j; /* 1/2 */
|
||||
pk = pj + j; /* 5/6 */
|
||||
|
||||
if (quicksort_compare_vectors(pi, pj) < 0) {
|
||||
if (quicksort_compare_vectors(pi, pk) < 0) {
|
||||
if (quicksort_compare_vectors(pj, pk) < 0)
|
||||
return (pj);
|
||||
return (pk);
|
||||
}
|
||||
return (pi);
|
||||
}
|
||||
|
||||
if (quicksort_compare_vectors(pj, pk) < 0) {
|
||||
if (quicksort_compare_vectors(pi, pk) < 0)
|
||||
return (pi);
|
||||
return (pk);
|
||||
}
|
||||
|
||||
return (pj);
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: quicksort
|
||||
|
||||
Author: Matthew R. Guthaus
|
||||
|
||||
Function: quicksort applies a recursive quicksort algorithm to two different
|
||||
input sets.
|
||||
|
||||
Source: MiBench
|
||||
http://wwweb.eecs.umich.edu/mibench
|
||||
|
||||
Original name: qsort
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: GPL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __QUICKSORTSTDLIB_H
|
||||
#define __QUICKSORTSTDLIB_H
|
||||
|
||||
int quicksort_compare_strings(const char *, const char *);
|
||||
int quicksort_compare_vectors(const char *, const char *);
|
||||
void quicksort_swapi(char *, char *, unsigned long);
|
||||
char *quicksort_pivot_strings(char *, unsigned long, unsigned long);
|
||||
char *quicksort_pivot_vectors(char *, unsigned long, unsigned long);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,66 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: math_private.h
|
||||
|
||||
Author: Unknown
|
||||
|
||||
Function: IEEE754 software library routines.
|
||||
|
||||
Source: Sun Microsystems
|
||||
|
||||
Original name: fdlibm.h
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: See the terms below.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
====================================================
|
||||
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
Permission to use, copy, modify, and distribute this
|
||||
software is freely granted, provided that this notice
|
||||
is preserved.
|
||||
====================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
from: @(#)fdlibm.h 5.1 93/09/24
|
||||
*/
|
||||
|
||||
#ifndef _MATH_PRIVATE_H_
|
||||
#define _MATH_PRIVATE_H_
|
||||
|
||||
/* A union which permits us to convert between a float and a 32 bit
|
||||
int. */
|
||||
|
||||
typedef union {
|
||||
float value;
|
||||
unsigned int word;
|
||||
} quicksort_ieee_float_shape_type;
|
||||
|
||||
/* Get a 32 bit int from a float. */
|
||||
|
||||
#define QUICKSORT_GET_FLOAT_WORD(i, d) \
|
||||
{ \
|
||||
quicksort_ieee_float_shape_type gf_u; \
|
||||
gf_u.value = (d); \
|
||||
(i) = gf_u.word; \
|
||||
}
|
||||
|
||||
/* Set a float from a 32 bit int. */
|
||||
|
||||
#define QUICKSORT_SET_FLOAT_WORD(d, i) \
|
||||
{ \
|
||||
quicksort_ieee_float_shape_type sf_u; \
|
||||
sf_u.word = (i); \
|
||||
(d) = sf_u.value; \
|
||||
}
|
||||
|
||||
#endif /* _MATH_PRIVATE_H_ */
|
||||
@ -0,0 +1,249 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: quicksort
|
||||
|
||||
Author: Matthew R. Guthaus
|
||||
|
||||
Function: quicksort applies a recursive quicksort algorithm to two different
|
||||
input sets.
|
||||
|
||||
Source: MiBench
|
||||
http://wwweb.eecs.umich.edu/mibench
|
||||
|
||||
Original name: qsort
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: GPL
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Include section
|
||||
*/
|
||||
|
||||
#include "quicksort.h"
|
||||
#include "quicksortlibm.h"
|
||||
#include "quicksortstdlib.h"
|
||||
|
||||
/*
|
||||
Forward declaration of functions
|
||||
*/
|
||||
|
||||
// Wasm loop bounds
|
||||
|
||||
|
||||
#include "input.c"
|
||||
#include "quicksortlibm.c"
|
||||
#include "quicksortstdlib.c"
|
||||
|
||||
|
||||
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
|
||||
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
|
||||
|
||||
__attribute__((always_inline)) static inline void quicksort_init(void);
|
||||
__attribute__((always_inline)) static inline int quicksort_return(void);
|
||||
__attribute__((always_inline)) static inline void
|
||||
quicksort_str(char *, unsigned long, unsigned long);
|
||||
__attribute__((always_inline)) static inline void
|
||||
quicksort_vec(char *, unsigned long, unsigned long);
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
quicksort_main(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("main")))
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void);
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
|
||||
extern const char *quicksort_input_string[681];
|
||||
char quicksort_strings[681][20];
|
||||
|
||||
extern unsigned int quicksort_input_vector[1000 * 3];
|
||||
struct quicksort_3DVertexStruct quicksort_vectors[1000];
|
||||
|
||||
volatile int quicksort_const_prop_border_i = 0;
|
||||
volatile char quicksort_const_prop_border_c = 0;
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
quicksort_init(void) {
|
||||
unsigned int i, j;
|
||||
unsigned int x, y, z;
|
||||
unsigned int read_counter = 0;
|
||||
|
||||
/* constant propagation border */
|
||||
__pragma_loopbound(3000, 3000);
|
||||
for (i = 0; i < 3000; i++)
|
||||
quicksort_input_vector[i] += quicksort_const_prop_border_i;
|
||||
|
||||
/* Init arrays */
|
||||
__pragma_loopbound(681, 681);
|
||||
for (i = 0; i < 681; i++) {
|
||||
__pragma_loopbound(1, 20);
|
||||
for (j = 0; j < 20 - 1; j++) {
|
||||
quicksort_strings[i][j] = quicksort_input_string[i][j];
|
||||
quicksort_strings[i][j] += quicksort_const_prop_border_c;
|
||||
|
||||
if (quicksort_input_string[i][j] == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
/* Terminate with '\0' anyways. */
|
||||
quicksort_strings[i][20 - 1] = '\0';
|
||||
}
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++) {
|
||||
x = quicksort_vectors[i].x = quicksort_input_vector[read_counter++];
|
||||
y = quicksort_vectors[i].y = quicksort_input_vector[read_counter++];
|
||||
z = quicksort_vectors[i].z = quicksort_input_vector[read_counter++];
|
||||
|
||||
quicksort_vectors[i].distance = quicksort_sqrt(
|
||||
quicksort_pow(x, 2) + quicksort_pow(y, 2) + quicksort_pow(z, 2));
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline int
|
||||
quicksort_return(void) {
|
||||
int checksum = 0;
|
||||
|
||||
checksum += quicksort_strings[42][1] + quicksort_vectors[42].x +
|
||||
quicksort_vectors[42].y + quicksort_vectors[42].z;
|
||||
|
||||
return (checksum);
|
||||
}
|
||||
|
||||
/*
|
||||
Algorithm core functions
|
||||
*/
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
quicksort_str(char *a, unsigned long n, unsigned long es) {
|
||||
unsigned long j;
|
||||
char *pi, *pj, *pn;
|
||||
|
||||
__pragma_loopbound(0, 8);
|
||||
while (n > 1) {
|
||||
if (n > 10)
|
||||
pi = quicksort_pivot_strings(a, n, es);
|
||||
else
|
||||
pi = a + (n >> 1) * es;
|
||||
|
||||
quicksort_swapi(a, pi, es);
|
||||
pi = a;
|
||||
pn = a + n * es;
|
||||
pj = pn;
|
||||
|
||||
__pragma_loopbound(0, 169);
|
||||
while (1) {
|
||||
__pragma_loopbound(1, 26);
|
||||
do
|
||||
pi += es;
|
||||
while ((pi < pn) && (quicksort_compare_strings(pi, a) < 0));
|
||||
|
||||
__pragma_loopbound(1, 23);
|
||||
do
|
||||
pj -= es;
|
||||
while ((pj > a) && (quicksort_compare_strings(pj, a) > 0));
|
||||
|
||||
if (pj < pi)
|
||||
break;
|
||||
quicksort_swapi(pi, pj, es);
|
||||
}
|
||||
quicksort_swapi(a, pj, es);
|
||||
j = (pj - a) / es;
|
||||
n = n - j - 1;
|
||||
|
||||
if (j >= n) {
|
||||
quicksort_str(a, j, es);
|
||||
a += (j + 1) * es;
|
||||
} else {
|
||||
quicksort_str(a + (j + 1) * es, n, es);
|
||||
n = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
quicksort_vec(char *a, unsigned long n, unsigned long es) {
|
||||
unsigned long j;
|
||||
char *pi, *pj, *pn;
|
||||
|
||||
__pragma_loopbound(0, 15);
|
||||
while (n > 1) {
|
||||
if (n > 10)
|
||||
pi = quicksort_pivot_vectors(a, n, es);
|
||||
else
|
||||
pi = a + (n >> 1) * es;
|
||||
|
||||
quicksort_swapi(a, pi, es);
|
||||
pi = a;
|
||||
pn = a + n * es;
|
||||
pj = pn;
|
||||
|
||||
__pragma_loopbound(1, 250);
|
||||
while (1) {
|
||||
__pragma_loopbound(1, 51);
|
||||
do
|
||||
pi += es;
|
||||
while ((pi < pn) && (quicksort_compare_vectors(pi, a) < 0));
|
||||
|
||||
__pragma_loopbound(1, 27);
|
||||
do
|
||||
pj -= es;
|
||||
while ((pj > a) && (quicksort_compare_vectors(pj, a) > 0));
|
||||
|
||||
if (pj < pi)
|
||||
break;
|
||||
|
||||
quicksort_swapi(pi, pj, es);
|
||||
}
|
||||
|
||||
quicksort_swapi(a, pj, es);
|
||||
j = (pj - a) / es;
|
||||
n = n - j - 1;
|
||||
|
||||
if (j >= n) {
|
||||
quicksort_vec(a, j, es);
|
||||
a += (j + 1) * es;
|
||||
} else {
|
||||
quicksort_vec(a + (j + 1) * es, n, es);
|
||||
n = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
quicksort_main(void) {
|
||||
_Pragma("marker recursivecall")
|
||||
_Pragma("flowrestriction 1*quicksort_str <= 521*recursivecall")
|
||||
quicksort_str(*quicksort_strings, 681, sizeof(char[20]));
|
||||
|
||||
_Pragma("marker recursivecall2")
|
||||
_Pragma("flowrestriction 1*quicksort_vec <= 650*recursivecall2")
|
||||
quicksort_vec((char *) quicksort_vectors, 1000,
|
||||
sizeof(struct quicksort_3DVertexStruct));
|
||||
}
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("main")))
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void) {
|
||||
quicksort_init();
|
||||
quicksort_main();
|
||||
|
||||
return (quicksort_return() - 1527923179 != 0);
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
|
||||
#ifndef __QUICKSORT_H
|
||||
#define __QUICKSORT_H
|
||||
|
||||
struct quicksort_3DVertexStruct {
|
||||
unsigned int x, y, z;
|
||||
double distance;
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,67 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: quicksortlibm.c
|
||||
|
||||
Author: Ian Lance Taylor
|
||||
|
||||
Function: IEEE754 software library routines.
|
||||
|
||||
Source: Sun Microsystems and Cygnus
|
||||
|
||||
Original name: Unknown
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: See quicksortlibm.c
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __QUICKSORTLIBM
|
||||
#define __QUICKSORTLIBM
|
||||
|
||||
// The following defines map the math functions to specialized calls
|
||||
#define quicksort_acos quicksort___ieee754_acosf
|
||||
#define quicksort_atan quicksort___atanf
|
||||
#define quicksort_cos quicksort___cosf
|
||||
#define quicksort_fabs quicksort___fabsf
|
||||
#define quicksort_fabsf quicksort___fabsf
|
||||
#define quicksort_isinf quicksort___isinff
|
||||
#define quicksort_pow quicksort___ieee754_powf
|
||||
#define quicksort_sqrt quicksort___ieee754_sqrtf
|
||||
#define quicksort_log10 quicksort___ieee754_log10f
|
||||
#define quicksort_log quicksort___ieee754_logf
|
||||
#define quicksort_sin quicksort___sinf
|
||||
|
||||
__attribute__((always_inline)) static inline float quicksort___atanf(float);
|
||||
__attribute__((always_inline)) static inline float quicksort___copysignf(float,
|
||||
float);
|
||||
__attribute__((always_inline)) static inline float quicksort___cosf(float);
|
||||
__attribute__((always_inline)) static inline float quicksort___fabsf(float);
|
||||
__attribute__((always_inline)) static inline float quicksort___floorf(float);
|
||||
__attribute__((always_inline)) static inline float
|
||||
quicksort___ieee754_acosf(float);
|
||||
__attribute__((always_inline)) static inline float
|
||||
quicksort___ieee754_powf(float, float);
|
||||
__attribute__((always_inline)) static inline int
|
||||
quicksort___ieee754_rem_pio2f(float, float *);
|
||||
__attribute__((always_inline)) static inline float
|
||||
quicksort___ieee754_sqrtf(float);
|
||||
__attribute__((always_inline)) static inline int quicksort___isinff(float);
|
||||
__attribute__((always_inline)) static inline float
|
||||
quicksort___kernel_cosf(float, float);
|
||||
__attribute__((always_inline)) static inline float
|
||||
quicksort___kernel_sinf(float, float, int);
|
||||
__attribute__((always_inline)) static inline int
|
||||
quicksort___kernel_rem_pio2f(float *, float *, int, int, int, const int *);
|
||||
__attribute__((always_inline)) static inline float quicksort___scalbnf(float,
|
||||
int);
|
||||
__attribute__((always_inline)) static inline float
|
||||
quicksort___ieee754_logf(float);
|
||||
__attribute__((always_inline)) static inline float
|
||||
quicksort___ieee754_log10f(float);
|
||||
__attribute__((always_inline)) static inline float quicksort___sinf(float);
|
||||
|
||||
#endif // __QUICKSORTLIBM
|
||||
@ -0,0 +1,134 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: quicksort
|
||||
|
||||
Author: Matthew R. Guthaus
|
||||
|
||||
Function: quicksort applies a recursive quicksort algorithm to two different
|
||||
input sets.
|
||||
|
||||
Source: MiBench
|
||||
http://wwweb.eecs.umich.edu/mibench
|
||||
|
||||
Original name: qsort
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: GPL
|
||||
|
||||
*/
|
||||
|
||||
#include "quicksort.h"
|
||||
|
||||
// Wasm loop bounds
|
||||
|
||||
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
|
||||
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
|
||||
|
||||
__attribute__((always_inline)) static inline int
|
||||
quicksort_strcmp(const char *str1, const char *str2) {
|
||||
__pragma_loopbound(0, 11);
|
||||
while (*str1 && (*str1 == *str2))
|
||||
++str1, ++str2;
|
||||
|
||||
return (*(const unsigned char *) str1 - *(const unsigned char *) str2);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline int
|
||||
quicksort_compare_strings(const char *elem1, const char *elem2) {
|
||||
int result;
|
||||
|
||||
result = quicksort_strcmp(elem1, elem2);
|
||||
|
||||
return ((result < 0) ? 1 : ((result == 0) ? 0 : -1));
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline int
|
||||
quicksort_compare_vectors(const char *elem1, const char *elem2) {
|
||||
/* D = [ (x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2 ]^(1/2) */
|
||||
/* sort based on distances from the origin... */
|
||||
|
||||
double distance1, distance2;
|
||||
|
||||
distance1 = (*((struct quicksort_3DVertexStruct *) elem1)).distance;
|
||||
distance2 = (*((struct quicksort_3DVertexStruct *) elem2)).distance;
|
||||
|
||||
return ((distance1 > distance2) ? 1 : ((distance1 == distance2) ? 0 : -1));
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
quicksort_swapi(char *ii, char *ij, unsigned long es) {
|
||||
char *i, *j, c;
|
||||
|
||||
i = (char *) ii;
|
||||
j = (char *) ij;
|
||||
|
||||
__pragma_loopbound(20, 24);
|
||||
do {
|
||||
c = *i;
|
||||
*i++ = *j;
|
||||
*j++ = c;
|
||||
es -= sizeof(char);
|
||||
} while (es != 0);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline char *
|
||||
quicksort_pivot_strings(char *a, unsigned long n, unsigned long es) {
|
||||
long j;
|
||||
char *pi, *pj, *pk;
|
||||
|
||||
j = n / 6 * es;
|
||||
pi = a + j; /* 1/6 */
|
||||
j += j;
|
||||
pj = pi + j; /* 1/2 */
|
||||
pk = pj + j; /* 5/6 */
|
||||
|
||||
if (quicksort_compare_strings(pi, pj) < 0) {
|
||||
if (quicksort_compare_strings(pi, pk) < 0) {
|
||||
if (quicksort_compare_strings(pj, pk) < 0)
|
||||
return (pj);
|
||||
return (pk);
|
||||
}
|
||||
return (pi);
|
||||
}
|
||||
|
||||
if (quicksort_compare_strings(pj, pk) < 0) {
|
||||
if (quicksort_compare_strings(pi, pk) < 0)
|
||||
return (pi);
|
||||
return (pk);
|
||||
}
|
||||
|
||||
return (pj);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline char *
|
||||
quicksort_pivot_vectors(char *a, unsigned long n, unsigned long es) {
|
||||
long j;
|
||||
char *pi, *pj, *pk;
|
||||
|
||||
j = n / 6 * es;
|
||||
pi = a + j; /* 1/6 */
|
||||
j += j;
|
||||
pj = pi + j; /* 1/2 */
|
||||
pk = pj + j; /* 5/6 */
|
||||
|
||||
if (quicksort_compare_vectors(pi, pj) < 0) {
|
||||
if (quicksort_compare_vectors(pi, pk) < 0) {
|
||||
if (quicksort_compare_vectors(pj, pk) < 0)
|
||||
return (pj);
|
||||
return (pk);
|
||||
}
|
||||
return (pi);
|
||||
}
|
||||
|
||||
if (quicksort_compare_vectors(pj, pk) < 0) {
|
||||
if (quicksort_compare_vectors(pi, pk) < 0)
|
||||
return (pi);
|
||||
return (pk);
|
||||
}
|
||||
|
||||
return (pj);
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: quicksort
|
||||
|
||||
Author: Matthew R. Guthaus
|
||||
|
||||
Function: quicksort applies a recursive quicksort algorithm to two different
|
||||
input sets.
|
||||
|
||||
Source: MiBench
|
||||
http://wwweb.eecs.umich.edu/mibench
|
||||
|
||||
Original name: qsort
|
||||
|
||||
Changes: No major functional changes.
|
||||
|
||||
License: GPL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __QUICKSORTSTDLIB_H
|
||||
#define __QUICKSORTSTDLIB_H
|
||||
|
||||
__attribute__((always_inline)) static inline int
|
||||
quicksort_compare_strings(const char *, const char *);
|
||||
__attribute__((always_inline)) static inline int
|
||||
quicksort_compare_vectors(const char *, const char *);
|
||||
__attribute__((always_inline)) static inline void
|
||||
quicksort_swapi(char *, char *, unsigned long);
|
||||
__attribute__((always_inline)) static inline char *
|
||||
quicksort_pivot_strings(char *, unsigned long, unsigned long);
|
||||
__attribute__((always_inline)) static inline char *
|
||||
quicksort_pivot_vectors(char *, unsigned long, unsigned long);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user