Skip to content
Snippets Groups Projects
Commit d2f3c3cc authored by Dustin Green's avatar Dustin Green
Browse files

split basicmath into seperate folders and add cosf

parent 3dbf450a
No related branches found
No related tags found
No related merge requests found
Showing
with 2806 additions and 0 deletions
Original provenience: MiBench benchmark suite,
http://wwweb.eecs.umich.edu/mibench
2016-02-09:
- Added TACLeBench header
- Renamed benchmark from 'basicmath_small' to 'basicmath'
- Fixed a typo in code comments: 'soem' -> 'some'
- Removed unused variable 'n' from the main funcion
- Added variable 'double Y' to the main function and accumulated the results of
'deg2rad(X)' and 'rad2deg(X)' in this variable so that the compiler warning
'statement with no effect' is fixed.
- Removed conditionally compiled main (test) function from isqrt.c
- Removed conditionally compiled main (test) function from cubic.c
- Removed commented-out code
- Removed unused function, variable, macro and type declarations, structs and
unions
- Removed seemingly unnecessary empty lines
- Renamed memcpy.t to basicmath_libc.c
- Removed unused files:
rad2deg.c
sniptype.h
sniptype.h
- Created basicmath_libc.h and put declaration of basicmath_memcpy() in it
- Reorganized snipmath.h so that the following are in the given order just
after the header
- includes
- declarations of functions
- Reorganized sniptype.h so that the following are in the given order just
after the header
- macro definitions
- type definitions
- Removed duplicated copyright information from wcclibm.c
- Removed __STDC__ checks from wcclibm.c and used only ANSI style function
arguments
- Removed 'last modified' comments from files
- Removed mention 'use __kernel_rem_pio2f()' from comments of function
__ieee754_rem_pio2f() since it doesn't really use it.
- Removed math functions specialization macros from wcclibm.h and updated call
sites with explicit nameks of the functions.
- Removed '#define double float' from wcclibm.h and replaced all 'double's
with 'float's in the benchmark
- Added a new main function that calls the old main function
- Annotated basicmath_main() as the entry point of the analysis
- Applied code formatting according to the following rules
- Lines shall not be wider than 80 characters; whenever possible, appropriate
line breaks shall be inserted to keep lines below 80 characters
- Indentation is done using whitespaces only, no tabs. Code is indented by
two whitespaces
- Two empty lines are put between any two functions
- In non-empty lists or index expressions, opening '(' and '[' are followed by
one whitespace, closing ')' and ']' are preceded by one whitespace
- In comma- or colon-separated argument lists, one whitespace is put after
each comma/colon
- Names of functions and global variables all start with a benchmark-specific
prefix (here: statemate_) followed by lowercase letter
- For pointer types, one whitespace is put before the '*'
- Operators within expressions shall be preceded and followed by one
whitespace
- Code of then- and else-parts of if-then-else statements shall be put in
separate lines, not in the same lines as the if-condition or the keyword
"else"
- Opening braces '{' denoting the beginning of code for some if-else or loop
body shall be put at the end of the same line where the keywords "if",
"else", "for", "while" etc. occur
2017-06-27
- Introduce basicmath_init and basicmath_return functions.
- Add prefix basicmath_ to global variables.
- Introduce dummy initialization in ieee754_rem_pio2f to please linter.
2017-07-10
- Fix possible stack buffer overflow caused by sizeof of incorrect type.
2019-03-07
-split basicmath into seperate files
-Add TACLeBench Header
-Add cosf.c as further benchmark
-put each benchmark into a seperate folder
-adjust the code formatting to the common TACLeBench code style
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: cosf
Author: Dustin Green
Function: cosf performs calculations of the cosinus function
Source:
Original name:
Changes:
License: this code is FREE with no restrictions
*/
#include "wcclibm.h"
/*
Forward declaration of functions
*/
void cosf_init( void );
void cosf_main( void );
int cosf_return( void );
int main( void );
/*
Declaration of global variables
*/
float cosf_solutions;
/*
Initialization function
*/
void cosf_init( void )
{
cosf_solutions = 0.0f;
}
/*
Return function
*/
int cosf_return( void )
{
int temp = cosf_solutions;
if ( temp == -4 )
return 0;
else
return -1;
}
/*
Main functions
*/
void cosf_main( void )
{
float i;
_Pragma( "loopbound min 100 max 100" )
for ( i = 0.0f; i < 10; i += 0.1f )
cosf_solutions += basicmath___cosf( i );
}
int main( void )
{
cosf_init();
cosf_main();
return cosf_return();
}
/*
====================================================
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
*/
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
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 above.
*/
#ifndef _MATH_PRIVATE_H_
#define _MATH_PRIVATE_H_
#include "wcclibm.h"
/* A union which permits us to convert between a float and a 32 bit int. */
typedef union {
float value;
u_int32_t word;
} ieee_float_shape_type;
/* Get a 32 bit int from a float. */
#define GET_FLOAT_WORD(i,d) \
{ \
ieee_float_shape_type gf_u; \
gf_u.value = (d); \
(i) = gf_u.word; \
}
/* Set a float from a 32 bit int. */
#define SET_FLOAT_WORD(d,i) \
{ \
ieee_float_shape_type sf_u; \
sf_u.word = (i); \
(d) = sf_u.value; \
}
#endif /* _MATH_PRIVATE_H_ */
This diff is collapsed.
/*
====================================================
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.
====================================================
*/
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: wcclibm.h
Author: Unknown
Function: IEEE754 software library routines.
Source: Sun Microsystems
Original name: wcclibm.h
Changes: No major functional changes.
License: See the terms above.
*/
#ifndef _WCCLIBM
#define _WCCLIBM
#define int32_t int
#define u_int32_t unsigned int
// Often used variables/consts
static const float basicmath_one = 1.0f,
basicmath_tiny = 1.0e-30f,
basicmath_half = 5.0000000000e-01, /* 0x3f000000 */
basicmath_huge = 1.0e30,
basicmath_two = 2.0,
basicmath_two24 = 16777216.0, /* 0x4b800000 */
basicmath_zero = 0.0;
float basicmath___copysignf( float x, float y );
float basicmath___cosf( float x );
float basicmath___fabsf( float x );
float basicmath___ieee754_acosf( float x );
float basicmath___ieee754_powf( float x, float y );
int32_t basicmath___ieee754_rem_pio2f( float x, float *y );
float basicmath___ieee754_sqrtf( float x );
int basicmath___isinff ( float x );
float basicmath___kernel_cosf( float x, float y );
float basicmath___kernel_sinf( float x, float y, int iy );
float basicmath___scalbnf ( float x, int n );
#endif // _WCCLIBM
Original provenience: MiBench benchmark suite,
http://wwweb.eecs.umich.edu/mibench
2016-02-09:
- Added TACLeBench header
- Renamed benchmark from 'basicmath_small' to 'basicmath'
- Fixed a typo in code comments: 'soem' -> 'some'
- Removed unused variable 'n' from the main funcion
- Added variable 'double Y' to the main function and accumulated the results of
'deg2rad(X)' and 'rad2deg(X)' in this variable so that the compiler warning
'statement with no effect' is fixed.
- Removed conditionally compiled main (test) function from isqrt.c
- Removed conditionally compiled main (test) function from cubic.c
- Removed commented-out code
- Removed unused function, variable, macro and type declarations, structs and
unions
- Removed seemingly unnecessary empty lines
- Renamed memcpy.t to basicmath_libc.c
- Removed unused files:
rad2deg.c
sniptype.h
sniptype.h
- Created basicmath_libc.h and put declaration of basicmath_memcpy() in it
- Reorganized snipmath.h so that the following are in the given order just
after the header
- includes
- declarations of functions
- Reorganized sniptype.h so that the following are in the given order just
after the header
- macro definitions
- type definitions
- Removed duplicated copyright information from wcclibm.c
- Removed __STDC__ checks from wcclibm.c and used only ANSI style function
arguments
- Removed 'last modified' comments from files
- Removed mention 'use __kernel_rem_pio2f()' from comments of function
__ieee754_rem_pio2f() since it doesn't really use it.
- Removed math functions specialization macros from wcclibm.h and updated call
sites with explicit nameks of the functions.
- Removed '#define double float' from wcclibm.h and replaced all 'double's
with 'float's in the benchmark
- Added a new main function that calls the old main function
- Annotated basicmath_main() as the entry point of the analysis
- Applied code formatting according to the following rules
- Lines shall not be wider than 80 characters; whenever possible, appropriate
line breaks shall be inserted to keep lines below 80 characters
- Indentation is done using whitespaces only, no tabs. Code is indented by
two whitespaces
- Two empty lines are put between any two functions
- In non-empty lists or index expressions, opening '(' and '[' are followed by
one whitespace, closing ')' and ']' are preceded by one whitespace
- In comma- or colon-separated argument lists, one whitespace is put after
each comma/colon
- Names of functions and global variables all start with a benchmark-specific
prefix (here: statemate_) followed by lowercase letter
- For pointer types, one whitespace is put before the '*'
- Operators within expressions shall be preceded and followed by one
whitespace
- Code of then- and else-parts of if-then-else statements shall be put in
separate lines, not in the same lines as the if-condition or the keyword
"else"
- Opening braces '{' denoting the beginning of code for some if-else or loop
body shall be put at the end of the same line where the keywords "if",
"else", "for", "while" etc. occur
2017-06-27
- Introduce basicmath_init and basicmath_return functions.
- Add prefix basicmath_ to global variables.
- Introduce dummy initialization in ieee754_rem_pio2f to please linter.
2017-07-10
- Fix possible stack buffer overflow caused by sizeof of incorrect type.
2019-03-07
-split basicmath into seperate files
-Add TACLeBench Header
-put each benchmark into a seperate folder
-adjust the code formatting to the common TACLeBench code style
/*
** CUBIC.C - Solve a cubic polynomial
** public domain by Ross Cottrell
*/
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: cubic
Author: Ross Cottrell
Function: cubic solves some cubic functions
Source: MiBench
http://wwweb.eecs.umich.edu/mibench
Original name: basicmath_small
Changes: no major functional changes
License: this code is FREE with no restrictions
*/
#include "wcclibm.h"
#include "snipmath.h"
/*
Forward declaration of functions
*/
void cubic_solveCubic( float a, float b, float c, float d,
int *solutions, float *x );
void cubic_main( void );
void cubic_init( void );
int cubic_return( void );
int main( void );
/*
Declaration of global variables
*/
float cubic_a1, cubic_b1, cubic_c1, cubic_d1;
float cubic_a2, cubic_b2, cubic_c2, cubic_d2;
float cubic_a3, cubic_b3, cubic_c3, cubic_d3;
float cubic_a4, cubic_b4, cubic_c4, cubic_d4;
float cubic_x[3];
float cubic_X, cubic_Y;
int cubic_solutions;
int cubic_checksum;
/*
Initialization function
*/
void cubic_init( void )
{
cubic_a1 = 1.0f, cubic_b1 = -10.5f, cubic_c1 = 32.0f, cubic_d1 = -30.0f;
cubic_a2 = 1.0f, cubic_b2 = -4.5f, cubic_c2 = 17.0f, cubic_d2 = -30.0f;
cubic_a3 = 1.0f, cubic_b3 = -3.5f, cubic_c3 = 22.0f, cubic_d3 = -31.0f;
cubic_a4 = 1.0f, cubic_b4 = -13.7f, cubic_c4 = 1.0f, cubic_d4 = -35.0f;
cubic_X = 0, cubic_Y = 0;
cubic_checksum = 0;
}
/*
Return function
*/
int cubic_return( void )
{
if ( cubic_checksum == 1051 )
return 0;
else
return -1;
}
/*
Main functions
*/
void cubic_main( void )
{
/* solve some cubic functions */
/* should get 3 solutions: 2, 6 & 2.5 */
cubic_solveCubic( cubic_a1, cubic_b1, cubic_c1, cubic_d1, &cubic_solutions, cubic_x );
cubic_checksum += cubic_solutions;
cubic_solveCubic( cubic_a2, cubic_b2, cubic_c2, cubic_d2, &cubic_solutions, cubic_x );
cubic_checksum += cubic_solutions;
cubic_solveCubic( cubic_a3, cubic_b3, cubic_c3, cubic_d3, &cubic_solutions, cubic_x );
cubic_checksum += cubic_solutions;
cubic_solveCubic( cubic_a4, cubic_b4, cubic_c4, cubic_d4, &cubic_solutions, cubic_x );
cubic_checksum += cubic_solutions;
/* Now solve some random equations */
_Pragma( "loopbound min 5 max 5" )
for ( cubic_a1 = 1; cubic_a1 < 10; cubic_a1 += 2 ) {
_Pragma( "loopbound min 5 max 5" )
for ( cubic_b1 = 10; cubic_b1 > 0; cubic_b1 -= 2 ) {
_Pragma( "loopbound min 7 max 7" )
for ( cubic_c1 = 5; cubic_c1 < 15; cubic_c1 += 1.5f ) {
_Pragma( "loopbound min 5 max 5" )
for ( cubic_d1 = -1; cubic_d1 > -11; cubic_d1 -= 2 ) {
cubic_solveCubic( cubic_a1, cubic_b1, cubic_c1, cubic_d1, &cubic_solutions, cubic_x );
cubic_checksum += cubic_solutions;
}
}
}
}
}
void cubic_solveCubic( float a, float b, float c, float d,
int *solutions, float *x )
{
float a1 = b / a, a2 = c / a, a3 = d / a;
float Q = ( a1 * a1 - 3.0f * a2 ) / 9.0f;
float R = ( 2.0f * a1 * a1 * a1 - 9.0f * a1 * a2 + 27.0f * a3 ) / 54.0f;
float R2_Q3 = R * R - Q * Q * Q;
float theta;
if ( R2_Q3 <= 0 ) {
*solutions = 3;
theta = basicmath___ieee754_acosf( R / basicmath___ieee754_sqrtf( Q * Q * Q ) );
x[0] = -2.0f * basicmath___ieee754_sqrtf( Q ) * basicmath___cosf(
theta / 3.0f ) - a1 / 3.0f;
x[1] = -2.0f * basicmath___ieee754_sqrtf( Q ) * basicmath___cosf( (
theta + 2.0f * PI ) / 3.0f ) - a1 / 3.0f;
x[2] = -2.0f * basicmath___ieee754_sqrtf( Q ) * basicmath___cosf( (
theta + 4.0f * PI ) / 3.0f ) - a1 / 3.0f;
} else {
*solutions = 1;
x[0] = basicmath___ieee754_powf( basicmath___ieee754_sqrtf( R2_Q3 ) +
basicmath___fabsf( R ), 1 / 3.0f );
x[0] += Q / x[0];
x[0] *= ( R < 0.0f ) ? 1 : -1;
x[0] -= a1 / 3.0f;
}
}
int main( void )
{
cubic_init();
cubic_main();
return cubic_return();
}
/*
====================================================
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
*/
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
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 above.
*/
#ifndef _MATH_PRIVATE_H_
#define _MATH_PRIVATE_H_
#include "wcclibm.h"
/* A union which permits us to convert between a float and a 32 bit int. */
typedef union {
float value;
u_int32_t word;
} ieee_float_shape_type;
/* Get a 32 bit int from a float. */
#define GET_FLOAT_WORD(i,d) \
{ \
ieee_float_shape_type gf_u; \
gf_u.value = (d); \
(i) = gf_u.word; \
}
/* Set a float from a 32 bit int. */
#define SET_FLOAT_WORD(d,i) \
{ \
ieee_float_shape_type sf_u; \
sf_u.word = (i); \
(d) = sf_u.value; \
}
#endif /* _MATH_PRIVATE_H_ */
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: pi
Author: unknown
Function: Header file for definition of pi
Source: MiBench
http://wwweb.eecs.umich.edu/mibench
Original name: basicmath_small
Changes: no major functional changes
License: this code is FREE with no restrictions
*/
#ifndef PI__H
#define PI__H
#ifndef PI
#define PI 3.14f
#endif
#endif /* PI__H */
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: snipmath
Author: unknown
Function: Header file for SNIPPETS math functions and macros
Source: MiBench
http://wwweb.eecs.umich.edu/mibench
Original name: basicmath_small
Changes: no major functional changes
License: this code is FREE with no restrictions
*/
/*
SNIPMATH.H - Header file for SNIPPETS math functions and macros
*/
#ifndef SNIPMATH__H
#define SNIPMATH__H
#include "wcclibm.h"
#include "pi.h"
struct int_sqrt {
unsigned short sqrt,
frac;
};
#endif /* SNIPMATH__H */
This diff is collapsed.
/*
====================================================
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.
====================================================
*/
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: wcclibm.h
Author: Unknown
Function: IEEE754 software library routines.
Source: Sun Microsystems
Original name: wcclibm.h
Changes: No major functional changes.
License: See the terms above.
*/
#ifndef _WCCLIBM
#define _WCCLIBM
#define int32_t int
#define u_int32_t unsigned int
// Often used variables/consts
static const float basicmath_one = 1.0f,
basicmath_tiny = 1.0e-30f,
basicmath_half = 5.0000000000e-01, /* 0x3f000000 */
basicmath_huge = 1.0e30,
basicmath_two = 2.0,
basicmath_two24 = 16777216.0, /* 0x4b800000 */
basicmath_zero = 0.0;
float basicmath___copysignf( float x, float y );
float basicmath___cosf( float x );
float basicmath___fabsf( float x );
float basicmath___ieee754_acosf( float x );
float basicmath___ieee754_powf( float x, float y );
int32_t basicmath___ieee754_rem_pio2f( float x, float *y );
float basicmath___ieee754_sqrtf( float x );
int basicmath___isinff ( float x );
float basicmath___kernel_cosf( float x, float y );
float basicmath___kernel_sinf( float x, float y, int iy );
float basicmath___scalbnf ( float x, int n );
#endif // _WCCLIBM
Original provenience: MiBench benchmark suite,
http://wwweb.eecs.umich.edu/mibench
2016-02-09:
- Added TACLeBench header
- Renamed benchmark from 'basicmath_small' to 'basicmath'
- Fixed a typo in code comments: 'soem' -> 'some'
- Removed unused variable 'n' from the main funcion
- Added variable 'double Y' to the main function and accumulated the results of
'deg2rad(X)' and 'rad2deg(X)' in this variable so that the compiler warning
'statement with no effect' is fixed.
- Removed conditionally compiled main (test) function from isqrt.c
- Removed conditionally compiled main (test) function from cubic.c
- Removed commented-out code
- Removed unused function, variable, macro and type declarations, structs and
unions
- Removed seemingly unnecessary empty lines
- Renamed memcpy.t to basicmath_libc.c
- Removed unused files:
rad2deg.c
sniptype.h
sniptype.h
- Created basicmath_libc.h and put declaration of basicmath_memcpy() in it
- Reorganized snipmath.h so that the following are in the given order just
after the header
- includes
- declarations of functions
- Reorganized sniptype.h so that the following are in the given order just
after the header
- macro definitions
- type definitions
- Removed duplicated copyright information from wcclibm.c
- Removed __STDC__ checks from wcclibm.c and used only ANSI style function
arguments
- Removed 'last modified' comments from files
- Removed mention 'use __kernel_rem_pio2f()' from comments of function
__ieee754_rem_pio2f() since it doesn't really use it.
- Removed math functions specialization macros from wcclibm.h and updated call
sites with explicit nameks of the functions.
- Removed '#define double float' from wcclibm.h and replaced all 'double's
with 'float's in the benchmark
- Added a new main function that calls the old main function
- Annotated basicmath_main() as the entry point of the analysis
- Applied code formatting according to the following rules
- Lines shall not be wider than 80 characters; whenever possible, appropriate
line breaks shall be inserted to keep lines below 80 characters
- Indentation is done using whitespaces only, no tabs. Code is indented by
two whitespaces
- Two empty lines are put between any two functions
- In non-empty lists or index expressions, opening '(' and '[' are followed by
one whitespace, closing ')' and ']' are preceded by one whitespace
- In comma- or colon-separated argument lists, one whitespace is put after
each comma/colon
- Names of functions and global variables all start with a benchmark-specific
prefix (here: statemate_) followed by lowercase letter
- For pointer types, one whitespace is put before the '*'
- Operators within expressions shall be preceded and followed by one
whitespace
- Code of then- and else-parts of if-then-else statements shall be put in
separate lines, not in the same lines as the if-condition or the keyword
"else"
- Opening braces '{' denoting the beginning of code for some if-else or loop
body shall be put at the end of the same line where the keywords "if",
"else", "for", "while" etc. occur
2017-06-27
- Introduce basicmath_init and basicmath_return functions.
- Add prefix basicmath_ to global variables.
- Introduce dummy initialization in ieee754_rem_pio2f to please linter.
2017-07-10
- Fix possible stack buffer overflow caused by sizeof of incorrect type.
2019-03-07
-split basicmath into seperate files
-Add TACLeBench Header
-put each benchmark into a seperate folder
-adjust the code formatting to the common TACLeBench code style
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: deg2rad
Author: unknown
Function: deg2rad performs conversion of degree to radiant
Source: MiBench
http://wwweb.eecs.umich.edu/mibench
Original name: basicmath_small
Changes: no major functional changes
License: this code is FREE with no restrictions
*/
#include "pi.h"
#define deg2rad(d) ((d)*PI/180)
/*
Forward declaration of functions
*/
void deg2rad_init( void );
void deg2rad_main( void );
int deg2rad_return( void );
int main( void );
/*
Declaration of global variables
*/
float deg2rad_X, deg2rad_Y;
/*
Initialization function
*/
void deg2rad_init( void )
{
deg2rad_X = 0;
deg2rad_Y = 0;
}
/*
Return function
*/
int deg2rad_return( void )
{
int temp = deg2rad_Y;
if ( temp == 1133 )
return 0;
else
return -1;
}
/*
Main functions
*/
void deg2rad_main( void )
{
/* convert some rads to degrees */
_Pragma( "loopbound min 361 max 361" )
for ( deg2rad_X = 0.0f; deg2rad_X <= 360.0f; deg2rad_X += 1.0f )
deg2rad_Y += deg2rad( deg2rad_X );
}
int main( void )
{
deg2rad_init();
deg2rad_main();
return deg2rad_return();
}
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: pi
Author: unknown
Function: Header file for definition of pi
Source: MiBench
http://wwweb.eecs.umich.edu/mibench
Original name: basicmath_small
Changes: no major functional changes
License: this code is FREE with no restrictions
*/
#ifndef PI__H
#define PI__H
#ifndef PI
#define PI 3.14f
#endif
#endif /* PI__H */
Original provenience: MiBench benchmark suite,
http://wwweb.eecs.umich.edu/mibench
2016-02-09:
- Added TACLeBench header
- Renamed benchmark from 'basicmath_small' to 'basicmath'
- Fixed a typo in code comments: 'soem' -> 'some'
- Removed unused variable 'n' from the main funcion
- Added variable 'double Y' to the main function and accumulated the results of
'deg2rad(X)' and 'rad2deg(X)' in this variable so that the compiler warning
'statement with no effect' is fixed.
- Removed conditionally compiled main (test) function from isqrt.c
- Removed conditionally compiled main (test) function from cubic.c
- Removed commented-out code
- Removed unused function, variable, macro and type declarations, structs and
unions
- Removed seemingly unnecessary empty lines
- Renamed memcpy.t to basicmath_libc.c
- Removed unused files:
rad2deg.c
sniptype.h
sniptype.h
- Created basicmath_libc.h and put declaration of basicmath_memcpy() in it
- Reorganized snipmath.h so that the following are in the given order just
after the header
- includes
- declarations of functions
- Reorganized sniptype.h so that the following are in the given order just
after the header
- macro definitions
- type definitions
- Removed duplicated copyright information from wcclibm.c
- Removed __STDC__ checks from wcclibm.c and used only ANSI style function
arguments
- Removed 'last modified' comments from files
- Removed mention 'use __kernel_rem_pio2f()' from comments of function
__ieee754_rem_pio2f() since it doesn't really use it.
- Removed math functions specialization macros from wcclibm.h and updated call
sites with explicit nameks of the functions.
- Removed '#define double float' from wcclibm.h and replaced all 'double's
with 'float's in the benchmark
- Added a new main function that calls the old main function
- Annotated basicmath_main() as the entry point of the analysis
- Applied code formatting according to the following rules
- Lines shall not be wider than 80 characters; whenever possible, appropriate
line breaks shall be inserted to keep lines below 80 characters
- Indentation is done using whitespaces only, no tabs. Code is indented by
two whitespaces
- Two empty lines are put between any two functions
- In non-empty lists or index expressions, opening '(' and '[' are followed by
one whitespace, closing ')' and ']' are preceded by one whitespace
- In comma- or colon-separated argument lists, one whitespace is put after
each comma/colon
- Names of functions and global variables all start with a benchmark-specific
prefix (here: statemate_) followed by lowercase letter
- For pointer types, one whitespace is put before the '*'
- Operators within expressions shall be preceded and followed by one
whitespace
- Code of then- and else-parts of if-then-else statements shall be put in
separate lines, not in the same lines as the if-condition or the keyword
"else"
- Opening braces '{' denoting the beginning of code for some if-else or loop
body shall be put at the end of the same line where the keywords "if",
"else", "for", "while" etc. occur
2017-06-27
- Introduce basicmath_init and basicmath_return functions.
- Add prefix basicmath_ to global variables.
- Introduce dummy initialization in ieee754_rem_pio2f to please linter.
2017-07-10
- Fix possible stack buffer overflow caused by sizeof of incorrect type.
2019-03-07
-split basicmath into seperate files
-Add TACLeBench Header
-put each benchmark into a seperate folder
-adjust the code formatting to the common TACLeBench code style
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: basicmath_libc
Author: unknown
Function: Implementation of basicmath_memcpy
Source: MiBench
http://wwweb.eecs.umich.edu/mibench
Original name: basicmath_small
Changes: no major functional changes
License: this code is FREE with no restrictions
*/
void basicmath_memcpy( void *a, const void *b, int c )
{
char *dest = ( char * ) a;
char *source = ( char * ) b;
int copied;
_Pragma( "loopbound min 4 max 4" )
for ( copied = 0; copied < c; copied++ ) {
*dest = *source;
dest++;
source++;
}
}
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: basicmath_libc
Author: unknown
Function: Header file for declaration of basicmath_memcpy
Source: MiBench
http://wwweb.eecs.umich.edu/mibench
Original name: basicmath_small
Changes: no major functional changes
License: this code is FREE with no restrictions
*/
#ifndef __BASICMATH_LIBC_H_
#define __BASICMATH_LIBC_H_
void basicmath_memcpy( void *a, const void *b, int c );
#endif // __BASICMATH_LIBC_H_
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: isqrt
Author: unknown
Function: isqrt calculates the integer square root of a number
Source: MiBench
http://wwweb.eecs.umich.edu/mibench
Original name: basicmath_small
Changes: no major functional changes
License: this code is FREE with no restrictions
*/
#include "basicmath_libc.h"
#include "snipmath.h"
#define BITSPERLONG 32
#define TOP2BITS(x) ((x & (3L << (BITSPERLONG-2))) >> (BITSPERLONG-2))
/* usqrt:
ENTRY x: unsigned long
EXIT returns floor(sqrt(x) * pow(2, BITSPERLONG/2))
Since the square root never uses more than half the bits
of the input, we use the other half of the bits to contain
extra bits of precision after the binary point.
EXAMPLE
suppose BITSPERLONG = 32
then usqrt(144) = 786432 = 12 * 65536
usqrt(32) = 370727 = 5.66 * 65536
NOTES
(1) change BITSPERLONG to BITSPERLONG/2 if you do not want
the answer scaled. Indeed, if you want n bits of
precision after the binary point, use BITSPERLONG/2+n.
The code assumes that BITSPERLONG is even.
(2) This is really better off being written in assembly.
The line marked below is really a "arithmetic shift left"
on the double-long value with r in the upper half
and x in the lower half. This operation is typically
expressible in only one or two assembly instructions.
(3) Unrolling this loop is probably not a bad idea.
ALGORITHM
The calculations are the base-two analogue of the square
root algorithm we all learned in grammar school. Since we're
in base 2, there is only one nontrivial trial multiplier.
Notice that absolutely no multiplications or divisions are performed.
This means it'll be fast on a wide range of processors.
*/
/*
Forward declaration of functions
*/
void isqrt_usqrt( unsigned long x, struct int_sqrt *q );
void isqrt_init( void );
void isqrt_main( void );
int isqrt_return( void );
int main( void );
/*
Declaration of global variables
*/
int isqrt_i;
struct int_sqrt isqrt_q;
unsigned long isqrt_l;
unsigned long isqrt_checksum;
/*
Initialization function
*/
void isqrt_init( void )
{
isqrt_l = 0x3fed0169L;
isqrt_checksum = 0;
}
/*
Return function
*/
int isqrt_return( void )
{
if ( isqrt_checksum == 53364 )
return 0;
else
return -1;
}
/*
Main functions
*/
void isqrt_usqrt( unsigned long x, struct int_sqrt *q )
{
unsigned long a = 0L; /* accumulator */
unsigned long r = 0L; /* remainder */
unsigned long e = 0L; /* trial product */
int i;
_Pragma( "loopbound min 32 max 32" )
for ( i = 0; i < BITSPERLONG; i++ ) { /* NOTE 1 */
r = ( r << 2 ) + TOP2BITS( x );
x <<= 2; /* NOTE 2 */
a <<= 1;
e = ( a << 1 ) + 1;
if ( r >= e ) {
r -= e;
a++;
}
}
basicmath_memcpy( q, &a, sizeof( *q ) );
}
void isqrt_main( void )
{
/* perform some integer square roots */
_Pragma( "loopbound min 1000 max 1000" )
for ( isqrt_i = 1; isqrt_i < 1001; isqrt_i += 1 ) {
isqrt_usqrt( isqrt_i, &isqrt_q );
isqrt_checksum += isqrt_q.frac;
// remainder differs on some machines
}
isqrt_usqrt( isqrt_l, &isqrt_q );
isqrt_checksum += isqrt_q.frac;
}
int main( void )
{
isqrt_init();
isqrt_main();
return isqrt_return();
}
/*
====================================================
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
*/
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
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 above.
*/
#ifndef _MATH_PRIVATE_H_
#define _MATH_PRIVATE_H_
#include "wcclibm.h"
/* A union which permits us to convert between a float and a 32 bit int. */
typedef union {
float value;
u_int32_t word;
} ieee_float_shape_type;
/* Get a 32 bit int from a float. */
#define GET_FLOAT_WORD(i,d) \
{ \
ieee_float_shape_type gf_u; \
gf_u.value = (d); \
(i) = gf_u.word; \
}
/* Set a float from a 32 bit int. */
#define SET_FLOAT_WORD(d,i) \
{ \
ieee_float_shape_type sf_u; \
sf_u.word = (i); \
(d) = sf_u.value; \
}
#endif /* _MATH_PRIVATE_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment