[llvm-commits] [test-suite] r46435 [1/4] - /test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/

Chris Lattner sabre at nondot.org
Sun Jan 27 21:23:40 PST 2008


Author: lattner
Date: Sun Jan 27 23:23:39 2008
New Revision: 46435

URL: http://llvm.org/viewvc/llvm-project?rev=46435&view=rev
Log:
add a VersaBench benchmark.

Added:
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/Makefile
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/calcMetricsData.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/chooseEntry.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/clearLine.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/closeFiles.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/consistent.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createDataObject.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexEntry.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexNode.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataManagement.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataObject.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dbms.ref.in
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dbms.train.in
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/delete.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/delete.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/deleteDataObject.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/deleteEntry.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/deleteIndexEntry.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/deleteIndexNode.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/errorMessage.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/errorMessage.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getDeleteCommand.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getDeleteCommand.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getFloat.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getFloat.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getInitCommand.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getInitCommand.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getInsertCommand.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getInsertCommand.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getInt.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getInt.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getKeyAttribute.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getKeyAttribute.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getNextCommandCode.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getNextCommandCode.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getNonKeyAttribute.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getNonKeyAttribute.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getQueryCommand.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getQueryCommand.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/getString.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/index.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/indexKey.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/initMetricsData.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/insert.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/insert.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/insertEntry.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/insertEntry.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/keyUnion.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/main.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/metrics.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/openFiles.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/openFiles.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/outputMetricsData.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/outputQuery.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/partitionEntries.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/penalty.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/query.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/query.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/setMetricsData.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/splitNode.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/splitNode.h
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/timer.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/updateMetricsData.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/valid.c
    test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/volume.c

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/Makefile?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/Makefile (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/Makefile Sun Jan 27 23:23:39 2008
@@ -0,0 +1,10 @@
+LEVEL = ../../../..
+
+PROG     = dbms
+ifdef SMALL_PROBLEM_SIZE
+RUN_OPTIONS = -i dbms.train.in
+else
+RUN_OPTIONS = -i dbms.ref.in
+endif
+include $(LEVEL)/MultiSource/Makefile.multisrc
+

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/calcMetricsData.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/calcMetricsData.c?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/calcMetricsData.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/calcMetricsData.c Sun Jan 27 23:23:39 2008
@@ -0,0 +1,139 @@
+
+/*
+ *  Name:           calcMetricsData
+ *  Input:          Metrics structure
+ *  Output:         Metrics structure
+ *  Return:         void
+ *  Description:    This routine calculates the average and standard 
+ *                  deviation of the provided command metric structures.
+ *                  The routine checks that at least one sample time
+ *                  difference is present in the command metric structure
+ *                  which is placed via the updateMetricsData() routine.
+ *                  Two errors are possible for this routine: (1) the
+ *                  command metric structure has no samples, and (2) 
+ *                  round-off has caused the calculated variance to be
+ *                  a negative number, although this is analytically
+ *                  impossible.  In the case of either error, the average
+ *                  and standard deviation members are set to zero which 
+ *                  may help prevent their later use if "junk" were left
+ *                  there either as initialization or from previous
+ *                  calculations.
+ *  Calls:          getTime()
+ *      System:     sqrt()
+ *  Author:         M.L.Rivas
+ *
+ *  Revision History:
+ *
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  27May99 Matthew Rivas   Created
+ *
+ *	Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+#include <assert.h>         /* for assert()                   */
+#include <math.h>           /* for sqrt() definition          */
+#include "dataManagement.h" /* for primitive type definitions */
+#include "metrics.h"        /* for Metrics definition         */
+
+/*
+ *  Function prototype
+ */
+extern Time getTime( void );
+
+void calcMetricsData( Metrics *metrics )  /*  metrics struct to calculate */
+{   /*  begin calcMetricsData()  */
+    Double temp;
+
+    assert( metrics );
+
+    /*
+     *  Determine total time for application execution
+     */
+    metrics->totalTime = getTime() - metrics->totalTime;
+
+    /*
+     *  Calculate metrics for Insert Command: calculate the average and the
+     *  the variance.  If the variance is non-negative, calculate the standard
+     *  deviation.
+     */
+    if ( metrics->insertCommandMetric.numOfCommands > 0 ) {
+        /*
+         *  Calculate metrics for Insert Command: calculate the average and the
+         *  the variance.  If the variance is non-negative, calculate the standard
+         *  deviation.
+         */
+        metrics->insertCommandMetric.avg = metrics->insertCommandMetric.sum 
+                               / metrics->insertCommandMetric.numOfCommands;
+        temp = metrics->insertCommandMetric.sumSquares 
+             - metrics->insertCommandMetric.sum 
+             * metrics->insertCommandMetric.sum 
+             / metrics->insertCommandMetric.numOfCommands;
+        if ( temp < 0.0 ) {
+            metrics->insertCommandMetric.avg       = MINIMUM_VALUE_OF_FLOAT;
+            metrics->insertCommandMetric.deviation = MINIMUM_VALUE_OF_FLOAT;
+        } /* end of temp < 0.0 - round-off error for variance */
+        else {
+            metrics->insertCommandMetric.deviation = sqrt( temp / 
+                   metrics->insertCommandMetric.numOfCommands );
+        } /* end of temp >= 0.0 */
+    } /* end of insert->numOfCommands > 0 */
+    else {
+        metrics->insertCommandMetric.avg       = MINIMUM_VALUE_OF_FLOAT;
+        metrics->insertCommandMetric.deviation = MINIMUM_VALUE_OF_FLOAT;
+    } /* end of insert->numOfCommands == 0 */
+
+    /*
+     *  Calculate metrics for Query Command: calculate the average and the
+     *  the variance.  If the variance is non-negative, calculate the standard
+     *  deviation.
+     */
+    if ( metrics->queryCommandMetric.numOfCommands > 0 ) {
+        metrics->queryCommandMetric.avg = metrics->queryCommandMetric.sum 
+                              / metrics->queryCommandMetric.numOfCommands;
+        temp = metrics->queryCommandMetric.sumSquares 
+             - metrics->queryCommandMetric.sum 
+             * metrics->queryCommandMetric.sum 
+             / metrics->queryCommandMetric.numOfCommands;
+        if ( temp < 0.0 ) {
+            metrics->queryCommandMetric.avg       = MINIMUM_VALUE_OF_FLOAT;
+            metrics->queryCommandMetric.deviation = MINIMUM_VALUE_OF_FLOAT;
+        } /* end of temp < 0.0 - round-off error for variance */
+        else {
+            metrics->queryCommandMetric.deviation = sqrt( temp / 
+                     metrics->queryCommandMetric.numOfCommands );
+        } /* end of temp >= 0.0 */
+    } /* end of query->numOfCommands > 0 */
+    else {
+        metrics->queryCommandMetric.avg       = MINIMUM_VALUE_OF_FLOAT;
+        metrics->queryCommandMetric.deviation = MINIMUM_VALUE_OF_FLOAT;
+    } /* end of query->numOfCommands == 0 */
+
+    /*
+     *  Calculate metrics for Delete Command: calculate the average and the
+     *  the variance.  If the variance is non-negative, calculate the standard
+     *  deviation.
+     */
+    if ( metrics->deleteCommandMetric.numOfCommands > 0 ) {
+        metrics->deleteCommandMetric.avg = metrics->deleteCommandMetric.sum 
+                               / metrics->deleteCommandMetric.numOfCommands;
+        temp = metrics->deleteCommandMetric.sumSquares 
+             - metrics->deleteCommandMetric.sum 
+             * metrics->deleteCommandMetric.sum 
+             / metrics->deleteCommandMetric.numOfCommands;
+        if ( temp < 0.0 ) {
+            metrics->deleteCommandMetric.avg       = MINIMUM_VALUE_OF_FLOAT;
+            metrics->deleteCommandMetric.deviation = MINIMUM_VALUE_OF_FLOAT;
+        } /* end of temp < 0.0 - round-off error for variance */
+        else {
+            metrics->deleteCommandMetric.deviation = sqrt( temp / 
+                 metrics->deleteCommandMetric.numOfCommands );
+        } /* end of temp >= 0.0 */
+    } /* end of delete->numOfCommands > 0 */
+    else {
+        metrics->deleteCommandMetric.avg       = MINIMUM_VALUE_OF_FLOAT;
+        metrics->deleteCommandMetric.deviation = MINIMUM_VALUE_OF_FLOAT;
+    } /* end of delete->numOfCommands == 0 */
+
+    return;
+}   /*  end of calcMetricsData() */

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/chooseEntry.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/chooseEntry.c?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/chooseEntry.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/chooseEntry.c Sun Jan 27 23:23:39 2008
@@ -0,0 +1,64 @@
+
+/*
+ *  Name:           chooseEntry
+ *  Input:          list of entries to choose from
+ *                  entry to choose with
+ *  Output:         entry within input list which minimizes penalty
+ *  Return:         IndexEntry pointer, or
+ *                  NULL if node is empty
+ *  Description:    Determines which entry of input list to add new entry.  
+ *                  Chosen entry provides the minimum penalty which is the 
+ *                  increase of the total hyper-cube volume.  No error is 
+ *                  possible, but the value of the entry returned can be set to 
+ *                  NULL which should be checked for in the calling routine.
+ *  Calls:          penalty();
+ *      System:     
+ *  Author:         M.L.Rivas
+ *
+ *  Revision History:
+ *
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *	Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+#include <assert.h>          /* for assert()                             */
+#include <stdlib.h>          /* for NULL definition                      */
+#include "dataManagement.h"  /* for primitive type definitions           */
+#include "index.h"           /* for IndexNode and IndexEntry definitions */
+
+/*
+ *  Function prototypes
+ */
+extern Float penalty( IndexEntry A, IndexEntry B );
+
+IndexEntry * chooseEntry( IndexNode  *node,     /*  node to choose from  */
+                          IndexEntry *entry )   /*  entry to choose with */
+{   /*  beginning of chooseEntry()  */
+    IndexEntry  *minPenaltyEntry;   /*  result entry to return  */
+    IndexEntry  *temp;              /*  used for looping        */
+    Float       minPenalty;         /*  value of min penalty    */
+    
+    assert( node );
+    assert( node->entries );
+    assert( entry );
+    
+    /*
+     *  Loop through entries of node to find minimum penalty.
+     */
+    minPenaltyEntry = node->entries;
+    minPenalty      = penalty( *minPenaltyEntry, *entry );
+    for ( temp = minPenaltyEntry->next; temp != NULL; temp = temp->next ) {
+        Float   tempPenalty;
+
+        tempPenalty = penalty( *temp, *entry );
+        if ( tempPenalty < minPenalty ) {
+            minPenaltyEntry = temp;
+            minPenalty      = tempPenalty;
+        }   /*  end of if ( tempPenalty < minPenalty )  */
+    }   /*  end of loop for temp    */
+
+    return ( minPenaltyEntry );
+}   /*  end of chooseEntry()    */

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/clearLine.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/clearLine.c?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/clearLine.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/clearLine.c Sun Jan 27 23:23:39 2008
@@ -0,0 +1,37 @@
+
+/*
+ *  Name:           clearLine
+ *  Input:          FILE ptr
+ *  Output:         none
+ *  Return:         void
+ *  Description:    Reads from the current file position to the end of the line 
+ *                  indicated by a new line character '\n' or carriage return 
+ *                  '\r'.  Will also stop at EOF.  Contents of line are not 
+ *                  saved and are lost.  The end-of-line indicator is also 
+ *                  removed from the stream.
+ *  Calls:          
+ *      System:     fgetc()
+ *
+ *  Revision History:
+ *
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *              Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+#include <stdio.h>          /* for FILE and fgetc() definitions */
+#include "dataManagement.h" /* for primitive data types         */
+
+void clearLine( FILE *file )
+{  /* begin clearLine() */
+    Int c; /* temporary character read from file */
+    
+    c = fgetc( file );
+    while ( c != EOF && c != '\n' && c != '\r' ) {
+        c = fgetc( file );
+    }  /*  end loop while ( c != EOF, etc. */
+
+    return;
+}  /* end of clearLine() */

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/closeFiles.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/closeFiles.c?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/closeFiles.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/closeFiles.c Sun Jan 27 23:23:39 2008
@@ -0,0 +1,70 @@
+
+/*
+ *  Name:           closeFiles
+ *  Input:          input FILE pointer
+ *                  output FILE pointer
+ *                  metric FILE pointer
+ *  Output:         none
+ *  Return:         void
+ *  Description:    Routine closes the three files used during application.  
+ *                  The return values for the system call to close the files 
+ *                  are checked but not acted upon.  Any error occuring during 
+ *                  the closing of the files is non-fatal, since the routine is 
+ *                  part of the Input & Output module exit process.  
+ *                  Appropriate messages are placed in the error message buffer 
+ *                  whenever an error does occur.
+ *  Calls:          errorMessage()
+ *      System:     assert()
+ *                  fclose()
+ *  Author:         M.L.Rivas
+ *
+ *  Revision History:
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *	Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+#include <assert.h>         /* for assert()                     */
+#include <stdio.h>          /* for FILE definition and fclose() */
+#include "dataManagement.h" /* for primitive data types         */
+#include "errorMessage.h"   /* for errorMessage() definition    */
+
+void closeFiles( FILE *inputFile,   /*  input file to close   */
+                 FILE *outputFile,  /*  output file to close  */
+                 FILE *metricFile ) /*  metrics file to close */
+{   /* beginning of closeFiles() */
+    Int error;  /* error return from fclose() system call */
+
+    static Char name[] = "closeFiles";
+
+    assert( inputFile );
+    assert( outputFile );
+    assert( metricFile );
+
+    /*
+     *  Close each file provided.  Return values are checked, but not acted 
+     *  upon.  Any error return is non-fatal since the files will only be 
+     *  closed during the Input & Output module exit.
+     */
+    error = fclose( inputFile );
+    if ( error != 0 ) {
+        errorMessage( "error closing input file", REPLACE );
+        errorMessage( name, PREPEND );
+    }   /*  end of if ( error != 0 )    */
+    
+    error = fclose( outputFile );
+    if ( error != 0 ) {
+        errorMessage( "error closing output file", REPLACE );
+        errorMessage( name, PREPEND );
+    }   /*  end of if ( error != 0 )    */
+    
+    error = fclose( metricFile );
+    if ( error != 0 ) {
+        errorMessage( "error closing metric file", REPLACE );
+        errorMessage( name, PREPEND );
+    }   /*  end of if ( error != 0 )    */
+    
+    return;
+}   /* end of closeFiles() */

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/consistent.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/consistent.c?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/consistent.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/consistent.c Sun Jan 27 23:23:39 2008
@@ -0,0 +1,121 @@
+
+/*
+ *  File Name:      consistent.c
+ *  Purpose:        Determines if either the two key or non-key values are 
+ *                  consistent.  Key values are consistent if the two 
+ *                  hyper-cubes intersect.  Non-key values are consistent if the
+ *                  first non-key character string completely constains the 
+ *                  second non-key character string.
+ *
+ *  Revision History:
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *	Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+#include <assert.h>         /* for assert()                   */
+#include <string.h>         /* for strstr() definition        */
+#include "dataManagement.h" /* for primitive type definitions */
+#include "indexKey.h"       /* for IndexKey definition        */
+
+/*
+ *
+ *  Name:           consistentKey
+ *  Input:          index key, A
+ *                  index key, B
+ *  Output:         flag indicating intersection
+ *  Return:         integer, TRUE or FALSE
+ *  Description:    Returns boolean value indicating if two input index keys 
+ *                  intersect.  The routine is communative, i.e., 
+ *                  consistent(A,B) == consistent(B,A).
+ *  Calls:          
+ *      System:     
+ *  Author:         M.L.Rivas
+ *
+ *  Revision History:
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *	Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+Boolean consistentKey( IndexKey *A, IndexKey *B )
+{   /*  beginning of consistentKey() */
+    Boolean flag; /* flag indicating consistency */
+
+    assert( A );
+    assert( B );
+
+    /*
+     *  Check each dimension for intersection.  If any dimension fails, then no 
+     *  intersection can occur, set flag and return.
+     */
+    flag = TRUE;
+    if ( A->lower.T > B->upper.T || B->lower.T > A->upper.T ) {
+        flag = FALSE;
+    } /* end of bounds check on T */
+    else {    
+        if ( A->lower.X > B->upper.X || B->lower.X > A->upper.X ) {
+            flag = FALSE;
+        } /* end of bounds check on X */
+        else {
+            if ( A->lower.Y > B->upper.Y || B->lower.Y > A->upper.Y ) {
+                flag = FALSE;
+            } /* end of bounds check on Y */
+            else {
+                if ( A->lower.Z > B->upper.Z || B->lower.Z > A->upper.Z ) {
+                    flag = FALSE;
+                }   /*  end of bounds check on Z   */
+            }   /*  end of check on Y   */
+        }   /*  end of check on X   */
+    }   /*  end of check on T   */
+        
+    return ( flag );
+}   /*  end of consistentKey()   */
+
+/*
+ *
+ *  Name:           consistentNonKey
+ *  Input:          character string, A
+ *                  character string, B
+ *  Output:         flag indicating intersection
+ *  Return:         integer, TRUE or FALSE
+ *  Description:    Returns boolean value indicating if two input character 
+ *                  strings are consistent.  The check is true if string A 
+ *                  entirely contains string B.  The routine is NOT communative,
+ *                  i.e., consistent(A,B) != consistent(B,A) in general.
+ *  Calls:          
+ *      System:     strstr()
+ *  Author:         M.L.Rivas
+ *
+ *  Revision History:
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *	Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+Boolean consistentNonKey( Char *A, Char *B )
+{   /*  beginning of consistentNonKey() */
+    Boolean flag;  /* flag indicating consistency */
+
+    assert( A );
+    assert( B );
+    
+    /*
+     *  Check for string B inside string A using library
+     *  routine.
+     */
+    if ( strstr( A, B ) != NULL ) {
+        flag = TRUE;
+    }  /*  end of if strstr != NULL */
+    else {
+        flag = FALSE;
+    }  /*  end of if strstr == NULL */
+
+    return ( flag );
+}   /*  end of consistentNonKey()  */

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createDataObject.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createDataObject.c?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createDataObject.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createDataObject.c Sun Jan 27 23:23:39 2008
@@ -0,0 +1,125 @@
+
+/*
+ *  Name:           createDataObject
+ *  Input:          data object type
+ *  Output:         new data object
+ *  Return:         DataObject pointer, or
+ *                  NULL (if allocation failed)
+ *  Description:    Routine creates a data object of specified type by 
+ *                  allocating appropriate amount of memory for number of 
+ *                  non-key attributes.  Note that memory is not allocated for 
+ *                  the individual non-key character strings since their 
+ *                  specific size is not known before hand.  The values for the 
+ *                  data object are also filled with default values which 
+ *                  produces an index key of a hyper-point at the lowest 
+ *                  possible position in the space and sets each non-key 
+ *                  character string to NULL.
+ *  Calls:          errorMessage()
+ *      System:     assert()
+ *                  malloc()
+ *                  free()
+ *  Author:         M.L.Rivas
+ *
+ *  Revision History:
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *	Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+#include <assert.h>         /* for assert()                  */
+#include <stdlib.h>         /* for NULL and malloc()         */
+#include "dataManagement.h" /* for primitive data types      */
+#include "dataObject.h"     /* for DataObject definition     */
+#include "errorMessage.h"   /* for errorMessage() definition */
+
+DataObject * createDataObject( DataObjectType dataObjectType )
+{   /*  beginning of createDataObject() */
+    Int             i;                  /* looping index for attributes */
+    Int             numberOfAttributes; /* number of attribute by type  */
+    DataObject *    dataObject;         /* data object to create        */
+
+    static Char name[] = "createDataObject";
+    
+    assert( !(dataObjectType != SMALL  && \
+              dataObjectType != MEDIUM && \
+              dataObjectType != LARGE ) );
+    assert( MIN_ATTRIBUTE_CODE < NUM_OF_KEY_ATTRIBUTES );
+    assert( MIN_ATTRIBUTE_CODE < MAX_ATTRIBUTE_CODE );
+    assert( MAX_ATTRIBUTE_CODE < NUM_OF_LARGE_ATTRIBUTES );
+    assert( NUM_OF_KEY_ATTRIBUTES < NUM_OF_SMALL_ATTRIBUTES );
+    assert( NUM_OF_KEY_ATTRIBUTES < NUM_OF_MEDIUM_ATTRIBUTES );
+    assert( NUM_OF_KEY_ATTRIBUTES < NUM_OF_LARGE_ATTRIBUTES );
+
+    /*
+     *  Create the data object
+     */
+    dataObject = (DataObject *)malloc( sizeof( DataObject ) );
+    if ( dataObject == NULL ) {
+        /*
+         *  Done: memory allocation error
+         */            
+        errorMessage( "memory allocation failure", REPLACE );
+        errorMessage( name, PREPEND );
+        return ( NULL );
+    }   /*  end if ( dataObject == NULL )    */
+
+    /*
+     *  Determine number of attributes based on type input
+     */
+    if ( dataObjectType == SMALL ) {
+        dataObject->type   = SMALL;
+        numberOfAttributes = NUM_OF_SMALL_ATTRIBUTES;
+    }   /*  end if ( dataObjectType == SMALL )      */
+    else if ( dataObjectType == MEDIUM ) {
+        dataObject->type   = MEDIUM;
+        numberOfAttributes = NUM_OF_MEDIUM_ATTRIBUTES;
+    }   /*  end if ( dataObjectType == MEDIUM )    */
+    else if ( dataObjectType == LARGE ) {
+        dataObject->type   = LARGE;
+        numberOfAttributes = NUM_OF_LARGE_ATTRIBUTES;
+    }   /*  end if ( dataObjectType == LARGE )      */
+    else {
+        errorMessage( "invalid object type to create", REPLACE );
+        errorMessage( name, PREPEND );
+        free( dataObject );
+
+        /*
+         *  Done: data object type error
+         */            
+        return ( NULL );
+    }   /*  end else    */
+    
+    /*
+     *  Allocate memory for attributes
+     */
+    dataObject->attributes =
+        (DataObjectAttribute *)malloc( numberOfAttributes * 
+            sizeof( DataObjectAttribute ) );
+    if ( dataObject->attributes == NULL ) {
+        /*
+         *  Done: memory allocation error
+         */            
+        errorMessage( "memory allocation failure", REPLACE );
+        errorMessage( name, PREPEND );
+        free( dataObject );
+        return ( NULL );
+    }   /* end if ( dataObject->attributes == NULL )    */
+
+    /*
+     *  Assign implausible initial key values
+     */
+    for ( i = MIN_ATTRIBUTE_CODE; i < NUM_OF_KEY_ATTRIBUTES; i++ ) {
+        dataObject->attributes[ i ].value.key = MINIMUM_VALUE_OF_FLOAT;
+    }   /*  end loop for i  */
+                
+    /*
+     *  Assign default non-key values
+     */
+    for ( i = NUM_OF_KEY_ATTRIBUTES; i < numberOfAttributes; i++ ) {
+        dataObject->attributes[ i ].value.nonKey = NULL;
+    }   /*  end loop for i  */
+
+    return ( dataObject );
+}   /*  end of createDataObject()   */

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexEntry.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexEntry.c?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexEntry.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexEntry.c Sun Jan 27 23:23:39 2008
@@ -0,0 +1,70 @@
+
+/*
+ *  Name:           createIndexEntry
+ *  Input:          none
+ *  Output:         new index entry
+ *  Return:         IndexEntry pointer, or
+ *                  NULL (if allocation failed)
+ *  Description:    Routine creates new index entry using system allocation 
+ *                  routine.  Returns pointer to new index entry or NULL if 
+ *                  allocation failed.  The value for the child reference is 
+ *                  set to NULL for later assignment and the index entry is set 
+ *                  to the largest possible volume.
+ *  Calls:          errorMessage()
+ *      System:     malloc()
+ *  Author:         M.L.Rivas
+ *
+ *  Revision History:
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *	Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+#include <stdlib.h>       /* for NULL and malloc() definitions */
+#include "errorMessage.h" /* for errorMessage() definition     */
+#include "index.h"        /* for IndexEntry definition         */
+
+IndexEntry * createIndexEntry( void )
+{   /*  beginning of createIndexEntry() */
+    IndexEntry * entry; /* entry to create */
+
+    static Char name[] = "createIndexEntry";
+
+    entry = NULL;
+    
+    /*
+     *  Allocate memory for new entry
+     */
+    entry = (IndexEntry *)malloc( sizeof( IndexEntry ) );
+    if ( entry == NULL ) {
+        errorMessage( "allocation failure", REPLACE );
+        errorMessage( name, PREPEND );
+    }   /*  end of if ( entry == NULL ) */
+    else {
+        /*
+         *  Set values of entry
+         *      - the pointer to the child reference is set to NULL
+         *      - the index key values are set to the largest
+         *        possible hyper-cube possible.  This give a good
+         *        probability that uninitialized key values will
+         *        be noticed in the case of an error. 
+         */
+        entry->child.node       = NULL;
+        entry->child.dataObject = NULL;
+        
+        entry->key.lower.T      = MINIMUM_VALUE_OF_FLOAT;
+        entry->key.lower.X      = MINIMUM_VALUE_OF_FLOAT;
+        entry->key.lower.Y      = MINIMUM_VALUE_OF_FLOAT;
+        entry->key.lower.Z      = MINIMUM_VALUE_OF_FLOAT;
+        entry->key.upper.T      = MAXIMUM_VALUE_OF_FLOAT;
+        entry->key.upper.X      = MAXIMUM_VALUE_OF_FLOAT;
+        entry->key.upper.Y      = MAXIMUM_VALUE_OF_FLOAT;
+        entry->key.upper.Z      = MAXIMUM_VALUE_OF_FLOAT;
+        
+        entry->next             = NULL;
+    }   /*  end of entry default assignment */
+
+    return ( entry );
+}   /*  end of createIndexEntry()   */

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexNode.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexNode.c?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexNode.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/createIndexNode.c Sun Jan 27 23:23:39 2008
@@ -0,0 +1,69 @@
+
+/*
+ *  Name:           createIndexNode
+ *  Input:          integer level
+ *  Output:         new index node
+ *  Return:         IndexNode pointer, or
+ *                  NULL (if allocation failed)
+ *  Description:    Routine creates new node using system allocation routine, 
+ *                  malloc.  Returns pointer to new node or NULL if allocation 
+ *                  failed.  The level of the new node is input and stored in 
+ *                  new node and the list of index entries is specified to be 
+ *                  empty.
+ *  Calls:          errorMessage()
+ *      System:     malloc()
+ *  Author:         M.L.Rivas
+ *
+ *  Revision History:
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *	Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+#include <stdlib.h>         /* for malloc() and NULL definitions */
+#include "dataManagement.h" /* for primitive type definitions    */
+#include "errorMessage.h"   /* for errorMessage() definition     */
+#include "index.h"          /* for IndexNode definition          */
+
+IndexNode * createIndexNode( Int level )    /*  level of new node   */
+{   /*  beginning of createIndexNode()  */
+    IndexNode * node; /* node to create */
+
+    static Char name[] = "createIndexNode";
+
+    node = NULL;
+    
+    /*
+     *  Check for invalid node level
+     */
+    if ( level < LEAF ) {
+        errorMessage( "invalid level specified", REPLACE );
+        errorMessage( name, PREPEND );
+        node = NULL;
+    }   /*  end of if ( level < LEAF )  */
+    /*
+     *  Create new node with specified level
+     */
+    else {
+        /*
+         *  Allocate memory for new node
+         */
+        node = (IndexNode *)malloc( sizeof( IndexNode ) );
+        if ( node == NULL ) {
+            errorMessage( "allocation failure", REPLACE );
+            errorMessage( name, PREPEND );
+        }   /*  end of if ( node == NULL )  */
+        else {
+            node->level = level;
+        }   /*  end of else */
+    }   /*  end of else */
+    
+    /*
+     *  Set entries of new node to empty list
+     */
+    node->entries = NULL;
+
+    return ( node );
+}   /*  end of createIndexNode  */

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataManagement.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataManagement.h?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataManagement.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataManagement.h Sun Jan 27 23:23:39 2008
@@ -0,0 +1,59 @@
+
+/*
+ *  DIS Data Management
+ *
+ *      This header file contains general type definitions and #define values
+ *      All routines in the Data Management baseline source code should
+ *      include this file.
+ *
+ *  Revision History:
+ *
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *              Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+
+#ifndef     DIS_DATA_MANAGEMENT_H
+#define     DIS_DATA_MANAGEMENT_H
+
+/*
+ *  Typedef primitive numeric types for greater portability
+ */
+typedef long int        Int;
+typedef float           Float;
+typedef char            Char;
+typedef char            Boolean;
+
+/*
+ *  Wild-Card parameters
+ *      - values defined by IEEE 754 Specification as required by DIS Benchmark 
+ *        Suite Specification
+ */
+#define MINIMUM_VALUE_OF_FLOAT     -3.40282347e38
+#define MAXIMUM_VALUE_OF_FLOAT      3.40282347e38
+#define MINIMUM_VALUE_OF_INT       -2147483647 
+#define MAXIMUM_VALUE_OF_INT        2147483647
+
+/*
+ *  Set boolean values
+ */
+#define TRUE                        1
+#define FALSE                       0
+
+/*
+ *  Index (R-Tree) Parameters
+ *      - minimum fan size allowable for the R-Tree index.  The value must
+ *        be greater than one, but no upper limit is made for the fan.
+ */
+#define MINIMUM_FAN_SIZE            2
+
+/*
+ *  LEAF level definition
+ *      - level of a leaf node.  All levels are greater than or equal to the
+ *        leaf level.
+ */
+#define LEAF                        0
+
+#endif  /*  DIS_DATA_MANAGEMENT_H   */

Added: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataObject.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataObject.h?rev=46435&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataObject.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/dataObject.h Sun Jan 27 23:23:39 2008
@@ -0,0 +1,131 @@
+
+/*
+ *  DIS Data Management Data Object
+ *
+ *      This structure represents the base type of data object stored by the 
+ *      R-Tree index for the DIS Benchmark Suite:Data Management.  The 
+ *      structure is made up of two members.  The first is a enumerated type 
+ *      defining the size of the data object, and the second is the array of 
+ *      attributes for this data object.  Each attribute can be either a value 
+ *      of Float for key attributes or Char * for non-key attributes.  A utility
+ *      structure is define, DataAttribute, which includes the attribute code 
+ *      for the DataObjectAttribute, which is used by the query and delete 
+ *      commands.  It also provides link-list capability to the 
+ *      DataObjectAttribute structure.
+ *
+ *  Revision History:
+ *
+ *  Date    Name            Revision
+ *  ------- --------------- ------------------------------
+ *  24May99 Matthew Rivas   Created
+ *
+ *              Copyright 1999, Atlantic Aerospace Electronics Corp.
+ */
+ 
+#ifndef     DIS_DATA_OBJECT_H
+#define     DIS_DATA_OBJECT_H
+
+#include "dataManagement.h" /* for data type primitives */
+
+/*
+ *  Data Object Type enumerator
+ *      - values defined by DIS Benchmark Suite Specification
+ *      - used to determine number of non-key attributes assigned to data object
+ */
+
+typedef enum
+{
+    SMALL   = 1,
+    MEDIUM  = 2,
+    LARGE   = 3
+} DataObjectType;
+
+/*
+ *  Data Object Attribute structure
+ *      - value of attribute is a union
+ *      - value can be key/Float or non-key/Char *
+ *      - used by DataObject structure
+ */
+
+typedef struct
+{
+    union
+    {
+        Float       key;
+        Char *      nonKey;
+    }               value;
+} DataObjectAttribute;
+
+/*
+ *  Data Attribute structure
+ *      - a subclass of DataObjectAttribute
+ *      - adds command code and link-list capability to DataObjectAttribute
+ *      - used by query and delete for key and non-key searches
+ *      - code must lie between 0 and MAX_ATTRIBUTE_CODE
+ *      - code value between 0 and NUM_OF_KEY_ATTRIBUTES is a float
+ *      - all other code values are character strings
+ */
+
+struct DataAttribute
+{
+    Int                     code;       /*  code of attribute       */
+    DataObjectAttribute     attribute;  /*  attribute for code      */
+
+    struct DataAttribute    *next;      /*  next attribute in list  */
+};
+
+typedef struct DataAttribute    DataAttribute;
+
+/*
+ *  Data Object structure
+ *      - basic storage unit of database which is referenced by R-Tree index
+ *      - contains key and non-key attributes
+ *      - number of attributes is determined by DataObjectType enumerator.
+ */
+
+struct DataObject
+{
+    DataObjectType          type;       /*  type of data object     */
+    DataObjectAttribute *   attributes; /*  attributes for object   */
+};
+
+typedef struct DataObject   DataObject;
+
+/*
+ *  Attribute parameters
+ *      - values defined by DIS Benchmark Suite Specification 
+ */
+#define MAX_SIZE_OF_NON_KEY_ATTRIBUTE   1024
+#define NUM_OF_SMALL_ATTRIBUTES           18
+#define NUM_OF_MEDIUM_ATTRIBUTES          25
+#define NUM_OF_LARGE_ATTRIBUTES           51
+#define NUM_OF_KEY_ATTRIBUTES              8
+#define MIN_ATTRIBUTE_CODE                 0
+#define MAX_ATTRIBUTE_CODE                50
+
+/*
+ *  Key attribute parameters
+ *      - value represents sequence of values placed in index key
+ *      - prevents hard-coded values placed in code
+ */
+enum {
+    LOWER_POINT_T = 0,
+    LOWER_POINT_X = 1,
+    LOWER_POINT_Y = 2,
+    LOWER_POINT_Z = 3,
+    UPPER_POINT_T = 4,
+    UPPER_POINT_X = 5,
+    UPPER_POINT_Y = 6,
+    UPPER_POINT_Z = 7
+};
+
+/*
+ *  Prototypes for routines which create, delete, and display DataObject 
+ *  structures.
+ */
+
+extern DataObject *    createDataObject( DataObjectType dataObjectType );
+extern void            deleteDataObject( DataObject * dataObject );
+extern void            outputDataObject( DataObject * dataObject, Int indent );
+
+#endif  /*  DIS_DATA_OBJECT_H   */





More information about the llvm-commits mailing list