~ubuntu-branches/debian/stretch/adios/stretch

« back to all changes in this revision

Viewing changes to src/write/adios_mpi_lustre.c

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2014-06-16 23:06:38 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20140616230638-5a0z7ylxx8i0edrg
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:
10
10
#include <math.h>
11
11
#include <string.h>
12
12
#include <errno.h>
 
13
#include <sys/types.h>
 
14
#include <sys/stat.h>
13
15
 
14
16
// xml parser
15
17
#include <mxml.h>
222
224
static void
223
225
adios_mpi_lustre_set_striping_unit(char *filename, char *parameters, struct adios_MPI_data_struct * md)
224
226
{
225
 
    MPI_File fh = md->fh;
226
 
    int nproc = md->size;
227
 
    struct statfs fsbuf;
228
 
    int err = 0, flag;
 
227
    int err = 0;
229
228
//    uint64_t striping_unit = 0;
230
 
    uint64_t block_unit = 0;
231
229
    uint16_t striping_count = 0;
232
230
    uint16_t stripe_offset = -1;
233
 
    char     value[64], *temp_string, *p_count,*p_size;
234
 
    MPI_Info info_used;
 
231
    char     *temp_string, *p_count,*p_size;
235
232
 
236
 
    int fd, old_mask, perm, num_ost, rc;
237
 
    struct lov_user_md lum;
238
 
    struct obd_uuid uuids[1024], * uuidp;
 
233
    int fd, old_mask, perm;
 
234
#ifdef HAVE_LUSTRE
 
235
    int num_ost;
 
236
#endif
239
237
 
240
238
    old_mask = umask(022);
241
239
    umask(old_mask);
247
245
 
248
246
#ifdef HAVE_LUSTRE
249
247
    // To get the number of ost's in the system
 
248
    struct obd_uuid uuids[1024];
 
249
    int rc;
250
250
    num_ost = 1024;
251
251
    rc = llapi_lov_get_uuids(fd, uuids, &num_ost);
252
252
    if (rc != 0)
256
256
                );
257
257
    }
258
258
#else
259
 
    num_ost = 0;
 
259
    //num_ost = 0;
260
260
#endif
261
261
 
262
262
    temp_string = (char *) malloc (strlen (parameters) + 1);
263
263
    strcpy (temp_string, parameters);
264
264
    trim_spaces (temp_string);
265
265
 
266
 
    if (p_count = strstr (temp_string, "stripe_count"))
 
266
    if ( (p_count = strstr (temp_string, "stripe_count")) )
267
267
    {
268
268
        char * p = strchr (p_count, '=');
269
269
        char * q = strtok (p, ",");
275
275
    else
276
276
    {
277
277
#ifdef HAVE_LUSTRE
 
278
        int nproc = md->size;
278
279
        striping_count = (nproc > num_ost ? -1 : nproc);
279
280
#else
280
281
        striping_count = 4;
284
285
    strcpy (temp_string, parameters);
285
286
    trim_spaces (temp_string);
286
287
 
287
 
    if (p_size = strstr (temp_string, "stripe_size"))
 
288
    if ( (p_size = strstr (temp_string, "stripe_size")))
288
289
    {
289
290
        char * p = strchr (p_size, '=');
290
291
        char * q = strtok (p, ",");
302
303
    strcpy (temp_string, parameters);
303
304
    trim_spaces (temp_string);
304
305
 
305
 
    if (p_size = strstr (temp_string, "stripe_offset"))
 
306
    if ( (p_size = strstr (temp_string, "stripe_offset")) )
306
307
    {
307
308
        char * p = strchr (p_size, '=');
308
309
        char * q = strtok (p, ",");
317
318
        stripe_offset = -1;
318
319
    }
319
320
 
320
 
    strcpy (temp_string, parameters);
321
 
    trim_spaces (temp_string);
322
 
 
323
 
    if (p_size = strstr (temp_string, "block_size"))
324
 
    {
325
 
        char * p = strchr (p_size, '=');
326
 
        char * q = strtok (p, ",");
327
 
        if (!q)
328
 
            block_unit = atoi(q + 1);
329
 
        else
330
 
            block_unit = atoi(p + 1);
331
 
    }
332
 
    else
333
 
    {
334
 
        // set block_unit to 0 to make one large write
335
 
        block_unit = 0;
336
 
    }
337
321
 
338
322
    free (temp_string);
339
323
 
361
345
static void
362
346
adios_mpi_lustre_set_block_unit(uint64_t *block_unit, char *parameters)
363
347
{
364
 
    char *temp_string, *p_count,*p_size;
 
348
    char *temp_string, *p_size;
365
349
 
366
350
    temp_string = (char *) malloc (strlen (parameters) + 1);
367
351
    strcpy (temp_string, parameters);
368
352
    trim_spaces (temp_string);
369
353
 
370
 
    if (p_size = strstr (temp_string, "block_size"))
 
354
    if ( (p_size = strstr (temp_string, "block_size")) )
371
355
    {
372
356
        char * p = strchr (p_size, '=');
373
357
        char * q = strtok (p, ",");
489
473
        char * buf_ptr = buf;
490
474
        while (total_written < len)
491
475
        {
492
 
            write_len = (to_write > INT32_MAX) ? INT32_MAX : to_write;
 
476
            write_len = (to_write > MAX_MPIWRITE_SIZE) ? MAX_MPIWRITE_SIZE : to_write;
493
477
            MPI_File_write (fh, buf_ptr, write_len, MPI_BYTE, &status);
494
478
            MPI_Get_count(&status, MPI_BYTE, &count);
495
479
            if (count != write_len)
858
842
                    }
859
843
                    // How to handle that each processor has varying amount of data??
860
844
                    md->striping_unit = offsets[1] - offsets[0];
861
 
                    if (md->striping_unit > 4 * 1024 * 1024 * 1024L)
 
845
                    if (md->striping_unit > 4 * 1024 * (uint64_t) (1024 * 1024L))
862
846
                    {
863
 
                        md->striping_unit = 4 * 1024 * 1024 * 1024L;
 
847
                        md->striping_unit = 4 * 1024 * (uint64_t) (1024 * 1024L);
864
848
                    }
865
849
 
866
850
                    md->b.pg_index_offset =   offsets [md->size - 1]
1377
1361
 
1378
1362
        // write payload
1379
1363
        // adios_write_var_payload_v1 (fd, v);
1380
 
        uint64_t var_size = adios_get_var_size (v, fd->group, v->data);
 
1364
        uint64_t var_size = adios_get_var_size (v, v->data);
1381
1365
        if (fd->base_offset + var_size > fd->pg_start_in_file + fd->write_size_bytes) 
1382
1366
            fprintf (stderr, "adios_mpi_write exceeds pg bound. File is corrupted. "
1383
1367
                             "Need to enlarge group size. \n");
1491
1475
                                                      method->method_data;
1492
1476
    struct adios_var_struct * v = fd->group->vars;
1493
1477
 
1494
 
    struct adios_parse_buffer_struct data;
1495
 
 
1496
 
    data.vars = v;
1497
 
    data.buffer = 0;
1498
 
    data.buffer_len = 0;
1499
 
 
1500
 
    switch (md->b.version & ADIOS_VERSION_NUM_MASK)
 
1478
    uint32_t version = md->b.version & ADIOS_VERSION_NUM_MASK;
 
1479
    switch (version)
1501
1480
    {
1502
1481
        case 1:
 
1482
        case 2:
1503
1483
        {
1504
1484
            // the three section headers
1505
1485
            struct adios_process_group_header_struct_v1 pg_header;
1581
1561
        }
1582
1562
 
1583
1563
        default:
1584
 
            fprintf (stderr, "MPI read: file version unknown: %u\n"
1585
 
                    ,md->b.version
1586
 
                    );
 
1564
            fprintf (stderr, "MPI read: file version unknown: %u\n", version);
1587
1565
            return;
1588
1566
    }
1589
1567
 
1642
1620
                adios_write_close_vars_v1 (fd);
1643
1621
                // fd->vars_start gets updated with the size written
1644
1622
                uint64_t count;
1645
 
                int retlen;
1646
1623
                START_TIMER (ADIOS_TIMER_MPI_LUSTRE_MD);
1647
1624
                count = adios_mpi_lustre_striping_unit_write(
1648
1625
                                  md->fh,
1654
1631
                if (count != md->vars_header_size)
1655
1632
                {
1656
1633
                    fprintf (stderr, "d:MPI method tried to write %llu, "
1657
 
                                     "only wrote %d\n"
 
1634
                                     "only wrote %llu\n"
1658
1635
                            ,md->vars_header_size
1659
1636
                            ,count
1660
1637
                            );