Skip to content
Snippets Groups Projects
Commit 08b536f4 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Logger: python use autotools function and add verbose

parent 012f1222
Branches
Tags
1 merge request!685Logger loader
......@@ -1007,38 +1007,23 @@ AC_ARG_WITH([python],
[with_python="no"]
)
if test "x$with_python" != "xno"; then
AC_CACHE_CHECK(
"python version",
ac_cv_ver_python,
[ac_cv_ver_python=`python -c 'import sys;print(sys.version[[:3]])' 2> /dev/null`]
)
if test "x$with_python" != "xyes" -a "x$with_python" != "x"; then
PYTHON_LIBS=""
PYTHON_INCS="-I$with_python/include/python$ac_cv_ver_python"
else
PYTHON_LIBS=""
PYTHON_INCS=""
fi
have_python="yes"
AC_CHECK_PROGS(
[PYTHON_BIN],
[python$ac_cv_ver_python],
[AC_MSG_ERROR(Cannot find python binary!)],
[$with_python/bin]
)
AC_CHECK_LIB(
[python${ac_cv_ver_python}m],
[PyArg_ParseTuple],
[AC_DEFINE([HAVE_PYTHON],1,[The python library appears to be present.])
],
[AC_MSG_ERROR(Cannot find python library!)],
[$PYTHON_LIBS])
AM_PATH_PYTHON([3], [], [AC_MSG_ERROR(python not found)])
AC_ARG_VAR([PYTHON_INCS], [Include flags for python, bypassing python-config])
AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
AS_IF([test -z "$PYTHON_INCS"], [
AS_IF([test -z "$PYTHON_CONFIG"], [
AC_PATH_PROGS([PYTHON_CONFIG],
[python$PYTHON_VERSION-config python-config],
[no],
[`dirname $PYTHON`])
AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON.])])
])
AC_MSG_CHECKING([python include flags])
PYTHON_INCS=`$PYTHON_CONFIG --includes`
AC_MSG_RESULT([$PYTHON_INCS])
])
have_python="yes"
fi
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYTHON_INCS])
AM_CONDITIONAL([HAVEPYTHON],[test -n "$PYTHON_INCS"])
......
......@@ -28,7 +28,7 @@ BIN_LDFLAGS = -version-info 0:0:0
GIT_CMD = @GIT_CMD@
# Additional dependencies for shared libraries.
EXTRA_LIBS = $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(PYTHON_LIBS) $(HDF5_LIBS) $(FFTW_LIBS) $(GRACKLE_LIBS) $(VELOCIRAPTOR_LIBS) $(GSL_LIBS)
EXTRA_LIBS = $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(HDF5_LIBS) $(FFTW_LIBS) $(GRACKLE_LIBS) $(VELOCIRAPTOR_LIBS) $(GSL_LIBS)
# MPI libraries.
# MPI_LIBS = $(MPI_THREAD_LIBS)
......
......@@ -140,9 +140,7 @@ void header_read(struct header *h, void *map) {
}
if (offset != h->offset_first) {
#ifdef SWIFT_DEBUG_CHECKS
header_print(h);
#endif
error("Wrong header size (in header %li, current %li)",
h->offset_first, offset);
}
......
......@@ -65,7 +65,7 @@ void io_close_file(int *fd, void **map) {
}
/**
* @brief read a maks with its offset
* @brief read a mask with its offset
*
* @param h #header file structure
* @param map file mapping
......
......@@ -4,6 +4,8 @@
#include "logger_time.h"
#include "logger_reader.h"
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <Python.h>
#include <errno.h>
#include <numpy/arrayobject.h>
......@@ -15,6 +17,7 @@
*
* @param offset PyArrayObject list of offset for each particle
* @param filename string filename of the dump file
* @param verbose Verbose level
* @return dictionnary containing the data read
*/
static PyObject *loadFromIndex(__attribute__((unused)) PyObject *self,
......@@ -37,10 +40,12 @@ static PyObject *loadFromIndex(__attribute__((unused)) PyObject *self,
PyArrayObject *id = NULL;
size_t time_offset;
int verbose = 0;
/* parse arguments */
if (!PyArg_ParseTuple(args, "OsL", &offset, &filename, &time_offset))
if (!PyArg_ParseTuple(args, "OsL|i", &offset, &filename, &time_offset,
&verbose))
return NULL;
if (!PyArray_Check(offset)) {
......@@ -65,7 +70,7 @@ static PyObject *loadFromIndex(__attribute__((unused)) PyObject *self,
if (!h.forward_offset) {
io_close_file(&fd, &map);
reverse_offset(filename);
reverse_offset(filename, verbose);
io_open_file(filename, &fd, &map);
......@@ -80,7 +85,10 @@ static PyObject *loadFromIndex(__attribute__((unused)) PyObject *self,
time_array_init(&times, &h, map, fd);
time_array_print(&times);
if (verbose > 0) {
time_array_print(&times);
}
/* get required time */
double time = time_array_get_time(&times, time_offset);
......@@ -231,17 +239,20 @@ static PyObject *loadFromIndex(__attribute__((unused)) PyObject *self,
* @brief Reverse offset in dump file
*
* @param filename string filename of the dump file
* @param verbose Verbose level
*/
static PyObject *pyReverseOffset(__attribute__((unused)) PyObject *self,
PyObject *args) {
/* input */
char *filename = NULL;
int verbose = 0;
/* parse arguments */
if (!PyArg_ParseTuple(args, "s", &filename)) return NULL;
if (!PyArg_ParseTuple(args, "s|i", &filename, &verbose)) return NULL;
reverse_offset(filename);
reverse_offset(filename, verbose);
return Py_BuildValue("");
}
......
......@@ -5,8 +5,9 @@
* @brief Reverse offset in dump file
*
* @param filename string filename of the dump file
* @param verbose Verbose level
*/
void reverse_offset(char *filename) {
void reverse_offset(char *filename, int verbose) {
struct header h;
/* open file */
......@@ -17,7 +18,9 @@ void reverse_offset(char *filename) {
/* read header */
header_read(&h, map);
header_print(&h);
if (verbose > 0) {
header_print(&h);
}
/* check offset direction */
if (h.forward_offset) {
......@@ -32,12 +35,16 @@ void reverse_offset(char *filename) {
#ifdef SWIFT_DEBUG_CHECKS
/* check offset */
printf("Check offsets...\n");
if (verbose > 0) {
printf("Check offsets...\n");
}
offset = h.offset_first;
while (offset < sz) {
tools_check_offset(&h, map, &offset);
}
printf("Check done\n");
if (verbose > 0) {
printf("Check done\n");
}
#endif
/* reverse header offset */
......@@ -46,20 +53,28 @@ void reverse_offset(char *filename) {
offset = h.offset_first;
/* reverse chunks */
printf("Reversing offsets...\n");
if (verbose > 0) {
printf("Reversing offsets...\n");
}
while (offset < sz) {
tools_reverse_offset(&h, map, &offset);
}
printf("Reversing done\n");
if (verbose > 0) {
printf("Reversing done\n");
}
#ifdef SWIFT_DEBUG_CHECKS
/* check offset */
printf("Check offsets...\n");
if (verbose > 0) {
printf("Check offsets...\n");
}
offset = h.offset_first;
while (offset < sz) {
tools_check_offset(&h, map, &offset);
}
printf("Check done\n");
if (verbose > 0) {
printf("Check done\n");
}
#endif
/* free internal variables */
......
#ifndef __LOGGER_READER_H__
#define __LOGGER_READER_H__
void reverse_offset(char *filename);
void reverse_offset(char *filename, int verbose);
#endif // __LOGGER_READER_H__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment