Skip to content
Snippets Groups Projects
Commit 88c63df1 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Move getPageSize to pio_util.

parent f3f0d58e
No related branches found
No related tags found
No related merge requests found
......@@ -112,56 +112,8 @@ lcm(size_t a, size_t b)
return a / gcd(a, b) * b;
}
enum {
/* 8192 is known to work on most systems (4096 isn't on Alpha) */
commonPageSize = 8192,
};
static bool largePageAlign;
static size_t
getPageSize(void)
{
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
#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;
}
static size_t
getXferBufAlign(const char *path)
{
......@@ -220,7 +172,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 = getPageSize(),
size_t pageSize = cdiPioGetPageSize(largePageAlign),
IOAlign = getXferBufAlign(filename);
bufBlockAlign = lcm(pageSize, IOAlign);
blockSize = lcm(blockSize, bufBlockAlign);
......
......@@ -8,6 +8,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "pio_util.h"
#include "cdi.h"
#include "dmemory.h"
......@@ -194,6 +196,50 @@ 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
#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:
......
......@@ -105,6 +105,15 @@ 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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment