add tacle demo

This commit is contained in:
Alwin Berger 2023-01-24 09:11:21 +01:00
parent 5dc9db28a0
commit aeb22a409c
109 changed files with 17468 additions and 0 deletions

View File

@ -78,6 +78,11 @@ ifeq ($(TMR_DEMO), 1)
SOURCE_FILES += main_tmr.c SOURCE_FILES += main_tmr.c
CFLAGS := -DmainCREATE_TMR_DEMO=1 CFLAGS := -DmainCREATE_TMR_DEMO=1
else
ifeq ($(TACLE_DEMO), 1)
SOURCE_FILES += main_tacle.c
CFLAGS := -DmainCREATE_TACLE_DEMO=1
else else
SOURCE_FILES += main_blinky.c SOURCE_FILES += main_blinky.c
@ -87,6 +92,7 @@ endif
endif endif
endif endif
endif endif
endif
DEFINES := -DQEMU_SOC_MPS2 -DHEAP3 DEFINES := -DQEMU_SOC_MPS2 -DHEAP3

View File

@ -79,6 +79,10 @@ int main()
{ {
main_tmr(); main_tmr();
} }
#elif ( mainCREATE_TACLE_DEMO == 1 )
{
main_tacle();
}
#else #else
{ {
#error "Invalid Selection...\nPlease Select a Demo application from the main command" #error "Invalid Selection...\nPlease Select a Demo application from the main command"

View File

@ -0,0 +1,250 @@
/*
* FreeRTOS V202111.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
#include <FreeRTOS.h>
#include <task.h>
#include <queue.h>
#include <stdio.h>
/*
TMR Demo with retry
prvSamplerTask will read 4 Bytes of Input into a buffer, unlocks xMutexInput
prvReplicateA and prvReplicateB wait on xMutexInput to average the Inputs and
sum up all numbers up to the Input.
ReplicateA will fail if mod 11 = 0, but only once
ReplicateB will fail if mod 12 = 0
ReplicateC also exists and will never fail, does not run by default
Each Replicate outputs to it's own queue
prvVoterTask will wait on ReplicateA&B
If they disagree ReplicateC will be started by mutex.
If all the Replicates disagree now the sampler will be engaged once more
*/
// include tacle benches
#include "tacle/kernel/bsort/bsort.c" // int bsort_BubbleSort( int Array[] )
#include "tacle/kernel/fac/fac.c" // int fac_fac ( int n )
#include "tacle/kernel/recursion/recursion.c" // int recursion_fib( int i )
#include "tacle/kernel/prime/prime.c" // unsigned char prime_prime ( unsigned int n )
#include "tacle/kernel/insertsort/insertsort.c" // unsigned char prime_prime ( unsigned int n )
__attribute__((noinline)) static void trigger_Qemu_break( void )
{
puts("Trigger");
while (1) {
}
}
// Begin Input Stuff
volatile unsigned char FUZZ_INPUT[4096] = {0xa,0xb,0xc,0xd,0xe,0xf};
volatile uint32_t FUZZ_LENGTH = 4096;
volatile uint32_t FUZZ_POINTER = 0;
// Read the Byte of Input, if the Input is exausted trigger the breakpoint instead
static unsigned char fuzz_input_next(void) {
// printf("Get next Input from %lx \n",FUZZ_INPUT);
if (FUZZ_POINTER < FUZZ_LENGTH) {
FUZZ_POINTER++;
// printf("Input no. %d %x\n",FUZZ_POINTER-1,FUZZ_INPUT[FUZZ_POINTER-1]);
return FUZZ_INPUT[FUZZ_POINTER-1];
} else {
// puts("End of Input");
// Exausted inputs early
trigger_Qemu_break();
}
}
// End Input Stuff
static void prvStage0( void * pvParameters );
static void prvStage1( void * pvParameters );
static void prvStage2a( void * pvParameters );
static void prvStage2b( void * pvParameters );
static void prvStage3( void * pvParameters );
static void prvStage4( void * pvParameters );
#define mainSTAGE0_TASK_PRIO ( tskIDLE_PRIORITY + 1 )
#define mainSTAGE1_TASK_PRIO ( tskIDLE_PRIORITY + 2 )
#define mainSTAGE2_TASK_PRIO ( tskIDLE_PRIORITY + 3 )
#define mainSTAGE3_TASK_PRIO ( tskIDLE_PRIORITY + 4 )
#define mainSTAGE4_TASK_PRIO ( tskIDLE_PRIORITY + 5 )
// Handles for direct messages
static TaskHandle_t xStage0 = NULL;
static TaskHandle_t xStage1 = NULL;
static TaskHandle_t xStage2a = NULL;
static TaskHandle_t xStage2b = NULL;
static TaskHandle_t xStage3 = NULL;
static TaskHandle_t xStage4 = NULL;
void main_tacle( void )
{
/* Start the two tasks as described in the comments at the top of this
* file. */
xTaskCreate( prvStage0, /* The function that implements the task. */
"Stage0", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
NULL, /* The parameter passed to the task - not used in this case. */
mainSTAGE0_TASK_PRIO, /* The priority assigned to the task. */
&xStage0 ); /* The task handle is not required, so NULL is passed. */
xTaskCreate( prvStage1, /* The function that implements the task. */
"Stage1", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
NULL, /* The parameter passed to the task - not used in this case. */
mainSTAGE1_TASK_PRIO, /* The priority assigned to the task. */
&xStage1 ); /* The task handle is not required, so NULL is passed. */
xTaskCreate( prvStage2a, /* The function that implements the task. */
"Stage2a", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
NULL, /* The parameter passed to the task - not used in this case. */
mainSTAGE2_TASK_PRIO, /* The priority assigned to the task. */
&xStage2a ); /* The task handle is not required, so NULL is passed. */
xTaskCreate( prvStage2b,
"Stage2b",
configMINIMAL_STACK_SIZE,
NULL,
mainSTAGE2_TASK_PRIO,
&xStage2b );
xTaskCreate( prvStage3,
"Stage3",
configMINIMAL_STACK_SIZE,
NULL,
mainSTAGE3_TASK_PRIO,
&xStage3 );
xTaskCreate( prvStage4, /* The function that implements the task. */
"Stage4", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
NULL, /* The parameter passed to the task - not used in this case. */
mainSTAGE4_TASK_PRIO, /* The priority assigned to the task. */
&xStage4 ); /* The task handle is not required, so NULL is passed. */
/* Start the tasks and timer running. */
vTaskStartScheduler();
/* If all is well, the scheduler will now be running, and the following
* line will never be reached. If the following line does execute, then
* there was insufficient FreeRTOS heap memory available for the Idle and/or
* timer tasks to be created. See the memory management section on the
* FreeRTOS web site for more details on the FreeRTOS heap
* http://www.freertos.org/a00111.html. */
for( ; ; )
{
}
}
static void prvStage0( void * pvParameters )
{
while (1)
{
puts("Stage 0");
for (int i=0; i<bsort_SIZE; i++)
{
char buf[sizeof(int)];
for (int j=0; j<sizeof(int);j++) {
buf[j]=fuzz_input_next();
}
bsort_Array[i]=*((int*)&buf);
}
bsort_BubbleSort(bsort_Array);
xTaskNotifyGive(xStage1);
}
}
static void prvStage1( void * pvParameters )
{
while (1)
{
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
puts("Stage 1");
char buf[sizeof(int)];
for (int j=0; j<sizeof(int);j++) {
buf[j]=fuzz_input_next();
}
if (*((unsigned int*)&buf) < 0xEFFF) {
xTaskNotifyGive(xStage2a);
} else {
xTaskNotifyGive(xStage2b);
}
}
}
static void prvStage2a( void * pvParameters )
{
while (1)
{
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
puts("Stage 2a");
int n = bsort_Array[bsort_SIZE-1];
if (n>0) {bsort_Array[bsort_SIZE-1] = fac_fac(n >> 26);}
xTaskNotifyGive(xStage3);
}
}
static void prvStage2b( void * pvParameters )
{
while (1)
{
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
puts("Stage 2b");
int n = bsort_Array[bsort_SIZE-1];
if (n>0) {bsort_Array[bsort_SIZE-1] = recursion_fib(n >> 26);}
xTaskNotifyGive(xStage3);
}
}
static void prvStage3( void * pvParameters )
{
while (1)
{
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
puts("Stage 3");
int n = bsort_Array[bsort_SIZE-1];
if (n>0) {bsort_Array[bsort_SIZE-1] = prime_prime((unsigned int)n);}
xTaskNotifyGive(xStage4);
}
}
static void prvStage4( void * pvParameters )
{
while (1) {
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
puts("Stage 4");
for (int i=0; i<bsort_SIZE/2 && i<100/2; i++)
{
char buf[sizeof(int)];
for (int j=0; j<sizeof(int);j++) {
buf[j]=fuzz_input_next();
}
bsort_Array[i]=*((int*)&buf);
}
insertsort_initialize(bsort_Array);
insertsort_main();
trigger_Qemu_break();
}
}
void isr_starter( void )
{
}
/*-----------------------------------------------------------*/

View File

@ -0,0 +1,42 @@
File: binarysearch.c
Original provenience: Mälardalen benchmark suite,
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/bs
2015-10-10:
- Removed original header comment, replaced by TACLeBench header.
- Added prefix "binarysearch_" to all global symbols.
- Added explicit forward declarations of functions, removed obsolete forward
declaration of function binary_search.
- Replaced initialization of global array "binarysearch_data" by
TACLeBench-compliant initialization code.
- Added new global variable "binarysearch_result" to store the found return
value.
- Added new function binarysearch_return producing the searched data element as
return value.
- Removed global variable "binarysearch_cnt1" that was used for profiling.
- Added new function binarysearch_main according to TACLeBench guidelines.
binarysearch_main is annotated as entry-point for timing analysis.
- Corrected flow fact in function "binarysearch_binary_search" to cover the
interval [1, 4] instead of [4, 4].
- 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: binarysearch_) followed by lowercase letter (e.g.,
binarysearch_square)
- 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

View File

@ -0,0 +1,156 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: binarysearch
Author: Sung-Soo Lim <sslim@archi.snu.ac.kr>
Function: binarysearch performs binary search in an array of 15 integer
elements.
This program is completely structured (no unconditional jumps, no exits
from loop bodies), and does not contain switch statements, no do-while
loops.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/bs/bs.c
Original name: bs
Changes: No major functional changes.
License: May be used, modified, and re-distributed freely, but
the SNU-RT Benchmark Suite must be acknowledged
*/
/*
This program is derived from the SNU-RT Benchmark Suite for Worst
Case Timing Analysis by Sung-Soo Lim
*/
/*
Forward declaration of functions
*/
void binarysearch_initSeed( void );
long binarysearch_randomInteger( void );
void binarysearch_init( void );
int binarysearch_return( void );
int binarysearch_binary_search( int );
void binarysearch_main( void );
int main( void );
/*
Declaration of global variables
*/
volatile int binarysearch_seed;
struct binarysearch_DATA {
int key;
int value;
};
struct binarysearch_DATA binarysearch_data[ 15 ];
int binarysearch_result;
/*
Initialization- and return-value-related functions
*/
/*
binarysearch_initSeed initializes the seed used in the "random" number
generator.
*/
void binarysearch_initSeed( void )
{
binarysearch_seed = 0;
}
/*
binarysearch_RandomInteger generates "random" integers between 0 and 8094.
*/
long binarysearch_randomInteger( void )
{
binarysearch_seed = ( ( binarysearch_seed * 133 ) + 81 ) % 8095;
return ( binarysearch_seed );
}
void binarysearch_init( void )
{
int i;
binarysearch_initSeed();
_Pragma( "loopbound min 15 max 15" )
for ( i = 0; i < 15; ++i ) {
binarysearch_data[ i ].key = binarysearch_randomInteger();
binarysearch_data[ i ].value = binarysearch_randomInteger();
}
}
int binarysearch_return( void )
{
return ( binarysearch_result );
}
/*
Algorithm core functions
*/
int binarysearch_binary_search( int x )
{
int fvalue, mid, up, low;
low = 0;
up = 14;
fvalue = -1;
_Pragma( "loopbound min 1 max 4" )
while ( low <= up ) {
mid = ( low + up ) >> 1;
if ( binarysearch_data[ mid ].key == x ) {
/* Item found */
up = low - 1;
fvalue = binarysearch_data[ mid ].value;
} else
if ( binarysearch_data[ mid ].key > x )
/* Item not found */
up = mid - 1;
else
low = mid + 1;
}
return ( fvalue );
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) binarysearch_main( void )
{
binarysearch_result = binarysearch_binary_search( 8 );
}
int main( void )
{
binarysearch_init();
binarysearch_main();
return ( binarysearch_return() - ( -1 ) != 0 );
}

View File

@ -0,0 +1,81 @@
File: bitcnt_1.c
Original provenience:
2017-04-18:
- Annotated bitcount_main as entry-point for timing analysis
2015-10-12:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Changed function bit_count to bitcount_bit_count
- Applied Code Style
File: bitcnt_2.c
Original provenience:
2015-10-12:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Changed function bitcount to bitcount_bitcount
- Applied Code Style
File: bitcnt_3.c
Original provenience:
2015-10-12:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Changed function {name} to bitcount_{name}
- Changed global variable bits to bitcount_bits
- Made int i volatile to prevent compiler optimalizations
- Added the bitcount_init3() function to initialize bitcount_bits during the init fase
- Applied Code Style
File: bitcnt_4.c
Original provenience:
2015-10-12:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Changed function {name} to bitcount_{name}
- Changed global variable bits to bitcount_bits
- Made int i volatile to prevent compiler optimalizations
- Added the bitcount_init4() function to initialize bitcount_bits during the init fase
- Applied Code Style
File: bitcount.c
Original provenience:
2015-10-12:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Changed global variable _randseed to bitcount_randseed
- Changed function {name} to bitcount_{name}
- Changed external functions to new name
- Moved local variables of main to global variables
- Added bitcount_init function to initialize global variables
- Added bitcount_main function for the calculations
- Added bitcount_main function for the return value
- Applied Code Style
File: bitops.h
Original provenience:
2015-10-12:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Removed unused defines
- Removed typedef unsigned int size_t ==> no references
- Replaced CHAR_BIT with value 8 and removed the define
- Applied Code Style
File: sniptype.h
Original provenience:
2015-10-12:
- Removed file, no usage of the definations and typedefs

View File

@ -0,0 +1,3 @@
From http://www.snippets.org/.
This code is FREE with no restrictions.

View File

@ -0,0 +1,36 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: bitcnt_1.c
Author: Ratko Tomic
Function: Test program for bit counting functions
Source: http://www.snippets.org/.
Changes: no major functional changes
License: May be used, modified, and re-distributed freely.
*/
#include "bitops.h"
int bitcount_bit_count( long x )
{
int n = 0;
/*
** The loop will execute once for each bit of x set, this is in average
** twice as fast as the shift/test method.
*/
if ( x ) {
_Pragma( "loopbound min 3 max 8" )
do {
n++;
} while ( 0 != ( x = x & ( x - 1 ) ) ) ;
}
return ( n );
}

View File

@ -0,0 +1,31 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: bitcnt_2.c
Author: Bob Stout & Auke Reitsma
Function: Test program for bit counting functions
Source: http://www.snippets.org/
Changes: no major functional changes
License: May be used, modified, and re-distributed freely.
*/
#include "bitops.h"
int bitcount_bitcount( long i )
{
i = ( ( i & 0xAAAAAAAAL ) >> 1 ) + ( i & 0x55555555L );
i = ( ( i & 0xCCCCCCCCL ) >> 2 ) + ( i & 0x33333333L );
i = ( ( i & 0xF0F0F0F0L ) >> 4 ) + ( i & 0x0F0F0F0FL );
i = ( ( i & 0xFF00FF00L ) >> 8 ) + ( i & 0x00FF00FFL );
i = ( ( i & 0xFFFF0000L ) >> 16 ) + ( i & 0x0000FFFFL );
return ( int )i;
}

View File

@ -0,0 +1,106 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: bitcnt_3.c
Author: Bob Stout & Auke Reitsma
Function: Bit counting functions using table lookup
Source: http://www.snippets.org/
Changes: no major functional changes
License: May be used, modified, and re-distributed freely.
*/
#include "bitops.h"
static char bitcount_bits[ 256 ];
/*
** Count bits in each nybble
**
** Note: Only the first 16 table entries are used, the rest could be
** omitted.
*/
void bitcount_init3( void )
{
int volatile i = 0;
char bitcount_bits_tmp[ 256 ] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
};
for ( i = 0; i < 256; i++ )
bitcount_bits[ i ] = bitcount_bits_tmp[ i ];
}
int bitcount_ntbl_bitcount( long int x )
{
return
bitcount_bits[ ( int ) ( x & 0x0000000FUL ) ] +
bitcount_bits[ ( int )( ( x & 0x000000F0UL ) >> 4 ) ] +
bitcount_bits[ ( int )( ( x & 0x00000F00UL ) >> 8 ) ] +
bitcount_bits[ ( int )( ( x & 0x0000F000UL ) >> 12 ) ] +
bitcount_bits[ ( int )( ( x & 0x000F0000UL ) >> 16 ) ] +
bitcount_bits[ ( int )( ( x & 0x00F00000UL ) >> 20 ) ] +
bitcount_bits[ ( int )( ( x & 0x0F000000UL ) >> 24 ) ] +
bitcount_bits[ ( int )( ( x & 0xF0000000UL ) >> 28 ) ];
}
/*
** Count bits in each byte
**
** by Bruce Wedding, works best on Watcom & Borland
*/
int bitcount_BW_btbl_bitcount( long int x )
{
union {
unsigned char ch[ 4 ];
long y;
} U;
U.y = x;
return bitcount_bits[ U.ch[ 0 ] ] + bitcount_bits[ U.ch[ 1 ] ] +
bitcount_bits[ U.ch[ 3 ] ] + bitcount_bits[ U.ch[ 2 ] ];
}
/*
** Count bits in each byte
**
** by Auke Reitsma, works best on Microsoft, Symantec, and others
*/
int bitcount_AR_btbl_bitcount( long int x )
{
unsigned char *ptr = ( unsigned char * ) & x ;
int accu ;
accu = bitcount_bits[ *ptr++ ];
accu += bitcount_bits[ *ptr++ ];
accu += bitcount_bits[ *ptr++ ];
accu += bitcount_bits[ *ptr ];
return accu;
}

View File

@ -0,0 +1,86 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: bitcnt_4.c
Author: Bob Stout
Function: Recursive bit counting functions using table lookup
Source: http://www.snippets.org/
Changes: no major functional changes
License: May be used, modified, and re-distributed freely.
*/
#include "bitops.h" /* from Snippets */
static char bitcount_bits[ 256 ];
/*
** Count bits in each nybble
**
** Note: Only the first 16 table entries are used, the rest could be
** omitted.
*/
void bitcount_init4( void )
{
int volatile i = 0;
char bitcount_bits_tmp[ 256 ] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
};
for ( i = 0; i < 256; i++ )
bitcount_bits[ i ] = bitcount_bits_tmp[ i ];
}
int bitcount_ntbl_bitcnt( unsigned long x )
{
int cnt = bitcount_bits[ ( int )( x & 0x0000000FL ) ];
if ( 0L != ( x >>= 4 ) )
cnt += bitcount_ntbl_bitcnt( x );
return cnt;
}
/*
** Count bits in each byte
*/
int bitcount_btbl_bitcnt( unsigned long x )
{
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
int idx = sizeof(x) - 1;
#else
int idx = 0;
#endif
int cnt = bitcount_bits[( ( char * ) & x )[idx] & 0xFF];
if ( 0L != ( x >>= 8 ) )
cnt += bitcount_btbl_bitcnt( x );
return cnt;
}

View File

@ -0,0 +1,146 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: bitcount.c
Author: Bob Stout & Auke Reitsma
Function: test program for bit counting functions
Source: www.snippest.com
Changes: no major functional changes
License: May be used, modified, and re-distributed freely.
*/
#include "bitops.h"
#define FUNCS 8
/*
Global variables
*/
unsigned long bitcount_randseed;
int bitcount_res;
unsigned long bitcount_seed;
unsigned long bitcount_n;
unsigned int bitcount_iterations;
/*
First declaration of the functions
*/
int bitcount_bit_shifter( long int x );
unsigned long bitcount_random( void );
void bitcount_main();
int bitcount_return();
void bitcount_init();
int main( void );
int bitcount_bit_shifter( long int x )
{
int n;
unsigned int i;
_Pragma( "loopbound min 31 max 31" )
for ( i = n = 0; x && ( i < ( sizeof( long ) * 8 ) ); ++i, x >>= 1 )
n += ( int )( x & 1L );
return n;
}
int bitcount_return()
{
return ( bitcount_n + ( -1095 ) ) != 0;
}
void bitcount_init()
{
bitcount_randseed = 1;
bitcount_n = 0;
bitcount_iterations = 10;
bitcount_init3();
bitcount_init4();
}
unsigned long bitcount_random( void )
{
long x, hi, lo, t;
/*
Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1).
From "Random number generators: good ones are hard to find",
Park and Miller, Communications of the ACM, vol. 31, no. 10,
October 1988, p. 1195.
*/
x = bitcount_randseed;
hi = x / 127773;
lo = x % 127773;
t = 16807 * lo - 2836 * hi;
if ( t <= 0 )
t += 0x7fffffff;
bitcount_randseed = t;
return ( t );
}
void _Pragma( "entrypoint" ) bitcount_main()
{
unsigned int i, j;
_Pragma( "loopbound min 8 max 8" )
for ( i = 0; i < FUNCS; i++ ) {
_Pragma( "loopbound min 10 max 10" )
for ( j = 0, bitcount_seed = bitcount_random(); j < bitcount_iterations;
j++, bitcount_seed += 13 ) {
// The original calls were done by function pointers
switch ( i ) {
case 0:
bitcount_res = bitcount_bit_count( bitcount_seed );
break;
case 1:
bitcount_res = bitcount_bitcount( bitcount_seed );
break;
case 2: {
_Pragma( "marker call_ntbl" )
bitcount_res = bitcount_ntbl_bitcnt( bitcount_seed );
break;
}
case 3: {
_Pragma( "marker call_btbl" )
bitcount_res = bitcount_btbl_bitcnt( bitcount_seed );
break;
}
case 4:
bitcount_res = bitcount_ntbl_bitcount( bitcount_seed );
break;
case 5:
bitcount_res = bitcount_BW_btbl_bitcount( bitcount_seed );
break;
case 6:
bitcount_res = bitcount_AR_btbl_bitcount( bitcount_seed );
break;
case 7:
bitcount_res = bitcount_bit_shifter( bitcount_seed );
break;
default:
break;
}
bitcount_n += bitcount_res;
}
}
_Pragma( "flowrestriction 1*ntbl_bitcount <= 8*call_ntbl" )
_Pragma( "flowrestriction 1*btbl_bitcount <= 4*call_btbl" )
}
int main( void )
{
bitcount_init();
bitcount_main();
return ( bitcount_return() );
}

View File

@ -0,0 +1,50 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: bitops.h
Author: Bob Stout & Auke Reitsma
Function: test program for bit counting functions
Source:
Changes: no major functional changes
License: May be used, modified, and re-distributed freely.
*/
#ifndef BITOPS__H
#define BITOPS__H
/*
** bitcount_1.c
*/
int bitcount_bit_count( long x );
/*
** bitcount_2.c
*/
int bitcount_bitcount( long i );
/*
** bitcount_3.c
*/
void bitcount_init3( void );
int bitcount_ntbl_bitcount( long int x );
int bitcount_BW_btbl_bitcount( long int x );
int bitcount_AR_btbl_bitcount( long int x );
/*
** bitcount_4.c
*/
void bitcount_init4( void );
int bitcount_ntbl_bitcnt( unsigned long x );
int bitcount_btbl_bitcnt( unsigned long x );
#endif /* BITOPS__H */

View File

@ -0,0 +1,53 @@
File: bitonic.c
Original provenience: StreamIt benchmark suite,
http://groups.csail.mit.edu/cag/streamit/results/bitonic/code/c/
2015-10-20:
- Removed original header comment, replaced by TACLeBench header.
- Added prefix "bitonic_"/"BITONIC_" to all global symbols
- adjusted names of bitonicSort and bitonicMerge functions to
bitonic_*.
- Replaced initialization code by TACLeBench-compliant initialization code.
- Added new function quicksort_return producing a checksum as return value.
- Added new function quicksort_main according to TACLeBench guidelines.
quicksort_main is annotated as entry-point for timing 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: bs_) followed by lowercase letter (e.g., bs_square)
- 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
2016-02-01:
- More formatting:
- In non-empty lists or index expressions, opening '(' and '[' are followed by
one whitespace, closing ')' and ']' are preceded by one whitespace
- Operators within expressions shall be preceded and followed by one
whitespace
2016-04-05:
- Return '0' on success
2016-04-06:
- Fixed generation of return value
2016-06-01:
- Changed all prefixes to lower-case

View File

@ -0,0 +1,157 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: bitonic
Author: Chris Leger
Function: bitonic implements a recursive sorting network algorithm.
Source: MiBench
http://wwweb.eecs.umich.edu/mibench
Changes: no major functional changes
License: MIT
*/
/*
Forward declaration of functions
*/
void bitonic_init( void );
int bitonic_return( void );
void bitonic_compare( int i, int j, int dir );
void bitonic_merge( int lo, int cnt, int dir );
void bitonic_sort( int lo, int cnt, int dir );
int main( void );
/*
Declaration of global variables
*/
int bitonic_numiters = 10;
int bitonic_a[ 32 ]; // the array to be sorted
const int bitonic_ASCENDING = 1;
const int bitonic_DESCENDING = 0;
const int bitonic_CHECKSUM = 55;
/*
Initialization- and return-value-related functions
*/
void bitonic_init( void )
{
/** Initialize array "a" with data **/
int i;
_Pragma( "loopbound min 32 max 32" )
for ( i = 0; i < 32; i++ )
bitonic_a[ i ] = ( 32 - i );
}
int bitonic_return( void )
{
int checksum = 0;
checksum += bitonic_a[ 0 ] + bitonic_a[ 21 ] + bitonic_a[ 31 ];
return ( ( checksum == bitonic_CHECKSUM ) ? 0 : -1 );
}
/*
Algorithm core functions
*/
/** A comparator is modelled by the procedure compare, where the
parameter dir indicates the sorting direction. If dir is ASCENDING
and a[i] > a[j] is true or dir is DESCENDING and a[i] > a[j] is
false then a[i] and a[j] are interchanged.
**/
void bitonic_compare( int i, int j, int dir )
{
if ( dir == ( bitonic_a[ i ] > bitonic_a[ j ] ) ) {
int h = bitonic_a[ i ];
bitonic_a[ i ] = bitonic_a[ j ];
bitonic_a[ j ] = h;
}
}
/** The procedure bitonicMerge recursively sorts a bitonic sequence in
ascending order, if dir = ASCENDING, and in descending order
otherwise. The sequence to be sorted starts at index position lo,
the number of elements is cnt.
**/
void bitonic_merge( int lo, int cnt, int dir )
{
int k = cnt / 2;
int i;
_Pragma( "loopbound min 0 max 16" )
for ( i = lo; i < lo + k; i++ )
bitonic_compare( i, i + k, dir );
if ( k > 1 ) {
bitonic_merge( lo, k, dir );
bitonic_merge( lo + k, k, dir );
}
}
/** Procedure bitonicSort first produces a bitonic sequence by
recursively sorting its two halves in opposite directions, and then
calls bitonicMerge.
**/
void bitonic_sort( int lo, int cnt, int dir )
{
int k = cnt;
k /= 2;
_Pragma( "marker recMerge" )
if ( cnt > 1 ) {
bitonic_sort( lo, k, bitonic_ASCENDING );
bitonic_sort( lo + k, k, bitonic_DESCENDING );
}
bitonic_merge( lo, cnt, dir );
_Pragma( "flowrestriction 1*bitonicMerge <= 31*recMerge" )
return;
}
/*
Main functions
*/
void _Pragma ( "entrypoint" ) bitonic_main( void )
{
int i;
/** When called with parameters lo = 0, cnt = a.length() and dir =
ASCENDING, procedure bitonicSort sorts the whole array a. **/
_Pragma( "marker recSort" )
bitonic_sort( 0, 32, bitonic_ASCENDING );
_Pragma( "flowrestriction 1*bitonicSort <= 63*recSort" )
/** Loop through array, printing out each element **/
_Pragma( "loopbound min 32 max 32" )
for ( i = 0; i < 32; i++ ) {
}
}
int main( void )
{
bitonic_init();
bitonic_main();
return ( bitonic_return() );
}

View File

@ -0,0 +1,21 @@
The MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,42 @@
File: bsort.c
Original provenience: Mälardalen benchmark suite,
Source: http://www.mrtc.mdh.se/projects/wcet/wcet_bench/bsort100/bsort100.c
2017-04-18:
- Annotated bsort_main as entry-point for timing analysis.
2016-04-20:
- Check upon call of bsort_return that bsort_Array is sorted.
2016-03-15:
- Renamed file from bsort100.c to bsort.c.
- Introduced comments to split file in sections for forward
declarations, global variables, initialization-related and
return-value-related functions, core benchmark functions, and
main routine.
- Added functions bsort_init and bsort_main that call
bsort_Initialize and bsort_BubbleSort, respectively.
- Added function bsort_return that handles the return value.
- Renamed function Initialize to bsort_Initialize.
- Renamed function BubbleSort to bsort_BubbleSort.
- Replaced preprocessor defines NUMELEMS and MAXDIM by unificated
define bsort_SIZE, fixed bug that caused the first element of the
array to be ignored during sorting.
- Replaced preprocessor defines TRUE, FALSE, WORSTCASE and
KNOWN_VALUE by their values.
- Fixed compiler warning "unused variable 'Seed'" by removing the
offending variable.
- Fixed compiler warning "no previous extern declaration for
non-static variable" by making global variables static.
- Fixed compiler warning "unused variable 'LastIndex'" by removing
the offending variable.
- Fixed compiler warning "declaration shadows a variable in the
global scope" by renaming global variable Array to bsort_Array.
- Fixed compiler warning "// comments are not allowed in this
language" by removing dead code.
- Replaced comment describing purpose of benchmark with generic
TACLeBench header.
- Applied TACLeBench formatting rules via
astyle --options=doc/example/astylerc.txt
- Tested conformance to C90 via
clang -fsyntax-only -Weverything -Wno-unknown-pragmas -pedantic -std=c90

View File

@ -0,0 +1,132 @@
/*
This program is part of the TACLeBench benchmark suite.
Version 2.0
Name: bsort
Author: unknown
Function: A program for testing the basic loop constructs,
integer comparisons, and simple array handling by
sorting 100 integers
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/bsort100/bsort100.c
Original name: bsort100
Changes: See ChangeLog.txt
License: May be used, modified, and re-distributed freely.
*/
/*
Forward declaration of functions
*/
void bsort_init( void );
void bsort_main( void );
int bsort_return( void );
int bsort_Initialize( int Array[] );
int bsort_BubbleSort( int Array[] );
/*
Declaration of global variables
*/
#define bsort_SIZE 100
static int bsort_Array[ bsort_SIZE ];
/*
Initialization- and return-value-related functions
*/
/* Initializes given array with randomly generated integers. */
int bsort_Initialize( int Array[] )
{
int Index;
_Pragma( "loopbound min 100 max 100" )
for ( Index = 0; Index < bsort_SIZE; Index ++ )
Array[ Index ] = ( Index + 1 ) * -1;
return 0;
}
void bsort_init( void )
{
bsort_Initialize( bsort_Array );
}
int bsort_return( void )
{
int Sorted = 1;
int Index;
_Pragma( "loopbound min 99 max 99" )
for ( Index = 0; Index < bsort_SIZE - 1; Index ++ )
Sorted = Sorted && ( bsort_Array[ Index ] < bsort_Array[ Index + 1 ] );
return 1 - Sorted;
}
/*
Core benchmark functions
*/
/* Sorts an array of integers of size bsort_SIZE in ascending
order with bubble sort. */
int bsort_BubbleSort( int Array[] )
{
int Sorted = 0;
int Temp, Index, i;
_Pragma( "loopbound min 99 max 99" )
for ( i = 0; i < bsort_SIZE - 1; i ++ ) {
Sorted = 1;
_Pragma( "loopbound min 3 max 99" )
for ( Index = 0; Index < bsort_SIZE - 1; Index ++ ) {
if ( Index > bsort_SIZE - i )
break;
if ( Array[ Index ] > Array[Index + 1] ) {
Temp = Array[ Index ];
Array[ Index ] = Array[ Index + 1 ];
Array[ Index + 1 ] = Temp;
Sorted = 0;
}
}
if ( Sorted )
break;
}
return 0;
}
void _Pragma( "entrypoint" ) bsort_main( void )
{
bsort_BubbleSort( bsort_Array );
}
/*
Main function
*/
// int main( void )
// {
// bsort_init();
// bsort_main();
// return bsort_return();
// }

View File

@ -0,0 +1,27 @@
File: complex_updates.c
Original provenience: DSP-Stone
2016-03-02:
- Rename n_complex_updates_float to n_complex_updates
- Add generic TACLeBench header
- Prefix global function with benchmark name
- Avoid accepting arbitrary number of parameters
- Introduce return statement
- Make A, B, C, D global variables
- Split code into n_complex_updates_init and n_complex_updates_main
2016-04-25:
- Rename to complex_updates in order to shorten prefixes
- Remove second call of pin_down, since this was originally used as a border for
constant propagation
- Move pin_down call into init function
- Add operation on input data with volatile variable to completely prevent
constant propagation
- Prefix all global symbols with benchmark name
- Add calculation of checksum on result data, which is used in return statement
- Apply code formatting with clang-format (manually move loop-bound annotation
into separate line and align assignments in complex_updates_main)
2016-04-25:
- Replace usages of macros by their expansions:
STORAGE_CLASS => register, TYPE => float
2016-05-25:
- Apply code formatting with astyle

View File

@ -0,0 +1,136 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: complex_updates
Author: Juan Martinez Velarde
Function: complex_updates is a program for filter benchmarking.
This program performs n complex updates of the form
D(i) = C(i) + A(i)*B(i),
where A(i), B(i), C(i) and D(i) are complex numbers,
and i = 1,...,N
A(i) = Ar(i) + j Ai(i)
B(i) = Br(i) + j Bi(i)
C(i) = Cr(i) + j Ci(i)
D(i) = C(i) + A(i)*B(i) = Dr(i) + j Di(i)
=> Dr(i) = Cr(i) + Ar(i)*Br(i) - Ai(i)*Bi(i)
=> Di(i) = Ci(i) + Ar(i)*Bi(i) + Ai(i)*Br(i)
Source: DSP-Stone
http://www.ice.rwth-aachen.de/research/tools-projects/entry/detail/dspstone/
Original name: n_complex_updates_float
Changes: no major functional changes
License: may be used, modified, and re-distributed freely
*/
#define N 16
/*
Forward declaration of functions
*/
void complex_updates_pin_down( float *pa, float *pb, float *pc, float *pd );
void complex_updates_init( void );
void complex_updates_main( void );
int main( void );
/*
Declaration of global variables
*/
float complex_updates_A[ 2 * N ], complex_updates_B[ 2 * N ],
complex_updates_C[ 2 * N ], complex_updates_D[ 2 * N ];
/*
Initialization- and return-value-related functions
*/
void complex_updates_init( void )
{
int i;
volatile float x = 0;
complex_updates_pin_down( &complex_updates_A[ 0 ], &complex_updates_B[ 0 ],
&complex_updates_C[ 0 ], &complex_updates_D[ 0 ] );
/* avoid constant propagation */
_Pragma( "loopbound min 16 max 16" )
for ( i = 0 ; i < N ; i++ ) {
complex_updates_A[ i ] += x;
complex_updates_B[ i ] += x;
complex_updates_C[ i ] += x;
complex_updates_D[ i ] += x;
}
}
void complex_updates_pin_down( float *pa, float *pb, float *pc, float *pd )
{
register int i;
_Pragma( "loopbound min 16 max 16" )
for ( i = 0; i < N; i++ ) {
*pa++ = 2;
*pa++ = 1;
*pb++ = 2;
*pb++ = 5;
*pc++ = 3;
*pc++ = 4;
*pd++ = 0;
*pd++ = 0;
}
}
int complex_updates_return( void )
{
float check_sum = 0;
int i;
_Pragma( "loopbound min 16 max 16" )
for ( i = 0; i < N; i++ )
check_sum += complex_updates_D[ i ];
return ( check_sum != 144.0f );
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) complex_updates_main( void )
{
register float *p_a = &complex_updates_A[ 0 ], *p_b = &complex_updates_B[ 0 ];
register float *p_c = &complex_updates_C[ 0 ], *p_d = &complex_updates_D[ 0 ];
int i;
_Pragma( "loopbound min 16 max 16" )
for ( i = 0 ; i < N ; i++, p_a++ ) {
*p_d = *p_c++ + *p_a++ * *p_b++ ;
*p_d++ -= *p_a * *p_b-- ;
*p_d = *p_c++ + *p_a-- * *p_b++ ;
*p_d++ += *p_a++ * *p_b++ ;
}
}
int main( void )
{
complex_updates_init();
complex_updates_main();
return complex_updates_return();
}

View File

@ -0,0 +1,79 @@
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

View File

@ -0,0 +1,86 @@
/*
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 _Pragma( "entrypoint" ) 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();
}

View File

@ -0,0 +1,68 @@
/*
====================================================
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_ */

View File

@ -0,0 +1,757 @@
/*
====================================================
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.c
Author: Unknown
Function: IEEE754 software library routines.
Source: Sun Microsystems
Original name: wcclibm.c
Changes: No major functional changes.
License: See the terms above.
*/
#include "wcclibm.h"
#include "math_private.h"
/* e_acosf.c -- float version of e_acos.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_pi = 3.1415925026e+00f, /* 0x40490fda */
basicmath_pio2_hi = 1.5707962513e+00f, /* 0x3fc90fda */
basicmath_pio2_lo = 7.5497894159e-08f, /* 0x33a22168 */
basicmath_pS0 = 1.6666667163e-01f, /* 0x3e2aaaab */
basicmath_pS1 = -3.2556581497e-01f, /* 0xbea6b090 */
basicmath_pS2 = 2.0121252537e-01f, /* 0x3e4e0aa8 */
basicmath_pS3 = -4.0055535734e-02f, /* 0xbd241146 */
basicmath_pS4 = 7.9153501429e-04f, /* 0x3a4f7f04 */
basicmath_pS5 = 3.4793309169e-05f, /* 0x3811ef08 */
basicmath_qS1 = -2.4033949375e+00f, /* 0xc019d139 */
basicmath_qS2 = 2.0209457874e+00f, /* 0x4001572d */
basicmath_qS3 = -6.8828397989e-01f, /* 0xbf303361 */
basicmath_qS4 = 7.7038154006e-02f; /* 0x3d9dc62e */
float basicmath___ieee754_acosf( float x )
{
float z, p, q, r, w, s, c, df;
int32_t hx, ix;
GET_FLOAT_WORD( hx, x );
ix = hx & 0x7fffffff;
if ( ix == 0x3f800000 ) { /* |x|==1 */
if ( hx > 0 ) return 0.0f; /* acos(1) = 0 */
else return basicmath_pi + ( float )2.0f * basicmath_pio2_lo; /* acos(-1)= pi */
} else
if ( ix > 0x3f800000 ) { /* |x| >= 1 */
return ( x - x ) / ( x - x ); /* acos(|x|>1) is NaN */
}
if ( ix < 0x3f000000 ) { /* |x| < 0.5 */
if ( ix <= 0x23000000 ) return basicmath_pio2_hi +
basicmath_pio2_lo; /*if|x|<2**-57*/
z = x * x;
p = z * ( basicmath_pS0 + z * ( basicmath_pS1 + z * ( basicmath_pS2 + z *
( basicmath_pS3 + z *
( basicmath_pS4 + z * basicmath_pS5 ) ) ) ) );
q = basicmath_one + z * ( basicmath_qS1 + z * ( basicmath_qS2 + z *
( basicmath_qS3 + z * basicmath_qS4 ) ) );
r = p / q;
return basicmath_pio2_hi - ( x - ( basicmath_pio2_lo - x * r ) );
} else
if ( hx < 0 ) { /* x < -0.5 */
z = ( basicmath_one + x ) * ( float )0.5f;
p = z * ( basicmath_pS0 + z * ( basicmath_pS1 + z * ( basicmath_pS2 + z *
( basicmath_pS3 + z *
( basicmath_pS4 + z * basicmath_pS5 ) ) ) ) );
q = basicmath_one + z * ( basicmath_qS1 + z * ( basicmath_qS2 + z *
( basicmath_qS3 + z * basicmath_qS4 ) ) );
s = basicmath___ieee754_sqrtf( z );
r = p / q;
w = r * s - basicmath_pio2_lo;
return basicmath_pi - ( float )2.0f * ( s + w );
} else { /* x > 0.5 */
int32_t idf;
z = ( basicmath_one - x ) * ( float )0.5f;
s = basicmath___ieee754_sqrtf( z );
df = s;
GET_FLOAT_WORD( idf, df );
SET_FLOAT_WORD( df, idf & 0xfffff000 );
c = ( z - df * df ) / ( s + df );
p = z * ( basicmath_pS0 + z * ( basicmath_pS1 + z * ( basicmath_pS2 + z *
( basicmath_pS3 + z *
( basicmath_pS4 + z * basicmath_pS5 ) ) ) ) );
q = basicmath_one + z * ( basicmath_qS1 + z * ( basicmath_qS2 + z *
( basicmath_qS3 + z * basicmath_qS4 ) ) );
r = p / q;
w = r * s + c;
return ( float )2.0f * ( df + w );
}
}
/* e_powf.c -- float version of e_pow.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_bp[] = {1.0f, 1.5f,},
basicmath_dp_h[] = { 0.0f, 5.84960938e-01f,}, /* 0x3f15c000 */
basicmath_dp_l[] = { 0.0f, 1.56322085e-06f,}, /* 0x35d1cfdc */
/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
basicmath_L1 = 6.0000002384e-01f, /* 0x3f19999a */
basicmath_L2 = 4.2857143283e-01f, /* 0x3edb6db7 */
basicmath_L3 = 3.3333334327e-01f, /* 0x3eaaaaab */
basicmath_L4 = 2.7272811532e-01f, /* 0x3e8ba305 */
basicmath_L5 = 2.3066075146e-01f, /* 0x3e6c3255 */
basicmath_L6 = 2.0697501302e-01f, /* 0x3e53f142 */
basicmath_P1 = 1.6666667163e-01f, /* 0x3e2aaaab */
basicmath_P2 = -2.7777778450e-03f, /* 0xbb360b61 */
basicmath_P3 = 6.6137559770e-05f, /* 0x388ab355 */
basicmath_P4 = -1.6533901999e-06f, /* 0xb5ddea0e */
basicmath_P5 = 4.1381369442e-08f, /* 0x3331bb4c */
basicmath_lg2 = 6.9314718246e-01f, /* 0x3f317218 */
basicmath_lg2_h = 6.93145752e-01f, /* 0x3f317200 */
basicmath_lg2_l = 1.42860654e-06f, /* 0x35bfbe8c */
basicmath_ovt = 4.2995665694e-08f, /* -(128-log2(ovfl+.5ulp)) */
basicmath_cp = 9.6179670095e-01f, /* 0x3f76384f =2/(3ln2) */
basicmath_cp_h = 9.6179199219e-01f, /* 0x3f763800 =head of cp */
basicmath_cp_l = 4.7017383622e-06f, /* 0x369dc3a0 =tail of cp_h */
basicmath_ivln2 = 1.4426950216e+00f, /* 0x3fb8aa3b =1/ln2 */
basicmath_ivln2_h = 1.4426879883e+00f, /* 0x3fb8aa00 =16b 1/ln2*/
basicmath_ivln2_l = 7.0526075433e-06f; /* 0x36eca570 =1/ln2 tail*/
float basicmath___ieee754_powf( float x, float y )
{
float z, ax, z_h, z_l, p_h, p_l;
float y1, t1, t2, r, s, t, u, v, w;
int32_t i, j, k, yisint, n;
int32_t hx, hy, ix, iy, is;
GET_FLOAT_WORD( hx, x );
GET_FLOAT_WORD( hy, y );
ix = hx & 0x7fffffff;
iy = hy & 0x7fffffff;
/* y==zero: x**0 = 1 */
if ( iy == 0 ) return basicmath_one;
/* x==+-1 */
if ( x == 1.0f ) return basicmath_one;
if ( x == -1.0f && basicmath___isinff( y ) ) return basicmath_one;
/* +-NaN return x+y */
if ( ix > 0x7f800000 ||
iy > 0x7f800000 )
return x + y;
/* determine if y is an odd int when x < 0
yisint = 0 ... y is not an integer
yisint = 1 ... y is an odd int
yisint = 2 ... y is an even int
*/
yisint = 0;
if ( hx < 0 ) {
if ( iy >= 0x4b800000 ) yisint = 2; /* even integer y */
else
if ( iy >= 0x3f800000 ) {
k = ( iy >> 23 ) - 0x7f; /* exponent */
j = iy >> ( 23 - k );
if ( ( j << ( 23 - k ) ) == iy ) yisint = 2 - ( j & 1 );
}
}
/* special value of y */
if ( iy == 0x7f800000 ) { /* y is +-inf */
if ( ix == 0x3f800000 )
return y - y; /* inf**+-1 is NaN */
else
if ( ix > 0x3f800000 ) /* (|x|>1)**+-inf = inf,0 */
return ( hy >= 0 ) ? y : basicmath_zero;
else /* (|x|<1)**-,+inf = inf,0 */
return ( hy < 0 ) ? -y : basicmath_zero;
}
if ( iy == 0x3f800000 ) { /* y is +-1 */
if ( hy < 0 ) return basicmath_one / x;
else return x;
}
if ( hy == 0x40000000 ) return x * x; /* y is 2 */
if ( hy == 0x3f000000 ) { /* y is 0.5 */
if ( hx >= 0 ) /* x >= +0 */
return basicmath___ieee754_sqrtf( x );
}
ax = basicmath___fabsf( x );
/* special value of x */
if ( ix == 0x7f800000 || ix == 0 || ix == 0x3f800000 ) {
z = ax; /*x is +-0,+-inf,+-1*/
if ( hy < 0 ) z = basicmath_one / z; /* z = (1/|x|) */
if ( hx < 0 ) {
if ( ( ( ix - 0x3f800000 ) | yisint ) == 0 ) {
z = ( z - z ) / ( z - z ); /* (-1)**non-int is NaN */
} else
if ( yisint == 1 )
z = -z; /* (x<0)**odd = -(|x|**odd) */
}
return z;
}
/* (x<0)**(non-int) is NaN */
if ( ( ( ( ( u_int32_t )hx >> 31 ) - 1 ) | yisint ) == 0 ) return ( x - x ) /
( x - x );
/* |y| is huge */
if ( iy > 0x4d000000 ) { /* if |y| > 2**27 */
/* over/underflow if x is not close to one */
if ( ix < 0x3f7ffff8 ) return ( hy < 0 ) ? basicmath_huge * basicmath_huge :
basicmath_tiny * basicmath_tiny;
if ( ix > 0x3f800007 ) return ( hy > 0 ) ? basicmath_huge * basicmath_huge :
basicmath_tiny * basicmath_tiny;
/* now |1-x| is tiny <= 2**-20, suffice to compute
log(x) by x-x^2/2+x^3/3-x^4/4 */
t = x - 1; /* t has 20 trailing zeros */
w = ( t * t ) * ( ( float )0.5f - t * ( ( float )0.333333333333f - t *
( float )0.25f ) );
u = basicmath_ivln2_h * t; /* ivln2_h has 16 sig. bits */
v = t * basicmath_ivln2_l - w * basicmath_ivln2;
t1 = u + v;
GET_FLOAT_WORD( is, t1 );
SET_FLOAT_WORD( t1, is & 0xfffff000 );
t2 = v - ( t1 - u );
} else {
float s2, s_h, s_l, t_h, t_l;
n = 0;
/* take care subnormal number */
if ( ix < 0x00800000 ) {
ax *= basicmath_two24;
n -= 24;
GET_FLOAT_WORD( ix, ax );
}
n += ( ( ix ) >> 23 ) - 0x7f;
j = ix & 0x007fffff;
/* determine interval */
ix = j | 0x3f800000; /* normalize ix */
if ( j <= 0x1cc471 ) k = 0; /* |x|<sqrt(3/2) */
else
if ( j < 0x5db3d7 ) k = 1; /* |x|<sqrt(3) */
else {
k = 0;
n += 1;
ix -= 0x00800000;
}
SET_FLOAT_WORD( ax, ix );
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
u = ax - basicmath_bp[ k ]; /* bp[0]=1.0, bp[1]=1.5 */
v = basicmath_one / ( ax + basicmath_bp[ k ] );
s = u * v;
s_h = s;
GET_FLOAT_WORD( is, s_h );
SET_FLOAT_WORD( s_h, is & 0xfffff000 );
/* t_h=ax+bp[k] High */
SET_FLOAT_WORD( t_h, ( ( ix >> 1 ) | 0x20000000 ) + 0x0040000 + ( k << 21 ) );
t_l = ax - ( t_h - basicmath_bp[ k ] );
s_l = v * ( ( u - s_h * t_h ) - s_h * t_l );
/* compute log(ax) */
s2 = s * s;
r = s2 * s2 * ( basicmath_L1 + s2 * ( basicmath_L2 + s2 *
( basicmath_L3 + s2 * ( basicmath_L4 + s2 *
( basicmath_L5 + s2 * basicmath_L6 ) ) ) ) );
r += s_l * ( s_h + s );
s2 = s_h * s_h;
t_h = ( float )3.0f + s2 + r;
GET_FLOAT_WORD( is, t_h );
SET_FLOAT_WORD( t_h, is & 0xfffff000 );
t_l = r - ( ( t_h - ( float )3.0f ) - s2 );
/* u+v = s*(1+...) */
u = s_h * t_h;
v = s_l * t_h + t_l * s;
/* 2/(3log2)*(s+...) */
p_h = u + v;
GET_FLOAT_WORD( is, p_h );
SET_FLOAT_WORD( p_h, is & 0xfffff000 );
p_l = v - ( p_h - u );
z_h = basicmath_cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */
z_l = basicmath_cp_l * p_h + p_l * basicmath_cp + basicmath_dp_l[ k ];
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
t = ( float )n;
t1 = ( ( ( z_h + z_l ) + basicmath_dp_h[ k ] ) + t );
GET_FLOAT_WORD( is, t1 );
SET_FLOAT_WORD( t1, is & 0xfffff000 );
t2 = z_l - ( ( ( t1 - t ) - basicmath_dp_h[ k ] ) - z_h );
}
s = basicmath_one; /* s (sign of result -ve**odd) = -1 else = 1 */
if ( ( ( ( ( u_int32_t )hx >> 31 ) - 1 ) | ( yisint - 1 ) ) == 0 )
s = -basicmath_one; /* (-ve)**(odd int) */
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
GET_FLOAT_WORD( is, y );
SET_FLOAT_WORD( y1, is & 0xfffff000 );
p_l = ( y - y1 ) * t1 + y * t2;
p_h = y1 * t1;
z = p_l + p_h;
GET_FLOAT_WORD( j, z );
if ( j > 0x43000000 ) /* if z > 128 */
return s * basicmath_huge * basicmath_huge; /* overflow */
else
if ( j == 0x43000000 ) { /* if z == 128 */
if ( p_l + basicmath_ovt > z - p_h ) return s * basicmath_huge *
basicmath_huge; /* overflow */
} else
if ( ( j & 0x7fffffff ) > 0x43160000 ) /* z <= -150 */
return s * basicmath_tiny * basicmath_tiny; /* underflow */
else
if ( ( u_int32_t ) j == 0xc3160000 ) { /* z == -150 */
if ( p_l <= z - p_h ) return s * basicmath_tiny *
basicmath_tiny; /* underflow */
}
/*
compute 2**(p_h+p_l)
*/
i = j & 0x7fffffff;
k = ( i >> 23 ) - 0x7f;
n = 0;
if ( i > 0x3f000000 ) { /* if |z| > 0.5, set n = [z+0.5] */
n = j + ( 0x00800000 >> ( k + 1 ) );
k = ( ( n & 0x7fffffff ) >> 23 ) - 0x7f; /* new k for n */
SET_FLOAT_WORD( t, n & ~( 0x007fffff >> k ) );
n = ( ( n & 0x007fffff ) | 0x00800000 ) >> ( 23 - k );
if ( j < 0 ) n = -n;
p_h -= t;
}
t = p_l + p_h;
GET_FLOAT_WORD( is, t );
SET_FLOAT_WORD( t, is & 0xfffff000 );
u = t * basicmath_lg2_h;
v = ( p_l - ( t - p_h ) ) * basicmath_lg2 + t * basicmath_lg2_l;
z = u + v;
w = v - ( z - u );
t = z * z;
t1 = z - t * ( basicmath_P1 + t * ( basicmath_P2 + t * ( basicmath_P3 + t *
( basicmath_P4 + t * basicmath_P5 ) ) ) );
r = ( z * t1 ) / ( t1 - basicmath_two ) - ( w + z * w );
z = basicmath_one - ( r - z );
GET_FLOAT_WORD( j, z );
j += ( n << 23 );
if ( ( j >> 23 ) <= 0 ) z = basicmath___scalbnf( z, n ); /* subnormal output */
else SET_FLOAT_WORD( z, j );
return s * z;
}
/* e_rem_pio2f.c -- float version of e_rem_pio2.c
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/* basicmath___ieee754_rem_pio2f(x,y)
return the remainder of x rem pi/2 in y[0]+y[1]
*/
/* This array is like the one in e_rem_pio2.c, but the numbers are
single precision and the last 8 bits are forced to 0. */
static const int32_t basicmath_npio2_hw[] = {
0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00,
0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00,
0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100,
0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00,
0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00,
0x4242c700, 0x42490f00
};
/*
invpio2: 24 bits of 2/pi
pio2_1: first 17 bit of pi/2
pio2_1t: pi/2 - pio2_1
pio2_2: second 17 bit of pi/2
pio2_2t: pi/2 - (pio2_1+pio2_2)
pio2_3: third 17 bit of pi/2
pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
*/
static const float basicmath_invpio2 = 6.3661980629e-01f, /* 0x3f22f984 */
basicmath_pio2_1 = 1.5707855225e+00f, /* 0x3fc90f80 */
basicmath_pio2_1t = 1.0804334124e-05f, /* 0x37354443 */
basicmath_pio2_2 = 1.0804273188e-05f, /* 0x37354400 */
basicmath_pio2_2t = 6.0770999344e-11f, /* 0x2e85a308 */
basicmath_pio2_3 = 6.0770943833e-11f, /* 0x2e85a300 */
basicmath_pio2_3t = 6.1232342629e-17f; /* 0x248d3132 */
int32_t basicmath___ieee754_rem_pio2f( float x, float *y )
{
float z, w, t, r, fn;
int32_t i, j, n, ix, hx;
GET_FLOAT_WORD( hx, x );
ix = hx & 0x7fffffff;
if ( ix <= 0x3f490fd8 ) { /* |x| ~<= pi/4 , no need for reduction */
y[ 0 ] = x;
y[ 1 ] = 0;
return 0;
}
if ( ix < 0x4016cbe4 ) { /* |x| < 3pi/4, special case with n=+-1 */
if ( hx > 0 ) {
z = x - basicmath_pio2_1;
if ( ( ix & 0xfffffff0 ) != 0x3fc90fd0 ) { /* 24+24 bit pi OK */
y[ 0 ] = z - basicmath_pio2_1t;
y[ 1 ] = ( z - y[ 0 ] ) - basicmath_pio2_1t;
} else { /* near pi/2, use 24+24+24 bit pi */
z -= basicmath_pio2_2;
y[ 0 ] = z - basicmath_pio2_2t;
y[ 1 ] = ( z - y[ 0 ] ) - basicmath_pio2_2t;
}
return 1;
} else { /* negative x */
z = x + basicmath_pio2_1;
if ( ( ix & 0xfffffff0 ) != 0x3fc90fd0 ) { /* 24+24 bit pi OK */
y[ 0 ] = z + basicmath_pio2_1t;
y[ 1 ] = ( z - y[ 0 ] ) + basicmath_pio2_1t;
} else { /* near pi/2, use 24+24+24 bit pi */
z += basicmath_pio2_2;
y[ 0 ] = z + basicmath_pio2_2t;
y[ 1 ] = ( z - y[ 0 ] ) + basicmath_pio2_2t;
}
return -1;
}
}
if ( ix <= 0x43490f80 ) { /* |x| ~<= 2^7*(pi/2), medium size */
t = basicmath___fabsf( x );
n = ( int32_t ) ( t * basicmath_invpio2 + basicmath_half );
fn = ( float )n;
r = t - fn * basicmath_pio2_1;
w = fn * basicmath_pio2_1t; /* 1st round good to 40 bit */
if ( n < 32 && ( int32_t )( ix & 0xffffff00 ) != basicmath_npio2_hw[n - 1] ) {
y[ 0 ] = r - w; /* quick check no cancellation */
} else {
u_int32_t high;
j = ix >> 23;
y[ 0 ] = r - w;
GET_FLOAT_WORD( high, y[ 0 ] );
i = j - ( ( high >> 23 ) & 0xff );
if ( i > 8 ) { /* 2nd iteration needed, good to 57 */
t = r;
w = fn * basicmath_pio2_2;
r = t - w;
w = fn * basicmath_pio2_2t - ( ( t - r ) - w );
y[ 0 ] = r - w;
GET_FLOAT_WORD( high, y[ 0 ] );
i = j - ( ( high >> 23 ) & 0xff );
if ( i > 25 ) { /* 3rd iteration need, 74 bits acc */
t = r; /* will cover all possible cases */
w = fn * basicmath_pio2_3;
r = t - w;
w = fn * basicmath_pio2_3t - ( ( t - r ) - w );
y[ 0 ] = r - w;
}
}
}
y[ 1 ] = ( r - y[ 0 ] ) - w;
if ( hx < 0 ) {
y[ 0 ] = -y[ 0 ];
y[ 1 ] = -y[ 1 ];
return -n;
} else return n;
}
/*
all other (large) arguments
*/
if ( ix >= 0x7f800000 ) { /* x is inf or NaN */
y[ 0 ] = y[ 1 ] = x - x;
return 0;
}
// This will never happen in basicmath_small, because
// up to this point we have already returned a value
// for each of the possible inputs
y[ 0 ] = y[ 1 ] = x - x; /* dummy initialization */
return 0;
}
/* e_sqrtf.c -- float version of e_sqrt.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
float basicmath___ieee754_sqrtf( float x )
{
float z;
int32_t sign = ( int )0x80000000;
int32_t ix, s, q, m, t, i;
u_int32_t r;
GET_FLOAT_WORD( ix, x );
/* take care of Inf and NaN */
if ( ( ix & 0x7f800000 ) == 0x7f800000 ) {
return x * x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
sqrt(-inf)=sNaN */
}
/* take care of zero */
if ( ix <= 0 ) {
if ( ( ix & ( ~sign ) ) == 0 ) return x; /* sqrt(+-0) = +-0 */
else
if ( ix < 0 )
return ( x - x ) / ( x - x ); /* sqrt(-ve) = sNaN */
}
/* normalize x */
m = ( ix >> 23 );
if ( m == 0 ) { /* subnormal x */
_Pragma( "loopbound min 0 max 0" )
for ( i = 0; ( ix & 0x00800000 ) == 0; i++ )
ix <<= 1;
m -= i - 1;
}
m -= 127; /* unbias exponent */
ix = ( ix & 0x007fffff ) | 0x00800000;
if ( m & 1 ) /* odd m, double x to make it even */
ix += ix;
m >>= 1; /* m = [m/2] */
/* generate sqrt(x) bit by bit */
ix += ix;
q = s = 0; /* q = sqrt(x) */
r = 0x01000000; /* r = moving bit from right to left */
_Pragma( "loopbound min 25 max 25" )
while ( r != 0 ) {
t = s + r;
if ( t <= ix ) {
s = t + r;
ix -= t;
q += r;
}
ix += ix;
r >>= 1;
}
/* use floating add to find out rounding direction */
if ( ix != 0 ) {
z = basicmath_one - basicmath_tiny; /* trigger inexact flag */
if ( z >= basicmath_one ) {
z = basicmath_one + basicmath_tiny;
if ( z > basicmath_one )
q += 2;
else
q += ( q & 1 );
}
}
ix = ( q >> 1 ) + 0x3f000000;
ix += ( m << 23 );
SET_FLOAT_WORD( z, ix );
return z;
}
/* k_cosf.c -- float version of k_cos.c
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_C1 = 4.1666667908e-02f, /* 0x3d2aaaab */
basicmath_C2 = -1.3888889225e-03f, /* 0xbab60b61 */
basicmath_C3 = 2.4801587642e-05f, /* 0x37d00d01 */
basicmath_C4 = -2.7557314297e-07f, /* 0xb493f27c */
basicmath_C5 = 2.0875723372e-09f, /* 0x310f74f6 */
basicmath_C6 = -1.1359647598e-11f; /* 0xad47d74e */
float basicmath___kernel_cosf( float x, float y )
{
float a, hz, z, r, qx;
int32_t ix;
GET_FLOAT_WORD( ix, x );
ix &= 0x7fffffff; /* ix = |x|'s high word*/
if ( ix < 0x32000000 ) { /* if x < 2**27 */
if ( ( ( int )x ) == 0 ) return basicmath_one; /* generate inexact */
}
z = x * x;
r = z * ( basicmath_C1 + z * ( basicmath_C2 + z * ( basicmath_C3 + z *
( basicmath_C4 + z * ( basicmath_C5 + z * basicmath_C6 ) ) ) ) );
if ( ix < 0x3e99999a ) /* if |x| < 0.3 */
return basicmath_one - ( ( float )0.5f * z - ( z * r - x * y ) );
else {
if ( ix > 0x3f480000 ) /* x > 0.78125 */
qx = ( float )0.28125f;
else {
SET_FLOAT_WORD( qx, ix - 0x01000000 ); /* x/4 */
}
hz = ( float )0.5f * z - qx;
a = basicmath_one - qx;
return a - ( hz - ( z * r - x * y ) );
}
}
/* k_sinf.c -- float version of k_sin.c
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_S1 = -1.6666667163e-01f, /* 0xbe2aaaab */
basicmath_S2 = 8.3333337680e-03f, /* 0x3c088889 */
basicmath_S3 = -1.9841270114e-04f, /* 0xb9500d01 */
basicmath_S4 = 2.7557314297e-06f, /* 0x3638ef1b */
basicmath_S5 = -2.5050759689e-08f, /* 0xb2d72f34 */
basicmath_S6 = 1.5896910177e-10f; /* 0x2f2ec9d3 */
float basicmath___kernel_sinf( float x, float y, int iy )
{
float z, r, v;
int32_t ix;
GET_FLOAT_WORD( ix, x );
ix &= 0x7fffffff; /* high word of x */
if ( ix < 0x32000000 ) { /* |x| < 2**-27 */
if ( ( int )x == 0 ) return x; /* generate inexact */
}
z = x * x;
v = z * x;
r = basicmath_S2 + z * ( basicmath_S3 + z * ( basicmath_S4 + z *
( basicmath_S5 + z * basicmath_S6 ) ) );
if ( iy == 0 ) return x + v * ( basicmath_S1 + z * r );
else return x - ( ( z * ( basicmath_half * y - v * r ) - y ) - v *
basicmath_S1 );
}
/* s_copysignf.c -- float version of s_copysign.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
copysignf(float x, float y)
copysignf(x,y) returns a value with the magnitude of x and
with the sign bit of y.
*/
float basicmath___copysignf( float x, float y )
{
u_int32_t ix, iy;
GET_FLOAT_WORD( ix, x );
GET_FLOAT_WORD( iy, y );
SET_FLOAT_WORD( x, ( ix & 0x7fffffff ) | ( iy & 0x80000000 ) );
return x;
}
/* s_cosf.c -- float version of s_cos.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
float basicmath___cosf( float x )
{
float y[ 2 ], z = 0.0f;
int32_t n, ix;
GET_FLOAT_WORD( ix, x );
/* |x| ~< pi/4 */
ix &= 0x7fffffff;
if ( ix <= 0x3f490fd8 ) return basicmath___kernel_cosf( x, z );
/* cos(Inf or NaN) is NaN */
else
if ( ix >= 0x7f800000 ) return x - x;
/* argument reduction needed */
else {
n = basicmath___ieee754_rem_pio2f( x, y );
switch ( n & 3 ) {
case 0:
return basicmath___kernel_cosf( y[ 0 ], y[ 1 ] );
case 1:
return -basicmath___kernel_sinf( y[ 0 ], y[ 1 ], 1 );
case 2:
return -basicmath___kernel_cosf( y[ 0 ], y[ 1 ] );
default:
return basicmath___kernel_sinf( y[ 0 ], y[ 1 ], 1 );
}
}
}
/* s_fabsf.c -- float version of s_fabs.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
fabsf(x) returns the absolute value of x.
*/
float basicmath___fabsf( float x )
{
u_int32_t ix;
GET_FLOAT_WORD( ix, x );
SET_FLOAT_WORD( x, ix & 0x7fffffff );
return x;
}
/*
isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0;
no branching!
*/
int basicmath___isinff ( float x )
{
int32_t ix, t;
GET_FLOAT_WORD( ix, x );
t = ix & 0x7fffffff;
t ^= 0x7f800000;
t |= -t;
return ~( t >> 31 ) & ( ix >> 30 );
}
/* s_scalbnf.c -- float version of s_scalbn.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_two25 = 3.355443200e+07f, /* 0x4c000000 */
basicmath_twom25 = 2.9802322388e-08f; /* 0x33000000 */
float basicmath___scalbnf ( float x, int n )
{
int32_t k, ix;
GET_FLOAT_WORD( ix, x );
k = ( ix & 0x7f800000 ) >> 23; /* extract exponent */
if ( k == 0 ) { /* 0 or subnormal x */
if ( ( ix & 0x7fffffff ) == 0 ) return x; /* +-0 */
x *= basicmath_two25;
GET_FLOAT_WORD( ix, x );
k = ( ( ix & 0x7f800000 ) >> 23 ) - 25;
}
if ( k == 0xff ) return x + x; /* NaN or Inf */
k = k + n;
if ( n > 50000 || k > 0xfe )
return basicmath_huge * basicmath___copysignf( basicmath_huge,
x ); /* overflow */
if ( n < -50000 )
return basicmath_tiny * basicmath___copysignf( basicmath_tiny,
x ); /*underflow*/
if ( k > 0 ) { /* normal result */
SET_FLOAT_WORD( x, ( ix & 0x807fffff ) | ( k << 23 ) );
return x;
}
if ( k <= -25 )
return basicmath_tiny * basicmath___copysignf( basicmath_tiny,
x ); /*underflow*/
k += 25; /* subnormal result */
SET_FLOAT_WORD( x, ( ix & 0x807fffff ) | ( k << 23 ) );
return x * basicmath_twom25;
}

View File

@ -0,0 +1,61 @@
/*
====================================================
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

View File

@ -0,0 +1,29 @@
File: countnegative.c
Original provenience: Mälardalen benchmark suite, www.mrtc.....
2015-11-26:
- Changed return type of InitSeed, Initialize, and Test to void
because the result was ignored anyway
- Prefixed all functions and global variables with "countnegative_"
- Added new function countnegative_return computing a checksum as
return value
- Separated initialization (called from countnegative_init) from
actual computation (called from countnegative_main), remove
pointless function countnegative_test afterwards
- Reordered functions in source code: initialization- and
return-value-related functions first, followed by algorithm core
function, followed by main functions
- Eliminated definition of macro WORSTCASE and kept only the relevant
part of the related #ifdef block
- Removed comments that referred to MAXSIZE being 100 (instead of 20)
- Made countnegative_seed volatile
- Changed C++ style comments to C style comments
- Applied code formatting with astyle as in the example
- Added general TACLeBench header to beginning of source code
2016-03-15:
- Return 0 if checksum is as expected, -1 otherwise
- Add entrypoint pragma
2016-04-20:
- Cast "expected" return value to int for comparison

View File

@ -0,0 +1,140 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: countnegative
Author: unknown
Function: Counts negative and non-negative numbers in a
matrix. Features nested loops, well-structured code.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/cnt/cnt.c
Changes: Changed split between initialization and computation
License: May be used, modified, and re-distributed freely
*/
/*
The dimension of the matrix
*/
#define MAXSIZE 20
/*
Type definition for the matrix
*/
typedef int matrix [ MAXSIZE ][ MAXSIZE ];
/*
Forward declaration of functions
*/
void countnegative_initSeed( void );
int countnegative_randomInteger( void );
void countnegative_initialize( matrix );
void countnegative_init( void );
int countnegative_return( void );
void countnegative_sum( matrix );
void countnegative_main( void );
int main( void );
/*
Globals
*/
volatile int countnegative_seed;
matrix countnegative_array;
int countnegative_postotal, countnegative_negtotal;
int countnegative_poscnt, countnegative_negcnt;
/*
Initializes the seed used in the random number generator.
*/
void countnegative_initSeed ( void )
{
countnegative_seed = 0;
}
/*
Generates random integers between 0 and 8094
*/
int countnegative_randomInteger( void )
{
countnegative_seed = ( ( countnegative_seed * 133 ) + 81 ) % 8095;
return countnegative_seed;
}
/*
Initializes the given array with random integers.
*/
void countnegative_initialize( matrix Array )
{
register int OuterIndex, InnerIndex;
_Pragma( "loopbound min 20 max 20" )
for ( OuterIndex = 0; OuterIndex < MAXSIZE; OuterIndex++ )
_Pragma( "loopbound min 20 max 20" )
for ( InnerIndex = 0; InnerIndex < MAXSIZE; InnerIndex++ )
Array[ OuterIndex ][ InnerIndex ] = countnegative_randomInteger();
}
void countnegative_init( void )
{
countnegative_initSeed();
countnegative_initialize( countnegative_array );
}
int countnegative_return( void )
{
int checksum = ( countnegative_postotal +
countnegative_poscnt +
countnegative_negtotal +
countnegative_negcnt );
return ( ( checksum == ( int )0x1778de ) ? 0 : -1 );
}
void countnegative_sum( matrix Array )
{
register int Outer, Inner;
int Ptotal = 0; /* changed these to locals in order to drive worst case */
int Ntotal = 0;
int Pcnt = 0;
int Ncnt = 0;
_Pragma( "loopbound min 20 max 20" )
for ( Outer = 0; Outer < MAXSIZE; Outer++ )
_Pragma( "loopbound min 20 max 20" )
for ( Inner = 0; Inner < MAXSIZE; Inner++ )
if ( Array[ Outer ][ Inner ] >= 0 ) {
Ptotal += Array[ Outer ][ Inner ];
Pcnt++;
} else {
Ntotal += Array[ Outer ][ Inner ];
Ncnt++;
}
countnegative_postotal = Ptotal;
countnegative_poscnt = Pcnt;
countnegative_negtotal = Ntotal;
countnegative_negcnt = Ncnt;
}
/*
The main function
*/
void _Pragma( "entrypoint" ) countnegative_main ( void )
{
countnegative_sum( countnegative_array );
}
// int main( void )
// {
// countnegative_init();
// countnegative_main();
// return ( countnegative_return() );
// }

View File

@ -0,0 +1,78 @@
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

View File

@ -0,0 +1,156 @@
/*
** 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 _Pragma( "entrypoint" ) 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();
}

View File

@ -0,0 +1,68 @@
/*
====================================================
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_ */

View File

@ -0,0 +1,31 @@
/*
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 */

View File

@ -0,0 +1,40 @@
/*
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 */

View File

@ -0,0 +1,757 @@
/*
====================================================
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.c
Author: Unknown
Function: IEEE754 software library routines.
Source: Sun Microsystems
Original name: wcclibm.c
Changes: No major functional changes.
License: See the terms above.
*/
#include "wcclibm.h"
#include "math_private.h"
/* e_acosf.c -- float version of e_acos.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_pi = 3.1415925026e+00f, /* 0x40490fda */
basicmath_pio2_hi = 1.5707962513e+00f, /* 0x3fc90fda */
basicmath_pio2_lo = 7.5497894159e-08f, /* 0x33a22168 */
basicmath_pS0 = 1.6666667163e-01f, /* 0x3e2aaaab */
basicmath_pS1 = -3.2556581497e-01f, /* 0xbea6b090 */
basicmath_pS2 = 2.0121252537e-01f, /* 0x3e4e0aa8 */
basicmath_pS3 = -4.0055535734e-02f, /* 0xbd241146 */
basicmath_pS4 = 7.9153501429e-04f, /* 0x3a4f7f04 */
basicmath_pS5 = 3.4793309169e-05f, /* 0x3811ef08 */
basicmath_qS1 = -2.4033949375e+00f, /* 0xc019d139 */
basicmath_qS2 = 2.0209457874e+00f, /* 0x4001572d */
basicmath_qS3 = -6.8828397989e-01f, /* 0xbf303361 */
basicmath_qS4 = 7.7038154006e-02f; /* 0x3d9dc62e */
float basicmath___ieee754_acosf( float x )
{
float z, p, q, r, w, s, c, df;
int32_t hx, ix;
GET_FLOAT_WORD( hx, x );
ix = hx & 0x7fffffff;
if ( ix == 0x3f800000 ) { /* |x|==1 */
if ( hx > 0 ) return 0.0f; /* acos(1) = 0 */
else return basicmath_pi + ( float )2.0f * basicmath_pio2_lo; /* acos(-1)= pi */
} else
if ( ix > 0x3f800000 ) { /* |x| >= 1 */
return ( x - x ) / ( x - x ); /* acos(|x|>1) is NaN */
}
if ( ix < 0x3f000000 ) { /* |x| < 0.5 */
if ( ix <= 0x23000000 ) return basicmath_pio2_hi +
basicmath_pio2_lo; /*if|x|<2**-57*/
z = x * x;
p = z * ( basicmath_pS0 + z * ( basicmath_pS1 + z * ( basicmath_pS2 + z *
( basicmath_pS3 + z *
( basicmath_pS4 + z * basicmath_pS5 ) ) ) ) );
q = basicmath_one + z * ( basicmath_qS1 + z * ( basicmath_qS2 + z *
( basicmath_qS3 + z * basicmath_qS4 ) ) );
r = p / q;
return basicmath_pio2_hi - ( x - ( basicmath_pio2_lo - x * r ) );
} else
if ( hx < 0 ) { /* x < -0.5 */
z = ( basicmath_one + x ) * ( float )0.5f;
p = z * ( basicmath_pS0 + z * ( basicmath_pS1 + z * ( basicmath_pS2 + z *
( basicmath_pS3 + z *
( basicmath_pS4 + z * basicmath_pS5 ) ) ) ) );
q = basicmath_one + z * ( basicmath_qS1 + z * ( basicmath_qS2 + z *
( basicmath_qS3 + z * basicmath_qS4 ) ) );
s = basicmath___ieee754_sqrtf( z );
r = p / q;
w = r * s - basicmath_pio2_lo;
return basicmath_pi - ( float )2.0f * ( s + w );
} else { /* x > 0.5 */
int32_t idf;
z = ( basicmath_one - x ) * ( float )0.5f;
s = basicmath___ieee754_sqrtf( z );
df = s;
GET_FLOAT_WORD( idf, df );
SET_FLOAT_WORD( df, idf & 0xfffff000 );
c = ( z - df * df ) / ( s + df );
p = z * ( basicmath_pS0 + z * ( basicmath_pS1 + z * ( basicmath_pS2 + z *
( basicmath_pS3 + z *
( basicmath_pS4 + z * basicmath_pS5 ) ) ) ) );
q = basicmath_one + z * ( basicmath_qS1 + z * ( basicmath_qS2 + z *
( basicmath_qS3 + z * basicmath_qS4 ) ) );
r = p / q;
w = r * s + c;
return ( float )2.0f * ( df + w );
}
}
/* e_powf.c -- float version of e_pow.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_bp[] = {1.0f, 1.5f,},
basicmath_dp_h[] = { 0.0f, 5.84960938e-01f,}, /* 0x3f15c000 */
basicmath_dp_l[] = { 0.0f, 1.56322085e-06f,}, /* 0x35d1cfdc */
/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
basicmath_L1 = 6.0000002384e-01f, /* 0x3f19999a */
basicmath_L2 = 4.2857143283e-01f, /* 0x3edb6db7 */
basicmath_L3 = 3.3333334327e-01f, /* 0x3eaaaaab */
basicmath_L4 = 2.7272811532e-01f, /* 0x3e8ba305 */
basicmath_L5 = 2.3066075146e-01f, /* 0x3e6c3255 */
basicmath_L6 = 2.0697501302e-01f, /* 0x3e53f142 */
basicmath_P1 = 1.6666667163e-01f, /* 0x3e2aaaab */
basicmath_P2 = -2.7777778450e-03f, /* 0xbb360b61 */
basicmath_P3 = 6.6137559770e-05f, /* 0x388ab355 */
basicmath_P4 = -1.6533901999e-06f, /* 0xb5ddea0e */
basicmath_P5 = 4.1381369442e-08f, /* 0x3331bb4c */
basicmath_lg2 = 6.9314718246e-01f, /* 0x3f317218 */
basicmath_lg2_h = 6.93145752e-01f, /* 0x3f317200 */
basicmath_lg2_l = 1.42860654e-06f, /* 0x35bfbe8c */
basicmath_ovt = 4.2995665694e-08f, /* -(128-log2(ovfl+.5ulp)) */
basicmath_cp = 9.6179670095e-01f, /* 0x3f76384f =2/(3ln2) */
basicmath_cp_h = 9.6179199219e-01f, /* 0x3f763800 =head of cp */
basicmath_cp_l = 4.7017383622e-06f, /* 0x369dc3a0 =tail of cp_h */
basicmath_ivln2 = 1.4426950216e+00f, /* 0x3fb8aa3b =1/ln2 */
basicmath_ivln2_h = 1.4426879883e+00f, /* 0x3fb8aa00 =16b 1/ln2*/
basicmath_ivln2_l = 7.0526075433e-06f; /* 0x36eca570 =1/ln2 tail*/
float basicmath___ieee754_powf( float x, float y )
{
float z, ax, z_h, z_l, p_h, p_l;
float y1, t1, t2, r, s, t, u, v, w;
int32_t i, j, k, yisint, n;
int32_t hx, hy, ix, iy, is;
GET_FLOAT_WORD( hx, x );
GET_FLOAT_WORD( hy, y );
ix = hx & 0x7fffffff;
iy = hy & 0x7fffffff;
/* y==zero: x**0 = 1 */
if ( iy == 0 ) return basicmath_one;
/* x==+-1 */
if ( x == 1.0f ) return basicmath_one;
if ( x == -1.0f && basicmath___isinff( y ) ) return basicmath_one;
/* +-NaN return x+y */
if ( ix > 0x7f800000 ||
iy > 0x7f800000 )
return x + y;
/* determine if y is an odd int when x < 0
yisint = 0 ... y is not an integer
yisint = 1 ... y is an odd int
yisint = 2 ... y is an even int
*/
yisint = 0;
if ( hx < 0 ) {
if ( iy >= 0x4b800000 ) yisint = 2; /* even integer y */
else
if ( iy >= 0x3f800000 ) {
k = ( iy >> 23 ) - 0x7f; /* exponent */
j = iy >> ( 23 - k );
if ( ( j << ( 23 - k ) ) == iy ) yisint = 2 - ( j & 1 );
}
}
/* special value of y */
if ( iy == 0x7f800000 ) { /* y is +-inf */
if ( ix == 0x3f800000 )
return y - y; /* inf**+-1 is NaN */
else
if ( ix > 0x3f800000 ) /* (|x|>1)**+-inf = inf,0 */
return ( hy >= 0 ) ? y : basicmath_zero;
else /* (|x|<1)**-,+inf = inf,0 */
return ( hy < 0 ) ? -y : basicmath_zero;
}
if ( iy == 0x3f800000 ) { /* y is +-1 */
if ( hy < 0 ) return basicmath_one / x;
else return x;
}
if ( hy == 0x40000000 ) return x * x; /* y is 2 */
if ( hy == 0x3f000000 ) { /* y is 0.5 */
if ( hx >= 0 ) /* x >= +0 */
return basicmath___ieee754_sqrtf( x );
}
ax = basicmath___fabsf( x );
/* special value of x */
if ( ix == 0x7f800000 || ix == 0 || ix == 0x3f800000 ) {
z = ax; /*x is +-0,+-inf,+-1*/
if ( hy < 0 ) z = basicmath_one / z; /* z = (1/|x|) */
if ( hx < 0 ) {
if ( ( ( ix - 0x3f800000 ) | yisint ) == 0 ) {
z = ( z - z ) / ( z - z ); /* (-1)**non-int is NaN */
} else
if ( yisint == 1 )
z = -z; /* (x<0)**odd = -(|x|**odd) */
}
return z;
}
/* (x<0)**(non-int) is NaN */
if ( ( ( ( ( u_int32_t )hx >> 31 ) - 1 ) | yisint ) == 0 ) return ( x - x ) /
( x - x );
/* |y| is huge */
if ( iy > 0x4d000000 ) { /* if |y| > 2**27 */
/* over/underflow if x is not close to one */
if ( ix < 0x3f7ffff8 ) return ( hy < 0 ) ? basicmath_huge * basicmath_huge :
basicmath_tiny * basicmath_tiny;
if ( ix > 0x3f800007 ) return ( hy > 0 ) ? basicmath_huge * basicmath_huge :
basicmath_tiny * basicmath_tiny;
/* now |1-x| is tiny <= 2**-20, suffice to compute
log(x) by x-x^2/2+x^3/3-x^4/4 */
t = x - 1; /* t has 20 trailing zeros */
w = ( t * t ) * ( ( float )0.5f - t * ( ( float )0.333333333333f - t *
( float )0.25f ) );
u = basicmath_ivln2_h * t; /* ivln2_h has 16 sig. bits */
v = t * basicmath_ivln2_l - w * basicmath_ivln2;
t1 = u + v;
GET_FLOAT_WORD( is, t1 );
SET_FLOAT_WORD( t1, is & 0xfffff000 );
t2 = v - ( t1 - u );
} else {
float s2, s_h, s_l, t_h, t_l;
n = 0;
/* take care subnormal number */
if ( ix < 0x00800000 ) {
ax *= basicmath_two24;
n -= 24;
GET_FLOAT_WORD( ix, ax );
}
n += ( ( ix ) >> 23 ) - 0x7f;
j = ix & 0x007fffff;
/* determine interval */
ix = j | 0x3f800000; /* normalize ix */
if ( j <= 0x1cc471 ) k = 0; /* |x|<sqrt(3/2) */
else
if ( j < 0x5db3d7 ) k = 1; /* |x|<sqrt(3) */
else {
k = 0;
n += 1;
ix -= 0x00800000;
}
SET_FLOAT_WORD( ax, ix );
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
u = ax - basicmath_bp[ k ]; /* bp[0]=1.0, bp[1]=1.5 */
v = basicmath_one / ( ax + basicmath_bp[ k ] );
s = u * v;
s_h = s;
GET_FLOAT_WORD( is, s_h );
SET_FLOAT_WORD( s_h, is & 0xfffff000 );
/* t_h=ax+bp[k] High */
SET_FLOAT_WORD( t_h, ( ( ix >> 1 ) | 0x20000000 ) + 0x0040000 + ( k << 21 ) );
t_l = ax - ( t_h - basicmath_bp[ k ] );
s_l = v * ( ( u - s_h * t_h ) - s_h * t_l );
/* compute log(ax) */
s2 = s * s;
r = s2 * s2 * ( basicmath_L1 + s2 * ( basicmath_L2 + s2 *
( basicmath_L3 + s2 * ( basicmath_L4 + s2 *
( basicmath_L5 + s2 * basicmath_L6 ) ) ) ) );
r += s_l * ( s_h + s );
s2 = s_h * s_h;
t_h = ( float )3.0f + s2 + r;
GET_FLOAT_WORD( is, t_h );
SET_FLOAT_WORD( t_h, is & 0xfffff000 );
t_l = r - ( ( t_h - ( float )3.0f ) - s2 );
/* u+v = s*(1+...) */
u = s_h * t_h;
v = s_l * t_h + t_l * s;
/* 2/(3log2)*(s+...) */
p_h = u + v;
GET_FLOAT_WORD( is, p_h );
SET_FLOAT_WORD( p_h, is & 0xfffff000 );
p_l = v - ( p_h - u );
z_h = basicmath_cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */
z_l = basicmath_cp_l * p_h + p_l * basicmath_cp + basicmath_dp_l[ k ];
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
t = ( float )n;
t1 = ( ( ( z_h + z_l ) + basicmath_dp_h[ k ] ) + t );
GET_FLOAT_WORD( is, t1 );
SET_FLOAT_WORD( t1, is & 0xfffff000 );
t2 = z_l - ( ( ( t1 - t ) - basicmath_dp_h[ k ] ) - z_h );
}
s = basicmath_one; /* s (sign of result -ve**odd) = -1 else = 1 */
if ( ( ( ( ( u_int32_t )hx >> 31 ) - 1 ) | ( yisint - 1 ) ) == 0 )
s = -basicmath_one; /* (-ve)**(odd int) */
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
GET_FLOAT_WORD( is, y );
SET_FLOAT_WORD( y1, is & 0xfffff000 );
p_l = ( y - y1 ) * t1 + y * t2;
p_h = y1 * t1;
z = p_l + p_h;
GET_FLOAT_WORD( j, z );
if ( j > 0x43000000 ) /* if z > 128 */
return s * basicmath_huge * basicmath_huge; /* overflow */
else
if ( j == 0x43000000 ) { /* if z == 128 */
if ( p_l + basicmath_ovt > z - p_h ) return s * basicmath_huge *
basicmath_huge; /* overflow */
} else
if ( ( j & 0x7fffffff ) > 0x43160000 ) /* z <= -150 */
return s * basicmath_tiny * basicmath_tiny; /* underflow */
else
if ( ( u_int32_t ) j == 0xc3160000 ) { /* z == -150 */
if ( p_l <= z - p_h ) return s * basicmath_tiny *
basicmath_tiny; /* underflow */
}
/*
compute 2**(p_h+p_l)
*/
i = j & 0x7fffffff;
k = ( i >> 23 ) - 0x7f;
n = 0;
if ( i > 0x3f000000 ) { /* if |z| > 0.5, set n = [z+0.5] */
n = j + ( 0x00800000 >> ( k + 1 ) );
k = ( ( n & 0x7fffffff ) >> 23 ) - 0x7f; /* new k for n */
SET_FLOAT_WORD( t, n & ~( 0x007fffff >> k ) );
n = ( ( n & 0x007fffff ) | 0x00800000 ) >> ( 23 - k );
if ( j < 0 ) n = -n;
p_h -= t;
}
t = p_l + p_h;
GET_FLOAT_WORD( is, t );
SET_FLOAT_WORD( t, is & 0xfffff000 );
u = t * basicmath_lg2_h;
v = ( p_l - ( t - p_h ) ) * basicmath_lg2 + t * basicmath_lg2_l;
z = u + v;
w = v - ( z - u );
t = z * z;
t1 = z - t * ( basicmath_P1 + t * ( basicmath_P2 + t * ( basicmath_P3 + t *
( basicmath_P4 + t * basicmath_P5 ) ) ) );
r = ( z * t1 ) / ( t1 - basicmath_two ) - ( w + z * w );
z = basicmath_one - ( r - z );
GET_FLOAT_WORD( j, z );
j += ( n << 23 );
if ( ( j >> 23 ) <= 0 ) z = basicmath___scalbnf( z, n ); /* subnormal output */
else SET_FLOAT_WORD( z, j );
return s * z;
}
/* e_rem_pio2f.c -- float version of e_rem_pio2.c
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/* basicmath___ieee754_rem_pio2f(x,y)
return the remainder of x rem pi/2 in y[0]+y[1]
*/
/* This array is like the one in e_rem_pio2.c, but the numbers are
single precision and the last 8 bits are forced to 0. */
static const int32_t basicmath_npio2_hw[] = {
0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00,
0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00,
0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100,
0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00,
0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00,
0x4242c700, 0x42490f00
};
/*
invpio2: 24 bits of 2/pi
pio2_1: first 17 bit of pi/2
pio2_1t: pi/2 - pio2_1
pio2_2: second 17 bit of pi/2
pio2_2t: pi/2 - (pio2_1+pio2_2)
pio2_3: third 17 bit of pi/2
pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
*/
static const float basicmath_invpio2 = 6.3661980629e-01f, /* 0x3f22f984 */
basicmath_pio2_1 = 1.5707855225e+00f, /* 0x3fc90f80 */
basicmath_pio2_1t = 1.0804334124e-05f, /* 0x37354443 */
basicmath_pio2_2 = 1.0804273188e-05f, /* 0x37354400 */
basicmath_pio2_2t = 6.0770999344e-11f, /* 0x2e85a308 */
basicmath_pio2_3 = 6.0770943833e-11f, /* 0x2e85a300 */
basicmath_pio2_3t = 6.1232342629e-17f; /* 0x248d3132 */
int32_t basicmath___ieee754_rem_pio2f( float x, float *y )
{
float z, w, t, r, fn;
int32_t i, j, n, ix, hx;
GET_FLOAT_WORD( hx, x );
ix = hx & 0x7fffffff;
if ( ix <= 0x3f490fd8 ) { /* |x| ~<= pi/4 , no need for reduction */
y[ 0 ] = x;
y[ 1 ] = 0;
return 0;
}
if ( ix < 0x4016cbe4 ) { /* |x| < 3pi/4, special case with n=+-1 */
if ( hx > 0 ) {
z = x - basicmath_pio2_1;
if ( ( ix & 0xfffffff0 ) != 0x3fc90fd0 ) { /* 24+24 bit pi OK */
y[ 0 ] = z - basicmath_pio2_1t;
y[ 1 ] = ( z - y[ 0 ] ) - basicmath_pio2_1t;
} else { /* near pi/2, use 24+24+24 bit pi */
z -= basicmath_pio2_2;
y[ 0 ] = z - basicmath_pio2_2t;
y[ 1 ] = ( z - y[ 0 ] ) - basicmath_pio2_2t;
}
return 1;
} else { /* negative x */
z = x + basicmath_pio2_1;
if ( ( ix & 0xfffffff0 ) != 0x3fc90fd0 ) { /* 24+24 bit pi OK */
y[ 0 ] = z + basicmath_pio2_1t;
y[ 1 ] = ( z - y[ 0 ] ) + basicmath_pio2_1t;
} else { /* near pi/2, use 24+24+24 bit pi */
z += basicmath_pio2_2;
y[ 0 ] = z + basicmath_pio2_2t;
y[ 1 ] = ( z - y[ 0 ] ) + basicmath_pio2_2t;
}
return -1;
}
}
if ( ix <= 0x43490f80 ) { /* |x| ~<= 2^7*(pi/2), medium size */
t = basicmath___fabsf( x );
n = ( int32_t ) ( t * basicmath_invpio2 + basicmath_half );
fn = ( float )n;
r = t - fn * basicmath_pio2_1;
w = fn * basicmath_pio2_1t; /* 1st round good to 40 bit */
if ( n < 32 && ( int32_t )( ix & 0xffffff00 ) != basicmath_npio2_hw[n - 1] ) {
y[ 0 ] = r - w; /* quick check no cancellation */
} else {
u_int32_t high;
j = ix >> 23;
y[ 0 ] = r - w;
GET_FLOAT_WORD( high, y[ 0 ] );
i = j - ( ( high >> 23 ) & 0xff );
if ( i > 8 ) { /* 2nd iteration needed, good to 57 */
t = r;
w = fn * basicmath_pio2_2;
r = t - w;
w = fn * basicmath_pio2_2t - ( ( t - r ) - w );
y[ 0 ] = r - w;
GET_FLOAT_WORD( high, y[ 0 ] );
i = j - ( ( high >> 23 ) & 0xff );
if ( i > 25 ) { /* 3rd iteration need, 74 bits acc */
t = r; /* will cover all possible cases */
w = fn * basicmath_pio2_3;
r = t - w;
w = fn * basicmath_pio2_3t - ( ( t - r ) - w );
y[ 0 ] = r - w;
}
}
}
y[ 1 ] = ( r - y[ 0 ] ) - w;
if ( hx < 0 ) {
y[ 0 ] = -y[ 0 ];
y[ 1 ] = -y[ 1 ];
return -n;
} else return n;
}
/*
all other (large) arguments
*/
if ( ix >= 0x7f800000 ) { /* x is inf or NaN */
y[ 0 ] = y[ 1 ] = x - x;
return 0;
}
// This will never happen in basicmath_small, because
// up to this point we have already returned a value
// for each of the possible inputs
y[ 0 ] = y[ 1 ] = x - x; /* dummy initialization */
return 0;
}
/* e_sqrtf.c -- float version of e_sqrt.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
float basicmath___ieee754_sqrtf( float x )
{
float z;
int32_t sign = ( int )0x80000000;
int32_t ix, s, q, m, t, i;
u_int32_t r;
GET_FLOAT_WORD( ix, x );
/* take care of Inf and NaN */
if ( ( ix & 0x7f800000 ) == 0x7f800000 ) {
return x * x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
sqrt(-inf)=sNaN */
}
/* take care of zero */
if ( ix <= 0 ) {
if ( ( ix & ( ~sign ) ) == 0 ) return x; /* sqrt(+-0) = +-0 */
else
if ( ix < 0 )
return ( x - x ) / ( x - x ); /* sqrt(-ve) = sNaN */
}
/* normalize x */
m = ( ix >> 23 );
if ( m == 0 ) { /* subnormal x */
_Pragma( "loopbound min 0 max 0" )
for ( i = 0; ( ix & 0x00800000 ) == 0; i++ )
ix <<= 1;
m -= i - 1;
}
m -= 127; /* unbias exponent */
ix = ( ix & 0x007fffff ) | 0x00800000;
if ( m & 1 ) /* odd m, double x to make it even */
ix += ix;
m >>= 1; /* m = [m/2] */
/* generate sqrt(x) bit by bit */
ix += ix;
q = s = 0; /* q = sqrt(x) */
r = 0x01000000; /* r = moving bit from right to left */
_Pragma( "loopbound min 25 max 25" )
while ( r != 0 ) {
t = s + r;
if ( t <= ix ) {
s = t + r;
ix -= t;
q += r;
}
ix += ix;
r >>= 1;
}
/* use floating add to find out rounding direction */
if ( ix != 0 ) {
z = basicmath_one - basicmath_tiny; /* trigger inexact flag */
if ( z >= basicmath_one ) {
z = basicmath_one + basicmath_tiny;
if ( z > basicmath_one )
q += 2;
else
q += ( q & 1 );
}
}
ix = ( q >> 1 ) + 0x3f000000;
ix += ( m << 23 );
SET_FLOAT_WORD( z, ix );
return z;
}
/* k_cosf.c -- float version of k_cos.c
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_C1 = 4.1666667908e-02f, /* 0x3d2aaaab */
basicmath_C2 = -1.3888889225e-03f, /* 0xbab60b61 */
basicmath_C3 = 2.4801587642e-05f, /* 0x37d00d01 */
basicmath_C4 = -2.7557314297e-07f, /* 0xb493f27c */
basicmath_C5 = 2.0875723372e-09f, /* 0x310f74f6 */
basicmath_C6 = -1.1359647598e-11f; /* 0xad47d74e */
float basicmath___kernel_cosf( float x, float y )
{
float a, hz, z, r, qx;
int32_t ix;
GET_FLOAT_WORD( ix, x );
ix &= 0x7fffffff; /* ix = |x|'s high word*/
if ( ix < 0x32000000 ) { /* if x < 2**27 */
if ( ( ( int )x ) == 0 ) return basicmath_one; /* generate inexact */
}
z = x * x;
r = z * ( basicmath_C1 + z * ( basicmath_C2 + z * ( basicmath_C3 + z *
( basicmath_C4 + z * ( basicmath_C5 + z * basicmath_C6 ) ) ) ) );
if ( ix < 0x3e99999a ) /* if |x| < 0.3 */
return basicmath_one - ( ( float )0.5f * z - ( z * r - x * y ) );
else {
if ( ix > 0x3f480000 ) /* x > 0.78125 */
qx = ( float )0.28125f;
else {
SET_FLOAT_WORD( qx, ix - 0x01000000 ); /* x/4 */
}
hz = ( float )0.5f * z - qx;
a = basicmath_one - qx;
return a - ( hz - ( z * r - x * y ) );
}
}
/* k_sinf.c -- float version of k_sin.c
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_S1 = -1.6666667163e-01f, /* 0xbe2aaaab */
basicmath_S2 = 8.3333337680e-03f, /* 0x3c088889 */
basicmath_S3 = -1.9841270114e-04f, /* 0xb9500d01 */
basicmath_S4 = 2.7557314297e-06f, /* 0x3638ef1b */
basicmath_S5 = -2.5050759689e-08f, /* 0xb2d72f34 */
basicmath_S6 = 1.5896910177e-10f; /* 0x2f2ec9d3 */
float basicmath___kernel_sinf( float x, float y, int iy )
{
float z, r, v;
int32_t ix;
GET_FLOAT_WORD( ix, x );
ix &= 0x7fffffff; /* high word of x */
if ( ix < 0x32000000 ) { /* |x| < 2**-27 */
if ( ( int )x == 0 ) return x; /* generate inexact */
}
z = x * x;
v = z * x;
r = basicmath_S2 + z * ( basicmath_S3 + z * ( basicmath_S4 + z *
( basicmath_S5 + z * basicmath_S6 ) ) );
if ( iy == 0 ) return x + v * ( basicmath_S1 + z * r );
else return x - ( ( z * ( basicmath_half * y - v * r ) - y ) - v *
basicmath_S1 );
}
/* s_copysignf.c -- float version of s_copysign.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
copysignf(float x, float y)
copysignf(x,y) returns a value with the magnitude of x and
with the sign bit of y.
*/
float basicmath___copysignf( float x, float y )
{
u_int32_t ix, iy;
GET_FLOAT_WORD( ix, x );
GET_FLOAT_WORD( iy, y );
SET_FLOAT_WORD( x, ( ix & 0x7fffffff ) | ( iy & 0x80000000 ) );
return x;
}
/* s_cosf.c -- float version of s_cos.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
float basicmath___cosf( float x )
{
float y[ 2 ], z = 0.0f;
int32_t n, ix;
GET_FLOAT_WORD( ix, x );
/* |x| ~< pi/4 */
ix &= 0x7fffffff;
if ( ix <= 0x3f490fd8 ) return basicmath___kernel_cosf( x, z );
/* cos(Inf or NaN) is NaN */
else
if ( ix >= 0x7f800000 ) return x - x;
/* argument reduction needed */
else {
n = basicmath___ieee754_rem_pio2f( x, y );
switch ( n & 3 ) {
case 0:
return basicmath___kernel_cosf( y[ 0 ], y[ 1 ] );
case 1:
return -basicmath___kernel_sinf( y[ 0 ], y[ 1 ], 1 );
case 2:
return -basicmath___kernel_cosf( y[ 0 ], y[ 1 ] );
default:
return basicmath___kernel_sinf( y[ 0 ], y[ 1 ], 1 );
}
}
}
/* s_fabsf.c -- float version of s_fabs.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
fabsf(x) returns the absolute value of x.
*/
float basicmath___fabsf( float x )
{
u_int32_t ix;
GET_FLOAT_WORD( ix, x );
SET_FLOAT_WORD( x, ix & 0x7fffffff );
return x;
}
/*
isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0;
no branching!
*/
int basicmath___isinff ( float x )
{
int32_t ix, t;
GET_FLOAT_WORD( ix, x );
t = ix & 0x7fffffff;
t ^= 0x7f800000;
t |= -t;
return ~( t >> 31 ) & ( ix >> 30 );
}
/* s_scalbnf.c -- float version of s_scalbn.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_two25 = 3.355443200e+07f, /* 0x4c000000 */
basicmath_twom25 = 2.9802322388e-08f; /* 0x33000000 */
float basicmath___scalbnf ( float x, int n )
{
int32_t k, ix;
GET_FLOAT_WORD( ix, x );
k = ( ix & 0x7f800000 ) >> 23; /* extract exponent */
if ( k == 0 ) { /* 0 or subnormal x */
if ( ( ix & 0x7fffffff ) == 0 ) return x; /* +-0 */
x *= basicmath_two25;
GET_FLOAT_WORD( ix, x );
k = ( ( ix & 0x7f800000 ) >> 23 ) - 25;
}
if ( k == 0xff ) return x + x; /* NaN or Inf */
k = k + n;
if ( n > 50000 || k > 0xfe )
return basicmath_huge * basicmath___copysignf( basicmath_huge,
x ); /* overflow */
if ( n < -50000 )
return basicmath_tiny * basicmath___copysignf( basicmath_tiny,
x ); /*underflow*/
if ( k > 0 ) { /* normal result */
SET_FLOAT_WORD( x, ( ix & 0x807fffff ) | ( k << 23 ) );
return x;
}
if ( k <= -25 )
return basicmath_tiny * basicmath___copysignf( basicmath_tiny,
x ); /*underflow*/
k += 25; /* subnormal result */
SET_FLOAT_WORD( x, ( ix & 0x807fffff ) | ( k << 23 ) );
return x * basicmath_twom25;
}

View File

@ -0,0 +1,61 @@
/*
====================================================
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

View File

@ -0,0 +1,78 @@
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

View File

@ -0,0 +1,90 @@
/*
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 _Pragma( "entrypoint" ) 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();
}

View File

@ -0,0 +1,31 @@
/*
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 */

View File

@ -0,0 +1,23 @@
File: fac.c
Original provenience: MDH WCET BENCHMARK SUITE
2016-02-26:
- Added TACLeBench header to line 1
- Removed unused functions
- Removed unused variables
- Declared s a global variable and renamed it to fac_s
- Declared n a global variable and renamed it to fac_n
- Renamed function fac to fac_fac
- Renamed function main to fac_main
- Created new function main, calling fac_init, fac_main and
returning fac_return
- Changed return type of fac_main to void
- Move initialization code into new function fac_init
- Reordered functions in source code: initialization- and
return-value-related functions first, followed by algorithm core
functions, followed by main functions
- Applied code formatting with astyle as in the example
2016-03-09:
- Subtract expected result from return value, such that the return code of the
program is 0 if success.

View File

@ -0,0 +1,97 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: fac
Author: unknown
Function: fac is a program to calculate factorials.
This program computes the sum of the factorials
from zero to five.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/fac/fac.c
Changes: CS 2006/05/19: Changed loop bound from constant to variable.
License: public domain
*/
/*
Forward declaration of functions
*/
int fac_fac( int n );
void fac_init();
int fac_return();
void fac_main();
// int main( void );
/*
Declaration of global variables
*/
int fac_s;
volatile int fac_n;
/*
Initialization- and return-value-related functions
*/
void fac_init()
{
fac_s = 0;
fac_n = 5;
}
int fac_return()
{
int expected_result = 154;
return fac_s - expected_result;
}
/*
Arithmetic math functions
*/
int fac_fac ( int n )
{
if ( n == 0 )
return 1;
else
return ( n * fac_fac ( n - 1 ) );
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) fac_main ()
{
int i;
_Pragma( "loopbound min 6 max 6" )
for ( i = 0; i <= fac_n; i++ ) {
_Pragma( "marker recursivecall" )
fac_s += fac_fac ( i );
_Pragma( "flowrestriction 1*fac_fac <= 6*recursivecall" )
}
}
// int main ( void )
// {
// fac_init();
// fac_main();
// return ( fac_return() );
// }

View File

@ -0,0 +1,35 @@
File: fft.c
Original provenience: DSP-Stone
2016-01-05:
- Rename fft_1024_13 to fft
- Add generic TACLeBench header
- Remove original header from DSP-Stone group
- Remove duplicate semicolon in bit_reduct
- Introduce fft_init (initialization of input)
and fft_main (main entry point)
- Update comments about separate input-data file
- Add entry-point annotation to fft_main
- Introduce non-zero return value and make input_data global to reduce impact of
compiler optimizations
- Prefix the functions pin_down, float2frac, convert, exp2f and the global
variables input_data, inputfract, input, twidtable with fft_
2016-03-02:
- Fix undefined behavior due to unsequenced modification and access
- Reformat large arrays using clang-format to 80 columns
- Apply code formatting with astyle as in the example
2016-04-25:
- Remove unnecessary braces in fft_bit_reduct
- Add void parameter to fft_float2fract
- Add all forward declarations
- Move input data into separate file
- Compute check sum and compare it to expected value in return function
2016-04-26:
- Remove unnecessary braces in fft_pin_down
- Avoid constant propagation through addition with volatile variable
on each element of fft_input_data, fft_twidtable, and fft_input
- Reorganize functions into logical segments in main source file
- Replace usage of macros by their expanded values:
STORAGE_CLASS => register, TYPE => int
2017-07-10:
- Fix loop bounds to avoid buffer overflow.

View File

@ -0,0 +1,333 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: fft
Author: Juan Martinez Velarde
Function: benchmarking of an integer stage scaling FFT
To avoid errors caused by overflow and bit growth,
the input data is scaled. Bit growth occurs potentially
at butterfly operations, which involve a complex
multiplication, a complex addition and a complex
subtraction. Maximal bit growth from butterfly input
to butterfly output is two bits.
The input data includes enough extra sign bits, called
guard bits, to ensure that bit growth never results in
overflow (Rabiner and Gold, 1975). Data can grow by a
maximum factor of 2.4 from butterfly input to output
(two bits of grow). However, a data value cannot grow by
maximum amount in two consecutive stages.
The number of guard bits necessary to compensate the
maximum bit growth in an N-point FFT is (log_2 (N))+1).
In a 16-point FFT (requires 4 stages), each of the
input samples should contain 5 guard bits. The input
data is then restricted to 10 bits, one sign bit and
nine magnitude bits, in order to prevent an
overflow from the integer multiplication with the
precalculed twiddle coefficients.
Another method to compensate bit growth is to scale the
outputs down by a factor of two unconditionally after
each stage. This approach is called unconditional scaling
Initially, 2 guard bits are included in the input data to
accomodate the maximum overflow in the first stage.
In each butterfly of a stage calculation, the data can
grow into the guard bits. To prevent overflow in the next
stage, the guard bits are replaced before the next stage is
executed by shifting the entire block of data one bit
to the right.
Input data should not be restricted to a 1.9 format.
Input data can be represented in a 1.13 format,that is
14 significant bits, one sign and 13 magnitude bits. In
the FFT calculation, the data loses a total of (log2 N) -1
bits because of shifting. Unconditional scaling results
in the same number of bits lost as in the input data scaling.
However, it produces more precise results because the
FFT starts with more precise input data. The tradeoff is
a slower FFT calculation because of the extra cycles needed
to shift the output of each stage.
Source: DSP-Stone
http://www.ice.rwth-aachen.de/research/tools-projects/entry/detail/dspstone/
Original name: fft_1024_13
(merged main1024_bit_reduct and fft_bit_reduct from DSP-Stone)
Changes: no major functional changes
License: may be used, modified, and re-distributed freely
*/
#define N_FFT 1024
#define NUMBER_OF_BITS 13 /* fract format 1.NUMBER_OF_BITS = 1.13 */
#define BITS_PER_TWID 13 /* bits per twiddle coefficient */
#define SHIFT BITS_PER_TWID /* fractional shift after each multiplication */
/*
Forward declaration of functions
*/
float fft_exp2f( float x );
float fft_modff( float x, float *intpart );
int fft_convert( float value );
void fft_bit_reduct( register int *int_pointer );
void fft_pin_down( int input_data[ ] );
void fft_init( void );
void fft_main( void );
int fft_return( void );
int main( void );
/*
Forward declaration of global variables
*/
int fft_input_data[ 2 * N_FFT ];
/* precalculated twiddle factors
for an integer 1024 point FFT
in format 1.13 => table twidtable[ 2*(N_FFT-1) ] ; */
extern int fft_twidtable[ 2046 ];
/* 1024 real values as input data in float format */
extern float fft_input[ 1024 ];
/* will hold the transformed data */
int fft_inputfract[ N_FFT ];
/*
Algorithm core function
*/
void fft_bit_reduct( register int *int_pointer )
{
register int i, j = 0 ;
register int tmpr, max = 2, m, n = N_FFT << 1 ;
/* do the bit reversal scramble of the input data */
_Pragma( "loopbound min 1024 max 1024" )
for ( i = 0; i < ( n - 1 ) ; i += 2 ) {
if ( j > i ) {
tmpr = *( int_pointer + j ) ;
*( int_pointer + j ) = *( int_pointer + i ) ;
*( int_pointer + i ) = tmpr ;
tmpr = *( int_pointer + j + 1 ) ;
*( int_pointer + j + 1 ) = *( int_pointer + i + 1 ) ;
*( int_pointer + i + 1 ) = tmpr ;
}
m = N_FFT;
_Pragma( "loopbound min 0 max 10" )
while ( m >= 2 && j >= m ) {
j -= m ;
m >>= 1;
}
j += m ;
}
{
register int *data_pointer = &fft_twidtable[ 0 ] ;
register int *p, *q ;
register int tmpi, fr = 0, level, k, l ;
_Pragma( "loopbound min 10 max 10" )
while ( n > max ) {
level = max << 1;
_Pragma( "loopbound min 1 max 512" )
for ( m = 1; m < max; m += 2 ) {
l = *( data_pointer + fr );
k = *( data_pointer + fr + 1 ) ;
fr += 2 ;
_Pragma( "loopbound min 1 max 512" )
for ( i = m; i <= n; i += level ) {
j = i + max;
p = int_pointer + j;
q = int_pointer + i;
tmpr = l * *( p - 1 );
tmpr -= ( k * *p );
tmpi = l * *p;
tmpi += ( k * *( p - 1 ) );
tmpr = tmpr >> SHIFT ;
tmpi = tmpi >> SHIFT ;
*( p - 1 ) = *( q - 1 ) - tmpr ;
*p = *q - tmpi ;
*( q - 1 ) += tmpr ;
*q += tmpi ;
}
}
/* implement unconditional bit reduction */
{
register int f;
p = int_pointer;
_Pragma( "loopbound min 2048 max 2048" )
for ( f = 0 ; f < 2 * N_FFT; f++ ) {
*p = *p >> 1;
p++;
}
}
max = level;
}
}
}
/*
Initialization- and return-value-related functions
*/
/* conversion function to 1.NUMBER_OF_BITS format */
float fft_exp2f( float x )
{
int i;
float ret = 2.0f;
_Pragma( "loopbound min 13 max 13" )
for ( i = 1; i < x; ++i )
ret *= 2.0f;
return ret;
}
float fft_modff( float x, float *intpart )
{
if ( intpart ) {
*intpart = ( int )x;
return x - *intpart;
} else
return x;
}
/* conversion function to 1.NUMBER_OF_BITS format */
int fft_convert( float value )
{
float man, t_val, frac, m, exponent = NUMBER_OF_BITS;
int rnd_val;
unsigned long int_val;
unsigned long pm_val;
m = fft_exp2f( exponent + 1 ) - 1;
t_val = value * m ;
frac = fft_modff( t_val, &man );
if ( frac < 0.0f ) {
rnd_val = ( -1 );
if ( frac > -0.5f ) rnd_val = 0;
} else {
rnd_val = 1;
if ( frac < 0.5f ) rnd_val = 0;
}
int_val = (long)man + (long)rnd_val;
pm_val = int_val ;
return ( ( int ) ( pm_val ) ) ;
}
void fft_float2fract( void )
{
float f ;
int j, i ;
_Pragma( "loopbound min 1024 max 1024" )
for ( j = 0 ; j < N_FFT ; j++ ) {
f = fft_input[ j ];
i = fft_convert( f );
fft_inputfract[ j ] = i;
}
}
void fft_pin_down( int input_data[ ] )
{
/* conversion from input to a 1.13 format */
fft_float2fract() ;
int *pd, *ps, f;
pd = &input_data[ 0 ];
ps = &fft_inputfract[ 0 ];
_Pragma( "loopbound min 1024 max 1024" )
for ( f = 0; f < N_FFT; f++ ) {
*pd++ = *ps++ ; /* fill in with real data */
*pd++ = 0 ; /* imaginary data is equal zero */
}
}
void fft_init( void )
{
int i;
volatile int x = 0;
fft_pin_down( &fft_input_data[ 0 ] );
/* avoid constant propagation of input values */
_Pragma( "loopbound min 2046 max 2046" )
for ( i = 0; i < 2 * ( N_FFT - 1 ); i++ ) {
fft_input_data[ i ] += x;
fft_twidtable[ i ] += x;
}
_Pragma( "loopbound min 2 max 2" )
for ( ; i < 2 * N_FFT; i++ )
fft_input_data[ i ] += x;
}
int fft_return( void )
{
int check_sum = 0;
int i = 0;
_Pragma( "loopbound min 2048 max 2048" )
for ( i = 0; i < 2 * N_FFT; ++i )
check_sum += fft_input_data[ i ];
return check_sum != 3968;
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) fft_main( void )
{
fft_bit_reduct( &fft_input_data[ 0 ] );
}
int main( void )
{
fft_init();
fft_main();
return fft_return();
}

View File

@ -0,0 +1,322 @@
int fft_twidtable[ 2046 ] = {
8192, 0, 8192, 0, 0, -8192, 8192, 0, 5792, -5792, 0,
-8191, -5792, -5792, 8192, 0, 7568, -3134, 5792, -5792, 3134, -7568,
0, -8192, -3134, -7568, -5792, -5792, -7568, -3134, 8192, 0, 8034,
-1598, 7568, -3134, 6811, -4551, 5792, -5792, 4551, -6811, 3134, -7568,
1598, -8034, 0, -8192, -1598, -8034, -3134, -7568, -4551, -6811, -5792,
-5792, -6811, -4551, -7568, -3134, -8034, -1598, 8192, 0, 8152, -802,
8034, -1598, 7839, -2378, 7568, -3134, 7224, -3861, 6811, -4551, 6332,
-5196, 5792, -5792, 5196, -6332, 4551, -6811, 3861, -7224, 3134, -7568,
2378, -7839, 1598, -8034, 802, -8152, 0, -8191, -802, -8152, -1598,
-8034, -2378, -7839, -3134, -7568, -3861, -7224, -4551, -6811, -5196, -6332,
-5792, -5792, -6332, -5196, -6811, -4551, -7224, -3861, -7568, -3134, -7839,
-2378, -8034, -1598, -8152, -802, 8192, 0, 8182, -401, 8152, -802,
8103, -1202, 8034, -1598, 7946, -1990, 7839, -2378, 7713, -2759, 7568,
-3134, 7405, -3502, 7224, -3861, 7026, -4211, 6811, -4551, 6579, -4879,
6332, -5196, 6069, -5501, 5792, -5792, 5501, -6069, 5196, -6332, 4879,
-6579, 4551, -6811, 4211, -7026, 3861, -7224, 3502, -7405, 3134, -7568,
2759, -7713, 2378, -7839, 1990, -7946, 1598, -8034, 1202, -8103, 802,
-8152, 401, -8182, 0, -8192, -401, -8182, -802, -8152, -1202, -8103,
-1598, -8034, -1990, -7946, -2378, -7839, -2759, -7713, -3134, -7568, -3502,
-7405, -3861, -7224, -4211, -7026, -4551, -6811, -4879, -6579, -5196, -6332,
-5501, -6069, -5792, -5792, -6069, -5501, -6332, -5196, -6579, -4879, -6811,
-4551, -7026, -4211, -7224, -3861, -7405, -3502, -7568, -3134, -7713, -2759,
-7839, -2378, -7946, -1990, -8034, -1598, -8103, -1202, -8152, -802, -8182,
-401, 8192, 0, 8189, -201, 8182, -401, 8169, -602, 8152, -802,
8130, -1002, 8103, -1202, 8071, -1400, 8034, -1598, 7992, -1794, 7946,
-1990, 7895, -2184, 7839, -2378, 7778, -2569, 7713, -2759, 7643, -2948,
7568, -3134, 7489, -3319, 7405, -3502, 7317, -3683, 7224, -3861, 7127,
-4037, 7026, -4211, 6921, -4382, 6811, -4551, 6697, -4717, 6579, -4879,
6458, -5039, 6332, -5196, 6203, -5350, 6069, -5501, 5933, -5648, 5792,
-5792, 5648, -5933, 5501, -6069, 5350, -6203, 5196, -6332, 5039, -6458,
4879, -6579, 4717, -6697, 4551, -6811, 4382, -6921, 4211, -7026, 4037,
-7127, 3861, -7224, 3683, -7317, 3502, -7405, 3319, -7489, 3134, -7568,
2948, -7643, 2759, -7713, 2569, -7778, 2378, -7839, 2184, -7895, 1990,
-7946, 1794, -7992, 1598, -8034, 1400, -8071, 1202, -8103, 1002, -8130,
802, -8152, 602, -8169, 401, -8182, 201, -8189, 0, -8192, -201,
-8189, -401, -8182, -602, -8169, -802, -8152, -1002, -8130, -1202, -8103,
-1400, -8071, -1598, -8034, -1794, -7992, -1990, -7946, -2184, -7895, -2378,
-7839, -2569, -7778, -2759, -7713, -2948, -7643, -3134, -7568, -3319, -7489,
-3502, -7405, -3683, -7317, -3861, -7224, -4037, -7127, -4211, -7026, -4382,
-6921, -4551, -6811, -4717, -6697, -4879, -6579, -5039, -6458, -5196, -6332,
-5350, -6203, -5501, -6069, -5648, -5933, -5792, -5792, -5933, -5648, -6069,
-5501, -6203, -5350, -6332, -5196, -6458, -5039, -6579, -4879, -6697, -4717,
-6811, -4551, -6921, -4382, -7026, -4211, -7127, -4037, -7224, -3861, -7317,
-3683, -7405, -3502, -7489, -3319, -7568, -3134, -7643, -2948, -7713, -2759,
-7778, -2569, -7839, -2378, -7895, -2184, -7946, -1990, -7992, -1794, -8034,
-1598, -8071, -1400, -8103, -1202, -8130, -1002, -8152, -802, -8169, -602,
-8182, -401, -8189, -201, 8192, 0, 8191, -100, 8189, -201, 8186,
-301, 8182, -401, 8176, -502, 8169, -602, 8161, -702, 8152, -802,
8142, -902, 8130, -1002, 8117, -1102, 8103, -1202, 8087, -1301, 8071,
-1400, 8053, -1499, 8034, -1598, 8014, -1696, 7992, -1794, 7970, -1892,
7946, -1990, 7921, -2087, 7895, -2184, 7867, -2281, 7839, -2378, 7809,
-2474, 7778, -2569, 7746, -2664, 7713, -2759, 7678, -2854, 7643, -2948,
7606, -3041, 7568, -3134, 7529, -3227, 7489, -3319, 7447, -3411, 7405,
-3502, 7361, -3593, 7317, -3683, 7271, -3772, 7224, -3861, 7176, -3950,
7127, -4037, 7077, -4124, 7026, -4211, 6974, -4297, 6921, -4382, 6866,
-4467, 6811, -4551, 6755, -4634, 6697, -4717, 6639, -4798, 6579, -4879,
6519, -4960, 6458, -5039, 6395, -5118, 6332, -5196, 6268, -5274, 6203,
-5350, 6136, -5426, 6069, -5501, 6001, -5575, 5933, -5648, 5863, -5721,
5792, -5792, 5721, -5863, 5648, -5933, 5575, -6001, 5501, -6069, 5426,
-6136, 5350, -6203, 5274, -6268, 5196, -6332, 5118, -6395, 5039, -6458,
4960, -6519, 4879, -6579, 4798, -6639, 4717, -6697, 4634, -6755, 4551,
-6811, 4467, -6866, 4382, -6921, 4297, -6974, 4211, -7026, 4124, -7077,
4037, -7127, 3950, -7176, 3861, -7224, 3772, -7271, 3683, -7317, 3593,
-7361, 3502, -7405, 3411, -7447, 3319, -7489, 3227, -7529, 3134, -7568,
3041, -7606, 2948, -7643, 2854, -7678, 2759, -7713, 2664, -7746, 2569,
-7778, 2474, -7809, 2378, -7839, 2281, -7867, 2184, -7895, 2087, -7921,
1990, -7946, 1892, -7970, 1794, -7992, 1696, -8014, 1598, -8034, 1499,
-8053, 1400, -8071, 1301, -8087, 1202, -8103, 1102, -8117, 1002, -8130,
902, -8142, 802, -8152, 702, -8161, 602, -8169, 502, -8176, 401,
-8182, 301, -8186, 201, -8189, 100, -8191, 0, -8192, -100, -8191,
-201, -8189, -301, -8186, -401, -8182, -502, -8176, -602, -8169, -702,
-8161, -802, -8152, -902, -8142, -1002, -8130, -1102, -8117, -1202, -8103,
-1301, -8087, -1400, -8071, -1499, -8053, -1598, -8034, -1696, -8014, -1794,
-7992, -1892, -7970, -1990, -7946, -2087, -7921, -2184, -7895, -2281, -7867,
-2378, -7839, -2474, -7809, -2569, -7778, -2664, -7746, -2759, -7713, -2854,
-7678, -2948, -7643, -3041, -7606, -3134, -7568, -3227, -7529, -3319, -7489,
-3411, -7447, -3502, -7405, -3593, -7361, -3683, -7317, -3772, -7271, -3861,
-7224, -3950, -7176, -4037, -7127, -4124, -7077, -4211, -7026, -4297, -6974,
-4382, -6921, -4467, -6866, -4551, -6811, -4634, -6755, -4717, -6697, -4798,
-6639, -4879, -6579, -4960, -6519, -5039, -6458, -5118, -6395, -5196, -6332,
-5274, -6268, -5350, -6203, -5426, -6136, -5501, -6069, -5575, -6001, -5648,
-5933, -5721, -5863, -5792, -5792, -5863, -5721, -5933, -5648, -6001, -5575,
-6069, -5501, -6136, -5426, -6203, -5350, -6268, -5274, -6332, -5196, -6395,
-5118, -6458, -5039, -6519, -4960, -6579, -4879, -6639, -4798, -6697, -4717,
-6755, -4634, -6811, -4551, -6866, -4467, -6921, -4382, -6974, -4297, -7026,
-4211, -7077, -4124, -7127, -4037, -7176, -3950, -7224, -3861, -7271, -3772,
-7317, -3683, -7361, -3593, -7405, -3502, -7447, -3411, -7489, -3319, -7529,
-3227, -7568, -3134, -7606, -3041, -7643, -2948, -7678, -2854, -7713, -2759,
-7746, -2664, -7778, -2569, -7809, -2474, -7839, -2378, -7867, -2281, -7895,
-2184, -7921, -2087, -7946, -1990, -7970, -1892, -7992, -1794, -8014, -1696,
-8034, -1598, -8053, -1499, -8071, -1400, -8087, -1301, -8103, -1202, -8117,
-1102, -8130, -1002, -8142, -902, -8152, -802, -8161, -702, -8169, -602,
-8176, -502, -8182, -401, -8186, -301, -8189, -201, -8191, -100, 8192,
0, 8191, -50, 8191, -100, 8190, -150, 8189, -201, 8188, -251,
8186, -301, 8184, -351, 8182, -401, 8179, -452, 8176, -502, 8173,
-552, 8169, -602, 8165, -652, 8161, -702, 8157, -752, 8152, -802,
8147, -852, 8142, -902, 8136, -952, 8130, -1002, 8124, -1052, 8117,
-1102, 8110, -1152, 8103, -1202, 8095, -1251, 8087, -1301, 8079, -1350,
8071, -1400, 8062, -1450, 8053, -1499, 8044, -1548, 8034, -1598, 8024,
-1647, 8014, -1696, 8003, -1745, 7992, -1794, 7981, -1843, 7970, -1892,
7958, -1941, 7946, -1990, 7934, -2039, 7921, -2087, 7908, -2136, 7895,
-2184, 7881, -2233, 7867, -2281, 7853, -2329, 7839, -2378, 7824, -2426,
7809, -2474, 7794, -2521, 7778, -2569, 7762, -2617, 7746, -2664, 7729,
-2712, 7713, -2759, 7696, -2807, 7678, -2854, 7661, -2901, 7643, -2948,
7624, -2995, 7606, -3041, 7587, -3088, 7568, -3134, 7549, -3181, 7529,
-3227, 7509, -3273, 7489, -3319, 7468, -3365, 7447, -3411, 7426, -3457,
7405, -3502, 7383, -3547, 7361, -3593, 7339, -3638, 7317, -3683, 7294,
-3728, 7271, -3772, 7248, -3817, 7224, -3861, 7200, -3905, 7176, -3950,
7152, -3994, 7127, -4037, 7102, -4081, 7077, -4124, 7052, -4168, 7026,
-4211, 7000, -4254, 6974, -4297, 6947, -4340, 6921, -4382, 6894, -4425,
6866, -4467, 6839, -4509, 6811, -4551, 6783, -4592, 6755, -4634, 6726,
-4675, 6697, -4717, 6668, -4758, 6639, -4798, 6609, -4839, 6579, -4879,
6549, -4920, 6519, -4960, 6488, -5000, 6458, -5039, 6427, -5079, 6395,
-5118, 6364, -5157, 6332, -5196, 6300, -5235, 6268, -5274, 6235, -5312,
6203, -5350, 6170, -5388, 6136, -5426, 6103, -5464, 6069, -5501, 6036,
-5538, 6001, -5575, 5967, -5612, 5933, -5648, 5898, -5685, 5863, -5721,
5828, -5756, 5792, -5792, 5756, -5828, 5721, -5863, 5685, -5898, 5648,
-5933, 5612, -5967, 5575, -6001, 5538, -6036, 5501, -6069, 5464, -6103,
5426, -6136, 5388, -6170, 5350, -6203, 5312, -6235, 5274, -6268, 5235,
-6300, 5196, -6332, 5157, -6364, 5118, -6395, 5079, -6427, 5039, -6458,
5000, -6488, 4960, -6519, 4920, -6549, 4879, -6579, 4839, -6609, 4798,
-6639, 4758, -6668, 4717, -6697, 4675, -6726, 4634, -6755, 4592, -6783,
4551, -6811, 4509, -6839, 4467, -6866, 4425, -6894, 4382, -6921, 4340,
-6947, 4297, -6974, 4254, -7000, 4211, -7026, 4168, -7052, 4124, -7077,
4081, -7102, 4037, -7127, 3994, -7152, 3950, -7176, 3905, -7200, 3861,
-7224, 3817, -7248, 3772, -7271, 3728, -7294, 3683, -7317, 3638, -7339,
3593, -7361, 3547, -7383, 3502, -7405, 3457, -7426, 3411, -7447, 3365,
-7468, 3319, -7489, 3273, -7509, 3227, -7529, 3181, -7549, 3134, -7568,
3088, -7587, 3041, -7606, 2995, -7624, 2948, -7643, 2901, -7661, 2854,
-7678, 2807, -7696, 2759, -7713, 2712, -7729, 2664, -7746, 2617, -7762,
2569, -7778, 2521, -7794, 2474, -7809, 2426, -7824, 2378, -7839, 2329,
-7853, 2281, -7867, 2233, -7881, 2184, -7895, 2136, -7908, 2087, -7921,
2039, -7934, 1990, -7946, 1941, -7958, 1892, -7970, 1843, -7981, 1794,
-7992, 1745, -8003, 1696, -8014, 1647, -8024, 1598, -8034, 1548, -8044,
1499, -8053, 1450, -8062, 1400, -8071, 1350, -8079, 1301, -8087, 1251,
-8095, 1202, -8103, 1152, -8110, 1102, -8117, 1052, -8124, 1002, -8130,
952, -8136, 902, -8142, 852, -8147, 802, -8152, 752, -8157, 702,
-8161, 652, -8165, 602, -8169, 552, -8173, 502, -8176, 452, -8179,
401, -8182, 351, -8184, 301, -8186, 251, -8188, 201, -8189, 150,
-8190, 100, -8191, 50, -8191, 0, -8191, -50, -8191, -100, -8191,
-150, -8190, -201, -8189, -251, -8188, -301, -8186, -351, -8184, -401,
-8182, -452, -8179, -502, -8176, -552, -8173, -602, -8169, -652, -8165,
-702, -8161, -752, -8157, -802, -8152, -852, -8147, -902, -8142, -952,
-8136, -1002, -8130, -1052, -8124, -1102, -8117, -1152, -8110, -1202, -8103,
-1251, -8095, -1301, -8087, -1350, -8079, -1400, -8071, -1450, -8062, -1499,
-8053, -1548, -8044, -1598, -8034, -1647, -8024, -1696, -8014, -1745, -8003,
-1794, -7992, -1843, -7981, -1892, -7970, -1941, -7958, -1990, -7946, -2039,
-7934, -2087, -7921, -2136, -7908, -2184, -7895, -2233, -7881, -2281, -7867,
-2329, -7853, -2378, -7839, -2426, -7824, -2474, -7809, -2521, -7794, -2569,
-7778, -2617, -7762, -2664, -7746, -2712, -7729, -2759, -7713, -2807, -7696,
-2854, -7678, -2901, -7661, -2948, -7643, -2995, -7624, -3041, -7606, -3088,
-7587, -3134, -7568, -3181, -7549, -3227, -7529, -3273, -7509, -3319, -7489,
-3365, -7468, -3411, -7447, -3457, -7426, -3502, -7405, -3547, -7383, -3593,
-7361, -3638, -7339, -3683, -7317, -3728, -7294, -3772, -7271, -3817, -7248,
-3861, -7224, -3905, -7200, -3950, -7176, -3994, -7152, -4037, -7127, -4081,
-7102, -4124, -7077, -4168, -7052, -4211, -7026, -4254, -7000, -4297, -6974,
-4340, -6947, -4382, -6921, -4425, -6894, -4467, -6866, -4509, -6839, -4551,
-6811, -4592, -6783, -4634, -6755, -4675, -6726, -4717, -6697, -4758, -6668,
-4798, -6639, -4839, -6609, -4879, -6579, -4920, -6549, -4960, -6519, -5000,
-6488, -5039, -6458, -5079, -6427, -5118, -6395, -5157, -6364, -5196, -6332,
-5235, -6300, -5274, -6268, -5312, -6235, -5350, -6203, -5388, -6170, -5426,
-6136, -5464, -6103, -5501, -6069, -5538, -6035, -5575, -6001, -5612, -5967,
-5648, -5933, -5685, -5898, -5721, -5863, -5756, -5828, -5792, -5792, -5828,
-5756, -5863, -5721, -5898, -5685, -5933, -5648, -5967, -5612, -6001, -5575,
-6036, -5538, -6069, -5501, -6103, -5464, -6136, -5426, -6170, -5388, -6203,
-5350, -6235, -5312, -6268, -5274, -6300, -5235, -6332, -5196, -6364, -5157,
-6395, -5118, -6427, -5079, -6458, -5039, -6488, -5000, -6519, -4960, -6549,
-4920, -6579, -4879, -6609, -4839, -6639, -4798, -6668, -4758, -6697, -4717,
-6726, -4675, -6755, -4634, -6783, -4592, -6811, -4551, -6839, -4509, -6866,
-4467, -6894, -4425, -6921, -4382, -6947, -4340, -6974, -4297, -7000, -4254,
-7026, -4211, -7052, -4168, -7077, -4124, -7102, -4081, -7127, -4037, -7152,
-3994, -7176, -3950, -7200, -3905, -7224, -3861, -7248, -3817, -7271, -3772,
-7294, -3728, -7317, -3683, -7339, -3638, -7361, -3593, -7383, -3547, -7405,
-3502, -7426, -3457, -7447, -3411, -7468, -3365, -7489, -3319, -7509, -3273,
-7529, -3227, -7549, -3181, -7568, -3134, -7587, -3088, -7606, -3041, -7624,
-2995, -7643, -2948, -7661, -2901, -7678, -2854, -7696, -2807, -7713, -2759,
-7729, -2712, -7746, -2664, -7762, -2617, -7778, -2569, -7794, -2521, -7809,
-2474, -7824, -2426, -7839, -2378, -7853, -2329, -7867, -2281, -7881, -2233,
-7895, -2184, -7908, -2136, -7921, -2087, -7934, -2039, -7946, -1990, -7958,
-1941, -7970, -1892, -7981, -1843, -7992, -1794, -8003, -1745, -8014, -1696,
-8024, -1647, -8034, -1598, -8044, -1548, -8053, -1499, -8062, -1450, -8071,
-1400, -8079, -1350, -8087, -1301, -8095, -1251, -8103, -1202, -8110, -1152,
-8117, -1102, -8124, -1052, -8130, -1002, -8136, -952, -8142, -902, -8147,
-852, -8152, -802, -8157, -752, -8161, -702, -8165, -652, -8169, -602,
-8173, -552, -8176, -502, -8179, -452, -8182, -401, -8184, -351, -8186,
-301, -8188, -251, -8189, -201, -8190, -150, -8191, -100, -8191, -50
};
/* 1024 real values as input data in float format */
float fft_input[ 1024 ] = {
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f,
0.243f, 0.323f, 0.505f, -0.176f, -0.87f, 0.353f, -0.344f, -0.443f,
-0.434f, -0.32f, 0.232f, -0.454f, -0.32f, -0.323f, -0.733f, 0.54f
};

View File

@ -0,0 +1,53 @@
File: filterbank.c
Original provenience: unknown
Source: unknown
2016-04-20:
- Add static global variable filterbank_return_value that depends on the
computation inside of filterbank_main, return this value in filterbank_return.
2016-01-06:
- Added original name to generic TACLeBench header.
- Applied TACLeBench formatting rules via
astyle --options=doc/example/astylerc.txt
2015-12-08:
- Added generic TACLeBench header.
- Introduced comments to split file in sections for forward declarations,
global variables, initialization-related and return-value-related functions,
core benchmark functions, and main routine.
- Renamed function begin to filterbank_main.
- Renamed function FBCore to filterbank_core.
- Renamed global variable numiters to filterbank_numiters and made it static.
- Added function filterbank_init that handles the initialization of filterbank_numiters.
- Added function filterbank_return that handles the original return value of main.
- Added new function main that first calls filterbank_init, then filterbank_main and
finally returns the return value of filterbank_return.
- Added forward declarations for all these functions.
- Changed all //-style comments to /* */-style comments
- 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
- 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
- Function arguments are specified in ANSI style, i.e.,
float my_sqrtf( float val )
and NOT in Kernighan&Ritchie style like, e.g.,
float my_sqrtf( val )
float val;
- Tested conformance to C90 via
clang -fsyntax-only -Weverything -Wno-unknown-pragmas -pedantic -std=c90

View File

@ -0,0 +1,170 @@
/*
This program is part of the TACLeBench benchmark suite.
Version 2.0
Name: filterbank
Author: unknown
Function: Creates a filter bank to perform multirate signal processing.
The coefficients for the sets of filters are created in the
top-level init function, and passed down through the init
functions to FIR filter objects.
On each branch, a delay, filter, and downsample is performed,
followed by an upsample, delay, and filter.
Source: StreamIt
(http://groups.csail.mit.edu/cag/streamit/shtml/benchmarks.shtml)
Original name: filterbank
Changes: See ChangeLog.txt
License: MIT License
*/
/*
Forward declaration of functions
*/
void filterbank_init( void );
void filterbank_main( void );
int filterbank_return( void );
void filterbank_core( float r[ 256 ],
float y[ 256 ],
float H[ 8 ][ 32 ],
float F[ 8 ][ 32 ] );
/*
Declaration of global variables
*/
static int filterbank_return_value;
static int filterbank_numiters;
/*
Initialization- and return-value-related functions
*/
void filterbank_init( void )
{
filterbank_numiters = 2;
}
int filterbank_return( void )
{
return filterbank_return_value;
}
/*
Core benchmark functions
*/
void _Pragma( "entrypoint" ) filterbank_main( void )
{
float r[ 256 ];
float y[ 256 ];
float H[ 8 ][ 32 ];
float F[ 8 ][ 32 ];
int i, j;
_Pragma( "loopbound min 256 max 256" )
for ( i = 0; i < 256; i++ )
r[ i ] = i + 1;
_Pragma( "loopbound min 32 max 32" )
for ( i = 0; i < 32; i++ ) {
_Pragma( "loopbound min 8 max 8" )
for ( j = 0; j < 8; j++ ) {
H[ j ][ i ] = i * 32 + j * 8 + j + i + j + 1;
F[ j ][ i ] = i * j + j * j + j + i;
}
}
_Pragma( "loopbound min 2 max 2" )
while ( filterbank_numiters-- > 0 )
filterbank_core( r, y, H, F );
filterbank_return_value = ( int )( y[ 0 ] ) - 9408;
}
/* the FB core gets the input vector (r) , the filter responses H and F and */
/* generates the output vector(y) */
void filterbank_core( float r[ 256 ],
float y[ 256 ],
float H[ 8 ][ 32 ],
float F[ 8 ][ 32 ] )
{
int i, j, k;
_Pragma( "loopbound min 256 max 256" )
for ( i = 0; i < 256; i++ )
y[ i ] = 0;
_Pragma( "loopbound min 8 max 8" )
for ( i = 0; i < 8; i++ ) {
float Vect_H[ 256 ]; /* (output of the H) */
float Vect_Dn[ ( int ) 256 / 8 ]; /* output of the down sampler; */
float Vect_Up[ 256 ]; /* output of the up sampler; */
float Vect_F[ 256 ]; /* this is the output of the */
/* convolving H */
_Pragma( "loopbound min 256 max 256" )
for ( j = 0; j < 256; j++ ) {
Vect_H[ j ] = 0;
_Pragma( "loopbound min 1 max 32" )
for ( k = 0; ( ( k < 32 ) & ( ( j - k ) >= 0 ) ); k++ )
Vect_H[ j ] += H[ i ][ k ] * r[ j - k ];
}
/* Down Sampling */
_Pragma( "loopbound min 32 max 32" )
for ( j = 0; j < 256 / 8; j++ )
Vect_Dn[ j ] = Vect_H[ j * 8 ];
/* Up Sampling */
_Pragma( "loopbound min 256 max 256" )
for ( j = 0; j < 256; j++ )
Vect_Up[ j ] = 0;
_Pragma( "loopbound min 32 max 32" )
for ( j = 0; j < 256 / 8; j++ )
Vect_Up[ j * 8 ] = Vect_Dn[ j ];
/* convolving F */
_Pragma( "loopbound min 256 max 256" )
for ( j = 0; j < 256; j++ ) {
Vect_F[ j ] = 0;
_Pragma( "loopbound min 1 max 32" )
for ( k = 0; ( ( k < 32 ) & ( ( j - k ) >= 0 ) ); k++ )
Vect_F[ j ] += F[ i ][ k ] * Vect_Up[ j - k ];
}
/* adding the results to the y matrix */
_Pragma( "loopbound min 256 max 256" )
for ( j = 0; j < 256; j++ )
y[ j ] += Vect_F[ j ];
}
}
/*
Main function
*/
int main( void )
{
filterbank_init();
filterbank_main();
return filterbank_return();
}

View File

@ -0,0 +1,21 @@
The MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,45 @@
File: fir2dim.c
Original provenience: DSP-Stone,
http://www.ice.rwth-aachen.de/research/tools-projects/entry/detail/dspstone/
2015-12-21:
- Renamed benchmark to fir2dim
- Renamed each function FUNC to fir2dim_FUNC
- Added functions fir2dim_init, fir2dim_return and main
- Added a global variable 'int fir2dim_result' to introduce a
non-optimizable return value
- Substituted all 4 defines:
#define STORAGE_CLASS register
#define TYPE float
#define IMAGEDIM 4
#define ARRAYDIM (IMAGEDIM + 2)
#define COEFFICIENTS 3
- Added forward declarations of all functions before the declarations of global
variables
- Removed return statement in void function fir2dim_main()
- Re-ordered functions to fit template-order
- Applied code formatting according to the following rules
(incomplete, to be discussed; I basically used astyle with the attached
options file):
- 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: st_) followed by lowercase letter (e.g., st_square)
- 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
- Added general TACLeBench header to beginning of source code

View File

@ -0,0 +1,199 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: fir2dim
Author: Juan Martinez Velarde
Function: prime calculates whether numbers are prime.
Source: DSP-Stone
http://www.ice.rwth-aachen.de/research/tools-projects/entry/detail/dspstone/
Original name: fir2dim_float
Changes: no major functional changes
License: may be used, modified, and re-distributed freely
*/
/*
Forward declaration of functions
*/
void fir2dim_initSeed( void );
long fir2dim_randomInteger();
void fir2dim_pin_down( float *pimage, float *parray, float *pcoeff,
float *poutput );
void fir2dim_init();
int fir2dim_return();
void fir2dim_main();
int main( void );
/*
Declaration of global variables
*/
static float fir2dim_coefficients[ 3 * 3 ] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
static float fir2dim_image[ 4 * 4 ] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static float fir2dim_array[ 6 * 6 ] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static float fir2dim_output[ 4 * 4 ] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
int fir2dim_result;
/*
Initialization- and return-value-related functions
*/
void fir2dim_init()
{
unsigned int i;
unsigned char *p;
volatile char bitmask = 0;
/*
Apply volatile XOR-bitmask to entire input array.
*/
p = ( unsigned char * ) &fir2dim_coefficients[ 0 ];
_Pragma( "loopbound min 36 max 36" )
for ( i = 0; i < sizeof( fir2dim_coefficients ); ++i, ++p )
*p ^= bitmask;
p = ( unsigned char * ) &fir2dim_image[ 0 ];
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < sizeof( fir2dim_image ); ++i, ++p )
*p ^= bitmask;
p = ( unsigned char * ) &fir2dim_array[ 0 ];
_Pragma( "loopbound min 144 max 144" )
for ( i = 0; i < sizeof( fir2dim_array ); ++i, ++p )
*p ^= bitmask;
p = ( unsigned char * ) &fir2dim_output[ 0 ];
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < sizeof( fir2dim_output ); ++i, ++p )
*p ^= bitmask;
}
int fir2dim_return()
{
return ( fir2dim_result - 14 != 0 );
}
/*
Helper functions
*/
void fir2dim_pin_down( float *pimage, float *parray, float *pcoeff,
float *poutput )
{
register float i, f;
_Pragma( "loopbound min 4 max 4" )
for ( i = 0 ; i < 4 ; i++ ) {
_Pragma( "loopbound min 4 max 4" )
for ( f = 0 ; f < 4 ; f++ )
*pimage++ = 1 ;
}
pimage = pimage - 4 * 4 ;
_Pragma( "loopbound min 9 max 9" )
for ( i = 0; i < 3 * 3; i++ )
*pcoeff++ = 1;
_Pragma( "loopbound min 6 max 6" )
for ( i = 0 ; i < 6 ; i++ )
*parray++ = 0 ;
_Pragma( "loopbound min 4 max 4" )
for ( f = 0 ; f < 4; f++ ) {
*parray++ = 0 ;
_Pragma( "loopbound min 4 max 4" )
for ( i = 0 ; i < 4 ; i++ )
*parray++ = *pimage++ ;
*parray++ = 0 ;
}
_Pragma( "loopbound min 6 max 6" )
for ( i = 0 ; i < 6 ; i++ )
*parray++ = 0 ;
_Pragma( "loopbound min 16 max 16" )
for ( i = 0 ; i < 4 * 4; i++ )
*poutput++ = 0 ;
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) fir2dim_main()
{
register float *parray = &fir2dim_array[ 0 ], *parray2, *parray3 ;
register float *pcoeff = &fir2dim_coefficients[ 0 ] ;
register float *poutput = &fir2dim_output[ 0 ] ;
int k, f, i;
fir2dim_pin_down( &fir2dim_image[ 0 ], &fir2dim_array[ 0 ],
&fir2dim_coefficients[ 0 ], &fir2dim_output[ 0 ] );
poutput = &fir2dim_output[ 0 ] ;
_Pragma( "loopbound min 4 max 4" )
for ( k = 0 ; k < 4 ; k++ ) {
_Pragma( "loopbound min 4 max 4" )
for ( f = 0 ; f < 4 ; f++ ) {
pcoeff = &fir2dim_coefficients[ 0 ] ;
parray = &fir2dim_array[ k * 6 + f ] ;
parray2 = parray + 6 ;
parray3 = parray + 6 + 6 ;
*poutput = 0 ;
_Pragma( "loopbound min 3 max 3" )
for ( i = 0 ; i < 3 ; i++ )
*poutput += *pcoeff++ **parray++ ;
_Pragma( "loopbound min 3 max 3" )
for ( i = 0 ; i < 3 ; i++ )
*poutput += *pcoeff++ **parray2++ ;
_Pragma( "loopbound min 3 max 3" )
for ( i = 0 ; i < 3 ; i++ )
*poutput += *pcoeff++ **parray3++ ;
poutput++ ;
}
}
fir2dim_result = fir2dim_output[ 0 ] + fir2dim_output[ 5 ] + fir2dim_array[ 9 ];
fir2dim_pin_down( &fir2dim_image[ 0 ], &fir2dim_array[ 0 ],
&fir2dim_coefficients[ 0 ], &fir2dim_output[ 0 ] );
}
int main( void )
{
fir2dim_init();
fir2dim_main();
return ( fir2dim_return() );
}

View File

@ -0,0 +1,39 @@
File: iir.c
Original provenience: DSPstone benchmark suite (floating point),
http://www.ice.rwth-aachen.de/research/tools-projects/entry/detail/dspstone
2015-10-10:
- Removed original header comment, replaced by TACLeBench header.
- Removed all preprocessor macros, integrated them directly in the source code.
- Added prefix "iir" to all global symbols.
- Added explicit forward declarations of functions.
- Replaced local variables "wi", "coefficients" and "x" that store the
benchmark's input data by global variables.
- Replaced initialization function iir_pin_down by TACLeBench-compliant
initialization code.
- Removed second call of iir_pin_down from function iir_main since it does
not make sense at all.
- Added new function iir_return producing a checksum as return value.
- Added new function iir_main according to TACLeBench guidelines.
iir_main is annotated as entry-point for timing 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: bs_) followed by lowercase letter (e.g., bs_square)
- 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

View File

@ -0,0 +1,163 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: iir
Author: Juan Martinez Velarde
Function:
The equations of each biquad section filter are:
w(n) = x(n) - ai1*w(n-1) - ai2*w(n-2)
y(n) = b0*w(n) + bi1*w(n-1) + bi2*w(n-2)
Biquads are sequentally positioned. Input sample for biquad i is
xi-1(n). Output sample for biquad i is xi(n).
System input sample is x0(n). System output sample is xN(n) = y(n)
for N biquads.
Each section performs following filtering (biquad i) :
wi(n)
xi-1(n) ---(-)---------->-|->---bi0---(+)-------> xi(n)
A | A
| |1/z| |
| | wi(n-1) |
| v |
|-<--ai1----<-|->---bi1-->-|
| | |
| |1/z| |
| | wi(n-2) |
| v |
|-<--ai2----<--->---bi2-->-|
The values wi(n-1) and wi(n-2) are stored in wi1 and wi2
Source: DSPstone
http://www.ice.rwth-aachen.de/research/tools-projects/entry/detail/dspstone
Original name: iir_N_sections_float
Changes:
24-03-94 creation fixed-point (Martinez Velarde)
16-03-95 adaption floating-point (Harald L. Schraut)
License: may be used, modified, and re-distributed freely
*/
/*
Forward declaration of functions
*/
void iir_init( void );
int iir_return( void );
void iir_main( void );
int main( void );
/*
Declaration of global variables
*/
volatile float iir_wi[ 2 * 4 ];
volatile float iir_coefficients[ 5 * 4 ];
float iir_x;
/*
Initialization- and return-value-related functions
*/
void iir_init( void )
{
int f;
unsigned int i;
unsigned char *p;
volatile char bitmask = 0;
_Pragma( "loopbound min 20 max 20" )
for ( f = 0 ; f < 5 * 4; f++ )
iir_coefficients[ f ] = 7;
_Pragma( "loopbound min 8 max 8" )
for ( f = 0 ; f < 2 * 4; f++ )
iir_wi[ f ] = 0;
iir_x = ( float ) 1;
/*
Apply volatile XOR-bitmask to entire input array.
*/
p = ( unsigned char * ) &iir_coefficients[ 0 ];
_Pragma( "loopbound min 80 max 80" )
for ( i = 0; i < sizeof( iir_coefficients ); ++i, ++p )
*p ^= bitmask;
p = ( unsigned char * ) &iir_wi[ 0 ];
_Pragma( "loopbound min 32 max 32" )
for ( i = 0; i < sizeof( iir_wi ); ++i, ++p )
*p ^= bitmask;
}
int iir_return( void )
{
float checksum = 0.0;
int f;
_Pragma( "loopbound min 8 max 8" )
for ( f = 0 ; f < 2 * 4; f++ )
checksum += iir_wi[ f ];
return ( ( int ) checksum );
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) iir_main( void )
{
register float w;
int f;
register volatile float *ptr_coeff, *ptr_wi1, *ptr_wi2;
register float y;
ptr_coeff = &iir_coefficients[ 0 ];
ptr_wi1 = &iir_wi[ 0 ];
ptr_wi2 = &iir_wi[ 1 ];
y = iir_x ;
_Pragma( "loopbound min 4 max 4" )
for ( f = 0 ; f < 4 ; f++ ) {
w = y - *ptr_coeff++ * *ptr_wi1;
w -= *ptr_coeff++ * *ptr_wi2;
y = *ptr_coeff++ * w;
y += *ptr_coeff++ * *ptr_wi1;
y += *ptr_coeff++ * *ptr_wi2;
*ptr_wi2++ = *ptr_wi1;
*ptr_wi1++ = w;
ptr_wi2++;
ptr_wi1++;
}
}
int main( void )
{
iir_init();
iir_main();
return ( iir_return() - 400 != 0 );
}

View File

@ -0,0 +1,10 @@
- Added general TACLeBench header to beginning of source code
- Removed #ifdef DEBUG till #endif
- Declaration of global variable unsigned int a[11] changed the variable name to insertion_a[11] as well as for iters_i, min_i, max_i, iters_a, min_a, max_a;
- Created insertsort_initialize(), insertsort_init() and insertsort_return();
- Removed all PROFILINGs
- Made i volatile for the initialization of the data array
- Added a checksum in the return function

View File

@ -0,0 +1,139 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: insertsort
Author: Sung-Soo Lim
Function: Insertion sort for 10 integer numbers.
The integer array insertsort_a[ ] is initialized in main function.
Input-data dependent nested loop with worst-case of
(n^2)/2 iterations (triangular loop).
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/insertsort/insertsort.c
Changes: a brief summary of major functional changes (not formatting)
License: may be used, modified, and re-distributed freely, but
the SNU-RT Benchmark Suite must be acknowledged
*/
/*
This program is derived from the SNU-RT Benchmark Suite for Worst
Case Timing Analysis by Sung-Soo Lim
*/
/*
Forward declaration of functions
*/
void insertsort_initialize( unsigned int *array );
void insertsort_init( void );
int insertsort_return( void );
void insertsort_main( void );
// int main( void );
/*
Declaration of global variables
*/
unsigned int insertsort_a[ 100 ];
int insertsort_iters_i, insertsort_min_i, insertsort_max_i;
int insertsort_iters_a, insertsort_min_a, insertsort_max_a;
/*
Initialization- and return-value-related functions
*/
void insertsort_initialize( unsigned int *array )
{
register volatile int i;
_Pragma( "loopbound min 11 max 11" )
for ( i = 0; i < 100; i++ )
insertsort_a[ i ] = array[ i ];
}
void insertsort_init()
{
unsigned int a[ 100 ] = {0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
insertsort_iters_i = 0;
insertsort_min_i = 100000;
insertsort_max_i = 0;
insertsort_iters_a = 0;
insertsort_min_a = 100000;
insertsort_max_a = 0;
insertsort_initialize( a );
}
int insertsort_return()
{
int i, returnValue = 0;
_Pragma( "loopbound min 11 max 11" )
for ( i = 0; i < 100; i++ )
returnValue += insertsort_a[ i ];
return ( returnValue + ( -65 ) ) != 0;
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) insertsort_main()
{
int i, j, temp;
i = 2;
insertsort_iters_i = 0;
_Pragma( "loopbound min 9 max 9" )
while ( i <= 100 ) {
insertsort_iters_i++;
j = i;
insertsort_iters_a = 0;
_Pragma( "loopbound min 1 max 9" )
while ( insertsort_a[ j ] < insertsort_a[ j - 1 ] ) {
insertsort_iters_a++;
temp = insertsort_a[ j ];
insertsort_a[ j ] = insertsort_a[ j - 1 ];
insertsort_a[ j - 1 ] = temp;
j--;
}
if ( insertsort_iters_a < insertsort_min_a )
insertsort_min_a = insertsort_iters_a;
if ( insertsort_iters_a > insertsort_max_a )
insertsort_max_a = insertsort_iters_a;
i++;
}
if ( insertsort_iters_i < insertsort_min_i )
insertsort_min_i = insertsort_iters_i;
if ( insertsort_iters_i > insertsort_max_i )
insertsort_max_i = insertsort_iters_i;
}
// int main( void )
// {
// insertsort_init();
// insertsort_main();
// return ( insertsort_return() );
// }

View File

@ -0,0 +1,78 @@
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

View File

@ -0,0 +1,35 @@
/*
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++;
}
}

View File

@ -0,0 +1,28 @@
/*
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_

View File

@ -0,0 +1,156 @@
/*
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 _Pragma( "entrypoint" ) 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();
}

View File

@ -0,0 +1,68 @@
/*
====================================================
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_ */

View File

@ -0,0 +1,31 @@
/*
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 */

View File

@ -0,0 +1,40 @@
/*
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 */

View File

@ -0,0 +1,757 @@
/*
====================================================
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.c
Author: Unknown
Function: IEEE754 software library routines.
Source: Sun Microsystems
Original name: wcclibm.c
Changes: No major functional changes.
License: See the terms above.
*/
#include "wcclibm.h"
#include "math_private.h"
/* e_acosf.c -- float version of e_acos.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_pi = 3.1415925026e+00f, /* 0x40490fda */
basicmath_pio2_hi = 1.5707962513e+00f, /* 0x3fc90fda */
basicmath_pio2_lo = 7.5497894159e-08f, /* 0x33a22168 */
basicmath_pS0 = 1.6666667163e-01f, /* 0x3e2aaaab */
basicmath_pS1 = -3.2556581497e-01f, /* 0xbea6b090 */
basicmath_pS2 = 2.0121252537e-01f, /* 0x3e4e0aa8 */
basicmath_pS3 = -4.0055535734e-02f, /* 0xbd241146 */
basicmath_pS4 = 7.9153501429e-04f, /* 0x3a4f7f04 */
basicmath_pS5 = 3.4793309169e-05f, /* 0x3811ef08 */
basicmath_qS1 = -2.4033949375e+00f, /* 0xc019d139 */
basicmath_qS2 = 2.0209457874e+00f, /* 0x4001572d */
basicmath_qS3 = -6.8828397989e-01f, /* 0xbf303361 */
basicmath_qS4 = 7.7038154006e-02f; /* 0x3d9dc62e */
float basicmath___ieee754_acosf( float x )
{
float z, p, q, r, w, s, c, df;
int32_t hx, ix;
GET_FLOAT_WORD( hx, x );
ix = hx & 0x7fffffff;
if ( ix == 0x3f800000 ) { /* |x|==1 */
if ( hx > 0 ) return 0.0f; /* acos(1) = 0 */
else return basicmath_pi + ( float )2.0f * basicmath_pio2_lo; /* acos(-1)= pi */
} else
if ( ix > 0x3f800000 ) { /* |x| >= 1 */
return ( x - x ) / ( x - x ); /* acos(|x|>1) is NaN */
}
if ( ix < 0x3f000000 ) { /* |x| < 0.5 */
if ( ix <= 0x23000000 ) return basicmath_pio2_hi +
basicmath_pio2_lo; /*if|x|<2**-57*/
z = x * x;
p = z * ( basicmath_pS0 + z * ( basicmath_pS1 + z * ( basicmath_pS2 + z *
( basicmath_pS3 + z *
( basicmath_pS4 + z * basicmath_pS5 ) ) ) ) );
q = basicmath_one + z * ( basicmath_qS1 + z * ( basicmath_qS2 + z *
( basicmath_qS3 + z * basicmath_qS4 ) ) );
r = p / q;
return basicmath_pio2_hi - ( x - ( basicmath_pio2_lo - x * r ) );
} else
if ( hx < 0 ) { /* x < -0.5 */
z = ( basicmath_one + x ) * ( float )0.5f;
p = z * ( basicmath_pS0 + z * ( basicmath_pS1 + z * ( basicmath_pS2 + z *
( basicmath_pS3 + z *
( basicmath_pS4 + z * basicmath_pS5 ) ) ) ) );
q = basicmath_one + z * ( basicmath_qS1 + z * ( basicmath_qS2 + z *
( basicmath_qS3 + z * basicmath_qS4 ) ) );
s = basicmath___ieee754_sqrtf( z );
r = p / q;
w = r * s - basicmath_pio2_lo;
return basicmath_pi - ( float )2.0f * ( s + w );
} else { /* x > 0.5 */
int32_t idf;
z = ( basicmath_one - x ) * ( float )0.5f;
s = basicmath___ieee754_sqrtf( z );
df = s;
GET_FLOAT_WORD( idf, df );
SET_FLOAT_WORD( df, idf & 0xfffff000 );
c = ( z - df * df ) / ( s + df );
p = z * ( basicmath_pS0 + z * ( basicmath_pS1 + z * ( basicmath_pS2 + z *
( basicmath_pS3 + z *
( basicmath_pS4 + z * basicmath_pS5 ) ) ) ) );
q = basicmath_one + z * ( basicmath_qS1 + z * ( basicmath_qS2 + z *
( basicmath_qS3 + z * basicmath_qS4 ) ) );
r = p / q;
w = r * s + c;
return ( float )2.0f * ( df + w );
}
}
/* e_powf.c -- float version of e_pow.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_bp[] = {1.0f, 1.5f,},
basicmath_dp_h[] = { 0.0f, 5.84960938e-01f,}, /* 0x3f15c000 */
basicmath_dp_l[] = { 0.0f, 1.56322085e-06f,}, /* 0x35d1cfdc */
/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
basicmath_L1 = 6.0000002384e-01f, /* 0x3f19999a */
basicmath_L2 = 4.2857143283e-01f, /* 0x3edb6db7 */
basicmath_L3 = 3.3333334327e-01f, /* 0x3eaaaaab */
basicmath_L4 = 2.7272811532e-01f, /* 0x3e8ba305 */
basicmath_L5 = 2.3066075146e-01f, /* 0x3e6c3255 */
basicmath_L6 = 2.0697501302e-01f, /* 0x3e53f142 */
basicmath_P1 = 1.6666667163e-01f, /* 0x3e2aaaab */
basicmath_P2 = -2.7777778450e-03f, /* 0xbb360b61 */
basicmath_P3 = 6.6137559770e-05f, /* 0x388ab355 */
basicmath_P4 = -1.6533901999e-06f, /* 0xb5ddea0e */
basicmath_P5 = 4.1381369442e-08f, /* 0x3331bb4c */
basicmath_lg2 = 6.9314718246e-01f, /* 0x3f317218 */
basicmath_lg2_h = 6.93145752e-01f, /* 0x3f317200 */
basicmath_lg2_l = 1.42860654e-06f, /* 0x35bfbe8c */
basicmath_ovt = 4.2995665694e-08f, /* -(128-log2(ovfl+.5ulp)) */
basicmath_cp = 9.6179670095e-01f, /* 0x3f76384f =2/(3ln2) */
basicmath_cp_h = 9.6179199219e-01f, /* 0x3f763800 =head of cp */
basicmath_cp_l = 4.7017383622e-06f, /* 0x369dc3a0 =tail of cp_h */
basicmath_ivln2 = 1.4426950216e+00f, /* 0x3fb8aa3b =1/ln2 */
basicmath_ivln2_h = 1.4426879883e+00f, /* 0x3fb8aa00 =16b 1/ln2*/
basicmath_ivln2_l = 7.0526075433e-06f; /* 0x36eca570 =1/ln2 tail*/
float basicmath___ieee754_powf( float x, float y )
{
float z, ax, z_h, z_l, p_h, p_l;
float y1, t1, t2, r, s, t, u, v, w;
int32_t i, j, k, yisint, n;
int32_t hx, hy, ix, iy, is;
GET_FLOAT_WORD( hx, x );
GET_FLOAT_WORD( hy, y );
ix = hx & 0x7fffffff;
iy = hy & 0x7fffffff;
/* y==zero: x**0 = 1 */
if ( iy == 0 ) return basicmath_one;
/* x==+-1 */
if ( x == 1.0f ) return basicmath_one;
if ( x == -1.0f && basicmath___isinff( y ) ) return basicmath_one;
/* +-NaN return x+y */
if ( ix > 0x7f800000 ||
iy > 0x7f800000 )
return x + y;
/* determine if y is an odd int when x < 0
yisint = 0 ... y is not an integer
yisint = 1 ... y is an odd int
yisint = 2 ... y is an even int
*/
yisint = 0;
if ( hx < 0 ) {
if ( iy >= 0x4b800000 ) yisint = 2; /* even integer y */
else
if ( iy >= 0x3f800000 ) {
k = ( iy >> 23 ) - 0x7f; /* exponent */
j = iy >> ( 23 - k );
if ( ( j << ( 23 - k ) ) == iy ) yisint = 2 - ( j & 1 );
}
}
/* special value of y */
if ( iy == 0x7f800000 ) { /* y is +-inf */
if ( ix == 0x3f800000 )
return y - y; /* inf**+-1 is NaN */
else
if ( ix > 0x3f800000 ) /* (|x|>1)**+-inf = inf,0 */
return ( hy >= 0 ) ? y : basicmath_zero;
else /* (|x|<1)**-,+inf = inf,0 */
return ( hy < 0 ) ? -y : basicmath_zero;
}
if ( iy == 0x3f800000 ) { /* y is +-1 */
if ( hy < 0 ) return basicmath_one / x;
else return x;
}
if ( hy == 0x40000000 ) return x * x; /* y is 2 */
if ( hy == 0x3f000000 ) { /* y is 0.5 */
if ( hx >= 0 ) /* x >= +0 */
return basicmath___ieee754_sqrtf( x );
}
ax = basicmath___fabsf( x );
/* special value of x */
if ( ix == 0x7f800000 || ix == 0 || ix == 0x3f800000 ) {
z = ax; /*x is +-0,+-inf,+-1*/
if ( hy < 0 ) z = basicmath_one / z; /* z = (1/|x|) */
if ( hx < 0 ) {
if ( ( ( ix - 0x3f800000 ) | yisint ) == 0 ) {
z = ( z - z ) / ( z - z ); /* (-1)**non-int is NaN */
} else
if ( yisint == 1 )
z = -z; /* (x<0)**odd = -(|x|**odd) */
}
return z;
}
/* (x<0)**(non-int) is NaN */
if ( ( ( ( ( u_int32_t )hx >> 31 ) - 1 ) | yisint ) == 0 ) return ( x - x ) /
( x - x );
/* |y| is huge */
if ( iy > 0x4d000000 ) { /* if |y| > 2**27 */
/* over/underflow if x is not close to one */
if ( ix < 0x3f7ffff8 ) return ( hy < 0 ) ? basicmath_huge * basicmath_huge :
basicmath_tiny * basicmath_tiny;
if ( ix > 0x3f800007 ) return ( hy > 0 ) ? basicmath_huge * basicmath_huge :
basicmath_tiny * basicmath_tiny;
/* now |1-x| is tiny <= 2**-20, suffice to compute
log(x) by x-x^2/2+x^3/3-x^4/4 */
t = x - 1; /* t has 20 trailing zeros */
w = ( t * t ) * ( ( float )0.5f - t * ( ( float )0.333333333333f - t *
( float )0.25f ) );
u = basicmath_ivln2_h * t; /* ivln2_h has 16 sig. bits */
v = t * basicmath_ivln2_l - w * basicmath_ivln2;
t1 = u + v;
GET_FLOAT_WORD( is, t1 );
SET_FLOAT_WORD( t1, is & 0xfffff000 );
t2 = v - ( t1 - u );
} else {
float s2, s_h, s_l, t_h, t_l;
n = 0;
/* take care subnormal number */
if ( ix < 0x00800000 ) {
ax *= basicmath_two24;
n -= 24;
GET_FLOAT_WORD( ix, ax );
}
n += ( ( ix ) >> 23 ) - 0x7f;
j = ix & 0x007fffff;
/* determine interval */
ix = j | 0x3f800000; /* normalize ix */
if ( j <= 0x1cc471 ) k = 0; /* |x|<sqrt(3/2) */
else
if ( j < 0x5db3d7 ) k = 1; /* |x|<sqrt(3) */
else {
k = 0;
n += 1;
ix -= 0x00800000;
}
SET_FLOAT_WORD( ax, ix );
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
u = ax - basicmath_bp[ k ]; /* bp[0]=1.0, bp[1]=1.5 */
v = basicmath_one / ( ax + basicmath_bp[ k ] );
s = u * v;
s_h = s;
GET_FLOAT_WORD( is, s_h );
SET_FLOAT_WORD( s_h, is & 0xfffff000 );
/* t_h=ax+bp[k] High */
SET_FLOAT_WORD( t_h, ( ( ix >> 1 ) | 0x20000000 ) + 0x0040000 + ( k << 21 ) );
t_l = ax - ( t_h - basicmath_bp[ k ] );
s_l = v * ( ( u - s_h * t_h ) - s_h * t_l );
/* compute log(ax) */
s2 = s * s;
r = s2 * s2 * ( basicmath_L1 + s2 * ( basicmath_L2 + s2 *
( basicmath_L3 + s2 * ( basicmath_L4 + s2 *
( basicmath_L5 + s2 * basicmath_L6 ) ) ) ) );
r += s_l * ( s_h + s );
s2 = s_h * s_h;
t_h = ( float )3.0f + s2 + r;
GET_FLOAT_WORD( is, t_h );
SET_FLOAT_WORD( t_h, is & 0xfffff000 );
t_l = r - ( ( t_h - ( float )3.0f ) - s2 );
/* u+v = s*(1+...) */
u = s_h * t_h;
v = s_l * t_h + t_l * s;
/* 2/(3log2)*(s+...) */
p_h = u + v;
GET_FLOAT_WORD( is, p_h );
SET_FLOAT_WORD( p_h, is & 0xfffff000 );
p_l = v - ( p_h - u );
z_h = basicmath_cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */
z_l = basicmath_cp_l * p_h + p_l * basicmath_cp + basicmath_dp_l[ k ];
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
t = ( float )n;
t1 = ( ( ( z_h + z_l ) + basicmath_dp_h[ k ] ) + t );
GET_FLOAT_WORD( is, t1 );
SET_FLOAT_WORD( t1, is & 0xfffff000 );
t2 = z_l - ( ( ( t1 - t ) - basicmath_dp_h[ k ] ) - z_h );
}
s = basicmath_one; /* s (sign of result -ve**odd) = -1 else = 1 */
if ( ( ( ( ( u_int32_t )hx >> 31 ) - 1 ) | ( yisint - 1 ) ) == 0 )
s = -basicmath_one; /* (-ve)**(odd int) */
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
GET_FLOAT_WORD( is, y );
SET_FLOAT_WORD( y1, is & 0xfffff000 );
p_l = ( y - y1 ) * t1 + y * t2;
p_h = y1 * t1;
z = p_l + p_h;
GET_FLOAT_WORD( j, z );
if ( j > 0x43000000 ) /* if z > 128 */
return s * basicmath_huge * basicmath_huge; /* overflow */
else
if ( j == 0x43000000 ) { /* if z == 128 */
if ( p_l + basicmath_ovt > z - p_h ) return s * basicmath_huge *
basicmath_huge; /* overflow */
} else
if ( ( j & 0x7fffffff ) > 0x43160000 ) /* z <= -150 */
return s * basicmath_tiny * basicmath_tiny; /* underflow */
else
if ( ( u_int32_t ) j == 0xc3160000 ) { /* z == -150 */
if ( p_l <= z - p_h ) return s * basicmath_tiny *
basicmath_tiny; /* underflow */
}
/*
compute 2**(p_h+p_l)
*/
i = j & 0x7fffffff;
k = ( i >> 23 ) - 0x7f;
n = 0;
if ( i > 0x3f000000 ) { /* if |z| > 0.5, set n = [z+0.5] */
n = j + ( 0x00800000 >> ( k + 1 ) );
k = ( ( n & 0x7fffffff ) >> 23 ) - 0x7f; /* new k for n */
SET_FLOAT_WORD( t, n & ~( 0x007fffff >> k ) );
n = ( ( n & 0x007fffff ) | 0x00800000 ) >> ( 23 - k );
if ( j < 0 ) n = -n;
p_h -= t;
}
t = p_l + p_h;
GET_FLOAT_WORD( is, t );
SET_FLOAT_WORD( t, is & 0xfffff000 );
u = t * basicmath_lg2_h;
v = ( p_l - ( t - p_h ) ) * basicmath_lg2 + t * basicmath_lg2_l;
z = u + v;
w = v - ( z - u );
t = z * z;
t1 = z - t * ( basicmath_P1 + t * ( basicmath_P2 + t * ( basicmath_P3 + t *
( basicmath_P4 + t * basicmath_P5 ) ) ) );
r = ( z * t1 ) / ( t1 - basicmath_two ) - ( w + z * w );
z = basicmath_one - ( r - z );
GET_FLOAT_WORD( j, z );
j += ( n << 23 );
if ( ( j >> 23 ) <= 0 ) z = basicmath___scalbnf( z, n ); /* subnormal output */
else SET_FLOAT_WORD( z, j );
return s * z;
}
/* e_rem_pio2f.c -- float version of e_rem_pio2.c
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/* basicmath___ieee754_rem_pio2f(x,y)
return the remainder of x rem pi/2 in y[0]+y[1]
*/
/* This array is like the one in e_rem_pio2.c, but the numbers are
single precision and the last 8 bits are forced to 0. */
static const int32_t basicmath_npio2_hw[] = {
0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00,
0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00,
0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100,
0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00,
0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00,
0x4242c700, 0x42490f00
};
/*
invpio2: 24 bits of 2/pi
pio2_1: first 17 bit of pi/2
pio2_1t: pi/2 - pio2_1
pio2_2: second 17 bit of pi/2
pio2_2t: pi/2 - (pio2_1+pio2_2)
pio2_3: third 17 bit of pi/2
pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
*/
static const float basicmath_invpio2 = 6.3661980629e-01f, /* 0x3f22f984 */
basicmath_pio2_1 = 1.5707855225e+00f, /* 0x3fc90f80 */
basicmath_pio2_1t = 1.0804334124e-05f, /* 0x37354443 */
basicmath_pio2_2 = 1.0804273188e-05f, /* 0x37354400 */
basicmath_pio2_2t = 6.0770999344e-11f, /* 0x2e85a308 */
basicmath_pio2_3 = 6.0770943833e-11f, /* 0x2e85a300 */
basicmath_pio2_3t = 6.1232342629e-17f; /* 0x248d3132 */
int32_t basicmath___ieee754_rem_pio2f( float x, float *y )
{
float z, w, t, r, fn;
int32_t i, j, n, ix, hx;
GET_FLOAT_WORD( hx, x );
ix = hx & 0x7fffffff;
if ( ix <= 0x3f490fd8 ) { /* |x| ~<= pi/4 , no need for reduction */
y[ 0 ] = x;
y[ 1 ] = 0;
return 0;
}
if ( ix < 0x4016cbe4 ) { /* |x| < 3pi/4, special case with n=+-1 */
if ( hx > 0 ) {
z = x - basicmath_pio2_1;
if ( ( ix & 0xfffffff0 ) != 0x3fc90fd0 ) { /* 24+24 bit pi OK */
y[ 0 ] = z - basicmath_pio2_1t;
y[ 1 ] = ( z - y[ 0 ] ) - basicmath_pio2_1t;
} else { /* near pi/2, use 24+24+24 bit pi */
z -= basicmath_pio2_2;
y[ 0 ] = z - basicmath_pio2_2t;
y[ 1 ] = ( z - y[ 0 ] ) - basicmath_pio2_2t;
}
return 1;
} else { /* negative x */
z = x + basicmath_pio2_1;
if ( ( ix & 0xfffffff0 ) != 0x3fc90fd0 ) { /* 24+24 bit pi OK */
y[ 0 ] = z + basicmath_pio2_1t;
y[ 1 ] = ( z - y[ 0 ] ) + basicmath_pio2_1t;
} else { /* near pi/2, use 24+24+24 bit pi */
z += basicmath_pio2_2;
y[ 0 ] = z + basicmath_pio2_2t;
y[ 1 ] = ( z - y[ 0 ] ) + basicmath_pio2_2t;
}
return -1;
}
}
if ( ix <= 0x43490f80 ) { /* |x| ~<= 2^7*(pi/2), medium size */
t = basicmath___fabsf( x );
n = ( int32_t ) ( t * basicmath_invpio2 + basicmath_half );
fn = ( float )n;
r = t - fn * basicmath_pio2_1;
w = fn * basicmath_pio2_1t; /* 1st round good to 40 bit */
if ( n < 32 && ( int32_t )( ix & 0xffffff00 ) != basicmath_npio2_hw[n - 1] ) {
y[ 0 ] = r - w; /* quick check no cancellation */
} else {
u_int32_t high;
j = ix >> 23;
y[ 0 ] = r - w;
GET_FLOAT_WORD( high, y[ 0 ] );
i = j - ( ( high >> 23 ) & 0xff );
if ( i > 8 ) { /* 2nd iteration needed, good to 57 */
t = r;
w = fn * basicmath_pio2_2;
r = t - w;
w = fn * basicmath_pio2_2t - ( ( t - r ) - w );
y[ 0 ] = r - w;
GET_FLOAT_WORD( high, y[ 0 ] );
i = j - ( ( high >> 23 ) & 0xff );
if ( i > 25 ) { /* 3rd iteration need, 74 bits acc */
t = r; /* will cover all possible cases */
w = fn * basicmath_pio2_3;
r = t - w;
w = fn * basicmath_pio2_3t - ( ( t - r ) - w );
y[ 0 ] = r - w;
}
}
}
y[ 1 ] = ( r - y[ 0 ] ) - w;
if ( hx < 0 ) {
y[ 0 ] = -y[ 0 ];
y[ 1 ] = -y[ 1 ];
return -n;
} else return n;
}
/*
all other (large) arguments
*/
if ( ix >= 0x7f800000 ) { /* x is inf or NaN */
y[ 0 ] = y[ 1 ] = x - x;
return 0;
}
// This will never happen in basicmath_small, because
// up to this point we have already returned a value
// for each of the possible inputs
y[ 0 ] = y[ 1 ] = x - x; /* dummy initialization */
return 0;
}
/* e_sqrtf.c -- float version of e_sqrt.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
float basicmath___ieee754_sqrtf( float x )
{
float z;
int32_t sign = ( int )0x80000000;
int32_t ix, s, q, m, t, i;
u_int32_t r;
GET_FLOAT_WORD( ix, x );
/* take care of Inf and NaN */
if ( ( ix & 0x7f800000 ) == 0x7f800000 ) {
return x * x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
sqrt(-inf)=sNaN */
}
/* take care of zero */
if ( ix <= 0 ) {
if ( ( ix & ( ~sign ) ) == 0 ) return x; /* sqrt(+-0) = +-0 */
else
if ( ix < 0 )
return ( x - x ) / ( x - x ); /* sqrt(-ve) = sNaN */
}
/* normalize x */
m = ( ix >> 23 );
if ( m == 0 ) { /* subnormal x */
_Pragma( "loopbound min 0 max 0" )
for ( i = 0; ( ix & 0x00800000 ) == 0; i++ )
ix <<= 1;
m -= i - 1;
}
m -= 127; /* unbias exponent */
ix = ( ix & 0x007fffff ) | 0x00800000;
if ( m & 1 ) /* odd m, double x to make it even */
ix += ix;
m >>= 1; /* m = [m/2] */
/* generate sqrt(x) bit by bit */
ix += ix;
q = s = 0; /* q = sqrt(x) */
r = 0x01000000; /* r = moving bit from right to left */
_Pragma( "loopbound min 25 max 25" )
while ( r != 0 ) {
t = s + r;
if ( t <= ix ) {
s = t + r;
ix -= t;
q += r;
}
ix += ix;
r >>= 1;
}
/* use floating add to find out rounding direction */
if ( ix != 0 ) {
z = basicmath_one - basicmath_tiny; /* trigger inexact flag */
if ( z >= basicmath_one ) {
z = basicmath_one + basicmath_tiny;
if ( z > basicmath_one )
q += 2;
else
q += ( q & 1 );
}
}
ix = ( q >> 1 ) + 0x3f000000;
ix += ( m << 23 );
SET_FLOAT_WORD( z, ix );
return z;
}
/* k_cosf.c -- float version of k_cos.c
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_C1 = 4.1666667908e-02f, /* 0x3d2aaaab */
basicmath_C2 = -1.3888889225e-03f, /* 0xbab60b61 */
basicmath_C3 = 2.4801587642e-05f, /* 0x37d00d01 */
basicmath_C4 = -2.7557314297e-07f, /* 0xb493f27c */
basicmath_C5 = 2.0875723372e-09f, /* 0x310f74f6 */
basicmath_C6 = -1.1359647598e-11f; /* 0xad47d74e */
float basicmath___kernel_cosf( float x, float y )
{
float a, hz, z, r, qx;
int32_t ix;
GET_FLOAT_WORD( ix, x );
ix &= 0x7fffffff; /* ix = |x|'s high word*/
if ( ix < 0x32000000 ) { /* if x < 2**27 */
if ( ( ( int )x ) == 0 ) return basicmath_one; /* generate inexact */
}
z = x * x;
r = z * ( basicmath_C1 + z * ( basicmath_C2 + z * ( basicmath_C3 + z *
( basicmath_C4 + z * ( basicmath_C5 + z * basicmath_C6 ) ) ) ) );
if ( ix < 0x3e99999a ) /* if |x| < 0.3 */
return basicmath_one - ( ( float )0.5f * z - ( z * r - x * y ) );
else {
if ( ix > 0x3f480000 ) /* x > 0.78125 */
qx = ( float )0.28125f;
else {
SET_FLOAT_WORD( qx, ix - 0x01000000 ); /* x/4 */
}
hz = ( float )0.5f * z - qx;
a = basicmath_one - qx;
return a - ( hz - ( z * r - x * y ) );
}
}
/* k_sinf.c -- float version of k_sin.c
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_S1 = -1.6666667163e-01f, /* 0xbe2aaaab */
basicmath_S2 = 8.3333337680e-03f, /* 0x3c088889 */
basicmath_S3 = -1.9841270114e-04f, /* 0xb9500d01 */
basicmath_S4 = 2.7557314297e-06f, /* 0x3638ef1b */
basicmath_S5 = -2.5050759689e-08f, /* 0xb2d72f34 */
basicmath_S6 = 1.5896910177e-10f; /* 0x2f2ec9d3 */
float basicmath___kernel_sinf( float x, float y, int iy )
{
float z, r, v;
int32_t ix;
GET_FLOAT_WORD( ix, x );
ix &= 0x7fffffff; /* high word of x */
if ( ix < 0x32000000 ) { /* |x| < 2**-27 */
if ( ( int )x == 0 ) return x; /* generate inexact */
}
z = x * x;
v = z * x;
r = basicmath_S2 + z * ( basicmath_S3 + z * ( basicmath_S4 + z *
( basicmath_S5 + z * basicmath_S6 ) ) );
if ( iy == 0 ) return x + v * ( basicmath_S1 + z * r );
else return x - ( ( z * ( basicmath_half * y - v * r ) - y ) - v *
basicmath_S1 );
}
/* s_copysignf.c -- float version of s_copysign.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
copysignf(float x, float y)
copysignf(x,y) returns a value with the magnitude of x and
with the sign bit of y.
*/
float basicmath___copysignf( float x, float y )
{
u_int32_t ix, iy;
GET_FLOAT_WORD( ix, x );
GET_FLOAT_WORD( iy, y );
SET_FLOAT_WORD( x, ( ix & 0x7fffffff ) | ( iy & 0x80000000 ) );
return x;
}
/* s_cosf.c -- float version of s_cos.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
float basicmath___cosf( float x )
{
float y[ 2 ], z = 0.0f;
int32_t n, ix;
GET_FLOAT_WORD( ix, x );
/* |x| ~< pi/4 */
ix &= 0x7fffffff;
if ( ix <= 0x3f490fd8 ) return basicmath___kernel_cosf( x, z );
/* cos(Inf or NaN) is NaN */
else
if ( ix >= 0x7f800000 ) return x - x;
/* argument reduction needed */
else {
n = basicmath___ieee754_rem_pio2f( x, y );
switch ( n & 3 ) {
case 0:
return basicmath___kernel_cosf( y[ 0 ], y[ 1 ] );
case 1:
return -basicmath___kernel_sinf( y[ 0 ], y[ 1 ], 1 );
case 2:
return -basicmath___kernel_cosf( y[ 0 ], y[ 1 ] );
default:
return basicmath___kernel_sinf( y[ 0 ], y[ 1 ], 1 );
}
}
}
/* s_fabsf.c -- float version of s_fabs.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
fabsf(x) returns the absolute value of x.
*/
float basicmath___fabsf( float x )
{
u_int32_t ix;
GET_FLOAT_WORD( ix, x );
SET_FLOAT_WORD( x, ix & 0x7fffffff );
return x;
}
/*
isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0;
no branching!
*/
int basicmath___isinff ( float x )
{
int32_t ix, t;
GET_FLOAT_WORD( ix, x );
t = ix & 0x7fffffff;
t ^= 0x7f800000;
t |= -t;
return ~( t >> 31 ) & ( ix >> 30 );
}
/* s_scalbnf.c -- float version of s_scalbn.c.
Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
static const float basicmath_two25 = 3.355443200e+07f, /* 0x4c000000 */
basicmath_twom25 = 2.9802322388e-08f; /* 0x33000000 */
float basicmath___scalbnf ( float x, int n )
{
int32_t k, ix;
GET_FLOAT_WORD( ix, x );
k = ( ix & 0x7f800000 ) >> 23; /* extract exponent */
if ( k == 0 ) { /* 0 or subnormal x */
if ( ( ix & 0x7fffffff ) == 0 ) return x; /* +-0 */
x *= basicmath_two25;
GET_FLOAT_WORD( ix, x );
k = ( ( ix & 0x7f800000 ) >> 23 ) - 25;
}
if ( k == 0xff ) return x + x; /* NaN or Inf */
k = k + n;
if ( n > 50000 || k > 0xfe )
return basicmath_huge * basicmath___copysignf( basicmath_huge,
x ); /* overflow */
if ( n < -50000 )
return basicmath_tiny * basicmath___copysignf( basicmath_tiny,
x ); /*underflow*/
if ( k > 0 ) { /* normal result */
SET_FLOAT_WORD( x, ( ix & 0x807fffff ) | ( k << 23 ) );
return x;
}
if ( k <= -25 )
return basicmath_tiny * basicmath___copysignf( basicmath_tiny,
x ); /*underflow*/
k += 25; /* subnormal result */
SET_FLOAT_WORD( x, ( ix & 0x807fffff ) | ( k << 23 ) );
return x * basicmath_twom25;
}

View File

@ -0,0 +1,61 @@
/*
====================================================
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

View File

@ -0,0 +1,70 @@
File: jfdctint.c
Original provenience: SNU-RT Benchmark Suite for Worst Case Timing Analysis
2016-02-01:
- Added generic TACLeBench header.
- Removed old file header (keep some information in TACLeBench header).
- Renamed global variable date to jfdctint_data.
- Renamed main to jfdctint_main.
- Moved initialisation code to jfdctint_init
- Implemented new main function according to TACLeBench guidlines.
- Implemented new function jfdctint_return, calculates checksum over
all data.
- 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: bs_) followed by lowercase letter (e.g., bs_square)
- 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
- In non-empty lists or index expressions, opening '(' and '[' are followed by
one whitespace, closing ')' and ']' are preceded by one whitespace
- Operators within expressions shall be preceded and followed by one
whitespace
2016-02-03:
- Removed all PROFILINGs.
- Macro types replaced by actual types:
- Replaced INT32 with int.
- Replaced DCTELEM with int.
- Removed macros:
- GLOBAL (useless)
- Unused "FIX_... FIX(..)" definitions (unused)
- BITS_IN_JSAMPLE (used in #ifdef...#else..., keep only #if part)
- SHIFT_TEMPS (empty)
- JPEG_INTERNALS (unused)
- MULTIPLY (simply multiply *)
- ONE (used only once)
- RIGHT_SHIFT (used only once)
2016-04-05:
- Return '0' on success
2016-04-06:
- Fixed generation of return value
2016-04-21:
- Fixed checksum value
- Fixed license
2016-06-01:
- Changed all prefixes to lower-case
- Changed return type of jfdctint_main
2016-06-08:
- Prefix
- removed return from jfdctint_main

View File

@ -0,0 +1,383 @@
The Independent JPEG Group's JPEG software
==========================================
README for release 6a of 7-Feb-96
=================================
This distribution contains the sixth public release of the Independent JPEG
Group's free JPEG software. You are welcome to redistribute this software and
to use it for any purpose, subject to the conditions under LEGAL ISSUES, below.
Serious users of this software (particularly those incorporating it into
larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to
our electronic mailing list. Mailing list members are notified of updates
and have a chance to participate in technical discussions, etc.
This software is the work of Tom Lane, Philip Gladstone, Luis Ortiz, Jim
Boucher, Lee Crocker, Julian Minguillon, George Phillips, Davide Rossi,
Ge' Weijers, and other members of the Independent JPEG Group.
IJG is not affiliated with the official ISO JPEG standards committee.
DOCUMENTATION ROADMAP
=====================
This file contains the following sections:
OVERVIEW General description of JPEG and the IJG software.
LEGAL ISSUES Copyright, lack of warranty, terms of distribution.
REFERENCES Where to learn more about JPEG.
ARCHIVE LOCATIONS Where to find newer versions of this software.
RELATED SOFTWARE Other stuff you should get.
FILE FORMAT WARS Software *not* to get.
TO DO Plans for future IJG releases.
Other documentation files in the distribution are:
User documentation:
install.doc How to configure and install the IJG software.
usage.doc Usage instructions for cjpeg, djpeg, jpegtran,
rdjpgcom, and wrjpgcom.
*.1 Unix-style man pages for programs (same info as usage.doc).
wizard.doc Advanced usage instructions for JPEG wizards only.
change.log Version-to-version change highlights.
Programmer and internal documentation:
libjpeg.doc How to use the JPEG library in your own programs.
example.c Sample code for calling the JPEG library.
structure.doc Overview of the JPEG library's internal structure.
filelist.doc Road map of IJG files.
coderules.doc Coding style rules --- please read if you contribute code.
Please read at least the files install.doc and usage.doc. Useful information
can also be found in the JPEG FAQ (Frequently Asked Questions) article. See
ARCHIVE LOCATIONS below to find out where to obtain the FAQ article.
If you want to understand how the JPEG code works, we suggest reading one or
more of the REFERENCES, then looking at the documentation files (in roughly
the order listed) before diving into the code.
OVERVIEW
========
This package contains C software to implement JPEG image compression and
decompression. JPEG (pronounced "jay-peg") is a standardized compression
method for full-color and gray-scale images. JPEG is intended for compressing
"real-world" scenes; line drawings, cartoons and other non-realistic images
are not its strong suit. JPEG is lossy, meaning that the output image is not
exactly identical to the input image. Hence you must not use JPEG if you
have to have identical output bits. However, on typical photographic images,
very good compression levels can be obtained with no visible change, and
remarkably high compression levels are possible if you can tolerate a
low-quality image. For more details, see the references, or just experiment
with various compression settings.
This software implements JPEG baseline, extended-sequential, and progressive
compression processes. Provision is made for supporting all variants of these
processes, although some uncommon parameter settings aren't implemented yet.
For legal reasons, we are not distributing code for the arithmetic-coding
variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting
the hierarchical or lossless processes defined in the standard.
We provide a set of library routines for reading and writing JPEG image files,
plus two sample applications "cjpeg" and "djpeg", which use the library to
perform conversion between JPEG and some other popular image file formats.
The library is intended to be reused in other applications.
In order to support file conversion and viewing software, we have included
considerable functionality beyond the bare JPEG coding/decoding capability;
for example, the color quantization modules are not strictly part of JPEG
decoding, but they are essential for output to colormapped file formats or
colormapped displays. These extra functions can be compiled out of the
library if not required for a particular application. We have also included
"jpegtran", a utility for lossless transcoding between different JPEG
processes, and "rdjpgcom" and "wrjpgcom", two simple applications for
inserting and extracting textual comments in JFIF files.
The emphasis in designing this software has been on achieving portability and
flexibility, while also making it fast enough to be useful. In particular,
the software is not intended to be read as a tutorial on JPEG. (See the
REFERENCES section for introductory material.) Rather, it is intended to
be reliable, portable, industrial-strength code. We do not claim to have
achieved that goal in every aspect of the software, but we strive for it.
We welcome the use of this software as a component of commercial products.
No royalty is required, but we do ask for an acknowledgement in product
documentation, as described under LEGAL ISSUES.
LEGAL ISSUES
============
In plain English:
1. We don't promise that this software works. (But if you find any bugs,
please let us know!)
2. You can use this software for whatever you want. You don't have to pay us.
3. You may not pretend that you wrote this software. If you use it in a
program, you must acknowledge somewhere in your documentation that
you've used the IJG code.
In legalese:
The authors make NO WARRANTY or representation, either express or implied,
with respect to this software, its quality, accuracy, merchantability, or
fitness for a particular purpose. This software is provided "AS IS", and you,
its user, assume the entire risk as to its quality and accuracy.
This software is copyright (C) 1991-1996, Thomas G. Lane.
All Rights Reserved except as specified below.
Permission is hereby granted to use, copy, modify, and distribute this
software (or portions thereof) for any purpose, without fee, subject to these
conditions:
(1) If any part of the source code for this software is distributed, then this
README file must be included, with this copyright and no-warranty notice
unaltered; and any additions, deletions, or changes to the original files
must be clearly indicated in accompanying documentation.
(2) If only executable code is distributed, then the accompanying
documentation must state that "this software is based in part on the work of
the Independent JPEG Group".
(3) Permission for use of this software is granted only if the user accepts
full responsibility for any undesirable consequences; the authors accept
NO LIABILITY for damages of any kind.
These conditions apply to any software derived from or based on the IJG code,
not just to the unmodified library. If you use our work, you ought to
acknowledge us.
Permission is NOT granted for the use of any IJG author's name or company name
in advertising or publicity relating to this software or products derived from
it. This software may be referred to only as "the Independent JPEG Group's
software".
We specifically permit and encourage the use of this software as the basis of
commercial products, provided that all warranty or liability claims are
assumed by the product vendor.
ansi2knr.c is included in this distribution by permission of L. Peter Deutsch,
sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA.
ansi2knr.c is NOT covered by the above copyright and conditions, but instead
by the usual distribution terms of the Free Software Foundation; principally,
that you must include source code if you redistribute it. (See the file
ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part
of any program generated from the IJG code, this does not limit you more than
the foregoing paragraphs do.
The configuration script "configure" was produced with GNU Autoconf. It
is copyright by the Free Software Foundation but is freely distributable.
It appears that the arithmetic coding option of the JPEG spec is covered by
patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot
legally be used without obtaining one or more licenses. For this reason,
support for arithmetic coding has been removed from the free JPEG software.
(Since arithmetic coding provides only a marginal gain over the unpatented
Huffman mode, it is unlikely that very many implementations will support it.)
So far as we are aware, there are no patent restrictions on the remaining
code.
WARNING: Unisys has begun to enforce their patent on LZW compression against
GIF encoders and decoders. You will need a license from Unisys to use the
included rdgif.c or wrgif.c files in a commercial or shareware application.
At this time, Unisys is not enforcing their patent against freeware, so
distribution of this package remains legal. However, we intend to remove
GIF support from the IJG package as soon as a suitable replacement format
becomes reasonably popular.
We are required to state that
"The Graphics Interchange Format(c) is the Copyright property of
CompuServe Incorporated. GIF(sm) is a Service Mark property of
CompuServe Incorporated."
REFERENCES
==========
We highly recommend reading one or more of these references before trying to
understand the innards of the JPEG software.
The best short technical introduction to the JPEG compression algorithm is
Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
(Adjacent articles in that issue discuss MPEG motion picture compression,
applications of JPEG, and related topics.) If you don't have the CACM issue
handy, a PostScript file containing a revised version of Wallace's article
is available at ftp.uu.net, graphics/jpeg/wallace.ps.gz. The file (actually
a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
omits the sample images that appeared in CACM, but it includes corrections
and some added material. Note: the Wallace article is copyright ACM and
IEEE, and it may not be used for commercial purposes.
A somewhat less technical, more leisurely introduction to JPEG can be found in
"The Data Compression Book" by Mark Nelson, published by M&T Books (Redwood
City, CA), 1991, ISBN 1-55851-216-0. This book provides good explanations and
example C code for a multitude of compression methods including JPEG. It is
an excellent source if you are comfortable reading C code but don't know much
about data compression in general. The book's JPEG sample code is far from
industrial-strength, but when you are ready to look at a full implementation,
you've got one here...
The best full description of JPEG is the textbook "JPEG Still Image Data
Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published
by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp.
The book includes the complete text of the ISO JPEG standards (DIS 10918-1
and draft DIS 10918-2). This is by far the most complete exposition of JPEG
in existence, and we highly recommend it.
The JPEG standard itself is not available electronically; you must order a
paper copy through ISO or ITU. (Unless you feel a need to own a certified
official copy, we recommend buying the Pennebaker and Mitchell book instead;
it's much cheaper and includes a great deal of useful explanatory material.)
In the USA, copies of the standard may be ordered from ANSI Sales at (212)
642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI
doesn't take credit card orders, but Global does.) It's not cheap: as of
1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7%
shipping/handling. The standard is divided into two parts, Part 1 being the
actual specification, while Part 2 covers compliance testing methods. Part 1
is titled "Digital Compression and Coding of Continuous-tone Still Images,
Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS
10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of
Continuous-tone Still Images, Part 2: Compliance testing" and has document
numbers ISO/IEC IS 10918-2, ITU-T T.83.
Extensions to the original JPEG standard are defined in JPEG Part 3, a new ISO
document. Part 3 is undergoing ISO balloting and is expected to be approved
by the end of 1995; it will have document numbers ISO/IEC IS 10918-3, ITU-T
T.84. IJG currently does not support any Part 3 extensions.
The JPEG standard does not specify all details of an interchangeable file
format. For the omitted details we follow the "JFIF" conventions, revision
1.02. A copy of the JFIF spec is available from:
Literature Department
C-Cube Microsystems, Inc.
1778 McCarthy Blvd.
Milpitas, CA 95035
phone (408) 944-6300, fax (408) 944-6314
A PostScript version of this document is available at ftp.uu.net, file
graphics/jpeg/jfif.ps.gz. It can also be obtained by e-mail from the C-Cube
mail server, netlib@c3.pla.ca.us. Send the message "send jfif_ps from jpeg"
to the server to obtain the JFIF document; send the message "help" if you have
trouble.
The TIFF 6.0 file format specification can be obtained by FTP from sgi.com
(192.48.153.1), file graphics/tiff/TIFF6.ps.Z; or you can order a printed
copy from Aldus Corp. at (206) 628-6593. The JPEG incorporation scheme
found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.
IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).
Instead, we recommend the JPEG design proposed by TIFF Technical Note #2
(Compression tag 7). Copies of this Note can be obtained from sgi.com or
from ftp.uu.net:/graphics/jpeg/. It is expected that the next revision of
the TIFF spec will replace the 6.0 JPEG design with the Note's design.
Although IJG's own code does not support TIFF/JPEG, the free libtiff library
uses our library to implement TIFF/JPEG per the Note. libtiff is available
from sgi.com:/graphics/tiff/.
ARCHIVE LOCATIONS
=================
The "official" archive site for this software is ftp.uu.net (Internet
address 192.48.96.9). The most recent released version can always be found
there in directory graphics/jpeg. This particular version will be archived
as graphics/jpeg/jpegsrc.v6a.tar.gz. If you are on the Internet, you
can retrieve files from ftp.uu.net by standard anonymous FTP. If you don't
have FTP access, UUNET's archives are also available via UUCP; contact
help@uunet.uu.net for information on retrieving files that way.
Numerous Internet sites maintain copies of the UUNET files. However, only
ftp.uu.net is guaranteed to have the latest official version.
You can also obtain this software in DOS-compatible "zip" archive format from
the SimTel archives (ftp.coast.net:/SimTel/msdos/graphics/), or on CompuServe
in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 "JPEG Tools".
Again, these versions may sometimes lag behind the ftp.uu.net release.
The JPEG FAQ (Frequently Asked Questions) article is a useful source of
general information about JPEG. It is updated constantly and therefore is
not included in this distribution. The FAQ is posted every two weeks to
Usenet newsgroups comp.graphics.misc, news.answers, and other groups.
You can always obtain the latest version from the news.answers archive at
rtfm.mit.edu. By FTP, fetch /pub/usenet/news.answers/jpeg-faq/part1 and
.../part2. If you don't have FTP, send e-mail to mail-server@rtfm.mit.edu
with body
send usenet/news.answers/jpeg-faq/part1
send usenet/news.answers/jpeg-faq/part2
RELATED SOFTWARE
================
Numerous viewing and image manipulation programs now support JPEG. (Quite a
few of them use this library to do so.) The JPEG FAQ described above lists
some of the more popular free and shareware viewers, and tells where to
obtain them on Internet.
If you are on a Unix machine, we highly recommend Jef Poskanzer's free
PBMPLUS image software, which provides many useful operations on PPM-format
image files. In particular, it can convert PPM images to and from a wide
range of other formats. You can obtain this package by FTP from ftp.x.org
(contrib/pbmplus*.tar.Z) or ftp.ee.lbl.gov (pbmplus*.tar.Z). There is also
a newer update of this package called NETPBM, available from
wuarchive.wustl.edu under directory /graphics/graphics/packages/NetPBM/.
Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software
is; you are likely to have difficulty making it work on any non-Unix machine.
A different free JPEG implementation, written by the PVRG group at Stanford,
is available from havefun.stanford.edu in directory pub/jpeg. This program
is designed for research and experimentation rather than production use;
it is slower, harder to use, and less portable than the IJG code, but it
is easier to read and modify. Also, the PVRG code supports lossless JPEG,
which we do not.
FILE FORMAT WARS
================
Some JPEG programs produce files that are not compatible with our library.
The root of the problem is that the ISO JPEG committee failed to specify a
concrete file format. Some vendors "filled in the blanks" on their own,
creating proprietary formats that no one else could read. (For example, none
of the early commercial JPEG implementations for the Macintosh were able to
exchange compressed files.)
The file format we have adopted is called JFIF (see REFERENCES). This format
has been agreed to by a number of major commercial JPEG vendors, and it has
become the de facto standard. JFIF is a minimal or "low end" representation.
We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF
Technical Note #2) for "high end" applications that need to record a lot of
additional data about an image. TIFF/JPEG is fairly new and not yet widely
supported, unfortunately.
The upcoming JPEG Part 3 standard defines a file format called SPIFF.
SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should
be able to read the most common variant of SPIFF. SPIFF has some technical
advantages over JFIF, but its major claim to fame is simply that it is an
official standard rather than an informal one. At this point it is unclear
whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto
standard. IJG intends to support SPIFF once the standard is frozen, but we
have not decided whether it should become our default output format or not.
(In any case, our decoder will remain capable of reading JFIF indefinitely.)
Various proprietary file formats incorporating JPEG compression also exist.
We have little or no sympathy for the existence of these formats. Indeed,
one of the original reasons for developing this free software was to help
force convergence on common, open format standards for JPEG files. Don't
use a proprietary file format!
TO DO
=====
In future versions, we are considering supporting some of the upcoming JPEG
Part 3 extensions --- principally, variable quantization and the SPIFF file
format.
Tuning the software for better behavior at low quality/high compression
settings is also of interest. The current method for scaling the
quantization tables is known not to be very good at low Q values.
As always, speeding things up is high on our priority list.
Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net.

View File

@ -0,0 +1,319 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: jfdctint
Author: Thomas G. Lane, Public domain JPEG source code.
Modified by Steven Li at Princeton University.
Function: JPEG slow-but-accurate integer implementation of the
forward DCT (Discrete Cosine Transform) on a 8x8
pixel block [from original file documentations]
Copyright (C) 1991-1994, Thomas G. Lane.
This file is part of the Independent JPEG Group's software.
For conditions of distribution and use, see the accompanying README file.
This file contains a slow-but-accurate integer implementation of the
forward DCT (Discrete Cosine Transform).
A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
on each column. Direct algorithms are also available, but they are
much more complex and seem not to be any faster when reduced to code.
This implementation is based on an algorithm described in
C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
The primary algorithm described there uses 11 multiplies and 29 adds.
We use their alternate method with 12 multiplies and 32 adds.
The advantage of this method is that no data path contains more than one
multiplication; this allows a very simple and accurate implementation in
scaled fixed-point arithmetic, with a minimal number of shifts.
Source: SNU-RT Benchmark Suite for Worst Case Timing Analysis
Collected and Modified by S.-S. Lim
Real-Time Research Group
Seoul National University
Changes: Moved initialisation code from jfdctint_main() to jfdctint_init(),
added checksum calculation in jfdctint_return()
License: see README
*/
/* COMMENTS: Long calculation sequences (i.e., long basic blocks), */
/* single-nested loops. */
/**********************************************************************
Functions to be timed
***********************************************************************/
/* This definitions are added by Steven Li so as to bypass the header
files.
*/
#define DCTSIZE 8
#define DESCALE(x,n) (((x) + (((int)1) << ((n)-1))) >> (n))
/*
The poop on this scaling stuff is as follows:
Each 1-D DCT step produces outputs which are a factor of sqrt(N)
larger than the true DCT outputs. The final outputs are therefore
a factor of N larger than desired; since N=8 this can be cured by
a simple right shift at the end of the algorithm. The advantage of
this arrangement is that we save two multiplications per 1-D DCT,
because the y0 and y4 outputs need not be divided by sqrt(N).
In the IJG code, this factor of 8 is removed by the quantization step
(in jcdctmgr.c), NOT in this module.
We have to do addition and subtraction of the integer inputs, which
is no problem, and multiplication by fractional constants, which is
a problem to do in integer arithmetic. We multiply all the constants
by CONST_SCALE and convert them to integer constants (thus retaining
CONST_BITS (13) bits of precision in the constants). After doing a
multiplication we have to divide the product by CONST_SCALE, with proper
rounding, to produce the correct output. This division can be done
cheaply as a right shift of CONST_BITS (13) bits. We postpone shifting
as long as possible so that partial sums can be added together with
full fractional precision.
The outputs of the first pass are scaled up by PASS1_BITS (2) bits so that
they are represented to better-than-integral precision. These outputs
require BITS_IN_JSAMPLE (8) + PASS1_BITS (2) + 3 bits; this fits in a
16-bit word with the recommended scaling. (For 12-bit sample data, the
intermediate array is int anyway.)
To avoid overflow of the 32-bit intermediate results in pass 2, we must
have BITS_IN_JSAMPLE (8) + CONST_BITS (13) + PASS1_BITS (2) <= 26.
Error analysis shows that the values given below are the most effective.
*/
/*
Forward declaration of functions
*/
void jfdctint_init();
int jfdctint_return();
void jfdctint_main();
int main( void );
#define CONST_BITS 13
#define PASS1_BITS 2
/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
causing a lot of useless floating-point operations at run time.
To get around this we use the following pre-calculated constants.
If you change CONST_BITS you may want to add appropriate values.
(With a reasonable C compiler, you can just rely on the FIX() macro...)
*/
#define FIX_0_298631336 ((int) 2446) /* FIX(0.298631336) */
#define FIX_0_390180644 ((int) 3196) /* FIX(0.390180644) */
#define FIX_0_541196100 ((int) 4433) /* FIX(0.541196100) */
#define FIX_0_765366865 ((int) 6270) /* FIX(0.765366865) */
#define FIX_0_899976223 ((int) 7373) /* FIX(0.899976223) */
#define FIX_1_175875602 ((int) 9633) /* FIX(1.175875602) */
#define FIX_1_501321110 ((int) 12299) /* FIX(1.501321110) */
#define FIX_1_847759065 ((int) 15137) /* FIX(1.847759065) */
#define FIX_1_961570560 ((int) 16069) /* FIX(1.961570560) */
#define FIX_2_053119869 ((int) 16819) /* FIX(2.053119869) */
#define FIX_2_562915447 ((int) 20995) /* FIX(2.562915447) */
#define FIX_3_072711026 ((int) 25172) /* FIX(3.072711026) */
/* Multiply an int variable by an int constant to yield an int result.
For 8-bit samples with the recommended scaling, all the variable
and constant values involved are no more than 16 bits wide, so a
16x16->32 bit multiply can be used instead of a full 32x32 multiply.
For 12-bit samples, a full 32-bit multiplication will be needed.
*/
int jfdctint_data[ 64 ];
const int jfdctint_CHECKSUM = 1668124;
void jfdctint_init()
{
int i, seed;
/* Worst case settings */
/* Set array to random values */
seed = 1;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < 64; i++ ) {
seed = ( ( seed * 133 ) + 81 ) % 65535;
jfdctint_data[ i ] = seed;
}
}
int jfdctint_return()
{
int checksum = 0;
int i;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < 64; ++i )
checksum += jfdctint_data[ i ];
return ( ( checksum == jfdctint_CHECKSUM ) ? 0 : -1 );
}
/*
Perform the forward DCT on one block of samples.
*/
void jfdctint_jpeg_fdct_islow( void )
{
int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
int tmp10, tmp11, tmp12, tmp13;
int z1, z2, z3, z4, z5;
int *dataptr;
int ctr;
/* Pass 1: process rows. */
/* Note results are scaled up by sqrt(8) compared to a true DCT; */
/* furthermore, we scale the results by 2**PASS1_BITS. */
dataptr = jfdctint_data;
_Pragma( "loopbound min 8 max 8" )
for ( ctr = DCTSIZE - 1; ctr >= 0; ctr-- ) {
tmp0 = dataptr[ 0 ] + dataptr[ 7 ];
tmp7 = dataptr[ 0 ] - dataptr[ 7 ];
tmp1 = dataptr[ 1 ] + dataptr[ 6 ];
tmp6 = dataptr[ 1 ] - dataptr[ 6 ];
tmp2 = dataptr[ 2 ] + dataptr[ 5 ];
tmp5 = dataptr[ 2 ] - dataptr[ 5 ];
tmp3 = dataptr[ 3 ] + dataptr[ 4 ];
tmp4 = dataptr[ 3 ] - dataptr[ 4 ];
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
dataptr[ 0 ] = ( int ) ( ( tmp10 + tmp11 ) << PASS1_BITS );
dataptr[ 4 ] = ( int ) ( ( tmp10 - tmp11 ) << PASS1_BITS );
z1 = ( tmp12 + tmp13 ) * FIX_0_541196100;
dataptr[ 2 ] = ( int ) DESCALE( z1 + tmp13 * FIX_0_765366865,
CONST_BITS - PASS1_BITS );
dataptr[ 6 ] = ( int ) DESCALE( z1 + tmp12 * ( - FIX_1_847759065 ),
CONST_BITS - PASS1_BITS );
z1 = tmp4 + tmp7;
z2 = tmp5 + tmp6;
z3 = tmp4 + tmp6;
z4 = tmp5 + tmp7;
z5 = ( z3 + z4 ) * FIX_1_175875602; /* sqrt(2) * c3 */
tmp4 = tmp4 * FIX_0_298631336; /* sqrt(2) * (-c1+c3+c5-c7) */
tmp5 = tmp5 * FIX_2_053119869; /* sqrt(2) * ( c1+c3-c5+c7) */
tmp6 = tmp6 * FIX_3_072711026; /* sqrt(2) * ( c1+c3+c5-c7) */
tmp7 = tmp7 * FIX_1_501321110; /* sqrt(2) * ( c1+c3-c5-c7) */
z1 = z1 * ( - FIX_0_899976223 ); /* sqrt(2) * (c7-c3) */
z2 = z2 * ( - FIX_2_562915447 ); /* sqrt(2) * (-c1-c3) */
z3 = z3 * ( - FIX_1_961570560 ); /* sqrt(2) * (-c3-c5) */
z4 = z4 * ( - FIX_0_390180644 ); /* sqrt(2) * (c5-c3) */
z3 += z5;
z4 += z5;
dataptr[ 7 ] = ( int ) DESCALE( tmp4 + z1 + z3, CONST_BITS - PASS1_BITS );
dataptr[ 5 ] = ( int ) DESCALE( tmp5 + z2 + z4, CONST_BITS - PASS1_BITS );
dataptr[ 3 ] = ( int ) DESCALE( tmp6 + z2 + z3, CONST_BITS - PASS1_BITS );
dataptr[ 1 ] = ( int ) DESCALE( tmp7 + z1 + z4, CONST_BITS - PASS1_BITS );
dataptr += DCTSIZE; /* advance pointer to next row */
}
dataptr = jfdctint_data;
_Pragma( "loopbound min 8 max 8" )
for ( ctr = DCTSIZE - 1; ctr >= 0; ctr-- ) {
tmp0 = dataptr[ DCTSIZE * 0 ] + dataptr[ DCTSIZE * 7 ];
tmp7 = dataptr[ DCTSIZE * 0 ] - dataptr[ DCTSIZE * 7 ];
tmp1 = dataptr[ DCTSIZE * 1 ] + dataptr[ DCTSIZE * 6 ];
tmp6 = dataptr[ DCTSIZE * 1 ] - dataptr[ DCTSIZE * 6 ];
tmp2 = dataptr[ DCTSIZE * 2 ] + dataptr[ DCTSIZE * 5 ];
tmp5 = dataptr[ DCTSIZE * 2 ] - dataptr[ DCTSIZE * 5 ];
tmp3 = dataptr[ DCTSIZE * 3 ] + dataptr[ DCTSIZE * 4 ];
tmp4 = dataptr[ DCTSIZE * 3 ] - dataptr[ DCTSIZE * 4 ];
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
dataptr[ DCTSIZE * 0 ] = ( int ) DESCALE( tmp10 + tmp11, PASS1_BITS );
dataptr[ DCTSIZE * 4 ] = ( int ) DESCALE( tmp10 - tmp11, PASS1_BITS );
z1 = ( tmp12 + tmp13 ) * FIX_0_541196100;
dataptr[ DCTSIZE * 2 ] = ( int ) DESCALE( z1 + tmp13 * FIX_0_765366865,
CONST_BITS + PASS1_BITS );
dataptr[ DCTSIZE * 6 ] = ( int ) DESCALE( z1
+ tmp12 * ( - FIX_1_847759065 ),
CONST_BITS + PASS1_BITS );
z1 = tmp4 + tmp7;
z2 = tmp5 + tmp6;
z3 = tmp4 + tmp6;
z4 = tmp5 + tmp7;
z5 = ( z3 + z4 ) * FIX_1_175875602; /* sqrt(2) * c3 */
tmp4 = tmp4 * FIX_0_298631336; /* sqrt(2) * (-c1+c3+c5-c7) */
tmp5 = tmp5 * FIX_2_053119869; /* sqrt(2) * ( c1+c3-c5+c7) */
tmp6 = tmp6 * FIX_3_072711026; /* sqrt(2) * ( c1+c3+c5-c7) */
tmp7 = tmp7 * FIX_1_501321110; /* sqrt(2) * ( c1+c3-c5-c7) */
z1 = z1 * ( - FIX_0_899976223 ); /* sqrt(2) * (c7-c3) */
z2 = z2 * ( - FIX_2_562915447 ); /* sqrt(2) * (-c1-c3) */
z3 = z3 * ( - FIX_1_961570560 ); /* sqrt(2) * (-c3-c5) */
z4 = z4 * ( - FIX_0_390180644 ); /* sqrt(2) * (c5-c3) */
z3 += z5;
z4 += z5;
dataptr[ DCTSIZE * 7 ] = ( int ) DESCALE( tmp4 + z1 + z3,
CONST_BITS + PASS1_BITS );
dataptr[ DCTSIZE * 5 ] = ( int ) DESCALE( tmp5 + z2 + z4,
CONST_BITS + PASS1_BITS );
dataptr[ DCTSIZE * 3 ] = ( int ) DESCALE( tmp6 + z2 + z3,
CONST_BITS + PASS1_BITS );
dataptr[ DCTSIZE * 1 ] = ( int ) DESCALE( tmp7 + z1 + z4,
CONST_BITS + PASS1_BITS );
dataptr++; /* advance pointer to next column */
}
}
/* Main function
Time to function execution time using logic analyzer,
which measures the OFF time of a LED on board.
The switching latency, including the function call/return time,
is measured to be equal to 1.1us (22 clock cycles).
*/
void _Pragma ( "entrypoint" ) jfdctint_main( void )
{
jfdctint_jpeg_fdct_islow();
}
int main( void )
{
jfdctint_init();
jfdctint_main();
return ( jfdctint_return() );
}

View File

@ -0,0 +1,13 @@
File: lms.c
Original provenience: C Algorithms for Real-Time DSP by Paul M. Embree, pp. 159,229-231
2016-06-16:
- The original source code from Paul M. Embree had several problems:
* Source code was copied from a copyrighted book
* Input generation used external math functions
* Thus execution time of input generation dominated total execution time
* Several arrays where uninitalised
* Output printed to stdout but was not checked for correctness
* lms() used static variables for internal state
- Completely rewritten and published with ISC license
- Replaced double constants using exponent notation by numerical constant.

View File

@ -0,0 +1,203 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: lms
Author: Jörg Mische
Function: LMS adaptive signal enhancement
Source: Completely rewritten for TACLeBench to avoid license issues.
It has the same functionality as lms.c from the book
"C Algorithms for Real-Time DSP" by Paul M. Embree, which
has been used in WCET benchmarking for many years.
Original name: lms.c
Changes: Simplified generation of the input (noisy sinus wave).
No static variables.
License: ISC (simplified BSD)
*/
/*
Copyright (c) 2016 Jörg Mische
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#define N 201
#define L 20
#define SAMPLING 5
float lms_input[ N + 1 ], lms_output[ N + 1 ];
/* The following table can be calculated by
for (i=0; i<=SAMPLING; i++)
lms_sintab[ k ] = sqrt(2.0) * sin(PI * i / (2*SAMPLING));
*/
double lms_sintab[ SAMPLING + 1 ] = {
0.00000000000000000,
0.43701603620715901,
0.83125389555938600,
1.14412282743652560,
1.34499703920997637,
1.41421356237309381,
};
double lms_sinus( int i )
{
int s = i % ( 4 * SAMPLING );
if ( s >= ( 2 * SAMPLING ) )
return -lms_sintab[ ( s > 3 * SAMPLING ) ?
( 4 * SAMPLING - s ) : ( s - 2 * SAMPLING ) ];
return lms_sintab[ ( s > SAMPLING ) ? ( 2 * SAMPLING - s ) : s ];
}
void lms_init( void )
{
unsigned long seed = 1;
int k;
lms_input[ 0 ] = 0.0;
{
double v1, v2, r;
const double scaleFactor = 0.000000000931322574615478515625;
do {
// generate two random numbers between -1.0 and +1.0
seed = seed * 1103515245 + 12345;
v1 = ( seed & 0x00007fffffff ) * scaleFactor - 1.0;
seed = seed * 1103515245 + 12345;
v2 = ( seed & 0x00007fffffff ) * scaleFactor - 1.0;
r = v1 * v1 + v2 * v2;
} while ( r > 1.0 );
// radius < 1
// remap v1 and v2 to two Gaussian numbers
double noise = 1 / r; // approximation of sqrt(0.96) * sqrt(-log(r)/r);
lms_input[1] = lms_sinus(1) + noise * v2;
}
_Pragma( "loopbound min 100 max 100" )
for ( k = 2 ; k < N ; k += 2 ) {
double v1, v2, r;
const double scaleFactor = 0.000000000931322574615478515625;
do {
// generate two random numbers between -1.0 and +1.0
seed = seed * 1103515245 + 12345;
v1 = ( seed & 0x00007fffffff ) * scaleFactor - 1.0;
seed = seed * 1103515245 + 12345;
v2 = ( seed & 0x00007fffffff ) * scaleFactor - 1.0;
r = v1 * v1 + v2 * v2;
} while ( r > 1.0 );
// radius < 1
// remap v1 and v2 to two Gaussian numbers
double noise = 1 / r; // approximation of sqrt(0.96) * sqrt(-log(r)/r);
lms_input[ k ] = lms_sinus(k) + noise * v2;
lms_input[ k + 1 ] = lms_sinus(k + 1) + noise * v1;
}
}
float lms_calc( float x,
float d,
float b[ ],
int l,
float mu,
float alpha,
float history[ ],
float *sigma )
{
int i;
// shift history
_Pragma( "loopbound min 20 max 20" )
for ( i = l ; i >= 1 ; i-- )
history[ i ] = history[ i - 1 ];
history[ 0 ] = x;
// calculate filter
float y = 0.0;
*sigma = alpha * x * x + ( 1 - alpha ) * ( *sigma );
_Pragma( "loopbound min 21 max 21" )
for ( i = 0 ; i <= l ; i++ )
y += b[ i ] * history[ i ];
// update coefficients
float e = mu * ( d - y ) / ( *sigma );
_Pragma( "loopbound min 21 max 21" )
for ( i = 0 ; i <= l ; i++ )
b[ i ] += e * history[ i ];
return y;
}
void _Pragma( "entrypoint" ) lms_main( void )
{
int i;
float b[ L + 1 ];
float history[ L + 1 ];
float sigma = 2.0;
_Pragma( "loopbound min 21 max 21" )
for ( i = 0; i <= L; i++ ) {
b[ i ] = 0.0;
history[ i ] = 0.0;
}
_Pragma( "loopbound min 201 max 201" )
for ( i = 0 ; i < N ; i++ ) {
lms_output[ i ] = lms_calc( lms_input[ i ],
lms_input[ i + 1 ],
b, L, 0.02 / ( L + 1 ), 0.01,
history, &sigma );
}
}
int lms_return( void )
{
int i;
double sum = 0.0;
_Pragma( "loopbound min 201 max 201" )
for ( i = 0 ; i < N ; i++ ) {
sum += lms_output[i];
}
return ( int )( 1000000.0 * ( sum + 4.705719 ) );
// How did this 'correct value' come to be? The previous calculation contained UB.
// correct value: -4.505242517625447362661361694336
}
int main()
{
lms_init();
lms_main();
return ( lms_return() );
}

View File

@ -0,0 +1,26 @@
File: ludcmp.c
Original provenience: SNU-RT benchmark suite, via Mälardalen benchmark
suite, www.mrtc.....
2015-11-27:
- Removed commented-out parameter nmax
- Made chkerr a global variable, set in the ludmp function
- Changed return value of ludcmp to void
- Renamed ludcmp to ludcmp_test, wrap call in new function ludcmp_main
- Move initialization code into new function ludcmp_init
- Compute checksum in new function ludcmp_return
- Prefix fabs and global variables with "ludcmp_"
- Reordered functions in source code: initialization- and
return-value-related functions first, followed by algorithm core
functions, followed by main functions
- Applied code formatting with astyle as in the example
2015-12-15:
- Sorted out licensing terms, added general TACLeBench header to
beginning of source code
2016-03-15:
- Return 0 if checksum is as expected, -1 otherwise
- Touch input matrix with volatile to rule out optimizations
- Add entrypoint pragma

View File

@ -0,0 +1,177 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: ludcmp
Author: Sung-Soo Lim
Function: Simultaneous linear equations by LU decomposition.
Source: SNU-RT Benchmark Suite, via MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/ludcmp/ludcmp.c
Changes: Moved initialization into separate function.
License: May be used, modified, and re-distributed freely, but
the SNU-RT Benchmark Suite must be acknowledged
*/
/*
This program is derived from the SNU-RT Benchmark Suite for Worst
Case Timing Analysis by Sung-Soo Lim
III-4. ludcmp.c : Simultaneous Linear Equations by LU Decomposition
(from the book C Programming for EEs by Hyun Soon Ahn)
*/
/*
Forward declaration of functions
*/
void ludcmp_init( void );
int ludcmp_return( void );
int ludcmp_test( int n, double eps );
void ludcmp_main( void );
int main( void );
double ludcmp_a[ 50 ][ 50 ], ludcmp_b[ 50 ], ludcmp_x[ 50 ];
int ludcmp_chkerr;
void ludcmp_init( void )
{
int i, j, n = 5;
double w;
volatile int x = 0;
_Pragma( "loopbound min 6 max 6" )
for ( i = 0; i <= n; i++ ) {
w = 0;
_Pragma( "loopbound min 6 max 6" )
for ( j = 0; j <= n; j++ ) {
ludcmp_a[ i ][ j ] = ( i + 1 ) + ( j + 1 );
if ( i == j )
ludcmp_a[ i ][ j ] *= 10;
w += ludcmp_a[ i ][ j ];
if ( x )
ludcmp_a[ i ][ j ] += x;
}
ludcmp_b[ i ] = w;
if ( x )
ludcmp_b[ i ] += x;
}
}
int ludcmp_return( void )
{
int i, n = 5;
double checksum = ludcmp_chkerr;
_Pragma( "loopbound min 6 max 6" )
for ( i = 0; i <= n; i++ )
checksum += ludcmp_x[ i ];
/* allow rounding errors for the checksum */
checksum -= 6.0;
return ( ( checksum < 0.000001 && checksum > -0.000001 ) ? 0 : -1 );
}
double ludcmp_fabs( double n )
{
double f;
if ( n >= 0 )
f = n;
else
f = -n;
return f;
}
int ludcmp_test( int n, double eps )
{
int i, j, k;
double w, y[ 100 ];
if ( n > 99 || eps <= 0 )
return ( 999 );
_Pragma( "loopbound min 5 max 5" )
for ( i = 0; i < n; i++ ) {
if ( ludcmp_fabs( ludcmp_a[ i ][ i ] ) <= eps )
return ( 1 );
_Pragma( "loopbound min 1 max 5" )
for ( j = i + 1; j <= n; j++ ) {
w = ludcmp_a[ j ][ i ];
if ( i != 0 ) {
_Pragma( "loopbound min 1 max 4" )
for ( k = 0; k < i; k++ )
w -= ludcmp_a[ j ][ k ] * ludcmp_a[ k ][ i ];
}
ludcmp_a[ j ][ i ] = w / ludcmp_a[ i ][ i ];
}
_Pragma( "loopbound min 1 max 5" )
for ( j = i + 1; j <= n; j++ ) {
w = ludcmp_a[ i + 1 ][ j ];
_Pragma( "loopbound min 1 max 5" )
for ( k = 0; k <= i; k++ )
w -= ludcmp_a[ i + 1 ][ k ] * ludcmp_a[ k ][ j ];
ludcmp_a[ i + 1 ][ j ] = w;
}
}
y[ 0 ] = ludcmp_b[ 0 ];
_Pragma( "loopbound min 5 max 5" )
for ( i = 1; i <= n; i++ ) {
w = ludcmp_b[ i ];
_Pragma( "loopbound min 1 max 5" )
for ( j = 0; j < i; j++ )
w -= ludcmp_a[ i ][ j ] * y[ j ];
y[ i ] = w;
}
ludcmp_x[ n ] = y[ n ] / ludcmp_a[ n ][ n ];
_Pragma( "loopbound min 5 max 5" )
for ( i = n - 1; i >= 0; i-- ) {
w = y[ i ];
_Pragma( "loopbound min 1 max 5" )
for ( j = i + 1; j <= n; j++ )
w -= ludcmp_a[ i ][ j ] * ludcmp_x[ j ];
ludcmp_x[ i ] = w / ludcmp_a[ i ][ i ];
}
return ( 0 );
}
void _Pragma( "entrypoint" ) ludcmp_main( void )
{
int n = 5;
double eps = 1;
ludcmp_chkerr = ludcmp_test( n, eps );
}
int main( void )
{
ludcmp_init();
ludcmp_main();
return ( ludcmp_return() );
}

View File

@ -0,0 +1,63 @@
File: matrix1.c
Original provenience: DSP-Stone benchmark suite, matrix1_fixed
http://www.ice.rwth-aachen.de/research/tools-projects/entry/detail/dspstone
2016-02-09:
- Added TACLeBench header
- Redefined function pin_down() as returning void since the return value is
insignificant
- Function pin_down() fills matrices A and B with 1s and matrix C with 0s.
First call to it is kept as the initilization part, but the second call at
the end of main function seems unnecessary, hence removed
- Added a new main function that first calls init function then the old main
function sans init
- Redefined matrices A, B and C as global variables so that they are not local
to new main function and can be initialized and processed with diferent
functions
- Annotated matrix1_fixed_main() as the entry point of the analysis
- Removed unnecessary dereference operator from '*p_c++;' (line TODO:XXX) to
remove compiler warning 'value computed not used'
- Removed seemingly unnecessary empty lines
- Moved around all the following so that they are in the given order just after
the header
- macro definitions
- forward declaration of functions
- declaration of global variables
- initialization functions
- main functions
- 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
2016-04-26:
- Renamed benchmark: matrix1_fixed -> matrix1
- Changed prefix in function/variable names (matrix1_fixed -> matrix1)
- Removed macro definition (#define TYPE int) and changed 'TYPE' into 'int'
- Removed macro definition (#define STORAGE_CLASS register) and changed 'STORAGE_CLASS'
into 'register'
- Declared initialisation value as volatile
- Added matrix1_return() function and call to this function from matrix1_main()
2016-10-08
- Added prefix to global matrix names: A -> matrix1_A, etc.
2017-08-03
- Fixed off-by-one error in loop header

View File

@ -0,0 +1,169 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: matrix1
Author: Juan Martinez Velarde
Function: Generic matrix - multiply benchmarking
This program performs a matrix multiplication of the form C=AB,
where A and B are two dimensional matrices of arbitrary dimension.
The only restriction os that the inner dimension of the arrays must
be greater than 1.
A[ X x Y ] * B[ Y x Z ] = C[ X x Z ]
|a11 a12 .. a1y|
|a21 a22 .. a2y|
matrix A[ X x Y ]= |.. .. .. .. |
|a(x-1)1 a(x-1)2 .. a(x-1)y|
|ax1 ax2 .. axy|
|b11 b12 .. b1z|
|b21 b22 .. b2z|
matrix B[ Y x Z ]= |.. .. .. .. |
|b(y-1)1 b(y-1)2 .. b(y-1)z|
|by1 by2 .. byz|
|c11 c12 .. c1z|
|c21 c22 .. c2z|
matrix C[ X x Z ]= |.. .. .. .. |
|c(x-1)1 c(x-1)2 .. c(x-1)z|
|cx1 cx2 .. cxz|
matrix elements are stored as
A[ X x Y ] = { a11, a12, .. , a1y,
a21, a22, .. , a2y,
...,
ax1, ax2, .. , axy}
B[ Y x Z ] = { b11, b21, .., b(y-1)1, by1, b12, b22, .. , b(y-1)z, byz }
C[ X x Z ] = { c11, c21, .. , c(x-1)1, cx1, c12, c22, .. ,c(x-1)z, cxz }
Source: DSP-Stone
http://www.ice.rwth-aachen.de/research/tools-projects/entry/detail/dspstone
Changes: no major functional changes
License: may be used, modified, and re-distributed freely
*/
/*
Macro definitions
*/
#define X 10 /* first dimension of array A */
#define Y 10 /* second dimension of array A, first dimension of array B */
#define Z 10 /* second dimension of array B */
/*
Forward declaration of functions
*/
void matrix1_pin_down( int A[ ], int B[ ], int C[ ] );
void matrix1_init( void );
void matrix1_main( void );
int main( void );
/*
Declaration of global variables
*/
int matrix1_A[ X * Y ];
int matrix1_B[ Y * Z ];
int matrix1_C[ X * Z ];
/*
Initialization functions
*/
void matrix1_pin_down( int A[ ], int B[ ], int C[ ] )
{
int i;
volatile int x = 1;
_Pragma( "loopbound min 100 max 100" )
for ( i = 0 ; i < X * Y; i++ )
A[ i ] = x ;
_Pragma( "loopbound min 100 max 100" )
for ( i = 0 ; i < Y * Z ; i++ )
B[ i ] = x ;
_Pragma( "loopbound min 100 max 100" )
for ( i = 0 ; i < X * Z ; i++ )
C[ i ] = 0 ;
}
void matrix1_init( void )
{
matrix1_pin_down( &matrix1_A[ 0 ], &matrix1_B[ 0 ], &matrix1_C[ 0 ] );
}
/*
Return function
*/
int matrix1_return( void )
{
int i;
int checksum = 0;
_Pragma( "loopbound min 100 max 100" )
for ( i = 0; i < X * Z; i++ )
checksum += matrix1_C[ i ];
return ( checksum == 1000 ? 0 : -1 );
}
/*
Main functions
*/
void _Pragma ( "entrypoint" ) matrix1_main( void )
{
register int *p_a = &matrix1_A[ 0 ];
register int *p_b = &matrix1_B[ 0 ];
register int *p_c = &matrix1_C[ 0 ];
register int f, i, k;
_Pragma( "loopbound min 10 max 10" )
for ( k = 0; k < Z; k++ ) {
p_a = &matrix1_A[ 0 ]; /* point to the beginning of array A */
_Pragma( "loopbound min 10 max 10" )
for ( i = 0; i < X; i++ ) {
p_b = &matrix1_B[ k * Y ]; /* take next column */
*p_c = 0;
_Pragma( "loopbound min 10 max 10" )
for ( f = 0; f < Y; f++ ) /* do multiply */
*p_c += *p_a++ * *p_b++;
p_c++;
}
}
}
int main( void )
{
matrix1_init();
matrix1_main();
return matrix1_return();
}

View File

@ -0,0 +1,17 @@
File: md5.c
Original provenience: RSA Data Security, Inc.
Original w O3L 26823249
2017-04-18:
- Annotated md5_main as entry-point for timing analysis
2016-04-26:
- Added generic TACLeBench header
2016-04-27:
- renaming of functions and variables
- removed static form functions and global variables
2016-05-19
- Applied Wolfgang's patch to increase context->state to avoid
wrong indexing in encode that is called for 16 elements.
2017-06-27
- Introduce md5_return function and update type signature of md5_main.

View File

@ -0,0 +1,632 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: md5.c
Author: unknown
Function: MD5 cryptographic hash function (see also RFC 1321).
Source: RSA Data Security, Inc., MD5 message-digest algorithm
Original name: md5c.c
Changes: no major functional changes, inlined include files
License: see below
*/
// Description: This is the MD5 algorithm comming form the Diffie-Hellman
// application in the Netbench benchmark suite
#define RANDOM_BYTES_NEEDED 256
// Here, it can be defined how many keys should be exchanged
#define EXCHANGEKEYS 10
////////////////////////// md5c.c /////////////////////
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
//////// global.h ///////////////
//#include "global.h"
/* GLOBAL.H - RSAREF types and constants */
/* Copyright (C) RSA Laboratories, a division of RSA Data Security,
Inc., created 1991. All rights reserved.
*/
#ifndef _GLOBAL_H_
#define _GLOBAL_H_ 1
/* PROTOTYPES should be set to one if and only if the compiler supports
function argument prototyping.
The following makes PROTOTYPES default to 1 if it has not already been
defined as 0 with C compiler flags.
*/
#ifndef PROTOTYPES
#define PROTOTYPES 1
#endif
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT2 defines a two byte word */
typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */
typedef unsigned long int UINT4;
#ifndef NULL_PTR
#define NULL_PTR ((POINTER)0)
#endif
#ifndef UNUSED_ARG
#define UNUSED_ARG(x) x = *(&x);
#endif
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
returns an empty list.
*/
#if PROTOTYPES
#define PROTO_LIST(list) list
#else
#define PROTO_LIST(list) ()
#endif
#endif /* end _GLOBAL_H_ */
//////// end global.h ///////////////
///////////// md5.h //////////////
//#include "md5.h"
/* MD5.H - header file for MD5C.C
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#ifndef _MD5_H_
#define _MD5_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/* MD5 context. */
typedef struct {
UINT4 state[ 16 ]; /* state (ABCD) */
UINT4 count[ 2 ]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[ 64 ]; /* input buffer */
} MD5_CTX;
#ifdef __cplusplus
}
#endif
#endif
/////////// end md5.h /////////
/* Constants for MD5Transform routine.
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
/* Random structure.
*/
typedef struct {
unsigned int bytesNeeded;
unsigned char state[ 16 ];
unsigned int outputAvailable;
unsigned char output[ 16 ];
} R_RANDOM_STRUCT;
void md5_orig_init PROTO_LIST ( ( MD5_CTX * ) );
void md5_update PROTO_LIST ( ( MD5_CTX *, unsigned char *, unsigned int ) );
void md5_final PROTO_LIST ( ( unsigned char [ 64 ], MD5_CTX * ) );
void md5_memset PROTO_LIST ( ( POINTER, int, unsigned int ) );
void md5_transform PROTO_LIST ( ( UINT4 [ 4 ], unsigned char [ 64 ] ) );
void md5_encode PROTO_LIST ( ( unsigned char *, UINT4 *, int ) );
void md5_decode PROTO_LIST ( ( UINT4 *, unsigned char *, unsigned int ) );
void md5_memcpy PROTO_LIST ( ( POINTER, POINTER, unsigned int ) );
void md5_R_memset ( POINTER output, int value, unsigned int len );
void md5_memset_x( unsigned char *ptr, int value, unsigned long len );
int md5_R_RandomInit ( R_RANDOM_STRUCT *randomStruct );
int md5_R_RandomUpdate ( R_RANDOM_STRUCT *randomStruct, unsigned char *block,
unsigned int blockLen );
void md5_InitRandomStruct ( R_RANDOM_STRUCT *randomStruct );
int md5_R_GetRandomBytesNeeded ( unsigned int *bytesNeeded,
R_RANDOM_STRUCT *randomStruct );
void md5_main( void );
void md5_init( void );
int md5_return( void );
int md5_bytesNeeded;
int main( void );
unsigned char md5_PADDING[ 64 ] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
void md5_orig_init ( MD5_CTX
*context ) /* context */
{
context->count[ 0 ] = context->count[ 1 ] = 0;
/* Load magic initialization constants.
*/
context->state[ 0 ] = 0x67452301;
context->state[ 1 ] = 0xefcdab89;
context->state[ 2 ] = 0x98badcfe;
context->state[ 3 ] = 0x10325476;
context->state[ 4 ] = 0x0;
context->state[ 5 ] = 0x0;
context->state[ 6 ] = 0x0;
context->state[ 7 ] = 0x0;
context->state[ 8 ] = 0x0;
context->state[ 9 ] = 0x0;
context->state[ 10 ] = 0x0;
context->state[ 11 ] = 0x0;
context->state[ 12 ] = 0x0;
context->state[ 13 ] = 0x0;
context->state[ 14 ] = 0x0;
context->state[ 15 ] = 0x0;
}
/* MD5 block update operation. Continues an MD5 message-digest
operation, processing another message block, and updating the
context.
*/
void md5_update ( MD5_CTX *context, unsigned char *input,
unsigned int inputLen )
//MD5_CTX *context; /* context */
//unsigned char *input; /* input block */
//unsigned int inputLen; /* length of input block */
{
unsigned int i, index, partLen;
/* Compute number of bytes mod 64 */
index = ( unsigned int )( ( context->count[ 0 ] >> 3 ) & 0x3F );
/* Update number of bits */
if ( ( context->count[ 0 ] += ( ( UINT4 )inputLen << 3 ) )
< ( ( UINT4 )inputLen << 3 ) )
context->count[ 1 ]++;
context->count[ 1 ] += ( ( UINT4 )inputLen >> 29 );
partLen = 64 - index;
/* Transform as many times as possible.
*/
if ( inputLen >= partLen ) {
md5_memcpy ( ( POINTER )&context->buffer[ index ], ( POINTER )input, partLen );
md5_transform ( context->state, context->buffer );
_Pragma( "loopbound min 0 max 0" )
for ( i = partLen; i + 63 < inputLen; i += 64 )
md5_transform ( context->state, &input[ i ] );
index = 0;
} else
i = 0;
/* Buffer remaining input */
md5_memcpy ( ( POINTER )&context->buffer[ index ], ( POINTER )&input[ i ],
inputLen - i );
}
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
void md5_final ( unsigned char digest[ 64 ], MD5_CTX *context )
//unsigned char digest[ 16 ]; /* message digest */
//MD5_CTX *context; /* context */
{
unsigned char bits[ 8 ];
unsigned int index, padLen;
/* Save number of bits */
md5_encode ( bits, context->count, 8 );
/* Pad out to 56 mod 64.
*/
index = ( unsigned int )( ( context->count[ 0 ] >> 3 ) & 0x3f );
padLen = ( index < 56 ) ? ( 56 - index ) : ( 120 - index );
md5_update ( context, md5_PADDING, padLen );
/* Append length (before padding) */
md5_update ( context, bits, 8 );
/* Store state in digest */
md5_encode ( digest, context->state, 64 );
/* Zeroize sensitive information.
*/
md5_memset ( ( POINTER )context, 0, sizeof ( *context ) );
}
/* Note: Replace "for loop" with standard memset if possible.
*/
void md5_memset ( POINTER output, int value, unsigned int len )
{
unsigned int i;
_Pragma( "loopbound min 128 max 208" )
for ( i = 0; i < len; i++ )
( ( char * )output )[ i ] = ( char )value;
}
/* MD5 basic transformation. Transforms state based on block.
*/
void md5_transform ( UINT4 state[ 4 ], unsigned char block[ 64 ] )
{
UINT4 a = state[ 0 ], b = state[ 1 ], c = state[ 2 ], d = state[ 3 ], x[ 16 ];
md5_decode ( x, block, 64 );
/* Round 1 */
FF ( a, b, c, d, x[ 0 ], S11, 0xd76aa478 ); /* 1 */
FF ( d, a, b, c, x[ 1 ], S12, 0xe8c7b756 ); /* 2 */
FF ( c, d, a, b, x[ 2 ], S13, 0x242070db ); /* 3 */
FF ( b, c, d, a, x[ 3 ], S14, 0xc1bdceee ); /* 4 */
FF ( a, b, c, d, x[ 4 ], S11, 0xf57c0faf ); /* 5 */
FF ( d, a, b, c, x[ 5 ], S12, 0x4787c62a ); /* 6 */
FF ( c, d, a, b, x[ 6 ], S13, 0xa8304613 ); /* 7 */
FF ( b, c, d, a, x[ 7 ], S14, 0xfd469501 ); /* 8 */
FF ( a, b, c, d, x[ 8 ], S11, 0x698098d8 ); /* 9 */
FF ( d, a, b, c, x[ 9 ], S12, 0x8b44f7af ); /* 10 */
FF ( c, d, a, b, x[ 10 ], S13, 0xffff5bb1 ); /* 11 */
FF ( b, c, d, a, x[ 11 ], S14, 0x895cd7be ); /* 12 */
FF ( a, b, c, d, x[ 12 ], S11, 0x6b901122 ); /* 13 */
FF ( d, a, b, c, x[ 13 ], S12, 0xfd987193 ); /* 14 */
FF ( c, d, a, b, x[ 14 ], S13, 0xa679438e ); /* 15 */
FF ( b, c, d, a, x[ 15 ], S14, 0x49b40821 ); /* 16 */
/* Round 2 */
GG ( a, b, c, d, x[ 1 ], S21, 0xf61e2562 ); /* 17 */
GG ( d, a, b, c, x[ 6 ], S22, 0xc040b340 ); /* 18 */
GG ( c, d, a, b, x[ 11 ], S23, 0x265e5a51 ); /* 19 */
GG ( b, c, d, a, x[ 0 ], S24, 0xe9b6c7aa ); /* 20 */
GG ( a, b, c, d, x[ 5 ], S21, 0xd62f105d ); /* 21 */
GG ( d, a, b, c, x[ 10 ], S22, 0x2441453 ); /* 22 */
GG ( c, d, a, b, x[ 15 ], S23, 0xd8a1e681 ); /* 23 */
GG ( b, c, d, a, x[ 4 ], S24, 0xe7d3fbc8 ); /* 24 */
GG ( a, b, c, d, x[ 9 ], S21, 0x21e1cde6 ); /* 25 */
GG ( d, a, b, c, x[ 14 ], S22, 0xc33707d6 ); /* 26 */
GG ( c, d, a, b, x[ 3 ], S23, 0xf4d50d87 ); /* 27 */
GG ( b, c, d, a, x[ 8 ], S24, 0x455a14ed ); /* 28 */
GG ( a, b, c, d, x[ 13 ], S21, 0xa9e3e905 ); /* 29 */
GG ( d, a, b, c, x[ 2 ], S22, 0xfcefa3f8 ); /* 30 */
GG ( c, d, a, b, x[ 7 ], S23, 0x676f02d9 ); /* 31 */
GG ( b, c, d, a, x[ 12 ], S24, 0x8d2a4c8a ); /* 32 */
/* Round 3 */
HH ( a, b, c, d, x[ 5 ], S31, 0xfffa3942 ); /* 33 */
HH ( d, a, b, c, x[ 8 ], S32, 0x8771f681 ); /* 34 */
HH ( c, d, a, b, x[ 11 ], S33, 0x6d9d6122 ); /* 35 */
HH ( b, c, d, a, x[ 14 ], S34, 0xfde5380c ); /* 36 */
HH ( a, b, c, d, x[ 1 ], S31, 0xa4beea44 ); /* 37 */
HH ( d, a, b, c, x[ 4 ], S32, 0x4bdecfa9 ); /* 38 */
HH ( c, d, a, b, x[ 7 ], S33, 0xf6bb4b60 ); /* 39 */
HH ( b, c, d, a, x[ 10 ], S34, 0xbebfbc70 ); /* 40 */
HH ( a, b, c, d, x[ 13 ], S31, 0x289b7ec6 ); /* 41 */
HH ( d, a, b, c, x[ 0 ], S32, 0xeaa127fa ); /* 42 */
HH ( c, d, a, b, x[ 3 ], S33, 0xd4ef3085 ); /* 43 */
HH ( b, c, d, a, x[ 6 ], S34, 0x4881d05 ); /* 44 */
HH ( a, b, c, d, x[ 9 ], S31, 0xd9d4d039 ); /* 45 */
HH ( d, a, b, c, x[ 12 ], S32, 0xe6db99e5 ); /* 46 */
HH ( c, d, a, b, x[ 15 ], S33, 0x1fa27cf8 ); /* 47 */
HH ( b, c, d, a, x[ 2 ], S34, 0xc4ac5665 ); /* 48 */
/* Round 4 */
II ( a, b, c, d, x[ 0 ], S41, 0xf4292244 ); /* 49 */
II ( d, a, b, c, x[ 7 ], S42, 0x432aff97 ); /* 50 */
II ( c, d, a, b, x[ 14 ], S43, 0xab9423a7 ); /* 51 */
II ( b, c, d, a, x[ 5 ], S44, 0xfc93a039 ); /* 52 */
II ( a, b, c, d, x[ 12 ], S41, 0x655b59c3 ); /* 53 */
II ( d, a, b, c, x[ 3 ], S42, 0x8f0ccc92 ); /* 54 */
II ( c, d, a, b, x[ 10 ], S43, 0xffeff47d ); /* 55 */
II ( b, c, d, a, x[ 1 ], S44, 0x85845dd1 ); /* 56 */
II ( a, b, c, d, x[ 8 ], S41, 0x6fa87e4f ); /* 57 */
II ( d, a, b, c, x[ 15 ], S42, 0xfe2ce6e0 ); /* 58 */
II ( c, d, a, b, x[ 6 ], S43, 0xa3014314 ); /* 59 */
II ( b, c, d, a, x[ 13 ], S44, 0x4e0811a1 ); /* 60 */
II ( a, b, c, d, x[ 4 ], S41, 0xf7537e82 ); /* 61 */
II ( d, a, b, c, x[ 11 ], S42, 0xbd3af235 ); /* 62 */
II ( c, d, a, b, x[ 2 ], S43, 0x2ad7d2bb ); /* 63 */
II ( b, c, d, a, x[ 9 ], S44, 0xeb86d391 ); /* 64 */
state[ 0 ] += a;
state[ 1 ] += b;
state[ 2 ] += c;
state[ 3 ] += d;
/* Zeroize sensitive information.
*/
md5_memset ( ( POINTER )x, 0, sizeof ( x ) );
}
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
a multiple of 4.
*/
void md5_encode ( unsigned char *output, UINT4 *input, int len )
{
int i = 0,
j;
_Pragma( "loopbound min 2 max 16" )
for ( j = 0; j < len; j += 4 ) {
output[ j ] = ( unsigned char )( input[ i ] & 0xff );
output[ j + 1 ] = ( unsigned char )( ( input[ i ] >> 8 ) & 0xff );
output[ j + 2 ] = ( unsigned char )( ( input[ i ] >> 16 ) & 0xff );
output[ j + 3 ] = ( unsigned char )( ( input[ i ] >> 24 ) & 0xff );
++i;
}
}
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
a multiple of 4.
*/
void md5_decode ( UINT4 *output, unsigned char *input, unsigned int len )
{
unsigned int i, j;
_Pragma( "loopbound min 16 max 16" )
for ( i = 0, j = 0; j < len; i++, j += 4 ) {
output[ i ] = ( ( UINT4 )input[ j ] ) | ( ( ( UINT4 )input[ j + 1 ] ) << 8 ) |
( ( ( UINT4 )input[ j + 2 ] ) << 16 ) | ( ( ( UINT4 )input[ j + 3 ] ) << 24 );
}
}
/* Note: Replace "for loop" with standard memcpy if possible.
*/
void md5_memcpy ( POINTER output, POINTER input, unsigned int len )
{
unsigned int i;
_Pragma( "loopbound min 0 max 55" )
for ( i = 0; i < len; i++ )
output[ i ] = input[ i ];
}
/////////////////// end md5c.c ////////////////////////
void md5_R_memset ( POINTER output, int value, unsigned int len )
//POINTER output; /* output block */
//int value; /* value */
//unsigned int len; /* length of block */
{
if ( len )
md5_memset_x ( output, value, len );
}
// Basic implementation of C's memset
void md5_memset_x( unsigned char *ptr, int value, unsigned long len )
{
_Pragma( "loopbound min 16 max 64" )
while ( len-- )
*ptr++ = value;
return;
}
int md5_R_RandomInit ( R_RANDOM_STRUCT *randomStruct )
//R_RANDOM_STRUCT *randomStruct; /* new random structure */
{
randomStruct->bytesNeeded = RANDOM_BYTES_NEEDED;
md5_R_memset ( ( POINTER )randomStruct->state, 0,
sizeof ( randomStruct->state ) );
randomStruct->outputAvailable = 0;
return ( 0 );
}
int md5_R_RandomUpdate ( R_RANDOM_STRUCT *randomStruct, unsigned char *block,
unsigned int blockLen )
//R_RANDOM_STRUCT *randomStruct; /* random structure */
//unsigned char *block; /* block of values to mix in */
//unsigned int blockLen; /* length of block */
{
MD5_CTX context;
unsigned char digest[ 64 ];
unsigned int i, x;
md5_orig_init ( &context );
md5_update ( &context, block, blockLen );
md5_final ( digest, &context );
/* add digest to state */
x = 0;
_Pragma( "loopbound min 16 max 16" )
for ( i = 0; i < 16; i++ ) {
x += randomStruct->state[ 15 - i ] + digest[ 15 - i ];
randomStruct->state[ 15 - i ] = ( unsigned char )x;
x >>= 8;
}
if ( randomStruct->bytesNeeded < blockLen )
randomStruct->bytesNeeded = 0;
else
randomStruct->bytesNeeded -= blockLen;
/* Zeroize sensitive information.
*/
md5_R_memset ( ( POINTER )digest, 0, sizeof ( digest ) );
return ( 0 );
}
/* Initialize the random structure with all zero seed bytes for test purposes.
NOTE that this will cause the output of the "random" process to be
the same every time. To produce random bytes, the random struct
needs random seeds!
*/
void md5_InitRandomStruct ( R_RANDOM_STRUCT *randomStruct )
{
static unsigned char seedByte = 0;
unsigned int bytesNeeded;
md5_R_RandomInit ( randomStruct );
/* Initialize with all zero seed bytes, which will not yield an actual
random number output.
*/
_Pragma( "loopbound min 256 max 256" )
while ( 1 ) {
md5_R_GetRandomBytesNeeded ( &bytesNeeded, randomStruct );
if ( bytesNeeded == 0 )
break;
md5_R_RandomUpdate ( randomStruct, &seedByte, 1 );
}
}
int md5_R_GetRandomBytesNeeded ( unsigned int *bytesNeeded,
R_RANDOM_STRUCT *randomStruct )
//unsigned int *bytesNeeded; /* number of mix-in bytes needed */
//R_RANDOM_STRUCT *randomStruct; /* random structure */
{
*bytesNeeded = randomStruct->bytesNeeded;
return ( 0 );
}
void md5_init( void )
{
// no initialisation needed
}
int md5_return( void )
{
return md5_bytesNeeded;
}
void _Pragma( "entrypoint" ) md5_main( void )
{
R_RANDOM_STRUCT randomStruct;
R_RANDOM_STRUCT randomStruct2;
/* We first generate parameters, and then do some key exchange each followed by a key computation...*/
int keys_exchanged = 0;
md5_InitRandomStruct ( &randomStruct );
_Pragma( "loopbound min 10 max 10" )
while ( keys_exchanged != EXCHANGEKEYS ) {
keys_exchanged++;
md5_InitRandomStruct ( &randomStruct2 );
}
md5_bytesNeeded = randomStruct.bytesNeeded + randomStruct2.bytesNeeded;
}
// int main( void )
// {
// md5_init();
// md5_main();
// // printf("%d\n", ret);
// return md5_return();
// }

View File

@ -0,0 +1,38 @@
File: minver.c
Original provenience: SNU-RT Benchmark Suite for Worst Case Timing Analysis
2016-02-26:
- Added TACLeBench header to line 1
- Rename global variable a to minver_a
- Rename global variable b to minver_b
- Rename global variable c to minver_c
- Rename global variable aa to minver_aa
- Rename global variable a_i to minver_a_i
- Rename global variable e to minver_e
- Rename global variable det to minver_det
- Renamed function minver to minver_minver
- Renamed function mmul to minver_mmul
- Renamed function fabs to minver_fabs
- Renamed function main to minver_main
- Created new function main, calling minver_init, minver_main and
returning minver_return
- Reordered functions in source code: initialization- and
return-value-related functions first, followed by algorithm core
functions, followed by main functions
- Applied code formatting with astyle as in the example
2016-03-09
- Removed static keyword from global minver_a array.
2016-05-23
- Added addition of volatile to test data to avoid constant propagation
- Added check_sum and comparison with expected value
2016-05-25
- Initialized variable r in function minver_minver()
- Removed parameter cols of minver_minver() function
- Renamed parameter rows of minver_minver() to side
2017-07-04
- Removed self-assignment for WCC's flow-fact manager to avoid clangs
self-assign warning.

View File

@ -0,0 +1,261 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: minver
Author: Sung-Soo Lim
Function: Matrix inversion for 3x3 floating point matrix.
Source: SNU-RT Benchmark Suite, via MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/minver/minver.c
Changes: a brief summary of major functional changes (not formatting)
License: may be used, modified, and re-distributed freely, but
the SNU-RT Benchmark Suite must be acknowledged
*/
/*
This program is derived from the SNU-RT Benchmark Suite for Worst
Case Timing Analysis by Sung-Soo Lim
Original source: Turbo C Programming for Engineering by Hyun Soo Ahn
*/
/*
Forward declaration of functions
*/
int minver_minver( int side, double eps );
int minver_mmul( int row_a, int col_a, int row_b, int col_b );
double minver_fabs( double n );
void minver_init();
int minver_return();
void minver_main();
int main( void );
/*
Declaration of global variables
*/
double minver_a[ 3 ][ 3 ] = {
{3.0, -6.0, 7.0},
{9.0, 0.0, -5.0},
{5.0, -8.0, 6.0},
};
double minver_b[ 3 ][ 3 ];
double minver_c[ 3 ][ 3 ];
double minver_aa[ 3 ][ 3 ];
double minver_a_i[ 3 ][ 3 ];
double minver_det;
/*
Arithmetic math functions
*/
double minver_fabs( double n )
{
double f;
if ( n >= 0 )
f = n;
else
f = -n;
return f;
}
int minver_mmul( int row_a, int col_a, int row_b, int col_b )
{
int i, j, k, row_c, col_c;
double w;
row_c = row_a;
col_c = col_b;
if ( row_c < 1 || row_b < 1 || col_c < 1 || col_a != row_b )
return ( 999 );
_Pragma( "loopbound min 3 max 3" )
for ( i = 0; i < row_c; i++ ) {
_Pragma( "loopbound min 3 max 3" )
for ( j = 0; j < col_c; j++ ) {
w = 0.0;
_Pragma( "loopbound min 3 max 3" )
for ( k = 0; k < row_b; k++ )
w += minver_a[ i ][ k ] * minver_b[ k ][ j ];
minver_c[ i ][ j ] = w;
}
}
return ( 0 );
}
int minver_minver( int side, double eps )
{
int work[ 500 ], i, j, k, iw;
int r = 0;
double w = 0, wmax, pivot, api, w1;
if ( side < 2 || side > 500 || eps <= 0.0 )
return ( 999 );
w1 = 1.0;
_Pragma( "loopbound min 3 max 3" )
for ( i = 0; i < side; i++ )
work[ i ] = i;
_Pragma( "loopbound min 3 max 3" )
for ( k = 0; k < side; k++ ) {
wmax = 0.0;
_Pragma( "loopbound min 1 max 3" )
for ( i = k; i < side; i++ ) {
w = minver_fabs( minver_a[ i ][ k ] );
if ( w > wmax ) {
wmax = w;
r = i;
}
}
pivot = minver_a[ r ][ k ];
api = minver_fabs( pivot );
if ( api <= eps ) {
minver_det = w1;
return ( 1 );
}
w1 *= pivot;
if ( r != k ) {
w1 = -w;
iw = work[ k ];
work[ k ] = work[ r ];
work[ r ] = iw;
_Pragma( "loopbound min 3 max 3" )
for ( j = 0; j < side; j++ ) {
w = minver_a[ k ][ j ];
minver_a[ k ][ j ] = minver_a[ r ][ j ];
minver_a[ r ][ j ] = w;
}
}
_Pragma( "loopbound min 3 max 3" )
for ( i = 0; i < side; i++ )
minver_a[ k ][ i ] /= pivot;
_Pragma( "loopbound min 3 max 3" )
for ( i = 0; i < side; i++ ) {
if ( i != k ) {
w = minver_a[ i ][ k ];
if ( w != 0.0 ) {
_Pragma( "loopbound min 3 max 3" )
for ( j = 0; j < side; j++ ) {
if ( j != k ) minver_a[ i ][ j ] -= w * minver_a[ k ][ j ];
}
minver_a[ i ][ k ] = -w / pivot;
}
}
}
minver_a[ k ][ k ] = 1.0 / pivot;
}
_Pragma( "loopbound min 3 max 3" )
for ( i = 0; i < side; ) {
_Pragma( "loopbound min 1 max 3" )
while ( 1 ) {
k = work[ i ];
if ( k == i ) break;
iw = work[ k ];
work[ k ] = work[ i ];
work[ i ] = iw;
_Pragma( "loopbound min 3 max 3" )
for ( j = 0; j < side; j++ ) {
w = minver_a [k ][ i ];
minver_a[ k ][ i ] = minver_a[ k ][ k ];
minver_a[ k ][ k ] = w;
}
}
i++;
}
minver_det = w1;
return ( 0 );
}
/*
Initialization- and return-value-related functions
*/
void minver_init()
{
int i, j;
volatile int x = 0;
_Pragma( "loopbound min 3 max 3" )
for ( i = 0; i < 3; i++ ) {
_Pragma( "loopbound min 3 max 3" )
for ( j = 0; j < 3; j++ )
minver_a[ i ][ j ] += x;
}
}
int minver_return()
{
int i, j;
double check_sum = 0;
_Pragma( "loopbound min 3 max 3" )
for ( i = 0; i < 3; i++ ) {
_Pragma( "loopbound min 3 max 3" )
for ( j = 0; j < 3; j++ )
check_sum += minver_a_i[ i ][ j ];
}
/* Avoid double comparison */
return ( int )( check_sum * 100 ) != 48;
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) minver_main()
{
int i, j;
double eps;
eps = 1.0e-6;
_Pragma( "loopbound min 3 max 3" )
for ( i = 0; i < 3; i++ ) {
_Pragma( "loopbound min 3 max 3" )
for ( j = 0; j < 3; j++ )
minver_aa[ i ][ j ] = minver_a[ i ][ j ];
}
minver_minver( 3, eps );
_Pragma( "loopbound min 3 max 3" )
for ( i = 0; i < 3; i++ ) {
_Pragma( "loopbound min 3 max 3" )
for ( j = 0; j < 3; j++ )
minver_a_i[ i ][ j ] = minver_a[ i ][ j ];
}
minver_mmul( 3, 3, 3, 3 );
}
int main( void )
{
minver_init();
minver_main();
return ( minver_return() );
}

View File

@ -0,0 +1,96 @@
File: pm.c
Original provenience: unknown
Source: HPEC Challenge Benchmark Suite
2016-04-20:
- Fixed some compiler warnings.
- Moved main to end of file.
2016-03-15:
- Renamed preprocessor defines MIN_NOISE and LOG10 to pm_MIN_NOISE and
pm_LOG10.
- Made sure that pm_return returns value 0 upon success.
2016-01-22:
- Moved math functions pm_log10f, pm_pow10f, pm_fabs, pm_floor, pm_ceil into
own files pm_math.h and pm_libm.c.
- Moved associated static global variables pm_log_coeff and pm_pow_coeff into
file pm_libm.c.
- Renamed function pm_init_coeff to pm_math_init and moved its call out of
pm_init_data.
- Moved stdlib functions pm_memcpy and pm_memset into own files pm_string.h
and pm_stdlib.c.
- Renamed input.c to pm_input.c
2016-01-21:
- Changed pm_ceil and pm_floor such that the expression !arg is not used
anymore to resolve compiler warning "implicit conversion turns
floating-point number into integer". However, NaN and infinity are not
handled correctly.
- Cast results of pm_ceil and pm_floor to int instead of the functions
themselves to resolve compiler warning about "cast from function call of
type 'float' to non-matching type 'int'".
- Cast parameter c of pm_memset to unsigned char to resolve compiler warning
that "implicit conversion loses integer precision".
- Cast result of sizeof operator in call to pm_memset to int to resolve
compiler warnings that "implicit conversion changes signedness".
- Converted type of local variables match_index and min_MSE_index in pm_kernel,
as well as array base type of member size in pm_float_array_t from
unsigned int to int to resolve compiler warnings that "implicit conversion
changes signedness".
- Removed register storage class for local variables in pm_kernel.
2016-01-07:
- Added original name to generic TACLeBench header.
- Added forward declarations for all functions.
- Renamed function main to pm_main.
- Renamed function init to pm_init_data.
- Renamed function clean to pm_clean.
- Changed all //-style comments to /* */-style comments
- Renamed function fabs_ to pm_fabs.
- Renamed function setcoeff to pm_init_coeff.
- Renamed pow10fpm to pm_pow10f.
- Renamed log10fpm to pm_log10f.
- Renamed my_floor to pm_floor.
- Renamed my_ceil to pm_ceil.
- Renamed my_memcpy to pm_memcpy.
- Renamed my_memset to pm_memset.
- Renamed function pm to pm_kernel.
- Added function pm_init that handles the initialization of the math library
functions.
- Added function pm_return that handles the original return value of main.
- Added new function main that first calls pm_init, then pm_main and finally
returns the return value of pm_return.
- Replaced local variables pmdata, lib, patternand result in main with global
static variables pm_data, pm_lib, pm_pattern and pm_result.
- Renamed global variables init_array_1, init_array_2, init_array_3,
init_array_4, init_array_5, init_array_6, init_array_7 and init_array_8 to
pm_init_array_1, pm_init_array_2, pm_init_array_3, pm_init_array_4,
pm_init_array_5, pm_init_array_6, pm_init_array_7 and pm_init_array_8 and
made them static.
- Renamed global variables pow_coeff and log_coeff to pm_pow_coeff and
pm_log_coeff and made them static.
- Tested conformance to C90 via
clang -fsyntax-only -Weverything -Wno-unknown-pragmas -pedantic -std=c90
2016-01-06:
- Applied TACLeBench formatting rules via
astyle --options=doc/example/astylerc.txt
2015-12-08:
- Replaced comments in line 1-37 with generic TACLeBench header.
- Introduced comments to split file in sections for type definition, forward
declarations, global variables, initialization-related and
return-value-related functions, core benchmark functions, and main routine.
- Moved BSD 3-clause license comment to own file license.txt.
- Renamed global variables lib_data and pattern_data to pm_lib_data and
pm_pattern_data.
- Renamed functions read_lib and read_pattern to pm_init_lib and
pm_init_pattern.
- Removed unnecessary return statements.
- Inlined definition of types PmData and PcaCArrayFloat from PcaCArray.h.
- Renamed type PmData to pm_data_t.
- Renamed type PcaCArrayFloat to pm_float_array_t.
2007-10-18 (Rathijit Sen, Universität des Saarlandes):
- Removed dynamic alloc, file I/O.

View File

@ -0,0 +1,27 @@
Copyright (c) 2006, Massachusetts Institute of Technology
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Massachusetts Institute of Technology nor
the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,743 @@
/*
This program is part of the TACLeBench benchmark suite.
Version 2.0
Name: pm
Author: Hector Chan
MIT Lincoln Laboratory
Function: This is the ANSI C Pattern Match kernel. It finds the closest
match of a pattern from a library of patterns. The code below
serves as a reference implemenation of the pattern match kernel.
Source: HPEC Challenge Benchmark Suite, Pattern Match Kernel Benchmark
Original name: pm
Changes: See ChangeLog.txt
License: BSD 3-clause
*/
/*
Include section
*/
#include "pm_math.h"
#include "pm_string.h"
/*
Definition of types
*/
typedef struct pm_float_array_t {
float *data;
void *datav;
int size[ 3 ];
unsigned int ndims;
unsigned int rctype;
char padding[ 4 ];
} pm_float_array_t;
typedef struct pm_data_t {
float *template_profiles_db; /* the library of patterns */
float *test_profile_db; /* the test pattern */
float *template_copy; /* temporary storage for a template */
float *test_noise_db_array; /* copies of test noise in an array for
fast copy */
float *MSE_scores; /* the likelihood of the matching between a
range shift of the test pattern and the libary */
float *mag_shift_scores; /* the likelihood of the matching between a
magnitude scaling of the test pattern and the
libary */
float *minimum_MSE_score; /* the likelihood of the matching between the
test pattern and the libary */
float *all_shifted_test_db; /* contains the shiftings of the test pattern */
unsigned char *template_exceed; /* marking where a library template
exceeds twice the noise level of
the test pattern */
float *test_exceed_means; /* pixels where test pattern exceeds twice
its noise level */
float shift_ratio; /* determines the number of range shifts */
int shift_size; /* the actual number of range shifts */
int profile_size; /* the length of the pattern */
int num_templates; /* the number of library templates */
int elsize; /* the size of a single fp number */
char padding[ 4 ];
} pm_data_t;
/*
Forward declaration of functions
*/
void pm_init_lib( pm_float_array_t *lib );
void pm_init_pattern( pm_float_array_t *pattern );
void pm_init_data( pm_data_t *pmdata,
pm_float_array_t *lib,
pm_float_array_t *pattern );
void pm_clean( pm_data_t *pmdata );
void pm_main( void );
void pm_init( void );
int pm_return( void );
int pm_kernel( pm_data_t *pmdata );
/*
Declaration of global variables
*/
/* input data */
extern float pm_lib_data[ 60 ][ 64 ];
extern float pm_pattern_data[ 60 ][ 64 ];
/* some magic number */
#define pm_MIN_NOISE 1e-10f
/* main data structures used by the benchmark */
static pm_data_t pm_data;
static pm_float_array_t pm_lib;
static float *pm_lib_ptr[ 60 ];
static pm_float_array_t pm_pattern;
static float *pm_pattern_ptr[ 60 ];
static int pm_result;
/* arrays for the pm_init_data function */
static unsigned char pm_init_array_1[ 64 ];
static float pm_init_array_2[ 21 ];
static float pm_init_array_3[ 64 ];
static float pm_init_array_4[ 64 ];
static float pm_init_array_5[ 21 ];
static float pm_init_array_6[ 21 ];
static float pm_init_array_7[ 72 ];
static float pm_init_array_8[ 110 ];
/*
Initialization- and return-value-related functions
*/
void pm_init_lib( pm_float_array_t *lib )
{
int i;
volatile int do_not_optimize_away = 0;
lib->rctype = 1;
lib->ndims = 2;
lib->size[ 0 ] = 60;
lib->size[ 1 ] = 64;
lib->size[ 2 ] = 0;
_Pragma( "loopbound min 60 max 60" )
for ( i = 0; i < 60; i++ )
pm_lib_ptr[ i ] = pm_lib_data[ i ];
_Pragma( "loopbound min 60 max 60" )
for ( i = 0; i < 60; i++ )
pm_lib_ptr[ i ] += do_not_optimize_away;
lib->data = *pm_lib_ptr;
lib->datav = ( void * )pm_lib_ptr;
}
void pm_init_pattern( pm_float_array_t *pattern )
{
int i;
volatile int do_not_optimize_away = 0;
pattern->rctype = 1;
pattern->ndims = 2;
pattern->size[ 0 ] = 60;
pattern->size[ 1 ] = 64;
pattern->size[ 2 ] = 0;
_Pragma( "loopbound min 60 max 60" )
for ( i = 0; i < 60; i++ )
pm_pattern_ptr[ i ] = pm_pattern_data[ i ];
_Pragma( "loopbound min 60 max 60" )
for ( i = 0; i < 60; i++ )
pm_pattern_ptr[ i ] += do_not_optimize_away;
pattern->data = *pm_pattern_ptr;
pattern->datav = ( void * )pm_pattern_ptr;
}
void pm_init( void )
{
pm_math_init();
}
int pm_return( void )
{
return pm_result - 12;
}
/*
Core benchmark functions
*/
void _Pragma( "entrypoint" ) pm_main( void )
{
pm_init_lib( &pm_lib );
pm_init_pattern( &pm_pattern );
pm_init_data( &pm_data, &pm_lib, &pm_pattern );
pm_result = pm_kernel( &pm_data );
pm_clean( &pm_data );
}
/***********************************************************************/
/* Allocate and initailize the test pattern, the template library, and
other necessary data structure. */
/***********************************************************************/
void pm_init_data( pm_data_t *pmdata, pm_float_array_t *lib,
pm_float_array_t *pattern )
{
int elsize = sizeof( float );
float x;
/* Getting the input parameters from the PCA C array structure */
pmdata->profile_size = lib->size[ 1 ];
pmdata->num_templates = lib->size[ 0 ];
pmdata->elsize = elsize;
pmdata->shift_ratio = 3.0f;
pmdata->template_profiles_db = lib->data;
pmdata->test_profile_db = pattern->data;
/* Equivalent to shift_size = roundf((float)profile_size / shift_ratio) */
x = ( float )( pmdata->profile_size ) / pmdata->shift_ratio;
pmdata->shift_size = ( ( x - ( int )( x ) ) < 0.5f ) ?
( int )( pm_floor( x ) ) :
( int )( pm_ceil( x ) );
pmdata->template_exceed = pm_init_array_1;
pmdata->test_exceed_means = pm_init_array_2;
pmdata->template_copy = pm_init_array_3;
pmdata->test_noise_db_array = pm_init_array_4;
pmdata->MSE_scores = pm_init_array_5;
pmdata->mag_shift_scores = pm_init_array_6;
pmdata->minimum_MSE_score = pm_init_array_7;
pmdata->all_shifted_test_db = pm_init_array_8;
}
/***********************************************************************/
/* Free up memory for all structures */
/***********************************************************************/
void pm_clean( pm_data_t *pmdata )
{
pmdata->test_exceed_means = 0;
pmdata->template_exceed = 0;
pmdata->template_copy = 0;
pmdata->test_noise_db_array = 0;
pmdata->MSE_scores = 0;
pmdata->mag_shift_scores = 0;
pmdata->minimum_MSE_score = 0;
pmdata->all_shifted_test_db = 0;
}
/***********************************************************************/
/* The pattern match kernel overlays two patterns to compute the likelihood
that the two vectors match. This process is performed on a library of
patterns. */
/***********************************************************************/
int pm_kernel( pm_data_t *pmdata )
{
const int elsize = pmdata->elsize; /* size of a single fp number */
const int shift_size = pmdata->shift_size; /* number of shifting to the
left and right of the test
profile */
const int profile_size =
pmdata->profile_size; /* number of pixels in a pattern */
const int num_templates =
pmdata->num_templates; /* number of library patterns */
float *test_profile_db =
pmdata->test_profile_db; /* the test pattern */
float *template_profiles_db =
pmdata->template_profiles_db; /* the library of patterns */
float *test_noise_db_array =
pmdata->test_noise_db_array; /* the noise in the test pattern in an array
for fast copy */
float *all_shifted_test_db =
pmdata->all_shifted_test_db; /* the shifted test pattern */
int match_index; /* the index of the most likely template that matches the
test pattern */
int min_MSE_index; /* the index of the range shifts with
the lowest mean square error */
unsigned int num_template_exceed,
num_test_exceed; /* the number of pixels exceeded the test pattern
and a library template */
unsigned char mag_shift_scores_flag; /* flag that tells if the magnitude
scaling loop has been run
(existed just to save ops) */
float test_peak,
template_peak; /* the maximum pixels of the test pattern and a library
template pattern */
float template_noise; /* the noise level of a library template */
float noise_shift,
noise_shift2; /* temporary storage for calculating the mse for range shifting */
float min_MSE, match_score; /* temporary storage for finding the minimum mse */
float sumWeights_inv = 1.0f / profile_size; /* the inverse of the weights
used for calculating the mse */
/* Note: weights for the kernel would be application dependent.
They are set to 1 for our purposes */
float mag_db; /* the magnitude shifts in dB */
float power_shift,
ave_power_ratio; /* the diff of the avg shifted test profile power to
the avg template power */
float power_ratio; /* the mean power of the pixels of a template that exceeded
twice test noise */
float test_noise = ( pm_pow10f( test_profile_db[ 0 ] * 0.1f )
+ /* noise level of the test pattern */
pm_pow10f( test_profile_db[ profile_size - 1 ] * 0.1f ) ) * 0.5f;
/* since "shift_size/2" is used a lot, so we create a var to hold it */
int half_shift_size = ( int )( pm_ceil( ( float )( shift_size ) / 2.0f ) );
int template_index, current_shift; /* indices */
int patsize = profile_size * elsize; /* number of bytes of a pattern */
float *minimum_MSE_score = pmdata->minimum_MSE_score;
float *MSE_scores = pmdata->MSE_scores;
float *mag_shift_scores = pmdata->mag_shift_scores;
float test_noise_db = ( test_noise == 0.0f ) ? -100.0f : 10.0f *
pm_log10f( pm_fabs( test_noise ) ); /* test noise in dB */
float test_noise_db_plus_3 = test_noise_db + 3.0f; /* twice test noise in the
power domain, approximately +3dB */
float *template_copy = pmdata->template_copy;
unsigned char *template_exceed = pmdata->template_exceed;
float *test_exceed_means = pmdata->test_exceed_means;
int i, j; /* indices */
float tmp1; /* temporary storage for calculating the mse for range shifting */
float sum_exceed; /* the sum of the test pattern pixels exceeded twice
test noise */
float template_exceed_mean = 0; /* the mean of a template pattern pixels
exceeded twice test noise */
float weighted_MSE; /* temporary storage for computing the weighted MSE */
/* These pointers are solely used for fast memory access */
float *cur_tp, *fptr, *fptr2, *fptr3, *endptr;
unsigned char *bptr;
/* Having an array of test noise for fast copying of noise returns */
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++ )
test_noise_db_array[ i ] = test_noise_db;
/* Finding the maximum pixels of the test pattern */
fptr = test_profile_db;
test_peak = *fptr++;
_Pragma( "loopbound min 63 max 63" )
for ( i = 1; i < profile_size; i++, fptr++ ) {
if ( test_peak < *fptr )
test_peak = *fptr;
}
/* Paddle array for all the possible range shifts. Essentially, we are
performing the following:
Adding these two portions to the beginning and end of the test pattern
| |
V V
|<------>| |<------>|
__ __
| | | |
| |___| |
| |
_________| |_________ <- test noise in dB domain
--------------------------------------- <- zero
|<--------------->|
original test pattern
The all_shifted_test_db will be accessed in a sliding window manner.
*/
pm_memcpy( ( void * ) all_shifted_test_db, ( void * ) test_noise_db_array,
elsize * half_shift_size );
pm_memcpy( ( void * ) ( all_shifted_test_db + half_shift_size ),
( void * ) test_profile_db, elsize * profile_size );
pm_memcpy( ( void * ) ( all_shifted_test_db + half_shift_size + profile_size ),
( void * ) test_noise_db_array, elsize * half_shift_size );
/* Set the pixels to test noise in dB domain if pixel is less than test
noise in dB */
fptr = all_shifted_test_db + half_shift_size;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++, fptr++ ) {
if ( *fptr < test_noise_db )
*fptr = test_noise_db;
}
/* Calculating the mean of the pixels that exceeded twice test noise for each
possible shift of the test profile */
fptr2 = test_exceed_means;
_Pragma( "loopbound min 21 max 21" )
for ( current_shift = 0; current_shift < shift_size; current_shift++ ) {
/* Pointer arithmetics to find the start and end pointers */
if ( current_shift < half_shift_size ) {
endptr = all_shifted_test_db + current_shift + profile_size;
fptr = all_shifted_test_db + half_shift_size;
} else {
endptr = all_shifted_test_db + half_shift_size + profile_size;
fptr = all_shifted_test_db + current_shift;
}
/* Summing the pixels that exceed twice test noise for the current shifts */
sum_exceed = 0.0f;
num_test_exceed = 0;
_Pragma( "loopbound min 53 max 64" )
while ( fptr != endptr ) {
if ( *fptr > test_noise_db_plus_3 ) {
num_test_exceed++;
sum_exceed += *fptr;
}
fptr++;
}
*fptr2++ = num_test_exceed ?
sum_exceed / ( float )( num_test_exceed ) :
0.0f;
}
/* Loop over all the templates. Determine the best shift distance, then
the best gain adjustment. */
_Pragma( "loopbound min 60 max 60" )
for ( template_index = 0; template_index < num_templates; template_index++ ) {
cur_tp = template_profiles_db + ( template_index * profile_size );
/* Scale the template profile we're currently working on so that its peak
is equal to the peak of the test profile */
fptr = cur_tp;
template_peak = *fptr++;
_Pragma( "loopbound min 63 max 63" )
for ( i = 1; i < profile_size; i++, fptr++ ) {
if ( template_peak < *fptr )
template_peak = *fptr;
}
/* Additively adjust the noise level of this template profile in the
raw power domain so that its noise level matches the noise level
of the test profile */
/* --------------------------------------------------------------------
Setting up all the constants */
noise_shift = test_peak - template_peak;
pm_memset ( ( void * )template_exceed, 0,
( ( int )sizeof( char ) )*profile_size );
sum_exceed = 0.0f;
num_template_exceed = 0;
/* --------------------------------------------------------------------
The following blocks are optimized code that essentially
perform the operations immediately below. The calculation of the
template noise constants is done once the exponentials are complete
*/
/* template_profile = template_profile + test_peak - template_peak
template = 10 ^ (template_profile / 10)
template = template + test_noise - template_noise
if (input < fp_epsilon) then clip the input to -100 dB
template = log10( abs(template) )
template_profile = 10 * template + test_noise_db */
fptr = cur_tp;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++ ) {
tmp1 = *fptr + noise_shift;
*fptr = pm_pow10f( tmp1 * 0.1f );
fptr++;
}
/* Calculates noise levels from first and last elements of the current
template */
template_noise = ( cur_tp[ 0 ] + cur_tp[ profile_size - 1 ] ) * 0.5f;
noise_shift2 = test_noise - template_noise;
fptr = cur_tp;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++ ) {
tmp1 = *fptr + noise_shift2;
if ( tmp1 == 0.0f )
tmp1 = pm_MIN_NOISE;
*fptr = 10.0f * pm_log10f( pm_fabs( tmp1 ) ) + test_noise_db;
/* Because many of the operations in the search for the best shift
amount depend on knowledge of which pixels in the template
have values exceeding twice test_noise (recall that 3db is roughly
equivalent to a doubling of raw power), we'll put those indices in
template_exceed */
if ( *fptr > test_noise_db_plus_3 ) {
template_exceed[ i ] = 1;
num_template_exceed++;
sum_exceed += *fptr;
}
fptr++;
}
/* Note: The following block has 4 different branches:
1. Both the current template and the test pattern have values exceeded
twice test noise.
2. Only the current template has values exceeded twice test noise.
3. Only the test pattern has values exceeded twice test noise.
4. Neither the current template nor the test pattern has values
exceeded twice test noise.
*/
/* If there is at least one pixel in the template we're
currently working on whose value exceeds twice test_noise */
if ( num_template_exceed ) {
template_exceed_mean = sum_exceed / ( float )( num_template_exceed );
fptr3 = test_exceed_means;
_Pragma( "loopbound min 21 max 21" )
for ( current_shift = 0; current_shift < shift_size;
current_shift++, fptr3++ ) {
/* Work on a copy of the template we're currently working on */
pm_memcpy ( ( void * )template_copy, ( void * )cur_tp, patsize );
/* If there is at least one pixel in the shifted test profile
whose value exceeds twice test noise. */
if ( *fptr3 != 0.0f ) {
/* CASE 1 */
/* Considering only those pixels whose powers exceed twice
test noise, compute the difference of the mean power in
template we're currently working on. */
power_ratio = *fptr3 - template_exceed_mean;
/* Scale template values that exceed twice test noise by power ratio
and set the values that are less than test noise in db to test
noise in db */
fptr = template_copy;
bptr = template_exceed;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++, fptr++ ) {
if ( *bptr++ )
*fptr += power_ratio;
if ( *fptr < test_noise_db )
*fptr = test_noise_db;
}
} /* if (*fptr3 != 0.0f) */
else {
/* CASE 2 */
/* Set those pixels in the template we're currently working on
whose values are less than test_noise to test_noise. */
fptr = cur_tp;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++ ) {
if ( *fptr++ < test_noise_db )
template_copy[ i ] = test_noise_db;
}
} /* else ... if (num_test_exceed) */
/* Compute the weighted MSE */
weighted_MSE = 0.0f;
fptr = all_shifted_test_db + current_shift;
fptr2 = template_copy;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++ ) {
tmp1 = *fptr++ - *fptr2++;
weighted_MSE += tmp1 * tmp1;
}
MSE_scores[ current_shift ] = weighted_MSE * sumWeights_inv;
} /* for current_shift */
} else { /* if (num_template_exceed) */
fptr3 = test_exceed_means;
_Pragma( "loopbound min 0 max 0" )
for ( current_shift = 0; current_shift < shift_size; current_shift++ ) {
/* CASE 3 */
/* If there is at least one pixel that exceeds twice test noise */
if ( *fptr3++ != 0.0f )
fptr2 = cur_tp;
else {
/* CASE 4 */
/* Work on a copy of the template we're currently working on. */
pm_memcpy ( ( void * )template_copy, ( void * )cur_tp, patsize );
fptr = cur_tp;
_Pragma( "loopbound min 0 max 0" )
for ( i = 0; i < profile_size; i++ ) {
if ( *fptr++ < test_noise_db )
template_copy[ i ] = test_noise_db;
}
fptr2 = template_copy;
}
/* Compute the weighted MSE */
weighted_MSE = 0.0f;
fptr = all_shifted_test_db + current_shift;
_Pragma( "loopbound min 0 max 0" )
for ( i = 0; i < profile_size; i++ ) {
tmp1 = *fptr++ - *fptr2++;
weighted_MSE += tmp1 * tmp1;
}
MSE_scores[ current_shift ] = weighted_MSE * sumWeights_inv;
} /* for current_shift */
} /* else .. if (num_template_exceed) */
/* Finding the minimum MSE for range shifting */
fptr = MSE_scores;
min_MSE_index = 0;
min_MSE = *fptr++;
_Pragma( "loopbound min 20 max 20" )
for ( i = 1; i < shift_size; i++, fptr++ ) {
if ( min_MSE > *fptr ) {
min_MSE = *fptr;
min_MSE_index = i;
}
}
/* Work on a copy of the template we're currently working on. */
pm_memcpy( ( void * )template_copy, ( void * )cur_tp, patsize );
mag_shift_scores_flag = 1;
if ( test_exceed_means[ min_MSE_index ] != 0.0f ) {
if ( num_template_exceed ) {
/* Compute the difference of the average shifted test profile
power to the average template power */
ave_power_ratio = test_exceed_means[ min_MSE_index ]
- template_exceed_mean;
/* Loop over all possible magnitude shifts */
_Pragma( "loopbound min 21 max 21" )
for ( j = 0, mag_db = -5.0f; mag_db <= 5.0f; mag_db += 0.5f ) {
power_shift = ave_power_ratio + mag_db;
bptr = template_exceed;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++ ) {
if ( *bptr++ )
template_copy[ i ] = cur_tp[ i ] + power_shift;
}
/* Compute the weighted MSE */
weighted_MSE = 0.0f;
fptr = all_shifted_test_db + min_MSE_index;
fptr2 = template_copy;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++ ) {
tmp1 = *fptr++ - *fptr2++;
weighted_MSE += tmp1 * tmp1;
}
mag_shift_scores[ j++ ] = weighted_MSE * sumWeights_inv;
} /* for mag_db */
} /* if (num_template_exceed) */
} else { /* if (num_test_exceed) */
/* Set those pixels in the template we're currently working on
whose values are less than test_noise to test_noise. */
fptr = cur_tp;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++ ) {
if ( *fptr++ < test_noise_db )
template_copy[ i ] = test_noise_db;
}
/* Compute the weighted MSE */
weighted_MSE = 0.0f;
fptr = all_shifted_test_db + min_MSE_index;
fptr2 = template_copy;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < profile_size; i++ ) {
tmp1 = *fptr++ - *fptr2++;
weighted_MSE += tmp1 * tmp1;
}
minimum_MSE_score[ template_index ] = weighted_MSE * sumWeights_inv;
mag_shift_scores_flag = 0;
} /* if (num_test_exceed) */
/* If magnitude shifting has performed above */
if ( mag_shift_scores_flag ) {
/* Find the minimum MSE for magnitude scaling */
fptr = mag_shift_scores;
min_MSE = *fptr++;
_Pragma( "loopbound min 20 max 20" )
for ( i = 1; i < 21; i++, fptr++ ) {
if ( min_MSE > *fptr )
min_MSE = *fptr;
}
minimum_MSE_score[ template_index ] = min_MSE;
}
} /* for template_index */
/* Find the minimum mean square error */
fptr = minimum_MSE_score;
match_index = 0;
match_score = *fptr++;
_Pragma( "loopbound min 59 max 59" )
for ( i = 1; i < num_templates; i++, fptr++ ) {
if ( match_score > *fptr ) {
match_score = *fptr;
match_index = i;
}
}
return match_index;
}
/*
Main function
*/
int main( void )
{
pm_init();
pm_main();
return pm_return();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,219 @@
/*
This file is part of the TACLeBench benchmark suite.
Version 2.0
Name: pm_libm.c
Author: Hector Chan
MIT Lincoln Laboratory
Function: This file contains the C math library functions used by pm.
Source: HPEC Challenge Benchmark Suite, Pattern Match Kernel Benchmark
Original name: pm
Changes: See ChangeLog.txt
License: BSD 3-clause
*/
/*
Include section
*/
#include "pm_math.h"
/*
Declaration of global variables
*/
#define pm_LOG10 2.302585093f
/* The coefficients for the pm_log10f and pm_pow10f functions below */
static float pm_pow_coeff[ 19 ];
static float pm_log_coeff[ 16 ];
/*
Math functions
*/
/***********************************************************************/
/* We found out the bottle neck of this kernel was in the pow and log
functions. Therefore, we have implemented our own log and pow, instead
of using the float fp ones in the standard C math libary. This function
sets up the coefficients for the single fp log and pow functions. */
/***********************************************************************/
void pm_math_init( void )
{
pm_pow_coeff[ 0 ] = 0.5f; /* 1/2! */
pm_pow_coeff[ 1 ] = 0.166666667f; /* 1/3! */
pm_pow_coeff[ 2 ] = 0.041666666f; /* 1/4! */
pm_pow_coeff[ 3 ] = 8.333333333e-3f;
pm_pow_coeff[ 4 ] = 1.388888889e-3f;
pm_pow_coeff[ 5 ] = 1.984126984e-4f;
pm_pow_coeff[ 6 ] = 2.480158730e-5f;
pm_pow_coeff[ 7 ] = 2.755731922e-6f;
pm_pow_coeff[ 8 ] = 2.755731922e-7f;
pm_pow_coeff[ 9 ] = 2.505210839e-8f;
pm_pow_coeff[ 10 ] = 2.087675699e-9f;
pm_pow_coeff[ 11 ] = 1.605904384e-10f;
pm_pow_coeff[ 12 ] = 1.147074560e-11f;
pm_pow_coeff[ 13 ] = 7.647163732e-13f;
pm_pow_coeff[ 14 ] = 4.779477332e-14f;
pm_pow_coeff[ 15 ] = 2.811457254e-15f;
pm_pow_coeff[ 16 ] = 1.561920697e-16f;
pm_pow_coeff[ 17 ] = 8.220635247e-18f;
pm_pow_coeff[ 18 ] = 4.110317623e-19f;
pm_log_coeff[ 0 ] = 0.333333333f; /* 1/3 */
pm_log_coeff[ 1 ] = 0.2f; /* 1/5 */
pm_log_coeff[ 2 ] = 0.142857143f; /* 1/7 */
pm_log_coeff[ 3 ] = 0.111111111f; /* 1/9 */
pm_log_coeff[ 4 ] = 9.090909091e-2f; /* 1/11 */
pm_log_coeff[ 5 ] = 7.692307692e-2f; /* 1/13 */
pm_log_coeff[ 6 ] = 6.666666667e-2f; /* 1/15 */
pm_log_coeff[ 7 ] = 5.882352941e-2f; /* 1/17 */
pm_log_coeff[ 8 ] = 5.263157895e-2f; /* 1/19 */
pm_log_coeff[ 9 ] = 4.761904762e-2f; /* 1/21 */
pm_log_coeff[ 10 ] = 4.347826087e-2f; /* 1/23 */
pm_log_coeff[ 11 ] = 0.04f; /* 1/25 */
pm_log_coeff[ 12 ] = 3.703703704e-2f; /* 1/27 */
pm_log_coeff[ 13 ] = 3.448275862e-2f; /* 1/29 */
pm_log_coeff[ 14 ] = 3.225806452e-2f; /* 1/31 */
pm_log_coeff[ 15 ] = 3.030303030e-2f; /* 1/33 */
}
/***********************************************************************/
/* This single fp pow base 10 function implements the corresponding
Taylor series. The loop has been unrolled to save ops. */
/***********************************************************************/
float pm_pow10f ( float exp )
{
float mul = exp * pm_LOG10;
float const term = exp * pm_LOG10;
float ans = 1.0f;
float const *fptr = pm_pow_coeff;
ans += mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
return ans;
}
/***********************************************************************/
/* This single fp log base 10 function implements the corresponding
Taylor series. The loop has been unrolled to save ops. */
/***********************************************************************/
float pm_log10f ( float exp )
{
float mul = ( exp - 1.0f ) / ( exp + 1.0f );
float ans = 0.0f;
float const *fptr = pm_log_coeff;
float const term = mul * mul;
ans = mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
mul *= term;
ans += *fptr++ * mul;
ans *= 0.86858896381f; /* ans = ans * 2 / log(10) */
return ans;
}
float pm_fabs( float n )
{
if ( n >= 0 )
return n;
else
return -n;
}
float pm_floor( float arg )
{
if ( arg >= 0 ) return ( int )arg;
return -( ( int )( -arg ) + 1 );
}
float pm_ceil( float arg )
{
if ( arg > 0 ) return ( int )( arg + 1 );
return ( int )( arg );
}

View File

@ -0,0 +1,37 @@
/*
This header is part of the TACLeBench benchmark suite.
Version 2.0
Name: pm_math.h
Author: Hector Chan
MIT Lincoln Laboratory
Function: This header contains the C math library functions used by pm.
Source: HPEC Challenge Benchmark Suite, Pattern Match Kernel Benchmark
Original name: pm
Changes: See ChangeLog.txt
License: BSD 3-clause
*/
#ifndef PM_MATH_H
#define PM_MATH_H
/*
Forward declaration of functions
*/
void pm_math_init( void );
float pm_fabs( float );
float pm_pow10f ( float );
float pm_log10f ( float );
float pm_floor( float );
float pm_ceil( float );
#endif /* PM_MATH_H */

View File

@ -0,0 +1,52 @@
/*
This file is part of the TACLeBench benchmark suite.
Version 2.0
Name: pm_stdlib.c
Author: Hector Chan
MIT Lincoln Laboratory
Function: This file contains the C standard library functions used by pm.
Source: HPEC Challenge Benchmark Suite, Pattern Match Kernel Benchmark
Original name: pm
Changes: See ChangeLog.txt
License: BSD 3-clause
*/
/*
Include section
*/
#include "pm_string.h"
/*
Standard library functions
*/
void pm_memcpy( void *dest, void *src, int size )
{
int i;
_Pragma( "loopbound min 44 max 256" )
for ( i = 0; i < size; i++ )
( ( unsigned char * )dest )[ i ] = ( ( unsigned char * )src )[ i ];
return;
}
void pm_memset( void *s, int c, int n )
{
int i;
_Pragma( "loopbound min 64 max 64" )
for ( i = 0; i < n; i++ )
( ( unsigned char * )s )[ i ] = ( unsigned char )c;
return;
}

View File

@ -0,0 +1,34 @@
/*
This header is part of the TACLeBench benchmark suite.
Version 2.0
Name: pm_string.h
Author: Hector Chan
MIT Lincoln Laboratory
Function: This header contains the C standard library functions used by pm.
Source: HPEC Challenge Benchmark Suite, Pattern Match Kernel Benchmark
Original name: pm
Changes: See ChangeLog.txt
License: BSD 3-clause
*/
#ifndef PM_STRING_H
#define PM_STRING_H
/*
Forward declaration of functions
*/
void pm_memcpy( void *, void *, int );
void pm_memset( void *, int, int );
#endif /* PM_STRING_H */

View File

@ -0,0 +1,38 @@
File: prime.c
Original provenience: Mälardalen benchmark suite,
ww.mrtc.mdh.se/projects/wcet/wcet_bench/prime/prime.c
2015-12-21:
- Renamed each function FUNC to prime_FUNC
- Added functions prime_init, prime_return and main
- Added a global variable 'int prime_result' to introduce a
non-optimizable return value
- Added forward declarations of all functions before the declarations of global
variables
- Replaced typedefs bool and uint.
- Re-ordered functions to fit template-order
- Applied code formatting according to the following rules
(incomplete, to be discussed; I basically used astyle with the attached
options file):
- 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: st_) followed by lowercase letter (e.g., st_square)
- 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
- Added general TACLeBench header to beginning of source code

View File

@ -0,0 +1,139 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: prime
Author: unknown
Function: prime calculates whether numbers are prime.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/prime/prime.c
Changes: no major functional changes
License: may be used, modified, and re-distributed freely
*/
/*
Forward declaration of functions
*/
unsigned char prime_divides ( unsigned int n, unsigned int m );
unsigned char prime_even ( unsigned int n );
unsigned char prime_prime ( unsigned int n );
void prime_swap ( unsigned int *a, unsigned int *b );
unsigned int prime_randomInteger();
void prime_initSeed();
void prime_init ();
int prime_return ();
void prime_main ();
// int main( void );
/*
Declaration of global variables
*/
unsigned int prime_x;
unsigned int prime_y;
int prime_result;
volatile int prime_seed;
/*
Initialization- and return-value-related functions
*/
void prime_initSeed()
{
prime_seed = 0;
}
unsigned int prime_randomInteger()
{
prime_seed = ( ( prime_seed * 133 ) + 81 ) % 8095;
return ( prime_seed );
}
void prime_init ()
{
prime_initSeed();
prime_x = prime_randomInteger();
prime_y = prime_randomInteger();
}
int prime_return ()
{
return prime_result;
}
/*
Algorithm core functions
*/
unsigned char prime_divides ( unsigned int n, unsigned int m )
{
return ( m % n == 0 );
}
unsigned char prime_even ( unsigned int n )
{
return ( prime_divides ( 2, n ) );
}
unsigned char prime_prime ( unsigned int n )
{
unsigned int i;
if ( prime_even ( n ) )
return ( n == 2 );
_Pragma( "loopbound min 0 max 16" )
for ( i = 3; i * i <= n; i += 2 ) {
if ( prime_divides ( i, n ) ) /* ai: loop here min 0 max 357 end; */
return 0;
}
return ( n > 1 );
}
void prime_swap ( unsigned int *a, unsigned int *b )
{
unsigned int tmp = *a;
*a = *b;
*b = tmp;
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) prime_main()
{
prime_swap ( &prime_x, &prime_y );
prime_result = !( !prime_prime( prime_x ) && !prime_prime( prime_y ) );
}
// int main( void )
// {
// prime_init();
// prime_main();
// return ( prime_return() ) ;
// }

View File

@ -0,0 +1,42 @@
File: quicksort.c
Original provenience: MiBench benchmark suite,
http://wwweb.eecs.umich.edu/mibench
2015-10-16:
- Removed original header comment, replaced by TACLeBench header.
- Removed all preprocessor macros, integrated them directly in the source code.
- Added prefix "quicksort_" to all global symbols.
- Added explicit forward declarations of functions.
- Replaced local variables "strings" and "vectors" that store the benchmark's
input data by global variables.
- Replaced initialization code by TACLeBench-compliant initialization code.
- Added new function quicksort_return producing a checksum as return value.
- Added new function quicksort_main according to TACLeBench guidelines.
quicksort_main is annotated as entry-point for timing 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: bs_) followed by lowercase letter (e.g., bs_square)
- 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 dummy initialization in ieee754_rem_pio2f to please linter.
2017-08-18
- Introduce proper constant propagation border to silence g++ warnings.

View File

@ -0,0 +1,605 @@
/*
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
*/
const char *quicksort_input_string[ 681 ] = {
"Kurt", "Vonneguts", "Commencement", "Address", "at", "MIT", "Ladies", "and",
"gentlemen", "of", "the", "class", "of", "97", "Wear", "sunscreen", "If", "I",
"could", "offer", "you", "only", "one", "tip", "for", "the", "future",
"sunscreen", "would", "be", "it", "The", "longterm", "benefits", "of",
"sunscreen", "have", "been", "proved", "by", "scientists", "whereas", "the",
"rest", "of", "my", "advice", "has", "no", "basis", "more", "reliable",
"than", "my", "own", "meandering", "experience", "I", "will", "dispense",
"this", "advice", "now", "Enjoy", "the", "power", "and", "beauty", "of",
"your", "youth", "Oh", "never", "mind", "You", "will", "not", "understand",
"the", "power", "and", "beauty", "of", "your", "youth", "until", "theyve",
"faded", "But", "trust", "me", "in", "20", "years", "youll", "look", "back",
"at", "photos", "of", "yourself", "and", "recall", "in", "a", "way", "you",
"cant", "grasp", "now", "how", "much", "possibility", "lay", "before", "you",
"and", "how", "fabulous", "you", "really", "looked", "You", "are", "not",
"as", "fat", "as", "you", "imagine", "Dont", "worry", "about", "the",
"future", "Or", "worry", "but", "know", "that", "worrying", "is", "as",
"effective", "as", "trying", "to", "solve", "an", "algebra", "equation", "by",
"chewing", "bubble", "gum", "The", "real", "troubles", "in", "your", "life",
"are", "apt", "to", "be", "things", "that", "never", "crossed", "your",
"worried", "mind", "the", "kind", "that", "blindside", "you", "at", "4", "pm",
"on", "some", "idle", "Tuesday", "Do", "one", "thing", "every", "day", "that",
"scares", "you", "Sing", "Dont", "be", "reckless", "with", "other", "peoples",
"hearts", "Dont", "put", "up", "with", "people", "who", "are", "reckless",
"with", "yours", "Floss", "Dont", "waste", "your", "time", "on", "jealousy",
"Sometimes", "youre", "ahead", "sometimes", "youre", "behind", "The", "race",
"is", "long", "and", "in", "the", "end", "its", "only", "with", "yourself",
"Remember", "compliments", "you", "receive", "Forget", "the", "insults", "If",
"you", "succeed", "in", "doing", "this", "tell", "me", "how", "Keep", "your",
"old", "love", "letters", "Throw", "away", "your", "old", "bank",
"statements", "Stretch", "Dont", "feel", "guilty", "if", "you", "dont",
"know", "what", "you", "want", "to", "do", "with", "your", "life", "The",
"most", "interesting", "people", "I", "know", "didnt", "know", "at", "22",
"what", "they", "wanted", "to", "do", "with", "their", "lives", "Some", "of",
"the", "most", "interesting", "40yearolds", "I", "know", "still", "dont",
"Get", "plenty", "of", "calcium", "Be", "kind", "to", "your", "knees",
"Youll", "miss", "them", "when", "theyre", "gone", "Maybe", "youll", "marry",
"maybe", "you", "wont", "Maybe", "youll", "have", "children", "maybe", "you",
"wont", "Maybe", "youll", "divorce", "at", "40", "maybe", "youll", "dance",
"the", "funky", "chicken", "on", "your", "75th", "wedding", "anniversary",
"Whatever", "you", "do", "dont", "congratulate", "yourself", "too", "much",
"or", "berate", "yourself", "either", "Your", "choices", "are", "half",
"chance", "So", "are", "everybody", "elses", "Enjoy", "your", "body", "Use",
"it", "every", "way", "you", "can", "Dont", "be", "afraid", "of", "it", "or",
"of", "what", "other", "people", "think", "of", "it", "Its", "the",
"greatest", "instrument", "youll", "ever", "own", "Dance", "even", "if",
"you", "have", "nowhere", "to", "do", "it", "but", "your", "living", "room",
"Read", "the", "directions", "even", "if", "you", "dont", "follow", "them",
"Do", "not", "read", "beauty", "magazines", "They", "will", "only", "make",
"you", "feel", "ugly", "Get", "to", "know", "your", "parents", "You", "never",
"know", "when", "theyll", "be", "gone", "for", "good", "Be", "nice", "to",
"your", "siblings", "Theyre", "your", "best", "link", "to", "your", "past",
"and", "the", "people", "most", "likely", "to", "stick", "with", "you", "in",
"the", "future", "Understand", "that", "friends", "come", "and", "go", "but",
"with", "a", "precious", "few", "you", "should", "hold", "on", "Work", "hard",
"to", "bridge", "the", "gaps", "in", "geography", "and", "lifestyle",
"because", "the", "older", "you", "get", "the", "more", "you", "need", "the",
"people", "who", "knew", "you", "when", "you", "were", "young", "Live", "in",
"New", "York", "City", "once", "but", "leave", "before", "it", "makes", "you",
"hard", "Live", "in", "Northern", "California", "once", "but", "leave",
"before", "it", "makes", "you", "soft", "Travel", "Accept", "certain",
"inalienable", "truths", "Prices", "will", "rise", "Politicians", "will",
"philander", "You", "too", "will", "get", "old", "And", "when", "you", "do",
"youll", "fantasize", "that", "when", "you", "were", "young", "prices",
"were", "reasonable", "politicians", "were", "noble", "and", "children",
"respected", "their", "elders", "Respect", "your", "elders", "Dont", "expect",
"anyone", "else", "to", "support", "you", "Maybe", "you", "have", "a",
"trust", "fund", "Maybe", "youll", "have", "a", "wealthy", "spouse", "But",
"you", "never", "know", "when", "either", "one", "might", "run", "out",
"Dont", "mess", "too", "much", "with", "your", "hair", "or", "by", "the",
"time", "youre", "40", "it", "will", "look", "85", "Be", "careful", "whose",
"advice", "you", "buy", "but", "be", "patient", "with", "those", "who",
"supply", "it", "Advice", "is", "a", "form", "of", "nostalgia", "Dispensing",
"it", "is", "a", "way", "of", "fishing", "the", "past", "from", "the",
"disposal", "wiping", "it", "off", "painting", "over", "the", "ugly", "parts",
"and", "recycling", "it", "for", "more", "than", "its", "worth", "But",
"trust", "me", "on", "the", "sunscreen"
};
unsigned int quicksort_input_vector[ 3000 ] = {
1681692777, 846930886, 1804289383, 424238335, 1957747793, 1714636915,
596516649, 1649760492, 719885386, 1350490027, 1025202362, 1189641421,
2044897763, 1102520059, 783368690, 1540383426, 1365180540, 1967513926,
35005211, 1303455736, 304089172, 1726956429, 294702567, 521595368,
278722862, 861021530, 336465782, 468703135, 2145174067, 233665123,
1315634022, 1801979802, 1101513929, 1125898167, 1369133069, 635723058,
628175011, 2089018456, 1059961393, 1653377373, 1131176229, 1656478042,
608413784, 1914544919, 859484421, 1973594324, 1734575198, 756898537,
1129566413, 2038664370, 149798315, 1424268980, 412776091, 184803526,
137806862, 749241873, 1911759956, 135497281, 982906996, 42999170,
1937477084, 2084420925, 511702305, 1159126505, 572660336, 1827336327,
1100661313, 1632621729, 805750846, 84353895, 1141616124, 1433925857,
1998898814, 2001100545, 939819582, 1585990364, 610515434, 1548233367,
1477171087, 760313750, 1374344043, 1889947178, 945117276, 356426808,
491705403, 709393584, 1780695788, 1474612399, 752392754, 1918502651,
1411549676, 1264095060, 2053999932, 1984210012, 943947739, 1843993368,
1469348094, 1749698586, 855636226, 463480570, 1036140795, 1956297539,
317097467, 1975960378, 2040651434, 927612902, 1376710097, 1892066601,
1687926652, 603570492, 1330573317, 485560280, 959997301, 660260756,
1194953865, 593209441, 402724286, 1947346619, 364228444, 894429689,
1063958031, 270744729, 221558440, 2007905771, 2114738097, 1633108117,
1610120709, 822890675, 1469834481, 498777856, 631704567, 791698927,
327254586, 524872353, 1255179497, 1703964683, 269455306, 1572276965,
160051528, 1600028624, 352406219, 1120048829, 112805732, 2040332871,
1713258270, 515530019, 378409503, 2077486715, 1409959708, 1573363368,
200747796, 1631518149, 1373226340, 168002245, 1117142618, 289700723,
990892921, 439493451, 150122846, 1622597488, 1231192379, 1760243555,
2147469841, 338888228, 111537764, 269441500, 1911165193, 438792350,
1869470124, 116087764, 2142757034, 1982275856, 8936987, 155324914,
350322227, 387346491, 1275373743, 1760281936, 1960709859, 841148365,
1244316437, 1186452551, 771151432, 213975407, 1476153275, 971899228,
653468858, 1626276121, 1139901474, 1884661237, 1239036029, 2130794395,
76065818, 1350573793, 1605908235, 1987231011, 1789366143, 1605894428,
2103318776, 1784639529, 1875335928, 2112255763, 1939964443, 1597322404,
352118606, 1067854538, 1432114613, 165344818, 1909002904, 1782436840,
1351797369, 532670688, 1395235128, 680466996, 1504569917, 492067917,
159259470, 496987743, 706043324, 1398295499, 480298490, 1359512183,
601385644, 2086206725, 1096689772, 243268139, 1544617505, 1172755590,
2027907669, 1272469786, 1012502954, 1820388464, 722308542, 968338082,
740759355, 6939507, 933110197, 502278611, 1789376348, 1285228804,
1034949299, 1037127828, 1450573622, 392035568, 1529195746, 654887343,
889023311, 87755422, 1335354340, 1369321801, 1447267605, 1494613810,
1308044878, 396473730, 745425661, 705178736, 1569229320, 1346811305,
1977648522, 434248626, 1590079444, 552473416, 1402586708, 1470503465,
559412924, 188213258, 1143408282, 201305624, 1473442062, 1884167637,
1238433452, 776532036, 238962600, 620145550, 1431419379, 1273911899,
707900973, 619290071, 1665947468, 7684930, 2113903881, 407487131,
404158660, 711845894, 1776808933, 1973387981, 2058657199, 937370163,
260152959, 1501252996, 1642548899, 1662739668, 824272813, 1472713773,
1850952926, 1967681095, 2025187190, 1176911340, 1704365084, 437116466,
1953443376, 1943327684, 638422090, 1237379107, 1069755936, 1876855542,
1856669179, 588219756, 349517445, 1823089412, 995706887, 1057418418,
387451659, 625032172, 1065103348, 298625210, 1562402336, 1469262009,
1799878206, 1057467587, 1295166342, 476667372, 382697713, 1555319301,
296864819, 260401255, 1070575321, 2001229904, 697517721, 774044599,
1797073940, 1335939811, 1950955939, 719346228, 1065311705, 1756915667,
1307565984, 1414829150, 846811127, 155789224, 324763920, 555996658,
780821396, 1389867269, 231602422, 195740084, 711645630, 619054081,
1253207672, 2006811972, 917679292, 1635905385, 1414647625, 570073850,
1896306640, 337739299, 1046741222, 446340713, 1111783898, 1343606042,
1782280524, 915256190, 1197352298, 700108581, 524688209, 846942590,
2114937732, 1371499336, 1566288819, 292218004, 1927495994, 726371155,
1682085273, 11614769, 882160379, 246247255, 630668850, 1662981776,
105575579, 1548348142, 1858721860, 1520223205, 2118421993, 964445884,
1857962504, 1017679567, 452867621, 822262754, 213801961, 201690613,
1737518944, 1411154259, 648031326, 114723506, 110613202, 282828202,
1486222842, 1676902021, 982936784, 1266235189, 255789528, 950390868,
1277849958, 1137949908, 1242608872, 1908518808, 653448036, 777210498,
1309383303, 364686248, 1023457753, 1280321648, 1329132133, 1129033333,
150517567, 1781999754, 501772890, 364319529, 1983690368, 212251746,
1775473788, 484238046, 1034514500, 1886086990, 767066249, 624549797,
1415505363, 1750003033, 739273303, 1671294892, 552910253, 78012497,
661761152, 1795519125, 1344247686, 1315209188, 425245975, 474613996,
1679895436, 1448703729, 235649157, 861543921, 430253414, 1545032460,
496060028, 932026304, 677870460, 332266748, 1144278050, 828388027,
816504794, 31308902, 1192707556, 1583571043, 655858699, 820697697,
1186090428, 1395132002, 559301039, 1739000681, 1473144500, 1974806403,
1387036159, 669908538, 1498617647, 1812282134, 1144522535, 12895151,
1113502215, 1380171692, 1328104339, 1543755629, 777720504, 860516127,
328298285, 1455590964, 1722060049, 1472576335, 136495343, 70636429,
1503885238, 1329202900, 402903177, 12260289, 2416949, 1219407971,
1407392292, 561717988, 655495367, 733053144, 389040743, 1841585795,
1402961682, 1887658390, 1433102829, 400000569, 1900553541, 672655340,
1780172261, 1081174232, 337453826, 410409117, 1941690360, 1450956042,
1866000081, 1516266761, 847228023, 2002495425, 1586903190, 1175526309,
1184214677, 1989806367, 500618996, 1186631626, 1061730690, 2004504234,
1748349614, 1717226057, 2016764524, 2137390358, 1411328205, 1276673168,
1877565100, 696947386, 2009726312, 1630634994, 1369602726, 1265204346,
564325578, 1707056552, 1665204916, 358532290, 1010528946, 1297893529,
1874799051, 1857756970, 1708302647, 1314218593, 885799631, 1426819080,
1156541312, 1386418627, 1281830857, 70788355, 1243439214, 318561886,
1788014412, 1112720090, 1505193512, 1051858969, 241909610, 1106059479,
1748806355, 104152274, 1095966189, 970925433, 1369356620, 826047641,
530498338, 887077888, 309198987, 1541027284, 37487770, 873524566,
1251300606, 1745790417, 1232056856, 2137100237, 1025125849, 959372260,
1376035217, 159473059, 126107205, 471990783, 478034945, 1282648518,
1584710873, 1983228458, 1353436873, 1826620483, 941804289, 993967637,
1930772757, 2037770478, 2045826607, 1152645729, 716334471, 1647149314,
2039723618, 1025533459, 470591100, 2077211388, 1899058025, 1001089438,
1675518157, 983631233, 394633074, 553160358, 1943003493, 1645933681,
712633417, 2069110699, 1635550270, 1190668363, 1204275569, 864101839,
1026413173, 410228794, 1336092622, 1968217462, 1404196431, 773319847,
1858504292, 1302539390, 452456682, 427355115, 802205057, 235745791,
1452888574, 1272796157, 1388391521, 1204462951, 126401947, 1280631491,
40610537, 521035021, 1210359231, 1983614030, 19485054, 738393740,
1905241081, 1655035325, 1291554098, 962033002, 371653516, 2004187516,
1372261796, 1707746139, 1047372231, 628974580, 333582338, 2073785404,
1931513970, 786039021, 1894519218, 586235379, 1021784812, 1605539862,
1859031536, 262692685, 2032894977, 1985433483, 1543324176, 1338299904,
358984857, 606199759, 395279207, 378469911, 1344593499, 435889744,
2033505236, 488663950, 272020127, 257675105, 345367818, 29777560,
1965421244, 1392740049, 991810563, 151519934, 1319041805, 216588711,
937558955, 1066077375, 845563291, 1959343768, 524133589, 629593614,
74552805, 409544918, 1215828993, 1617876982, 1747844822, 927376882,
76593093, 2143124030, 765326717, 1421186593, 431530126, 1124311574,
1909850543, 703550253, 1502781486, 107734713, 733327814, 1388803074,
1500474762, 1725138377, 1646478179, 672032919, 1941727088, 1464415775,
1738110294, 639806732, 1615935710, 114760235, 1269400346, 406011017,
524305153, 337745691, 217871137, 124666328, 1265122573, 292423943,
120306710, 2030449291, 1910300925, 551836836, 1007277217, 1986894018,
1255387090, 362575055, 1260596963, 1988714904, 1751378130, 1022963858,
1566369633, 1250372661, 1130698571, 1360613073, 567304789, 483689685,
2000419805, 35756851, 1155722604, 1122336503, 441767868, 746349250,
1460082195, 659639006, 861109485, 577721120, 952062949, 1385414639,
460686763, 714880226, 1510080967, 1467963981, 554290596, 1630387677,
1830539036, 1814887560, 34740865, 1434433518, 690367770, 1290127955,
537322532, 1821066342, 1131359211, 1104627321, 157272379, 550245196,
1140384172, 1312994984, 1910858270, 1582152040, 2059344234, 1763794427,
94307398, 772970072, 738647283, 1046370347, 10901063, 51245830,
1761250573, 1520982030, 628966950, 168057522, 1003886059, 1089653714,
1982945082, 1038626924, 410134047, 525829204, 181271232, 93189435,
199411898, 1312630443, 1527622954, 356684278, 1862875640, 2064945486,
1669679262, 1626250262, 1022089159, 1581539848, 1242561041, 14989683,
207026272, 1981208324, 1597141723, 217927335, 2032454154, 1691449122,
1738909365, 513937457, 590335821, 595311776, 1603591171, 204102747,
1633938701, 2013725218, 372160269, 1815209933, 2106914653, 207621703,
980356728, 1487053959, 733450907, 695748720, 1404515797, 932862806,
174515334, 279121308, 1289547084, 1417076376, 294110991, 811742698,
1250801052, 1891252715, 245798898, 1135771559, 1435218189, 452825171,
1649709016, 2025554010, 670752506, 1105816539, 82173109, 262178224,
972058109, 454333378, 857490000, 931489114, 661955081, 343945053,
271059426, 1395405989, 11671338, 1675575223, 180785147, 992028067,
1954696532, 1470332231, 1687776787, 101323875, 134591281, 1862292122,
1992576590, 380390179, 1131884850, 1280311131, 833215350, 235202254,
1158381494, 1503967857, 1370973813, 1240554603, 1766146081, 873199181,
1694887982, 476152433, 1979015720, 209359415, 820097487, 803590181,
1604765404, 831768825, 1735079296, 1785550551, 1823796892, 2006138722,
1108399134, 1364090032, 1534230297, 1242990415, 1078898506, 1341443181,
1623380595, 63299708, 1442767057, 309112297, 298501962, 1287859999,
1813080154, 1669475776, 420687483, 1431742587, 395191309, 1579068977,
1907895021, 226723382, 672139932, 580508860, 1030313563, 219544266,
1412277685, 617909211, 428903682, 1088590930, 476564285, 2033669086,
305197314, 2010794583, 1671735990, 1384095820, 1204754116, 632651476,
1447395528, 500037525, 1875641892, 1745897490, 1787897525, 1351538839,
1267889618, 61101360, 1660651136, 1663080928, 1640170337, 1326247643,
1889804310, 164826621, 610506582, 772634225, 384370888, 370917955,
1390543437, 813274570, 951426815, 1867107722, 699460008, 216220853,
1730418657, 223712350, 1304811783, 787689126, 856363827, 1610009097,
1287726651, 584522071, 846621269, 928140528, 1936060910, 146533149,
989241888, 1449228398, 1892430639, 481928577, 627992393, 1012836610,
646755199, 1238498976, 528433890, 1031126087, 1609416931, 270754552,
1844400657, 413360099, 1043388777, 396377017, 629580952, 286448566,
620089368, 1934392735, 6072641, 1476453195, 1396918184, 1736491298,
2060975266, 96055805, 376696776, 1849552528, 242588954, 1664423428,
1151297278, 2135019593, 445080308, 1779289672, 1000372555, 1434322197,
870305000, 1528806445, 1916250774, 332238283, 1799560997, 415522325,
745598382, 695466127, 1446648412, 1375179334, 981914693, 1143565421,
1162088421, 987987334, 1539942439, 411522957, 576994985, 12548159,
507578762, 953691761, 1489001354, 750167716, 470631541, 1402492972,
737703662, 915711850, 1104561852, 1738076217, 202550399, 108375482,
1119399015, 2118801173, 1887665154, 771476364, 386839851, 610486506,
1466942491, 1833488263, 942724790, 301373537, 829570037, 1688323172,
1289360871, 222028828, 916018859, 1866355856, 234576987, 2078107280,
672563970, 1723578341, 342146590, 1143195511, 978587665, 849725352,
2058907361, 2083149517, 1599893069, 113974112, 44041351, 190113083,
85291638, 1931706506, 1928189300, 472131489, 394709364, 900104667,
158136104, 1337434154, 1671581032, 987706141, 878273679, 991039875,
1209734969, 1794292538, 1292413412, 1444311956, 1724916170, 434290636,
1020406649, 2067062760, 153162844, 1998994314, 769304465, 825726814,
1934660183, 221713886, 1968922326, 1978701535, 411826969, 1880346039,
1762924393, 192532621, 1994320152, 10150109, 1092637289, 2079611790,
1347584264, 616734673, 404259631, 78374295, 1607774548, 562395735,
1872666833, 752704313, 1550101877, 1450099355, 1186994949, 612353198,
1369678468, 1340157793, 2056665155, 2138982933, 18400960, 929588156,
213213171, 1987323286, 781098823, 625040140, 1720185677, 568275358,
817572761, 1567022181, 399493245, 1910210050, 1499150323, 14933990,
379461075, 1903409954, 25084100, 1987235624, 318322042, 1372668364,
592456289, 1868423919, 1451042659, 1779451238, 333293469, 1176225844,
972125383, 242474976, 478841551, 990526343, 1172063133, 1848520019,
830365981, 1953161956, 1840019304, 403068011, 373953666, 2053232475,
1970090192, 773446912, 530788967, 1321756868, 788380902, 1348361729,
1077683174, 813465002, 1111088131, 1396005216, 38649718, 1490549207,
1116945487, 1489692377, 1330301183, 1450238957, 518434573, 1922757472,
1692713933, 997276125, 1554725062, 717293418, 698312496, 379366797,
522971726, 390848153, 1369893141, 896925393, 296596980, 52775474,
1670372305, 827385948, 455843485, 311269559, 28264029, 278450030,
1124734562, 1139352160, 1600206898, 1163384280, 482417719, 530406424,
505593010, 1812718902, 1926411641, 1024027583, 1587992726, 895873480,
2021303708, 995234140, 198628789, 572132557, 1374600938, 1891342723,
962980710, 597010431, 461152493, 1259577690, 649785905, 984124220,
2086963638, 1105629391, 1881049613, 2115227667, 1384079421, 1403938270,
1107096180, 836802671, 1715207829, 1589513899, 1367209095, 692458743,
1254749154, 1146137088, 1855843024, 695258232, 2042010569, 213952386,
1690492373, 93155710, 1237979969, 917609663, 1984498433, 1111800030,
1514620094, 298167279, 1683932587, 16922351, 1282291499, 499429649,
1122551742, 1015857464, 1759007339, 359147515, 272312086, 1698487330,
1195950186, 1987519915, 1666231349, 415675634, 532495011, 625843881,
1561812722, 240854387, 67874133, 1456339643, 454806773, 1322623287,
1549495354, 1692786742, 2017881519, 1386510139, 657103124, 1560890244,
1684677418, 193552063, 331016259, 819485269, 692981712, 1845636353,
1835342733, 304505404, 1862558705, 2107654819, 2002992734, 837626799,
1947691087, 1521740435, 1196774315, 332702450, 100669, 245240853,
573556837, 67974802, 660916487, 1028363610, 1390598089, 75245562,
573666704, 1260995960, 1531585205, 1230769829, 674402557, 933596911,
1424321892, 1005418816, 172623403, 2117303605, 703571522, 1857300821,
274325361, 418646579, 529302443, 129834447, 1256273378, 217161528,
1651574882, 305564045, 177332700, 1651675551, 550804899, 2125023787,
1719650353, 1211721386, 310242589, 962764794, 1286966948, 883799426,
76277107, 671068506, 1912163036, 750679664, 1604665417, 338346092,
1756098480, 1777288820, 1569115921, 312186354, 1487105994, 845954166,
730832933, 2016408437, 815774123, 1987106312, 86086317, 1090099484,
145186709, 263419017, 1219933931, 695991608, 240959156, 724025165,
1907712995, 551201745, 228217069, 1047196295, 1435001171, 1947867422,
1718264801, 1199680559, 763148569, 1175446571, 1538026652, 839425676,
805251743, 959658925, 1590105340, 144874089, 1805613091, 1198720172,
13798878, 473903566, 1510906527, 99885196, 1564003050, 94255812,
363304213, 636453333, 2081362124, 604263370, 1360478499, 79065186,
1155465115, 1588695568, 775056794, 442982639, 1389079342, 535286141,
1642663198, 4744263, 1582482437, 1033206202, 844169939, 1153263590,
1992865128, 286791631, 181226513, 1650994571, 1485511804, 986478257,
2124898138, 848934683, 1131352346, 1541417540, 943190495, 1145151225,
30387226, 877068972, 1245036421, 1390865725, 956134158, 1608340634,
832077645, 1731190952, 65120356, 73673339, 118993446, 1220585472,
78417603, 1701475883, 1663568111, 922587542, 707255825, 1158747661,
1209379174, 888482339, 44470216, 547407330, 1874960596, 2037335344,
1396342013, 858829294, 1540846267, 192048860, 2003980519, 1518260757,
1069117832, 1101533292, 912194650, 2025251990, 562390279, 942581876,
1608959295, 627510635, 185963953, 1727952741, 1848096107, 1018041598,
1281944976, 1364180570, 1091714937, 1989200801, 375444584, 1170132540,
730199492, 419914800, 2092720083, 457676440, 309766496, 1154615609,
1316505735, 1850612763, 1702022939, 1173002606, 1221389873, 950881304,
127052251, 2133584523, 1142930164, 689442530, 928682751, 64564349,
1316953165, 1114646704, 2089816339, 1017565625, 2132688302, 1551291986,
234262547, 1076919591, 1131761079, 609707131, 99568484, 266222407,
1029621931, 44804919, 107939561, 1339388427, 1199420528, 838139053,
1042517543, 753959819, 1295815494, 116423768, 1704841123, 464837581,
102524643, 700287639, 1637840187, 1031207394, 764851988, 1764892438,
2145854098, 707184680, 306851320, 2131058752, 110993018, 1623804486,
1060494695, 1242754098, 493886463, 1160063179, 1508976505, 728149010,
1204868098, 1616916066, 1337856142, 256804978, 307571472, 219994425,
1010764797, 1603386966, 1559382853, 568122272, 2068224547, 454416748,
1268409912, 1558581086, 570840516, 2033261900, 1175989877, 673365159,
592962932, 1482841197, 1704572553, 703955951, 959162035, 1702943003,
1946710049, 1453048498, 1686518107, 1308202906, 33713861, 599529154,
777635325, 1371570003, 1759592334, 1085206797, 1591564428, 816976784,
541110115, 1003463633, 1073781763, 461851014, 1457880381, 2084546560,
2020432100, 2028720897, 505185185, 1048938329, 554602408, 1773595097,
384295879, 111691313, 1659373349, 1343457914, 1814634316, 104852634,
649022765, 1353668775, 808808585, 682736626, 1953197930, 608034986,
2054306629, 1565306616, 1916237892, 1498387409, 234799752, 546389569,
354367395, 1308581515, 1631596366, 1812247776, 1245644428, 25222833,
1693485026, 1750829613, 487073847, 100603786, 1376941062, 360022300,
212295100, 888830763, 1408960629, 2026929416, 993683397, 1793256508,
1233114544, 1802491982, 989230775, 1038828826, 263043320, 1638253540,
456651794, 31797565, 173506518, 691451546, 578187134, 80329499,
2000033062, 62299853, 1578716908, 1098193842, 87522686, 1933084303,
701539807, 574596534, 1597848432, 2078480869, 934618834, 1143849810,
819827984, 196095815, 1244453596, 1813511382, 1989352324, 1456748696,
1468519716, 831099451, 1336194465, 1731563037, 321869343, 421825361,
1763360602, 495375861, 1460654187, 194064088, 575705360, 1917305981,
256363941, 6938620, 461273879, 343886628, 1940022924, 313823293,
918483162, 1390387708, 1412017135, 1853101996, 386753870, 2113556942,
2049197811, 1631207466, 2044554163, 1891066487, 940472515, 716898500,
574682290, 129183332, 382926234, 896551633, 551008693, 1851445950,
1391927494, 2011662880, 1435525339, 1967632854, 1781485213, 1051402293,
1974571475, 95275444, 1245466382, 1767110751, 409098738, 1501830323,
1010014811, 1821115873, 1845716951, 1396768681, 1787189168, 616716465,
880492499, 1684259683, 322334813, 1820965014, 253674535, 224048977,
1950148346, 636600769, 2115115464, 353673391, 340563072, 542314107,
217852623, 1776088411, 1438865740, 1999337836, 680007057, 683309587,
2094613281, 1925473439, 503458793, 356228371, 1279820114, 330546620,
29860596, 978053418, 2097657371, 1817049764, 1594769883, 960188534,
1353825800, 1917104697, 209473567, 1607500335, 2141153674, 1089966067,
96617457, 2108785490, 763447433, 437180529, 503615949, 566112132,
65785292, 1942481690, 919785523, 745792349, 478307629, 1137638147,
523782140, 981766422, 989492335, 1803602255, 1312313043, 936621968,
634172025, 1262486766, 1292850339, 81458260, 75191653, 1322710936,
1998562957, 284665220, 992277052, 1992232983, 1374631287, 198619204,
1953534826, 2138078721, 1806119540, 309667127, 556707205, 1902736997,
104665169, 1476492728, 192433878, 582972798, 466647227, 258219170,
1564739221, 1456139563, 1004011520, 729568616, 245277883, 1527793660,
1992055382, 1538128223, 1183912267, 2067247035, 713355511, 1818084292,
204428608, 1705632563, 1899542553, 1579059895, 1904251768, 1750621862,
1569654968, 1562887660, 1595371198, 2126362173, 1318141009, 1401422376,
1455371254, 1510574887, 1711089503, 1922018481, 1768794057, 1815754673,
1230674396, 625321929, 251243823, 1475952280, 5631942, 1815983044,
866596855, 1189544209, 398068012, 1579952366, 860144854, 242639747,
1138101281, 612203759, 162403134, 894869401, 215341973, 366831742,
310273413, 1810713171, 1945891638, 1628414422, 1064651899, 1368062958,
991505661, 628257755, 1346941484, 612816071, 296528780, 654829090,
1238138000, 547772603, 429363923, 1243769942, 216272000, 1660038320,
285830504, 614340012, 988506952, 1145975358, 856979759, 1855103807,
1758179117, 1019382894, 1287572525, 1973521090, 1386214636, 278190158,
1636750614, 1184622626, 1173059560, 553918865, 405201937, 1483332973,
1182176620, 1752143421, 964263748, 1478705400, 259488863, 1955769409,
2026478004, 688852786, 421101832, 95266356, 201407458, 1659239833,
709606368, 1189914410, 755526127, 1566586128, 897534569, 1041356631,
438485374, 37623446, 39848341, 1824700010, 315813605, 1798027458,
861838989, 1488873165, 1624064901, 1267040926, 824722490, 1113331867,
871700699, 1788986238, 1667250732, 1131189562, 1597272000, 701943705,
1820042348, 2018373832, 33165457, 2021449807, 1530130017, 2059643461,
1063880569, 138172497, 7426169, 1961415139, 1179529128, 717032538,
1999038585, 1219377470, 136135018, 167368542, 869921280, 574620392,
1656241707, 346502533, 251836754, 333480550, 1459834400, 1113675743,
2122466788, 979601485, 233233021, 1572255140, 1681545190, 1104933720,
1443145325, 1714710647, 88639634, 825791694, 1626870461, 1908681983,
963964191, 1634296630, 1782648142, 2143493320, 203845520, 699045063,
1215387142, 339980538, 512976554, 2085308422, 914600930, 364531492,
284327308, 1166437685, 531900034, 1744161708, 132629780, 40658094,
576279545, 365862802, 374138644, 110341087, 1470796522, 349121784,
1825051735, 1559436157, 1921376925, 1304438548, 1320634492, 1217038602,
791251530, 955798986, 2042830296, 995097051, 1654844049, 859310840,
1335077589, 20336956, 855320512, 102194872, 384868448, 2070707654,
1268632557, 916768482, 2008532428, 1401262337, 957426576, 145376088,
1767125139, 1331565220, 1889537797, 1090438014, 1680687005, 318333694,
502390523, 1454580282, 428674782, 1823025015, 524135236, 106242869,
631340353, 419481884, 1410681417, 138700754, 1278792724, 54449299,
159037710, 2134113236, 1049546350, 543906158, 2057337242, 237140292,
1460674641, 1918386023, 339335164, 270617569, 2063762111, 1607967721,
1602182790, 1805816260, 861746410, 1135386147, 2124149955, 481387902,
442482781, 405341089, 1571825916, 966618017, 511583958, 2074216439,
1386099901, 1922265375, 1749757806, 517408978, 1976714674, 233614511,
504038566, 878777377, 372315265, 413892161, 1115917669, 531352976,
184794536, 1455252833, 1075259134, 101072999, 915736906, 388450127,
1906889260, 1777483316, 659067697, 1883555567, 111387570, 113766839,
141413008, 1683213486, 1249152986, 652996966, 1609946277, 1691635767,
427778693, 1212220435, 510770136, 257009719, 1445834946, 1896870037,
1135787096, 1818150212, 266795367, 104221117, 202019540, 770833934,
1559473950, 1277278674, 1184726095, 327727208, 1665728802, 1369520631,
2105210525, 177312851, 1470593630, 69114447, 291079690, 1229999242,
1752327934, 1540232676, 966071161, 1214790563, 1084384795, 1107484169,
279527351, 1595154931, 1760481135, 1725362297, 1344541320, 40776180,
1396028861, 1611336688, 297785900, 1598048401, 234686974, 1433572996,
727843428, 1419413069, 1537794114, 246088582, 641450052, 949784416,
423401433, 2112043682, 1277511625, 714481123, 1194559277, 1235238502,
107230151, 13146790, 1304352949, 1191614946, 1120630960, 909197235,
639286229, 733628447, 2123987799, 1983827549, 774404628, 256031502,
1447680589, 1072190528, 1981393799, 1682367563, 358279876, 1229939013,
954296984, 1896073990, 680503766, 1595747036, 698374759, 1408347194,
1560307071, 1975886384, 1654435776, 607382700, 1063641238, 2077837209,
620529490, 220510539, 644834684, 1741160450, 1129707775, 752064835,
327305250, 1106211926, 1943679781, 1101709878, 1362243428, 435482362,
26416758, 1196153579, 271826264, 384696634, 278608944, 1719506853,
133286977, 959112711, 1254390769, 831661736, 219976257, 61204105,
660064472, 1874412034, 1656951142, 1723705710, 1804765595, 1069774565,
1944216249, 302116632, 1677157265, 926440376, 1054181467, 150203107,
2032652302, 850377601, 1891363558, 1247412082, 1285859963, 71185160,
296082014, 1557686227, 1172895038, 574690958, 1129709433, 1199311796,
1533803669, 236616554, 1584008430, 1753779927, 297820659, 1717295407,
1480708313, 1954771801, 401473495, 1137990260, 877062718, 1061537967,
1440106892, 406736335, 637760029, 346804712, 556939443, 434492631,
1197182313, 300819353, 1360933007, 335558628, 372004513, 1246101662,
1893244856, 1544899551, 346030096, 875470641, 596727699, 642112110,
1112087195, 33252481, 1216803069, 1409907854, 1750547889, 603123090,
1217196008, 4537736, 209419369, 2094258726, 1066075704, 1690127682,
353511414, 1703835733, 680634295, 910450857, 2138328364, 2120741187,
1211270210, 1351777724, 320062251, 1583274723, 450395738, 1517244564,
980690626, 796425834, 1852803193, 1577418325, 1438537945, 1598564401,
1610670806, 507857366, 326551394, 1213735047, 1110980456, 1438638589,
1218272784, 1320399826, 701062795, 136864840, 863043860, 1918258803,
1840700573, 1543678155, 1865033882, 1831545290, 1516935695, 71061648,
1035839366, 1836997946, 981512505, 1486235104, 1206758863, 45299067,
135177290, 912078408, 1628573790, 1573715235, 363159161, 461780768,
2081572601, 689710555, 2039199093, 1045069410, 2128349144, 1502386251,
217985588, 681928291, 568637651, 1081029448, 452703447, 1786910435,
477223956, 170253681, 1923775275, 1994159651, 241315329, 1616992200,
1683673949, 1222827834, 1301053842, 742949164, 1268126901, 189409560,
1655027572, 749217043, 1675644664, 2018186733, 1210997811, 1810821955,
560413640, 1102713256, 1237053542, 541279136, 457615859, 1171142496,
1223207428, 1026253510, 68728258, 1675910875, 665680297, 286713846,
1846164556, 441971924, 1367743294, 2087479885, 2058964125, 1844967250,
1162824071, 1212534319, 1691643253, 283467324, 1401943880, 1227833555,
1032684367, 930104896, 1970782719, 96198530, 593443203, 1478326644,
1198911786, 1830496746, 1349029729, 1656527645, 854155594, 1909443370,
535297508, 922883852, 303238858, 1200977805, 1209597698, 1526446286,
1642949730, 429857344, 1054873513, 1554430207, 127340947, 753554421,
619480878, 1818984200, 693550658, 2021424758, 899334107, 1856374729,
804046007, 722633179, 2139842053, 1397489210, 53476175, 1025042772,
1080502308, 1402505904, 1121241302, 1934657902, 1164465626, 172669440,
710058106, 1467704485, 1829197086, 1919655804, 846667123, 217010946,
202029501, 1901540637, 1417988751, 329370448, 507611410, 913454833,
871000, 1201162069, 320401392, 900205108, 910053150, 939882271,
1622838287, 902411556, 813823381, 1676314462, 1927454328, 1617869388,
931336718, 901211983, 867874951, 2095802345, 1073881423, 1948377259,
1416023182, 755594861, 1735551514, 115206657, 972605807, 298125972,
2016747294, 243110911, 70298129, 376875057, 1156565744, 272327630,
1578037126, 1476967137, 601698078, 340606628, 269365760, 602569078,
1243018184, 1083189141, 1502774186, 1022988865, 553574882, 978128825,
1924200848, 1421449833, 506959639, 850598623, 1222343444, 1438296358,
1606193485, 810411310, 1386615055, 431315644, 1108537283, 655154589,
674426555, 1178835412, 770361246, 1830992300, 1451163042, 639624893,
1160475789, 2052861120, 1016499950, 1429841549, 507946550, 447053428,
365547042, 2010720737, 787660056, 919121924, 841365914, 2030678241,
193088109, 1348325554, 906183458, 1415431554, 639138264, 682900658,
78359216, 2025753319, 1533499281, 1186896499, 533424260, 992209118,
218248263, 1303785506, 1423524763, 1669411305, 1943410399, 2097951318,
1574788777, 812426701, 1781459970, 2082735328, 1259480129, 794452111,
1945972417, 2047140186, 76810012, 639854683, 1930334779, 442357055,
1988180237, 689034589, 1361478979, 479834853, 1371935247, 1554567089,
358104524, 757950880, 822514995, 891528784, 1750159999, 900874211,
47830643, 1026201114, 2087770711, 1991241042, 976668784, 158535326,
656184096, 610645107, 1827946632, 1915664225, 1405097218, 1255251761,
1815320763, 1481907231, 1190503441, 1598171894, 1924264286, 988992210,
139722835, 1138259617, 1628846894, 1511658082, 545343058, 1469543483,
122125315, 1367858053, 1949378337, 1872285314, 121248617, 159999213,
751002780, 61535680, 1051527998, 1727671564, 220071006, 1099358641,
190833023, 2048017638, 943116035, 1595930242, 1155785752, 1599300131,
930353825, 198805545, 1367480709, 707134463, 1187797756, 1035317824,
1845394080, 669161002, 486006071, 243253491, 2138704485, 625728906,
1611111544, 1940599174, 2137386989, 1732360161, 2100598388, 112028656,
1793895841, 1004642738, 1984313970, 2013966848, 2104001379, 587833102,
1914500838, 899633766, 168021018, 922802942, 351450250, 358854042,
1121608488, 1718930959, 1954784284, 161922596, 606765135, 737654461,
831083598, 1092771206, 1444788924, 822304435, 1718500113, 1142699356,
615419962, 1708403454, 1385952847, 568534702, 1820432110, 849580744,
1573177440, 1657262432, 434457257, 1529695171, 97611886, 80869451,
281845289, 265632904, 2094836299, 633295539, 624486946, 1861853489,
204742850, 431787582, 637172784, 811507986, 1169442043, 1758781272,
1904279192, 466747319, 1920703868, 1475295657, 1609446676, 604303818,
1036215463, 847915875, 1426608253, 709163925, 1697496619, 2042028215,
218942709, 2131953877, 463079269, 316554595, 65339680, 2036256709,
582187500, 12692331, 1418468232, 1206674446, 1874545820, 1700313522,
1638462029, 364234956, 186125413, 660420424, 2123016228, 390868264,
1127167744, 1896236448, 1202376250, 589130772, 353056618, 959171794,
1437046647, 1779664872, 286983804, 987059619, 1674209439, 1323199267,
971529848, 2137288709, 2032363193, 1036869528, 2026061770, 103822254,
1049561859, 1297046355, 420376850, 776624031, 849876229, 1002564350,
1140858988, 1036001642, 61755148, 1116391568, 1426869906, 1700217177,
865144369, 481762508, 213153954, 1218200987, 1440934303, 1340321698,
850382211, 1727918107, 1929452470, 377108003, 903633726, 1219015469,
366913064, 788513271, 58591440, 245491186, 892335526, 1030121288,
1542537541, 1312712376, 2066990816, 244930122, 167793078, 969069027,
1280931765, 229548226, 1745693059, 560318023, 1929765404, 739068399,
1042080532, 2142919358, 1855459967, 335531187, 1335757408, 573120688,
2063449294, 1117726230, 1791321676, 819599372, 189258051, 494220239,
1608112644, 247849492, 871328242, 352964522, 1277970780, 1238241306,
1665676898, 1197477949, 1483732493, 1833469976, 19063328, 878786386,
2063018202, 1764756387, 1123716509, 1845299958, 356341138, 257164626,
1840735668, 64317458, 817482649, 1029009428, 637438146, 1859563181,
2146735658, 281276174, 47610720, 188510062, 775496414, 2111060014,
436359554, 1646824656, 783175739, 1714330334, 737582315, 243804735,
764324635, 73831160, 596769257, 783387964, 952617546, 114962507,
400660703, 2076334055, 1948432483, 757001842, 186015033, 1863967037,
821319300, 1003497683, 1561783348, 1458757446, 715577216, 1255035368,
1740033621, 763187937, 136561149, 368046387, 726764303, 135813159,
2014871043, 1509940042, 324323221, 604969710, 1753744777, 760682775,
678800870, 203030386, 327529462, 1631418417, 317992893, 1091854097,
1560268824, 118941728, 1875242061, 1746283858, 1982908766, 128419117,
602297893, 1397208466, 885420959, 1317875109, 504760186, 1706740259,
2081063046, 641321335, 1018014057, 660343702, 777134495, 610564030,
22800096, 1101457716, 978610417, 1776544874, 1862140492, 845997813,
1979575260, 42186306, 1450967523, 150084506, 1134040403, 2129768394,
269026234, 861798817, 1613703163, 104451352, 990217934, 1026488339,
1501659818, 1875638893, 625288549, 2006420005, 1434895504, 1227586442,
500257692, 305425913, 397977904, 1277392187, 915989944, 331557302,
231366256, 1894600361, 991901004, 2093506748, 593114526, 1014701101,
2135693054, 2044082050, 643762327, 1122249809, 2026366796, 475853939,
1984048626, 1492586311, 625938445, 826782912, 371591002, 894964680,
554938157, 996879552, 999416032, 1989833661, 76982346, 353592203,
147775927, 474960250, 212528560, 1063765871, 806517553, 712786252,
810882584, 1798418557, 1990178440, 1403997111, 665636010, 74061048,
1300595513, 1309398337, 20084148, 1179478661, 1785252277, 8293554,
524581324, 263707074, 1130543363, 896172326, 1158671754, 967108342,
1893051878, 10604139, 1793891254, 1970034225, 364196342, 201345764,
297510827, 576724902, 43695777, 1104028380, 1289511154, 191471704,
754963290, 1132205946, 1255237575, 1420599300, 1206266994, 2066120160,
582513990, 1226351142, 1322633623, 220282619, 1234644696, 475745488,
483989693, 217704412, 1655224149, 1642661448, 1184812754, 32321825,
1653265587, 831220360, 928494151, 2017461929, 1032566124, 674062382,
446703183, 1076261902, 496612959, 1736214337, 1267733606, 794123786,
720936636, 375487534, 1898152167, 1927203630, 294124046, 505631809,
1006071125, 1616757669, 1926231109, 93232173, 2092503157, 361261451,
310936585, 1600243658, 581544070, 1495749339, 1632565483, 1065533764,
179486052, 413575986, 560711564, 1212052176, 1087638368, 66493503,
140830430, 1584251327, 2083955432, 1408564037, 230891466, 383174967,
1784051571, 2129043633, 2119389304, 2078175617, 487191794, 692842292,
1547449638, 265939255, 472562275, 1492469147, 627200707, 1478633400,
945229157, 1208744777, 1571865573, 430310992, 126794893, 1882802159,
843886978, 687506457, 1231067850, 1931525347, 753999960, 1410553902,
1368293026, 690471744, 475122431, 1599184492, 1073646711, 615952861,
1580744477, 1045552368, 2024516898, 2067936271, 1738394660, 1661084821,
186391879, 63473287, 1591776790, 813592586, 1542106687, 991742780,
2022337363, 966488613, 336728279, 1648609, 701807124, 1281957436,
689155066, 1932874974, 1712268428, 1443155027, 1195945229, 408671759,
2133626771, 1671067660, 192713458, 1059789835, 139536873, 1561006484,
2105342203, 16570124, 1012707329, 1696253215, 1677654945, 445968158,
1759726503, 1121948088, 366420782, 1154349542, 2113690868, 552812661,
2120838155, 302935500, 1366405247, 675161631, 1584892936, 1241258962,
460552958, 1149677717, 1242907571, 1656498187, 1558349476, 1932062638,
1180082199, 1751062934, 1227734017, 1319619072, 1164585770, 1213877140
};

View File

@ -0,0 +1,67 @@
/*
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_ */

View File

@ -0,0 +1,245 @@
/*
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
*/
void quicksort_init( void );
int quicksort_return( void );
void quicksort_str( char *, unsigned long, unsigned long );
void quicksort_vec( char *, unsigned long, unsigned long );
void quicksort_main( void );
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 min 3000 max 3000" )
for ( i = 0; i < 3000; i++ )
quicksort_input_vector[ i ] += quicksort_const_prop_border_i;
/* Init arrays */
_Pragma( "loopbound min 681 max 681" )
for ( i = 0; i < 681; i++ ) {
_Pragma( "loopbound min 1 max 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 min 1000 max 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 min 0 max 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 min 0 max 169" )
while ( 1 ) {
_Pragma( "loopbound min 1 max 26" )
do
pi += es;
while ( ( pi < pn ) && ( quicksort_compare_strings( pi, a ) < 0 ) );
_Pragma( "loopbound min 1 max 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 min 0 max 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 min 1 max 250" )
while ( 1 ) {
_Pragma( "loopbound min 1 max 51" )
do
pi += es;
while ( ( pi < pn ) && ( quicksort_compare_vectors( pi, a ) < 0 ) );
_Pragma( "loopbound min 1 max 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
*/
void _Pragma ( "entrypoint" ) 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 ) );
}
int main( void )
{
quicksort_init();
quicksort_main();
return ( quicksort_return() - 1527923179 != 0 );
}

View File

@ -0,0 +1,9 @@
#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

View File

@ -0,0 +1,58 @@
/*
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

View File

@ -0,0 +1,142 @@
/*
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"
int quicksort_strcmp( const char *str1, const char *str2 )
{
_Pragma( "loopbound min 0 max 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 min 20 max 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 );
}

View File

@ -0,0 +1,34 @@
/*
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

View File

@ -0,0 +1,78 @@
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

View File

@ -0,0 +1,31 @@
/*
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 */

View File

@ -0,0 +1,89 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.9
Name: rad2deg
Author: unknown
Function: rad2deg performs conversion of radiant to degree
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 rad2deg(r) ((r)*180/PI)
/*
Forward declaration of functions
*/
void rad2deg_init( void );
void rad2deg_main( void );
int rad2deg_return( void );
int main( void );
/*
Declaration of global variables
*/
float rad2deg_X, rad2deg_Y;
/*
Initialization function
*/
void rad2deg_init( void )
{
rad2deg_X = 0;
rad2deg_Y = 0;
}
/*
Return function
*/
int rad2deg_return( void )
{
int temp = rad2deg_Y;
if ( temp == 64620 )
return 0;
else
return -1;
}
/*
Main functions
*/
void _Pragma ( "entrypoint" ) rad2deg_main( void )
{
_Pragma( "loopbound min 360 max 360" )
for ( rad2deg_X = 0.0f; rad2deg_X <= ( 2 * PI + 1e-6f ); rad2deg_X += ( PI / 180 ) )
rad2deg_Y += rad2deg( rad2deg_X );
}
int main( void )
{
rad2deg_init();
rad2deg_main();
return rad2deg_return();
}

View File

@ -0,0 +1,17 @@
File: recursion.c
Original provenience: Mälardalen benchmark suite, www.mrtc.....
2017-04-18:
- Annotated recursion_main as entry-point for timing analysis
2015-10-12:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Renamed function fib to recursion_fib
- Added forward decleration of functions
- Added recursion_main, recursion_init, recursion_return function
- create input value for recursion_fib function
- Applied Code Style
- Added checksum in return function
- Made input value volatile

View File

@ -0,0 +1,89 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: recursion
Author: unknown
Function: recursion is a recursion program.
This program computes the Fibonacci number recursively.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/recursion/recursion.c
Changes: no major functional changes
License: May be used, modified, and re-distributed freely.
*/
/*
Global Variables
*/
int recursion_result;
int recursion_input;
/*
Forward declaration of functions
*/
int recursion_fib( int i );
void recursion_main( void );
void recursion_init( void );
int recursion_return( void );
// int main ( void );
void recursion_init()
{
int volatile temp_input = 10;
recursion_input = temp_input;
}
int recursion_fib( int i )
{
if ( i == 0 )
return 1;
if ( i == 1 )
return 1;
return recursion_fib( i - 1 ) + recursion_fib( i - 2 );
}
int loop_fib( int i )
{
int h,j = 1;
if ( i == 0 )
return 1;
if ( i == 1 )
return 1;
for (int z=2; z<=i; z++) {
int tmp = h+j;
j=h;
h=tmp;
}
return h;
// return recursion_fib( i - 1 ) + recursion_fib( i - 2 );
}
int recursion_return()
{
return ( recursion_result + ( -89 ) ) != 0;
}
void _Pragma( "entrypoint" ) recursion_main( void )
{
_Pragma( "marker recursivecall" )
_Pragma( "flowrestriction 1*fib <= 177*recursivecall" )
recursion_result = recursion_fib( recursion_input );
}
// int main( void )
// {
// recursion_init();
// recursion_main();
// return ( recursion_return() );
// }

View File

@ -0,0 +1,108 @@
File: sha.c
Original provenience:
2017-04-18:
- Annotated sha_main as entry-point for timing analysis
2015-03-30:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Removed IFDEF lines
- Added main functionality from sha_driver.c
- Added prefix to functions (sha_functionname)
- Added sha_main, sha_init, sha_return functions
- Changed local to global variable for the init function
- Added checksum in return to return 0 when calculated correctly
- Applied Code Style
File: sha.h
Original provenience:
2015-03-30:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Add forward declaration of functions
- Applied Code Style
File: glibc_common.h
Original provenience:
2015-03-30:
- Removed file and copy to sha.h
File: my_file.h
Original provenience:
2015-03-30:
- Removed file and copy to sha.h
File: my_file.c
Original provenience:
2015-03-30:
- Remove file and copy to sha.c
File: input_small.c
Original provenience:
2015-03-30:
- Remove comment on line 1
- reformatted data to 20 chars per line
- Added generic TACLeBench header to line 1
- Applied Code Style
File: memhelper.h
Original provenience:
2015-03-30:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Removed unnecessary #IFNDEF
- Applied Code Style
File: memhelper.c
Original provenience:
2015-03-30:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Added break; to switch statement
- Applied Code Style
File: memset.h
Original provenience:
2015-03-30:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Applied Code Style
File: memset.c
Original provenience:
2015-03-30:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Applied Code Style
File: memcpy.h
Original provenience:
2015-03-30:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Added prefix to functions (sha_functionname)
- Applied Code Style
File: memcpy.c
Original provenience:
2015-03-30:
- Remove comment on line 1
- Added generic TACLeBench header to line 1
- Added prefix to functions (sha_functionname)
- Applied Code Style

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: memcpy.c
Author: Torbjorn Granlund
NIST Secure Hash Algorithm
Copy memory to memory until the specified number of bytes
has been copied. Overlap is NOT handled correctly.
Source: GNU C Library
Changes: no major functional changes
License: Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc.
*/
#include "memcpy.h"
void *sha_glibc_memcpy( void *dstpp, const void *srcpp, size_t len )
{
unsigned long int dstp = ( long int ) dstpp;
unsigned long int srcp = ( long int ) srcpp;
size_t __nbytes;
/* Copy from the beginning to the end. */
/* If there not too few bytes to copy, use word copy. */
if ( len >= OP_T_THRES ) {
/* Copy just a few bytes to make DSTP aligned. */
len -= ( -dstp ) % OPSIZ;
__nbytes = ( -dstp ) % OPSIZ;
_Pragma( "loopbound min 0 max 0" )
while ( __nbytes > 0 ) {
BYTE __x = ( ( BYTE * ) srcp )[ 0 ];
srcp += 1;
__nbytes -= 1;
( ( BYTE * ) dstp )[ 0 ] = __x;
dstp += 1;
}
/* Copy whole pages from SRCP to DSTP by virtual address manipulation,
as much as possible. */
PAGE_COPY_FWD_MAYBE ( dstp, srcp, len, len );
/* Copy from SRCP to DSTP taking advantage of the known alignment of
DSTP. Number of bytes remaining is put in the third argument,
i.e. in LEN. This number may vary from machine to machine. */
WORD_COPY_FWD ( dstp, srcp, len, len );
/* Fall out and copy the tail. */
}
/* There are just a few bytes to copy. Use byte memory operations. */
__nbytes = len;
_Pragma( "loopbound min 0 max 7" )
while ( __nbytes > 0 ) {
BYTE __x = ( ( BYTE * ) srcp )[ 0 ];
srcp += 1;
__nbytes -= 1;
( ( BYTE * ) dstp )[ 0 ] = __x;
dstp += 1;
}
return dstpp;
}

Some files were not shown because too many files have changed in this diff Show More