Commit ec354705 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Also detect whether the current POSIX implementation offers the optional...

Also detect whether the current POSIX implementation offers the optional function posix_fallocate(). If not, switch off the particle streamed logging.
parent cd218003
......@@ -379,10 +379,16 @@ AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
or use CPPFLAGS and LDFLAGS if the library is installed in a
non-standard location.]))
# Check whether POSIX thread barriers are implemented (e.g. OSX does not have them)
AC_CHECK_LIB(pthread, pthread_barrier_init,
AC_DEFINE([HAVE_PTHREAD_BARRIERS], [1], [The posix library implements barriers]),
AC_MSG_WARN(POSIX implementation does not have barriers. SWIFT will use home-made ones.))
# Check whether POSIX file allocation functions exist (e.g. OSX does not have them)
AC_CHECK_LIB(pthread, posix_fallocate,
AC_DEFINE([HAVE_POSIX_FALLOCATE], [1], [The posix library implements file allocation functions.]),
AC_MSG_WARN(POSIX implementation does not have file allocation functions.))
# Check for metis. Note AX_LIB_METIS exists, but cannot be configured
# to be default off (i.e. given no option it tries to locate METIS), so we
# don't use that.
......
......@@ -17,9 +17,20 @@
*
******************************************************************************/
/* Config parameters. */
/* Config parameters. */
#include "../config.h"
#ifdef HAVE_POSIX_FALLOCATE
/* This object's header. */
#include "dump.h"
/* Local headers. */
#include "atomic.h"
#include "error.h"
/* Some standard headers. */
#include <errno.h>
#include <fcntl.h>
......@@ -29,13 +40,6 @@
#include <sys/types.h>
#include <unistd.h>
/* This object's header. */
#include "dump.h"
/* Local headers. */
#include "atomic.h"
#include "error.h"
/**
* @brief Obtain a chunk of memory from a dump.
*
......@@ -44,7 +48,6 @@
* @param offset The offset of the returned memory address within the dump file.
* @return A pointer to the memory-mapped chunk of data.
*/
void *dump_get(struct dump *d, size_t count, size_t *offset) {
size_t local_offset = atomic_add(&d->count, count);
*offset = local_offset + d->file_offset;
......@@ -54,7 +57,6 @@ void *dump_get(struct dump *d, size_t count, size_t *offset) {
/**
* @brief Ensure that at least size bytes are available in the #dump.
*/
void dump_ensure(struct dump *d, size_t size) {
/* If we have enough space already, just bail. */
......@@ -88,7 +90,6 @@ void dump_ensure(struct dump *d, size_t size) {
/**
* @brief Flush the #dump to disk.
*/
void dump_sync(struct dump *d) {
if (msync(d->data, d->count, MS_SYNC) != 0)
error("Failed to sync memory-mapped data.");
......@@ -97,7 +98,6 @@ void dump_sync(struct dump *d) {
/**
* @brief Finalize the #dump.
*/
void dump_close(struct dump *d) {
/* Unmap the data in memory. */
if (munmap(d->data, d->count) != 0) {
......@@ -121,7 +121,6 @@ void dump_close(struct dump *d) {
* note that it will be overwritten.
* @param size The initial buffer size for this #dump.
*/
void dump_init(struct dump *d, const char *filename, size_t size) {
/* Create the output file. */
......@@ -151,3 +150,5 @@ void dump_init(struct dump *d, const char *filename, size_t size) {
d->file_offset = 0;
d->page_mask = page_mask;
}
#endif /* HAVE_POSIX_FALLOCATE */
......@@ -19,8 +19,13 @@
#ifndef SWIFT_DUMP_H
#define SWIFT_DUMP_H
/* Includes. */
#include "lock.h"
/* Config parameters. */
#include "../config.h"
#ifdef HAVE_POSIX_FALLOCATE /* Are we on a sensible platform? */
/* Standard headers */
#include <stdlib.h>
/* Some constants. */
#define dump_grow_ensure_factor 10
......@@ -54,4 +59,6 @@ void dump_sync(struct dump *d);
void dump_close(struct dump *d);
void *dump_get(struct dump *d, size_t count, size_t *offset);
#endif /* HAVE_POSIX_FALLOCATE */
#endif /* SWIFT_DUMP_H */
......@@ -20,6 +20,8 @@
/* Config parameters. */
#include "../config.h"
#ifdef HAVE_POSIX_FALLOCATE /* Are we on a sensible platform? */
/* Some standard headers. */
#include <stdint.h>
#include <stdlib.h>
......@@ -41,7 +43,6 @@
*
* @return The size of the logger message in bytes.
*/
int logger_size(unsigned int mask) {
/* Start with 8 bytes for the header. */
......@@ -95,7 +96,6 @@ int logger_size(unsigned int mask) {
* @param offset Pointer to the offset of the previous log of this particle.
* @param dump The #dump in which to log the particle data.
*/
void logger_log_part(struct part *p, unsigned int mask, size_t *offset,
struct dump *dump) {
......@@ -176,7 +176,6 @@ void logger_log_part(struct part *p, unsigned int mask, size_t *offset,
* @param offset Pointer to the offset of the previous log of this particle.
* @param dump The #dump in which to log the particle data.
*/
void logger_log_gpart(struct gpart *p, unsigned int mask, size_t *offset,
struct dump *dump) {
......@@ -270,7 +269,6 @@ void logger_log_timestamp(unsigned long long int timestamp, size_t *offset,
*
* @return The mask containing the values read.
*/
int logger_read_part(struct part *p, size_t *offset, const char *buff) {
/* Jump to the offset. */
......@@ -349,7 +347,6 @@ int logger_read_part(struct part *p, size_t *offset, const char *buff) {
*
* @return The mask containing the values read.
*/
int logger_read_gpart(struct gpart *p, size_t *offset, const char *buff) {
/* Jump to the offset. */
......@@ -416,7 +413,6 @@ int logger_read_gpart(struct gpart *p, size_t *offset, const char *buff) {
*
* @return The mask containing the values read.
*/
int logger_read_timestamp(unsigned long long int *t, size_t *offset,
const char *buff) {
......@@ -444,3 +440,5 @@ int logger_read_timestamp(unsigned long long int *t, size_t *offset,
/* Finally, return the mask of the values we just read. */
return mask;
}
#endif /* HAVE_POSIX_FALLOCATE */
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