Changeset 4798 in /cluster/svnroot


Ignore:
Timestamp:
Jul 9, 2014 6:07:13 PM (6 years ago)
Author:
amweeden06
Message:

HPCU Precipitate Distributed - initial solution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bccd-ng/hpcu-weekly-challenge/precipitate-distributed/precipitate.c

    r4797 r4798  
    4040/* ARRAYS */
    4141int *ParticleStates;
     42int *MyParticleStates;
    4243int *ParticleDirections;
    4344int *XPositions;
     45int *MyXPositions;
    4446int *YPositions;
     47int *MyYPositions;
    4548
    4649/* FUNCTION DECLARATIONS */
     
    8689
    8790    ParticleStates = (int*) malloc(NParticles * sizeof(int));
     91    MyParticleStates = (int*) malloc(NParticles/NProcs * sizeof(int));
    8892    ParticleDirections = (int*) malloc(NParticles * sizeof(int));
    8993    XPositions = (int*) malloc(NParticles * sizeof(int));
     94    MyXPositions = (int*) malloc(NParticles/NProcs * sizeof(int));
    9095    YPositions = (int*) malloc(NParticles * sizeof(int));
     96    MyYPositions = (int*) malloc(NParticles/NProcs * sizeof(int));
    9197
    9298    randomizePositions();
     99
     100    MPI_Allgather(MyXPositions, NParticles/NProcs, MPI_INT,
     101            XPositions, NParticles/NProcs, MPI_INT, MPI_COMM_WORLD);
    93102
    94103    for (i = 0; i < NTimeSteps; i++) {
     
    161170    int i;
    162171
    163     for (i = 0; i < NParticles; i++) {
    164         ParticleStates[i] = NONE;
    165         XPositions[i] = (EnvWidth - PartWidth) * random() / RAND_MAX;
    166         YPositions[i] = (EnvHeight - PartHeight) * random() / RAND_MAX;
     172    for (i = 0; i < NParticles/NProcs; i++) {
     173        MyParticleStates[i] = NONE;
     174        MyXPositions[i] = (EnvWidth - PartWidth) * random() / RAND_MAX;
     175        MyYPositions[i] = (EnvHeight - PartHeight) * random() / RAND_MAX;
    167176    }
    168177}
Note: See TracChangeset for help on using the changeset viewer.