Skip to content

Commit

Permalink
Merge pull request ESMCI#1752 from NCAR/ejh_bget
Browse files Browse the repository at this point in the history
Remove bget
  • Loading branch information
edwardhartnett authored Sep 15, 2020
2 parents 14ba346 + d048ed5 commit d0d4a98
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 1,836 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/a4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ jobs:
make
sudo make install
popd
- name: cmake build
run: |
set -x
gcc --version
echo 'export PATH=/home/runner/mpich/bin:$PATH' > .bashrc
source .bashrc
export CC=/home/runner/mpich/bin/mpicc
export FC=/home/runner/mpich/bin/mpifort
export LD_LIBRARY_PATH="/home/runner/netcdf-c/lib:/home/runner/mpich/lib:/home/runner/hdf5/lib:/home/runner/netcdf-fortran/lib:/home/runner/pnetcdf/lib:$LD_LIBRARY_PATH"
mkdir build
cd build
cmake -Wno-dev -DNetCDF_C_LIBRARY=/home/runner/netcdf-c/lib/libnetcdf.so -DNetCDF_C_INCLUDE_DIR=/home/runner/netcdf-c/include -DPnetCDF_PATH='/home/runner/pnetcdf' -DPIO_ENABLE_FORTRAN=Off -DPIO_ENABLE_LOGGING=On -DPIO_ENABLE_TIMING=Off .. || (cat CMakeFiles/CMakeOutput.log && cat CMakeFiles/CMakeError.log)
make VERBOSE=1
make tests VERBOSE=1
# ctest -VV
- name: autotools build
run: |
set -x
Expand All @@ -129,3 +144,4 @@ jobs:
./configure --enable-fortran
make -j check
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ option (PIO_INTERNAL_DOC "Enable PIO developer documentation" OFF)
option (PIO_TEST_BIG_ENDIAN "Enable test to see if machine is big endian" ON)
option (PIO_USE_MPIIO "Enable support for MPI-IO auto detect" ON)
option (PIO_USE_MPISERIAL "Enable mpi-serial support (instead of MPI)" OFF)
option (PIO_USE_MALLOC "Use native malloc (instead of bget package)" ON)
option (PIO_USE_PNETCDF_VARD "Use pnetcdf put_vard " OFF)
option (WITH_PNETCDF "Require the use of PnetCDF" ON)

Expand All @@ -103,11 +102,7 @@ else()
endif()

# Set a variable that appears in the config.h.in file.
if(PIO_USE_MALLOC)
set(USE_MALLOC 1)
else()
set(USE_MALLOC 0)
endif()
set(USE_MALLOC 1)

# Set a variable that appears in the config.h.in file.
if(PIO_ENABLE_LOGGING)
Expand Down
2 changes: 1 addition & 1 deletion src/clib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project (PIOC C)
#==============================================================================

set (src topology.c pio_file.c pioc_support.c pio_lists.c
pioc.c pioc_sc.c pio_spmd.c pio_rearrange.c pio_nc4.c bget.c
pioc.c pioc_sc.c pio_spmd.c pio_rearrange.c pio_nc4.c
pio_nc.c pio_put_nc.c pio_get_nc.c pio_getput_int.c pio_msg.c
pio_darray.c pio_darray_int.c pio_get_vard.c pio_put_vard.c pio_error.c)
if (NETCDF_INTEGRATION)
Expand Down
4 changes: 2 additions & 2 deletions src/clib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ libpioc_la_LDFLAGS = -version-info 4:1:3
include_HEADERS = pio.h uthash.h pio_meta.h

# The library soure files.
libpioc_la_SOURCES = bget.c pioc_sc.c pio_darray.c pio_file.c \
libpioc_la_SOURCES = pioc_sc.c pio_darray.c pio_file.c \
pio_getput_int.c pio_msg.c pio_nc.c pio_rearrange.c pioc.c \
pioc_support.c pio_darray_int.c pio_get_nc.c pio_lists.c pio_nc4.c \
pio_put_nc.c pio_spmd.c pio_get_vard.c pio_put_vard.c pio_error.c \
pio_internal.h bget.h uthash.h pio_error.h
pio_internal.h uthash.h pio_error.h

EXTRA_DIST = CMakeLists.txt topology.c pio_meta.h.in
1,677 changes: 0 additions & 1,677 deletions src/clib/bget.c

This file was deleted.

41 changes: 0 additions & 41 deletions src/clib/bget.h

This file was deleted.

26 changes: 13 additions & 13 deletions src/clib/pio_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ PIOc_write_darray_multi(int ncid, const int *varids, int ioid, int nvars,
if (rlen > 0)
{
/* Allocate memory for the buffer for all vars/records. */
if (!(file->iobuf = bget(iodesc->mpitype_size * (size_t)rlen)))
if (!(file->iobuf = malloc(iodesc->mpitype_size * (size_t)rlen)))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);
PLOG((3, "allocated %lld bytes for variable buffer", (size_t)rlen * iodesc->mpitype_size));

Expand All @@ -294,7 +294,7 @@ PIOc_write_darray_multi(int ncid, const int *varids, int ioid, int nvars,
/* this assures that iobuf is allocated on all iotasks thus
assuring that the flush_output_buffer call above is called
collectively (from all iotasks) */
if (!(file->iobuf = bget(1)))
if (!(file->iobuf = malloc(1)))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);
PLOG((3, "allocated token for variable buffer"));
}
Expand Down Expand Up @@ -341,7 +341,7 @@ PIOc_write_darray_multi(int ncid, const int *varids, int ioid, int nvars,
if (file->iobuf)
{
PLOG((3,"freeing variable buffer in pio_darray"));
brel(file->iobuf);
free(file->iobuf);
file->iobuf = NULL;
}
}
Expand All @@ -365,9 +365,9 @@ PIOc_write_darray_multi(int ncid, const int *varids, int ioid, int nvars,

/* Get a buffer. */
if (ios->io_rank == 0)
vdesc0->fillbuf = bget(iodesc->maxholegridsize * iodesc->mpitype_size * nvars);
vdesc0->fillbuf = malloc(iodesc->maxholegridsize * iodesc->mpitype_size * nvars);
else if (iodesc->holegridsize > 0)
vdesc0->fillbuf = bget(iodesc->holegridsize * iodesc->mpitype_size * nvars);
vdesc0->fillbuf = malloc(iodesc->holegridsize * iodesc->mpitype_size * nvars);

/* copying the fill value into the data buffer for the box
* rearranger. This will be overwritten with data where
Expand Down Expand Up @@ -403,7 +403,7 @@ PIOc_write_darray_multi(int ncid, const int *varids, int ioid, int nvars,
/* Free resources. */
if (vdesc0->fillbuf)
{
brel(vdesc0->fillbuf);
free(vdesc0->fillbuf);
vdesc0->fillbuf = NULL;
}
}
Expand Down Expand Up @@ -718,7 +718,7 @@ PIOc_write_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, void *arra
if (!wmb)
{
/* Allocate a buffer. */
if (!(wmb = bget((bufsize)sizeof(wmulti_buffer))))
if (!(wmb = malloc(sizeof(wmulti_buffer))))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);

/* Set pointer to newly allocated buffer and initialize.*/
Expand Down Expand Up @@ -808,22 +808,22 @@ PIOc_write_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, void *arra
/* Get memory for data. */
if (arraylen > 0)
{
if (!(wmb->data = bgetr(wmb->data, (1 + wmb->num_arrays) * arraylen * iodesc->mpitype_size)))
if (!(wmb->data = realloc(wmb->data, (1 + wmb->num_arrays) * arraylen * iodesc->mpitype_size)))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);
PLOG((2, "got %ld bytes for data", (1 + wmb->num_arrays) * arraylen * iodesc->mpitype_size));
}
#endif

/* vid is an array of variable ids in the wmb list, grow the list
* and add the new entry. */
if (!(wmb->vid = bgetr(wmb->vid, sizeof(int) * (1 + wmb->num_arrays))))
if (!(wmb->vid = realloc(wmb->vid, sizeof(int) * (1 + wmb->num_arrays))))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);

/* wmb->frame is the record number, we assume that the variables
* in the wmb list may not all have the same unlimited dimension
* value although they usually do. */
if (vdesc->record >= 0)
if (!(wmb->frame = bgetr(wmb->frame, sizeof(int) * (1 + wmb->num_arrays))))
if (!(wmb->frame = realloc(wmb->frame, sizeof(int) * (1 + wmb->num_arrays))))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);

/* If we need a fill value, get it. If we are using the subset
Expand All @@ -832,7 +832,7 @@ PIOc_write_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, void *arra
if (iodesc->needsfill)
{
/* Get memory to hold fill value. */
if (!(wmb->fillvalue = bgetr(wmb->fillvalue, iodesc->mpitype_size * (1 + wmb->num_arrays))))
if (!(wmb->fillvalue = realloc(wmb->fillvalue, iodesc->mpitype_size * (1 + wmb->num_arrays))))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);

memcpy((char *)wmb->fillvalue + iodesc->mpitype_size * wmb->num_arrays,
Expand Down Expand Up @@ -961,7 +961,7 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,

/* Allocate a buffer for one record. */
if (ios->ioproc && rlen > 0)
if (!(iobuf = bget(iodesc->mpitype_size * rlen)))
if (!(iobuf = malloc(iodesc->mpitype_size * rlen)))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);

/* Call the correct darray read function based on iotype. */
Expand Down Expand Up @@ -1018,7 +1018,7 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,

/* Free the buffer. */
if (rlen > 0)
brel(iobuf);
free(iobuf);

#ifdef USE_MPE
pio_stop_mpe_log(DARRAY_READ, __func__);
Expand Down
98 changes: 11 additions & 87 deletions src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
extern PIO_Offset pio_buffer_size_limit;

/** Initial size of compute buffer. */
bufsize pio_cnbuffer_limit = 33554432;
long pio_cnbuffer_limit = 33554432;

/** Global buffer pool pointer. */
extern void *CN_bpool;
Expand Down Expand Up @@ -1339,8 +1339,8 @@ pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobuf)

if (tmp_bufsize > 0)
{
startlist[rrlen] = bget(fndims * sizeof(PIO_Offset));
countlist[rrlen] = bget(fndims * sizeof(PIO_Offset));
startlist[rrlen] = malloc(fndims * sizeof(PIO_Offset));
countlist[rrlen] = malloc(fndims * sizeof(PIO_Offset));

for (int j = 0; j < fndims; j++)
{
Expand Down Expand Up @@ -1380,8 +1380,8 @@ pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobuf)
/* Release the start and count arrays. */
for (int i = 0; i < rrlen; i++)
{
brel(startlist[i]);
brel(countlist[i]);
free(startlist[i]);
free(countlist[i]);
}
}
}
Expand Down Expand Up @@ -1825,7 +1825,7 @@ flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize)
if (file->iobuf)
{
PLOG((3,"freeing variable buffer in flush_output_buffer"));
brel(file->iobuf);
free(file->iobuf);
file->iobuf = NULL;
}

Expand All @@ -1835,7 +1835,7 @@ flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize)
return pio_err(NULL, file, ierr, __FILE__, __LINE__);
if (vdesc->fillbuf)
{
brel(vdesc->fillbuf);
free(vdesc->fillbuf);
vdesc->fillbuf = NULL;
}
}
Expand All @@ -1845,82 +1845,6 @@ flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize)
return ierr;
}

/**
* Print out info about the buffer for debug purposes. This should
* only be called when logging is enabled.
*
* @param ios pointer to the IO system structure
* @param collective true if collective report is desired
* @ingroup PIO_write_darray_c
* @author Jim Edwards
*/
void
cn_buffer_report(iosystem_desc_t *ios, bool collective)
{
int mpierr; /* Return code from MPI functions. */

PLOG((2, "cn_buffer_report ios->iossysid = %d collective = %d CN_bpool = %d",
ios->iosysid, collective, CN_bpool));
if (CN_bpool)
{
long bget_stats[5];
long bget_mins[5];
long bget_maxs[5];

bstats(bget_stats, bget_stats+1,bget_stats+2,bget_stats+3,bget_stats+4);
if (collective)
{
PLOG((3, "cn_buffer_report calling MPI_Reduce ios->comp_comm = %d", ios->comp_comm));
if ((mpierr = MPI_Reduce(bget_stats, bget_maxs, 5, MPI_LONG, MPI_MAX, 0, ios->comp_comm)))
check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__);
PLOG((3, "cn_buffer_report calling MPI_Reduce"));
if ((mpierr = MPI_Reduce(bget_stats, bget_mins, 5, MPI_LONG, MPI_MIN, 0, ios->comp_comm)))
check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__);
if (ios->compmaster == MPI_ROOT)
{
PLOG((1, "Currently allocated buffer space %ld %ld", bget_mins[0], bget_maxs[0]));
PLOG((1, "Currently available buffer space %ld %ld", bget_mins[1], bget_maxs[1]));
PLOG((1, "Current largest free block %ld %ld", bget_mins[2], bget_maxs[2]));
PLOG((1, "Number of successful bget calls %ld %ld", bget_mins[3], bget_maxs[3]));
PLOG((1, "Number of successful brel calls %ld %ld", bget_mins[4], bget_maxs[4]));
}
}
else
{
PLOG((1, "Currently allocated buffer space %ld", bget_stats[0]));
PLOG((1, "Currently available buffer space %ld", bget_stats[1]));
PLOG((1, "Current largest free block %ld", bget_stats[2]));
PLOG((1, "Number of successful bget calls %ld", bget_stats[3]));
PLOG((1, "Number of successful brel calls %ld", bget_stats[4]));
}
}
}

/**
* Free the buffer pool. If malloc is used (that is, PIO_USE_MALLOC is
* non zero), this function does nothing.
*
* @param ios pointer to the IO system structure.
* @ingroup PIO_write_darray_c
* @author Jim Edwards
*/
void
free_cn_buffer_pool(iosystem_desc_t *ios)
{
#if !PIO_USE_MALLOC
PLOG((2, "free_cn_buffer_pool CN_bpool = %d", CN_bpool));
/* Note: it is possible that CN_bpool has been freed and set to NULL by bpool_free() */
if (CN_bpool)
{
cn_buffer_report(ios, false);
bpoolrelease(CN_bpool);
PLOG((2, "free_cn_buffer_pool done!"));
free(CN_bpool);
CN_bpool = NULL;
}
#endif /* !PIO_USE_MALLOC */
}

/**
* Flush the buffer.
*
Expand Down Expand Up @@ -1958,21 +1882,21 @@ flush_buffer(int ncid, wmulti_buffer *wmb, bool flushtodisk)
wmb->num_arrays = 0;

/* Release the list of variable IDs. */
brel(wmb->vid);
free(wmb->vid);
wmb->vid = NULL;

/* Release the data memory. */
brel(wmb->data);
free(wmb->data);
wmb->data = NULL;

/* If there is a fill value, release it. */
if (wmb->fillvalue)
brel(wmb->fillvalue);
free(wmb->fillvalue);
wmb->fillvalue = NULL;

/* Release the record number. */
if (wmb->frame)
brel(wmb->frame);
free(wmb->frame);
wmb->frame = NULL;

if (ret)
Expand Down
2 changes: 1 addition & 1 deletion src/clib/pio_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ PIOc_sync(int ncid)
if (wmb->num_arrays > 0)
flush_buffer(ncid, wmb, true);
HASH_DEL(file->buffer, wmb);
brel(wmb);
free(wmb);

}
file->buffer = NULL;
Expand Down
1 change: 0 additions & 1 deletion src/clib/pio_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <config.h>
#include <pio.h>
#include <pio_error.h>
#include <bget.h>
#include <limits.h>
#include <math.h>
#include <netcdf.h>
Expand Down
Loading

0 comments on commit d0d4a98

Please sign in to comment.