Commit d280fcb7 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Move page size query to serial implementation.

* This function will then be used by lazy netcdf implementation to map
  a page of inaccessible memory.
parent cea3faf1
......@@ -85,6 +85,11 @@ AC_SUBST([UUID_C_LIB])
AC_CHECK_DECLS([isnan],,,[AC_INCLUDES_DEFAULT
@%:@include <math.h>])
# check for sysconf names
AC_CHECK_DECLS([_SC_LARGE_PAGESIZE, PAGESIZE, PAGE_SIZE, _SC_PAGE_SIZE, dnl
_SC_PAGESIZE, _PC_REC_XFER_ALIGN, POSIX_REC_XFER_ALIGN],,,[AC_INCLUDES_DEFAULT
@%:@include <limits.h>
@%:@include <unistd.h>])
#
# Check for non-standard builtin
AS_FOR([builtin_macro],[builtin],[__builtin_ctz],
......@@ -207,10 +212,6 @@ main(int argc, char **argv)
])
AS_IF([test "x$MPI_LAUNCH" = xtrue],
[AC_MSG_WARN([MPI launch command unavailable])])
AC_CHECK_DECLS([_SC_LARGE_PAGESIZE, PAGESIZE, PAGE_SIZE, _SC_PAGE_SIZE, dnl
_SC_PAGESIZE, _PC_REC_XFER_ALIGN, POSIX_REC_XFER_ALIGN],,,[AC_INCLUDES_DEFAULT
@%:@include <limits.h>
@%:@include <unistd.h>])
PKG_CHECK_MODULES([YAXT],[yaxt],
[AC_DEFINE([HAVE_YAXT],,[yaxt library is available])],
......
......@@ -424,6 +424,13 @@ void cdiStreamSync_(stream_t *streamptr);
const char *cdiUnitNamePtr(int cdi_unit);
enum {
/* 8192 is known to work on most systems (4096 isn't on Alpha) */
commonPageSize = 8192,
};
size_t cdiGetPageSize(bool largePageAlign);
void zaxisGetIndexList(int nzaxis, int *zaxisIndexList);
void zaxisDefLtype2(int zaxisID, int ltype2);
......
......@@ -2,8 +2,10 @@
# include "config.h"
#endif
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "cdi.h"
#include "cdi_int.h"
......@@ -114,6 +116,52 @@ const char *cdiUnitNamePtr(int cdi_unit)
return name;
}
size_t
cdiGetPageSize(bool largePageAlign)
{
long pagesize = -1L;
bool nameAssigned = false;
#if HAVE_DECL__SC_LARGE_PAGESIZE || HAVE_DECL__SC_PAGE_SIZE || HAVE_DECL__SC_PAGESIZE
int name;
# if HAVE_DECL__SC_LARGE_PAGESIZE
if (largePageAlign)
{
name = _SC_LARGE_PAGESIZE;
nameAssigned = true;
}
else
# else
(void)largePageAlign;
# endif
{
# if HAVE_DECL__SC_PAGESIZE || HAVE_DECL__SC_PAGE_SIZE
name =
# if HAVE_DECL__SC_PAGESIZE
_SC_PAGESIZE
# elif HAVE_DECL__SC_PAGE_SIZE
_SC_PAGE_SIZE
# endif
;
nameAssigned = true;
# endif
}
if (nameAssigned)
pagesize = sysconf(name);
#endif
if (pagesize == -1L)
pagesize =
#if HAVE_DECL_PAGESIZE
PAGESIZE
#elif HAVE_DECL_PAGE_SIZE
PAGE_SIZE
#else
commonPageSize
#endif
;
return (size_t)pagesize;
}
/*
* Local Variables:
* c-file-style: "Java"
......
......@@ -17,6 +17,7 @@
#include <mpi.h>
#include "cdi.h"
#include "cdi_int.h"
#include "dmemory.h"
#include "error.h"
#include "namespace.h"
......@@ -172,7 +173,7 @@ initAFiledataFileWriteAtReblock(const char *filename, size_t bufSize)
#undef MINBLOCKSIZE
/* ensure block size also meets page and direct I/O buffer
* alignment requirements */
size_t pageSize = cdiPioGetPageSize(largePageAlign),
size_t pageSize = cdiGetPageSize(largePageAlign),
IOAlign = getXferBufAlign(filename);
bufBlockAlign = lcm(pageSize, IOAlign);
blockSize = lcm(blockSize, bufBlockAlign);
......
......@@ -1048,7 +1048,7 @@ writeGribStream(size_t streamIdx,
* (size_t)1024 * (size_t)1024,
sizeof (double) * myAggSize);
if (posix_memalign(&rxWin[streamIdx].aggBuf,
cdiPioGetPageSize(conf->largePageAlign),
cdiGetPageSize(conf->largePageAlign),
aggBufSize) == 0) ;
else
rxWin[streamIdx].aggBuf = Malloc(aggBufSize);
......
......@@ -196,51 +196,6 @@ cdiPioQueryVarDims(int varShape[3], int vlistID, int varID)
return (varShape[2] == 1)?2:3;
}
size_t
cdiPioGetPageSize(bool largePageAlign)
{
long pagesize = -1L;
bool nameAssigned = false;
#if HAVE_DECL__SC_LARGE_PAGESIZE || HAVE_DECL__SC_PAGE_SIZE || HAVE_DECL__SC_PAGESIZE
int name;
# if HAVE_DECL__SC_LARGE_PAGESIZE
if (largePageAlign)
{
name = _SC_LARGE_PAGESIZE;
nameAssigned = true;
}
else
# else
(void)largePageAlign;
# endif
{
# if HAVE_DECL__SC_PAGESIZE || HAVE_DECL__SC_PAGE_SIZE
name =
# if HAVE_DECL__SC_PAGESIZE
_SC_PAGESIZE
# elif HAVE_DECL__SC_PAGE_SIZE
_SC_PAGE_SIZE
# endif
;
nameAssigned = true;
# endif
}
if (nameAssigned)
pagesize = sysconf(name);
#endif
if (pagesize == -1L)
pagesize =
#if HAVE_DECL_PAGESIZE
PAGESIZE
#elif HAVE_DECL_PAGE_SIZE
PAGE_SIZE
#else
commonPageSize
#endif
;
return (size_t)pagesize;
}
void
......
......@@ -94,7 +94,7 @@ void printArray ( const char *, const char *, const void *, int, int, const char
#define xprintArray(ps,array,n,datatype) \
if ( ddebug ) \
printArray ( debugString, ps, array, n, datatype, __func__, __FILE__, __LINE__ )
#define xprintArray3(ps,array,n,datatype) \
if ( ddebug == MAXDEBUG ) \
printArray ( debugString, ps, array, n, datatype, __func__, __FILE__, __LINE__ )
......@@ -105,15 +105,6 @@ void printArray ( const char *, const char *, const void *, int, int, const char
int
cdiPioQueryVarDims(int varShape[3], int vlistID, int varID);
enum {
/* 8192 is known to work on most systems (4096 isn't on Alpha) */
commonPageSize = 8192,
};
size_t
cdiPioGetPageSize(bool largePageAlign);
#endif
/*
* Local Variables:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment