Changeset 5814 in /cluster/svnroot


Ignore:
Timestamp:
Oct 4, 2016 3:37:39 PM (4 years ago)
Author:
amweeden06
Message:

Fixing #855

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bccd-ng/branches/aaron/bccd-3.3.4/trees/etc/skel/Area-under-curve/area.c

    r3751 r5814  
    3535
    3636#ifdef STAT_KIT
    37 #include "../StatKit/petakit/pkit.h"    // For PetaKit output
     37#include "../StatKit/petakit/pkit.h"
    3838#endif
    3939
     
    5151int main(int argc, char** argv)
    5252{
    53 
    5453#ifdef STAT_KIT
    55          startTimer();
    56 #endif
    57 
     54    startTimer();
     55#endif
    5856
    5957    /* Declare the constants, variables, and data structures */
    6058    int OUR_RANK = 0, OUR_NUMBER_OF_THREADS = 1, OUR_NUMBER_OF_RECTANGLES = 10,
    6159        NUMBER_OF_RECTANGLES = 10, NUMBER_OF_PROCESSES = 1, MY_THREAD_NUM = 0,
    62         my_current_rectangle_id = 0;
     60        my_current_rectangle_id = 0, MY_CARDINALITY = 0;
    6361    double OUR_X_LEFT = 0.0, X_LEFT = 0.0, X_RIGHT = 10.0, WIDTH = 0.0,
    6462           RECTANGLE_WIDTH = 0.0, our_total_sum = 0.0, the_total_sum = 0.0,
    6563           my_current_rectangle_left = 0.0, my_current_rectangle_height = 0.0;
    6664    double * our_areas;
    67     int our_cardinality = 0;
    6865
    6966    /* For command line parsing */
     
    7572        MPI_Comm_rank(MPI_COMM_WORLD, &OUR_RANK);
    7673        MPI_Comm_size(MPI_COMM_WORLD, &NUMBER_OF_PROCESSES);
    77         our_cardinality += NUMBER_OF_PROCESSES;
     74        MY_CARDINALITY += NUMBER_OF_PROCESSES;
    7875    #endif
    7976
     
    109106
    110107    #ifdef OMP
    111     #pragma omp parallel
    112         {
     108    #pragma omp parallel private(MY_THREAD_NUM)
     109      {
    113110        MY_THREAD_NUM = omp_get_thread_num();
    114         our_cardinality += omp_get_num_threads();
     111        OUR_NUMBER_OF_THREADS = omp_get_num_threads();
     112        MY_CARDINALITY += omp_get_num_threads();
    115113    #endif
    116114
     
    137135            /* Calculate the left x-boundary of the
    138136             *  process. */
    139             OUR_X_LEFT = (OUR_RANK * (NUMBER_OF_RECTANGLES /
    140                     NUMBER_OF_PROCESSES)) + X_LEFT;
     137            OUR_X_LEFT = OUR_RANK * (NUMBER_OF_RECTANGLES /
     138                    NUMBER_OF_PROCESSES) * ((X_RIGHT - X_LEFT) /
     139                    NUMBER_OF_RECTANGLES) + X_LEFT;
    141140        }
    142141    #ifdef OMP
     
    177176    #endif
    178177   
    179         /* Print the total sum */
    180         if (OUR_RANK == 0)
    181                 printf("%f\n", the_total_sum);
     178    /* Print the total sum */
     179    if (OUR_RANK == 0)
     180        printf("%f\n", the_total_sum);
    182181
    183182    /* Deallocate the array */
     
    190189
    191190#ifdef STAT_KIT
    192         if (our_cardinality == 0)
    193                 our_cardinality = 1;
    194         printStats("Are Under Curve",our_cardinality,"mpi",NUMBER_OF_RECTANGLES, "1", 0, 0);
     191    if (MY_CARDINALITY == 0)
     192    {
     193        MY_CARDINALITY = 1;
     194    }
     195    printStats("Area Under the Curve", MY_CARDINALITY, "mpi",
     196               NUMBER_OF_RECTANGLES, "1", 0, 0);
    195197#endif
    196198
     
    198200    return 0;
    199201}
     202
Note: See TracChangeset for help on using the changeset viewer.