~ubuntu-branches/ubuntu/vivid/adios/vivid-proposed

« back to all changes in this revision

Viewing changes to src/write/adios_var_merge.c

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2014-06-16 23:06:38 UTC
  • mfrom: (15.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20140616230638-cxryhot6b8ge32l6
Tags: 1.7.0-1
* New upstream release.
* Add adios.pc pkgconfig file. adios_config now uses this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#include <stdlib.h>
6
6
#include <math.h>
7
7
#include <string.h>
 
8
#include <assert.h>
8
9
 
9
10
// xml parser
10
11
#include <mxml.h>
153
154
        case adios_string:
154
155
        case adios_complex:
155
156
        case adios_double_complex:
 
157
        default:
156
158
            adios_error (err_unspecified,
157
159
                         "Cannot convert type %s to integer for var %s\n",
158
160
                         adios_type_to_string_int (type), parent_name);
231
233
static int cal_layout(int *procs, int rank, int nprocs, int ndims, MPI_Comm comm, uint64_t *ldims, uint64_t *gdims, uint64_t *offsets)
232
234
{
233
235
    char *sbuf, *recvbuf;
234
 
    int slen, recvlen, blen;
235
 
    uint64_t *t_ldims, *t_offsets, prev_off[3];
 
236
    int slen, blen;
 
237
    uint64_t *t_ldims, *t_offsets;
236
238
    int i,j;
237
239
    int decomp=0;
238
240
 
 
241
    assert (ndims <= 3);
239
242
 
240
243
    for(i=0;i<3;i++){
241
244
        procs[i]=-1;
251
254
    slen+=ndims*sizeof(uint64_t);
252
255
 
253
256
    recvbuf=(char *)malloc(nprocs*ndims*2*sizeof(uint64_t));
254
 
    recvlen=0;
255
257
    //rank 0 calculate the info then send to the rest
256
258
    if(rank==0) {
257
259
        //gather all the info to rank 0
364
366
 
365
367
static void cal_offsets(int *procs, int rank, int ndims, int decomp, int *offsets)
366
368
{
367
 
    int i;
368
 
 
369
369
    if(decomp>=1) {
370
370
        offsets[sequence[0]]=rank%procs[sequence[0]];
371
371
    }
381
381
static void cal_process_map(int rank, int *procs)
382
382
{
383
383
    int i,j,k;
384
 
    int pos, cnt=0;
 
384
    int cnt=0;
 
385
    //int pos;
385
386
 
386
387
    if(layout==0) {
387
388
        for(i=0;i<procs[2];i++) {
388
389
            for(j=0;j<procs[1];j++) {
389
390
                for(k=0;k<procs[0];k++) {
390
 
                    pos=i*procs[0]*procs[1]+j*procs[0]+k;
 
391
                    //pos=i*procs[0]*procs[1]+j*procs[0]+k;
391
392
                    proc_map[i*procs[0]*procs[1]+j*procs[0]+k]=cnt;
392
393
                    cnt++;
393
394
                }
398
399
        for(i=0;i<procs[0];i++) {
399
400
            for(j=0;j<procs[1];j++) {
400
401
                for(k=0;k<procs[2];k++) {
401
 
                    pos=k*procs[0]*procs[1]+j*procs[0]+i;
 
402
                    //pos=k*procs[0]*procs[1]+j*procs[0]+i;
402
403
                    proc_map[k*procs[0]*procs[1]+j*procs[0]+i]=cnt;
403
404
                    cnt++;
404
405
                }
410
411
 
411
412
static int get_clients_2d(int ndims, int level, int *offsets, int scale, int *procs, int rank)
412
413
{
413
 
    int posx, posy, posz, pos;
 
414
    int posx, posy, pos;
414
415
 
415
416
    if((offsets[0]+scale)<procs[0]) {
416
417
        posx=offsets[0]+1*scale;
513
514
{
514
515
    int scale=1, step=2;
515
516
    int aggrx, aggry, aggrz;
516
 
    int aggr=1;
517
517
    int i,j,k;
518
518
    int prev_step, hole;
519
519
    int *offsets;
560
560
                memset(aggr1d_clients[i-1], 0x00, mal_size*sizeof(struct aggr_client));
561
561
            }
562
562
 
563
 
            int posx, posy, posz, pos;
 
563
            int pos;
564
564
 
565
565
            //3D variable
566
566
            /*FIXME XXX: hard coded for calculating aggr_clients*/
701
701
   return 0;
702
702
}
703
703
 
 
704
#if 0
704
705
//find the variable within the buffer link list
705
706
static int var_lookup(const char *varname, char *path, struct aggr_var_struct *list)
706
707
{
722
723
    //variable is not within the list, return -1
723
724
    return -1;
724
725
}
 
726
#endif
725
727
 
726
728
static void output_vars(struct aggr_var_struct *vars, int varcnt, struct
727
729
        adios_MPI_data_struct * md, struct adios_file_struct * fd)
728
730
{
729
 
    int i,j;
 
731
    int i;
730
732
    char file_mode[2];
731
 
    char fname[256];
732
 
    uint64_t adios_size, datasize;
733
 
    int iocnt=0;
734
 
    char *output;
 
733
    uint64_t adios_size;
735
734
 
736
735
    if(convert_file_mode(fd->mode, file_mode) == -1) //strange file mode
737
736
        return;
798
797
 
799
798
void init_output_parameters(const PairStruct *params)
800
799
{
801
 
    int len;
802
800
    const PairStruct *p = params;
803
801
 
804
802
    while (p) {
806
804
            errno = 0;
807
805
            aggr_chunksize = strtol(p->value, NULL, 10);
808
806
            if (aggr_chunksize > 0 && !errno) {
809
 
                log_debug ("Chunk size set to %llu for VAR_MERGE method\n", aggr_chunksize);
 
807
                log_debug ("Chunk size set to %d for VAR_MERGE method\n", aggr_chunksize);
810
808
            } else {
811
809
                log_error ("Invalid 'chunk_size' parameter given to the VAR_MERGE method"
812
810
                           "method: '%s'\n", p->value);
857
855
}
858
856
 
859
857
 
860
 
static void adios_var_to_comm (const char * comm_name
861
 
                              ,enum ADIOS_FLAG host_language_fortran
862
 
                              ,void * data
863
 
                              ,MPI_Comm * comm
864
 
                              )
865
 
{
866
 
    if (data)
867
 
    {
868
 
        int t = *(int *) data;
869
 
 
870
 
        if (!comm_name)
871
 
        {
872
 
            if (!t)
873
 
            {
874
 
                log_warn ("TIAN method: communicator not provided and none "
875
 
                          "listed in XML.  Defaulting to MPI_COMM_SELF\n");
876
 
 
877
 
                *comm = MPI_COMM_SELF;
878
 
            }
879
 
            else
880
 
            {
881
 
                if (host_language_fortran == adios_flag_yes)
882
 
                {
883
 
                    *comm = MPI_Comm_f2c (t);
884
 
                }
885
 
                else
886
 
                {
887
 
                    *comm = *(MPI_Comm *) data;
888
 
                }
889
 
            }
890
 
        }
891
 
        else
892
 
        {
893
 
            if (!strcmp (comm_name, ""))
894
 
            {
895
 
                if (!t)
896
 
                {
897
 
                    log_warn ("TIAN method: communicator not provided and none "
898
 
                              "listed in XML.  Defaulting to MPI_COMM_SELF\n");
899
 
 
900
 
                    *comm = MPI_COMM_SELF;
901
 
                }
902
 
                 else
903
 
                 {
904
 
                     if (host_language_fortran == adios_flag_yes)
905
 
                     {
906
 
                         *comm = MPI_Comm_f2c (t);
907
 
                     }
908
 
                     else
909
 
                     {
910
 
                         *comm = *(MPI_Comm *) data;
911
 
                     }
912
 
                 }
913
 
             }
914
 
             else
915
 
             {
916
 
                 if (!t)
917
 
                 {
918
 
                     log_warn ("TIAN method: communicator not provided but one "
919
 
                               "listed in XML.  Defaulting to MPI_COMM_WORLD\n");
920
 
 
921
 
                     *comm = MPI_COMM_WORLD;
922
 
                 }
923
 
                 else
924
 
                 {
925
 
                     if (host_language_fortran == adios_flag_yes)
926
 
                     {
927
 
                         *comm = MPI_Comm_f2c (t);
928
 
                     }
929
 
                     else
930
 
                     {
931
 
                         *comm = *(MPI_Comm *) data;
932
 
                     }
933
 
                 }
934
 
             }
935
 
         }
936
 
     }
937
 
     else
938
 
     {
939
 
         log_warn ("TIAN method: coordination-communication not provided. "
940
 
                   "Using MPI_COMM_WORLD instead\n");
941
 
 
942
 
         *comm = MPI_COMM_WORLD;
943
 
     }
944
 
}
945
858
 
946
859
static void init_method_parameters()
947
860
{
996
909
                                         ,struct adios_method_struct * method)
997
910
{
998
911
 
999
 
    struct adios_MPI_data_struct * md = (struct adios_MPI_data_struct *)
1000
 
                                                    method->method_data;
1001
912
    switch (fd->mode)
1002
913
    {
1003
914
        case adios_mode_read:
1023
934
    return adios_flag_no;
1024
935
}
1025
936
 
 
937
#if 0
1026
938
static void prepare_data(void **data, uint64_t varsize, int dims)
1027
939
{
1028
940
    int i,j,k,l;
1040
952
        }
1041
953
    }
1042
954
}
 
955
#endif
1043
956
 
 
957
#if 0
1044
958
static struct aggr_var_struct *allocate_vars(int varcnt, struct aggr_var_struct *vars)
1045
959
{
1046
960
     if(varcnt==0) {
1054
968
 
1055
969
     return vars;
1056
970
}
 
971
#endif
1057
972
 
1058
973
void adios_var_merge_write (struct adios_file_struct * fd
1059
974
                     ,struct adios_var_struct * v
1067
982
    struct adios_dimension_struct * d = v->dimensions;
1068
983
    struct aggr_var_struct *tmp;
1069
984
    uint8_t dims_count = 0;
1070
 
    uint64_t total_size, varsize, alloc_size;
1071
 
    int64_t afd;
 
985
    uint64_t varsize, alloc_size;
1072
986
    int i, ndims,type_size=0;
1073
987
    uint64_t *ldims, *offsets, *gdims;
1074
 
    char *new_ldims, *dimensions, *local_offsets, *global_dimensions;
 
988
    char *new_ldims;
1075
989
    int chunk_cnt, decomp=0;
1076
990
 
1077
991
    ndims=0;
1092
1006
    init_vars(vars, v, ndims);
1093
1007
 
1094
1008
    //retrieve the chunk size
1095
 
    varsize=adios_get_var_size(v, method->group, data);
 
1009
    varsize=adios_get_var_size(v, data);
1096
1010
 
1097
1011
    //number of the dimensions of this variable
1098
1012
    ndims=count_dimensions(v->dimensions);
1136
1050
 
1137
1051
        if(type_size==1) {
1138
1052
            vars->multidim=adios_flag_yes;
1139
 
            varsize=adios_get_var_size(v, method->group, data);
 
1053
            varsize=adios_get_var_size(v, data);
1140
1054
            vars->data=malloc(varsize);
1141
1055
            memcpy(vars->data, data, varsize);
1142
1056
        }
1235
1149
    {
1236
1150
        vars->multidim=adios_flag_no;
1237
1151
 
1238
 
        varsize=adios_get_var_size(v, method->group, data);
 
1152
        varsize=adios_get_var_size(v, data);
1239
1153
        vars->data=malloc(varsize);
1240
1154
        memcpy(vars->data, data, varsize);
1241
1155
    }
1242
1156
 
1243
1157
    totalsize+=varsize;
1244
1158
    if(varsize>0) {
1245
 
        // NCSU ALACRITY-ADIOS: In the future, the transform type string here needs to be reconsidered, to possibly allow transforms after aggregation...
1246
 
        adios_common_define_var(grp, vars->name, vars->path, vars->type, vars->dimensions, vars->global_dimensions, vars->local_offsets, "");
 
1159
        adios_common_define_var(grp, vars->name, vars->path, vars->type, vars->dimensions, vars->global_dimensions, vars->local_offsets);
 
1160
        // NCSU ALACRITY-ADIOS: In the future, the transform method here needs to be 
 
1161
        // reconsidered, to possibly allow transforms after aggregation...
 
1162
        // call adios_common_set_transform (var, transform_string)
1247
1163
        varcnt++;
1248
1164
    }
1249
1165
    else { //move back the pointer, and release the memory
1410
1326
static uint64_t do_spatial_aggr(int level, int *procs, int ndims, uint64_t *ldims, uint64_t *offsets, char *new_ldims, int rank,  void *data, uint64_t varsize, void *output, int type_size, MPI_Comm comm)
1411
1327
{
1412
1328
    //struct adios_var_struct * v = g->vars;
1413
 
    int i, j, k, client_cnt, lev;
1414
 
    uint64_t aggrsize, buff_offset, tmpsize, alloc_size;
 
1329
    int i, j, k, lev;
 
1330
    uint64_t buff_offset, tmpsize, alloc_size;
1415
1331
    uint64_t *tmp_dims, *tmp_offsets, *gdims, *ldims_list, *size_list;
1416
1332
    char   *tmpbuf, *recvbuf, *sendbuf;
1417
1333
    MPI_Status status;
1575
1491
static void aggr_chunks(char **output, int *procs, int ndims, uint64_t *ldims_list,
1576
1492
    uint64_t *gdims, uint64_t *size_list, uint64_t totalsize, int nchunks, int rank, int level, int type_size)
1577
1493
{
1578
 
    uint64_t count[3];
1579
 
    uint64_t size;
1580
 
    int i,j,k, m, cnt;
 
1494
    int i,j,k,cnt;
1581
1495
    uint64_t var_offset, dset_offset, buff_offset, size_in_dset[2];
1582
1496
    uint64_t datasize, dst_stride, src_stride;
1583
1497
    //cycles_t c1, c2;
1584
 
    double tmem=0;
1585
1498
    char *input;
1586
 
    int chunk_cnt;
 
1499
    //int chunk_cnt;
1587
1500
    uint64_t prev_x, prev_y, prev_z;
1588
1501
    uint64_t m_offx, m_offy, m_offz;
1589
1502
    uint64_t offx, offy, offz;
1590
1503
    int ni, nj, nk;
1591
1504
 
1592
 
    chunk_cnt=(int)pow(2, ndims);
 
1505
    //chunk_cnt=(int)pow(2, ndims);
1593
1506
    input=(char *)malloc(totalsize);
1594
1507
    memcpy(input, *output, totalsize);
1595
1508