reorganization
This commit is contained in:
parent
ef4a9512e2
commit
e4b490b34f
22 changed files with 120 additions and 210 deletions
|
@ -3,10 +3,8 @@ ACLOCAL_AMFLAGS = -I m4
|
|||
lib_LTLIBRARIES = libsharp.la
|
||||
|
||||
libsharp_la_SOURCES = \
|
||||
c_utils/c_utils.c \
|
||||
c_utils/c_utils.h \
|
||||
c_utils/walltime_c.c \
|
||||
c_utils/walltime_c.h \
|
||||
libsharp/sharp_utils.c \
|
||||
libsharp/sharp_utils.h \
|
||||
libsharp/sharp.c \
|
||||
libsharp/sharp_almhelpers.c \
|
||||
libsharp/sharp_core.c \
|
||||
|
@ -48,7 +46,7 @@ EXTRA_DIST = \
|
|||
runtest.sh
|
||||
|
||||
check_PROGRAMS = sharp_testsuite
|
||||
sharp_testsuite_SOURCES = libsharp/sharp_testsuite.c c_utils/memusage.c c_utils/memusage.h
|
||||
sharp_testsuite_SOURCES = test/sharp_testsuite.c test/memusage.c test/memusage.h
|
||||
sharp_testsuite_LDADD = libsharp.la @POCKETFFT_LIBS@
|
||||
|
||||
TESTS = runtest.sh
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* This file is part of libc_utils.
|
||||
*
|
||||
* libc_utils is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* libc_utils is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with libc_utils; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* libc_utils is being developed at the Max-Planck-Institut fuer Astrophysik */
|
||||
|
||||
/*
|
||||
* Functionality for reading wall clock time
|
||||
*
|
||||
* Copyright (C) 2010-2019 Max-Planck-Society
|
||||
* Author: Martin Reinecke
|
||||
*/
|
||||
|
||||
#if defined (_OPENMP)
|
||||
#include <omp.h>
|
||||
#elif defined (USE_MPI)
|
||||
#include "mpi.h"
|
||||
#elif defined (_WIN32)
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "c_utils/walltime_c.h"
|
||||
|
||||
double wallTime(void)
|
||||
{
|
||||
#if defined (_OPENMP)
|
||||
return omp_get_wtime();
|
||||
#elif defined (USE_MPI)
|
||||
return MPI_Wtime();
|
||||
#elif defined (_WIN32)
|
||||
static double inv_freq = -1.;
|
||||
if (inv_freq<0)
|
||||
{
|
||||
LARGE_INTEGER freq;
|
||||
QueryPerformanceFrequency(&freq);
|
||||
inv_freq = 1. / double(freq.QuadPart);
|
||||
}
|
||||
LARGE_INTEGER count;
|
||||
QueryPerformanceCounter(&count);
|
||||
return count.QuadPart*inv_freq;
|
||||
#else
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
return t.tv_sec + 1e-6*t.tv_usec;
|
||||
#endif
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This file is part of libc_utils.
|
||||
*
|
||||
* libc_utils is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* libc_utils is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with libc_utils; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* libc_utils is being developed at the Max-Planck-Institut fuer Astrophysik */
|
||||
|
||||
/*! \file walltime_c.h
|
||||
* Functionality for reading wall clock time
|
||||
*
|
||||
* Copyright (C) 2010-2019 Max-Planck-Society
|
||||
* \author Martin Reinecke
|
||||
*/
|
||||
|
||||
#ifndef PLANCK_WALLTIME_C_H
|
||||
#define PLANCK_WALLTIME_C_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*! Returns an approximation of the current wall time (in seconds).
|
||||
The first available of the following timers will be used:
|
||||
<ul>
|
||||
<li> \a omp_get_wtime(), if OpenMP is available
|
||||
<li> \a MPI_Wtime(), if MPI is available
|
||||
<li> \a gettimeofday() otherwise
|
||||
</ul>
|
||||
\note Only useful for measuring time differences.
|
||||
\note This function has an execution time between 10 and 100 nanoseconds. */
|
||||
double wallTime(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -30,8 +30,7 @@
|
|||
#include "pocketfft/pocketfft.h"
|
||||
#include "libsharp/sharp_ylmgen_c.h"
|
||||
#include "libsharp/sharp_internal.h"
|
||||
#include "c_utils/c_utils.h"
|
||||
#include "c_utils/walltime_c.h"
|
||||
#include "libsharp/sharp_utils.h"
|
||||
#include "libsharp/sharp_almhelpers.h"
|
||||
#include "libsharp/sharp_geomhelpers.h"
|
||||
|
||||
|
@ -836,7 +835,7 @@ NOINLINE static void phase2map (sharp_job *job, int mmax, int llim, int ulim)
|
|||
|
||||
NOINLINE static void sharp_execute_job (sharp_job *job)
|
||||
{
|
||||
double timer=wallTime();
|
||||
double timer=sharp_wallTime();
|
||||
job->opcnt=0;
|
||||
int lmax = job->ainfo->lmax,
|
||||
mmax=sharp_get_mmax(job->ainfo->mval, job->ainfo->nm);
|
||||
|
@ -910,7 +909,7 @@ NOINLINE static void sharp_execute_job (sharp_job *job)
|
|||
|
||||
DEALLOC(job->norm_l);
|
||||
dealloc_phase (job);
|
||||
job->time=wallTime()-timer;
|
||||
job->time=sharp_wallTime()-timer;
|
||||
}
|
||||
|
||||
static void sharp_build_job_common (sharp_job *job, sharp_jobtype type,
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
* \author Martin Reinecke \author Dag Sverre Seljebotn
|
||||
*/
|
||||
|
||||
#ifndef PLANCK_SHARP_H
|
||||
#define PLANCK_SHARP_H
|
||||
#ifndef SHARP_SHARP_H
|
||||
#define SHARP_SHARP_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
@ -253,6 +253,10 @@ int sharp_execute_mpi_maybe (void *pcomm, sharp_jobtype type, int spin,
|
|||
|
||||
/*! \} */
|
||||
|
||||
int sharp_get_mlim (int lmax, int spin, double sth, double cth);
|
||||
int sharp_veclen(void);
|
||||
const char *sharp_architecture(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include "libsharp/sharp_almhelpers.h"
|
||||
#include "c_utils/c_utils.h"
|
||||
#include "libsharp/sharp_utils.h"
|
||||
|
||||
void sharp_make_triangular_alm_info (int lmax, int mmax, int stride,
|
||||
sharp_alm_info **alm_info)
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
* \author Martin Reinecke
|
||||
*/
|
||||
|
||||
#ifndef PLANCK_SHARP_ALMHELPERS_H
|
||||
#define PLANCK_SHARP_ALMHELPERS_H
|
||||
#ifndef SHARP_ALMHELPERS_H
|
||||
#define SHARP_ALMHELPERS_H
|
||||
|
||||
#include "libsharp/sharp.h"
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ DECL2(avx)
|
|||
architecture_ = sharp_architecture_default;
|
||||
}
|
||||
|
||||
#pragma GCC visibility push(hidden)
|
||||
|
||||
void inner_loop (sharp_job *job, const int *ispair,const double *cth,
|
||||
const double *sth, int llim, int ulim, sharp_Ylmgen_C *gen, int mi,
|
||||
|
@ -113,16 +114,20 @@ void inner_loop (sharp_job *job, const int *ispair,const double *cth,
|
|||
if (!inner_loop_) assign_funcs();
|
||||
inner_loop_(job, ispair, cth, sth, llim, ulim, gen, mi, mlim);
|
||||
}
|
||||
int sharp_veclen(void)
|
||||
{
|
||||
if (!veclen_) assign_funcs();
|
||||
return veclen_();
|
||||
}
|
||||
|
||||
int sharp_max_nvec(int spin)
|
||||
{
|
||||
if (!max_nvec_) assign_funcs();
|
||||
return max_nvec_(spin);
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
int sharp_veclen(void)
|
||||
{
|
||||
if (!veclen_) assign_funcs();
|
||||
return veclen_();
|
||||
}
|
||||
const char *sharp_architecture(void)
|
||||
{
|
||||
if (!architecture_) assign_funcs();
|
||||
|
|
|
@ -40,7 +40,9 @@
|
|||
#include "libsharp/sharp_vecsupport.h"
|
||||
#include "libsharp/sharp.h"
|
||||
#include "libsharp/sharp_internal.h"
|
||||
#include "c_utils/c_utils.h"
|
||||
#include "libsharp/sharp_utils.h"
|
||||
|
||||
#pragma GCC visibility push(hidden)
|
||||
|
||||
// In the following, we explicitly allow the compiler to contract floating
|
||||
// point operations, like multiply-and-add.
|
||||
|
@ -1208,6 +1210,8 @@ const char *XARCH(sharp_architecture)(void)
|
|||
return xstr(ARCH);
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
* \author Martin Reinecke
|
||||
*/
|
||||
|
||||
#ifndef PLANCK_SHARP_CXX_H
|
||||
#define PLANCK_SHARP_CXX_H
|
||||
#ifndef SHARP_CXX_H
|
||||
#define SHARP_CXX_H
|
||||
|
||||
#include <complex>
|
||||
#include "libsharp/sharp.h"
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <math.h>
|
||||
#include "libsharp/sharp_geomhelpers.h"
|
||||
#include "libsharp/sharp_legendre_roots.h"
|
||||
#include "c_utils/c_utils.h"
|
||||
#include "libsharp/sharp_utils.h"
|
||||
#include "pocketfft/pocketfft.h"
|
||||
|
||||
void sharp_make_subset_healpix_geom_info (int nside, int stride, int nrings,
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
* \author Martin Reinecke
|
||||
*/
|
||||
|
||||
#ifndef PLANCK_SHARP_GEOMHELPERS_H
|
||||
#define PLANCK_SHARP_GEOMHELPERS_H
|
||||
#ifndef SHARP_GEOMHELPERS_H
|
||||
#define SHARP_GEOMHELPERS_H
|
||||
|
||||
#include "libsharp/sharp.h"
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
* \author Martin Reinecke \author Dag Sverre Seljebotn
|
||||
*/
|
||||
|
||||
#ifndef PLANCK_SHARP_INTERNAL_H
|
||||
#define PLANCK_SHARP_INTERNAL_H
|
||||
#ifndef SHARP_INTERNAL_H
|
||||
#define SHARP_INTERNAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#error This header file cannot be included from C++, only from C
|
||||
|
@ -54,14 +54,10 @@ typedef struct
|
|||
unsigned long long opcnt;
|
||||
} sharp_job;
|
||||
|
||||
int sharp_get_mlim (int lmax, int spin, double sth, double cth);
|
||||
|
||||
void inner_loop (sharp_job *job, const int *ispair,const double *cth,
|
||||
const double *sth, int llim, int ulim, sharp_Ylmgen_C *gen, int mi,
|
||||
const int *mlim);
|
||||
|
||||
int sharp_veclen(void);
|
||||
int sharp_max_nvec(int spin);
|
||||
const char *sharp_architecture(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <math.h>
|
||||
#include "libsharp/sharp_legendre_roots.h"
|
||||
#include "c_utils/c_utils.h"
|
||||
#include "libsharp/sharp_utils.h"
|
||||
|
||||
static inline double one_minus_x2 (double x)
|
||||
{ return (fabs(x)>0.1) ? (1.+x)*(1.-x) : 1.-x*x; }
|
||||
|
|
|
@ -211,7 +211,7 @@ static void sharp_execute_job_mpi (sharp_job *job, MPI_Comm comm)
|
|||
{ sharp_execute_job (job); return; }
|
||||
|
||||
MPI_Barrier(comm);
|
||||
double timer=wallTime();
|
||||
double timer=sharp_wallTime();
|
||||
job->opcnt=0;
|
||||
sharp_mpi_info minfo;
|
||||
sharp_make_mpi_info(comm, job, &minfo);
|
||||
|
@ -306,7 +306,7 @@ static void sharp_execute_job_mpi (sharp_job *job, MPI_Comm comm)
|
|||
dealloc_phase (job);
|
||||
}
|
||||
sharp_destroy_mpi_info(&minfo);
|
||||
job->time=wallTime()-timer;
|
||||
job->time=sharp_wallTime()-timer;
|
||||
}
|
||||
|
||||
void sharp_execute_mpi (MPI_Comm comm, sharp_jobtype type, int spin,
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
* \author Martin Reinecke \author Dag Sverre Seljebotn
|
||||
*/
|
||||
|
||||
#ifndef PLANCK_SHARP_MPI_H
|
||||
#define PLANCK_SHARP_MPI_H
|
||||
#ifndef SHARP_MPI_H
|
||||
#define SHARP_MPI_H
|
||||
|
||||
#include <mpi.h>
|
||||
#include "libsharp/sharp.h"
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/*
|
||||
* This file is part of libc_utils.
|
||||
* This file is part of libsharp.
|
||||
*
|
||||
* libc_utils is free software; you can redistribute it and/or modify
|
||||
* libsharp is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* libc_utils is distributed in the hope that it will be useful,
|
||||
* libsharp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with libc_utils; if not, write to the Free Software
|
||||
* along with libsharp; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* libc_utils is being developed at the Max-Planck-Institut fuer Astrophysik */
|
||||
/* libsharp is being developed at the Max-Planck-Institut fuer Astrophysik */
|
||||
|
||||
/*
|
||||
* Convenience functions
|
||||
|
@ -26,17 +26,13 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "c_utils/c_utils.h"
|
||||
#include "libsharp/sharp_utils.h"
|
||||
|
||||
void util_fail_ (const char *file, int line, const char *func, const char *msg)
|
||||
void sharp_fail_ (const char *file, int line, const char *func, const char *msg)
|
||||
{
|
||||
fprintf(stderr,"%s, %i (%s):\n%s\n",file,line,func,msg);
|
||||
exit(1);
|
||||
}
|
||||
void util_warn_ (const char *file, int line, const char *func, const char *msg)
|
||||
{
|
||||
fprintf(stderr,"%s, %i (%s):\n%s\n",file,line,func,msg);
|
||||
}
|
||||
|
||||
/* This function tries to avoid allocations with a total size close to a high
|
||||
power of two (called the "critical stride" here), by adding a few more bytes
|
||||
|
@ -53,7 +49,7 @@ static size_t manipsize(size_t sz)
|
|||
|
||||
#ifdef __SSE__
|
||||
#include <xmmintrin.h>
|
||||
void *util_malloc_ (size_t sz)
|
||||
void *sharp_malloc_ (size_t sz)
|
||||
{
|
||||
void *res;
|
||||
if (sz==0) return NULL;
|
||||
|
@ -61,10 +57,10 @@ void *util_malloc_ (size_t sz)
|
|||
UTIL_ASSERT(res,"_mm_malloc() failed");
|
||||
return res;
|
||||
}
|
||||
void util_free_ (void *ptr)
|
||||
void sharp_free_ (void *ptr)
|
||||
{ if ((ptr)!=NULL) _mm_free(ptr); }
|
||||
#else
|
||||
void *util_malloc_ (size_t sz)
|
||||
void *sharp_malloc_ (size_t sz)
|
||||
{
|
||||
void *res;
|
||||
if (sz==0) return NULL;
|
||||
|
@ -72,6 +68,41 @@ void *util_malloc_ (size_t sz)
|
|||
UTIL_ASSERT(res,"malloc() failed");
|
||||
return res;
|
||||
}
|
||||
void util_free_ (void *ptr)
|
||||
void sharp_free_ (void *ptr)
|
||||
{ if ((ptr)!=NULL) free(ptr); }
|
||||
#endif
|
||||
|
||||
#if defined (_OPENMP)
|
||||
#include <omp.h>
|
||||
#elif defined (USE_MPI)
|
||||
#include "mpi.h"
|
||||
#elif defined (_WIN32)
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
double sharp_wallTime(void)
|
||||
{
|
||||
#if defined (_OPENMP)
|
||||
return omp_get_wtime();
|
||||
#elif defined (USE_MPI)
|
||||
return MPI_Wtime();
|
||||
#elif defined (_WIN32)
|
||||
static double inv_freq = -1.;
|
||||
if (inv_freq<0)
|
||||
{
|
||||
LARGE_INTEGER freq;
|
||||
QueryPerformanceFrequency(&freq);
|
||||
inv_freq = 1. / double(freq.QuadPart);
|
||||
}
|
||||
LARGE_INTEGER count;
|
||||
QueryPerformanceCounter(&count);
|
||||
return count.QuadPart*inv_freq;
|
||||
#else
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
return t.tv_sec + 1e-6*t.tv_usec;
|
||||
#endif
|
||||
}
|
|
@ -26,8 +26,8 @@
|
|||
* \note This file should only be included from .c files, NOT from .h files.
|
||||
*/
|
||||
|
||||
#ifndef PLANCK_C_UTILS_H
|
||||
#define PLANCK_C_UTILS_H
|
||||
#ifndef SHARP_UTILS_H
|
||||
#define SHARP_UTILS_H
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -37,10 +37,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void util_fail_ (const char *file, int line, const char *func, const char *msg);
|
||||
void util_warn_ (const char *file, int line, const char *func, const char *msg);
|
||||
void *util_malloc_ (size_t sz);
|
||||
void util_free_ (void *ptr);
|
||||
void sharp_fail_ (const char *file, int line, const char *func, const char *msg);
|
||||
void *sharp_malloc_ (size_t sz);
|
||||
void sharp_free_ (void *ptr);
|
||||
|
||||
#if defined (__GNUC__)
|
||||
#define UTIL_FUNC_NAME__ __func__
|
||||
|
@ -53,43 +52,32 @@ void util_free_ (void *ptr);
|
|||
source file name and line number of the call, as well as \a msg;
|
||||
then exit the program with an error status. */
|
||||
#define UTIL_ASSERT(cond,msg) \
|
||||
if(!(cond)) util_fail_(__FILE__,__LINE__,UTIL_FUNC_NAME__,msg)
|
||||
if(!(cond)) sharp_fail_(__FILE__,__LINE__,UTIL_FUNC_NAME__,msg)
|
||||
/*! \def UTIL_WARN(cond,msg)
|
||||
If \a cond is false, print an warning containing function name,
|
||||
source file name and line number of the call, as well as \a msg. */
|
||||
#define UTIL_WARN(cond,msg) \
|
||||
if(!(cond)) util_warn_(__FILE__,__LINE__,UTIL_FUNC_NAME__,msg)
|
||||
/*! \def UTIL_FAIL(msg)
|
||||
Print an error message containing function name,
|
||||
source file name and line number of the call, as well as \a msg;
|
||||
then exit the program with an error status. */
|
||||
#define UTIL_FAIL(msg) \
|
||||
util_fail_(__FILE__,__LINE__,UTIL_FUNC_NAME__,msg)
|
||||
sharp_fail_(__FILE__,__LINE__,UTIL_FUNC_NAME__,msg)
|
||||
|
||||
/*! \def ALLOC(ptr,type,num)
|
||||
Allocate space for \a num objects of type \a type. Make sure that the
|
||||
allocation succeeded, else stop the program with an error. Return the
|
||||
resulting pointer in \a ptr. */
|
||||
#define ALLOC(ptr,type,num) \
|
||||
do { (ptr)=(type *)util_malloc_((num)*sizeof(type)); } while (0)
|
||||
do { (ptr)=(type *)sharp_malloc_((num)*sizeof(type)); } while (0)
|
||||
/*! \def RALLOC(type,num)
|
||||
Allocate space for \a num objects of type \a type. Make sure that the
|
||||
allocation succeeded, else stop the program with an error. Cast the
|
||||
resulting pointer to \a (type*). */
|
||||
#define RALLOC(type,num) \
|
||||
((type *)util_malloc_((num)*sizeof(type)))
|
||||
((type *)sharp_malloc_((num)*sizeof(type)))
|
||||
/*! \def DEALLOC(ptr)
|
||||
Deallocate \a ptr. It must have been allocated using \a ALLOC or
|
||||
\a RALLOC. */
|
||||
#define DEALLOC(ptr) \
|
||||
do { util_free_(ptr); (ptr)=NULL; } while(0)
|
||||
do { sharp_free_(ptr); (ptr)=NULL; } while(0)
|
||||
#define RESIZE(ptr,type,num) \
|
||||
do { util_free_(ptr); ALLOC(ptr,type,num); } while(0)
|
||||
#define GROW(ptr,type,sz_old,sz_new) \
|
||||
do { \
|
||||
if ((sz_new)>(sz_old)) \
|
||||
{ RESIZE(ptr,type,2*(sz_new));sz_old=2*(sz_new); } \
|
||||
} while(0)
|
||||
do { sharp_free_(ptr); ALLOC(ptr,type,num); } while(0)
|
||||
/*! \def SET_ARRAY(ptr,i1,i2,val)
|
||||
Set the entries \a ptr[i1] ... \a ptr[i2-1] to \a val. */
|
||||
#define SET_ARRAY(ptr,i1,i2,val) \
|
||||
|
@ -97,14 +85,6 @@ void util_free_ (void *ptr);
|
|||
ptrdiff_t cnt_; \
|
||||
for (cnt_=(i1);cnt_<(i2);++cnt_) (ptr)[cnt_]=(val); \
|
||||
} while(0)
|
||||
/*! \def COPY_ARRAY(src,dest,i1,i2)
|
||||
Copy the entries \a src[i1] ... \a src[i2-1] to
|
||||
\a dest[i1] ... \a dest[i2-1]. */
|
||||
#define COPY_ARRAY(src,dest,i1,i2) \
|
||||
do { \
|
||||
ptrdiff_t cnt_; \
|
||||
for (cnt_=(i1);cnt_<(i2);++cnt_) (dest)[cnt_]=(src)[cnt_]; \
|
||||
} while(0)
|
||||
|
||||
#define ALLOC2D(ptr,type,num1,num2) \
|
||||
do { \
|
||||
|
@ -119,8 +99,6 @@ void util_free_ (void *ptr);
|
|||
|
||||
#define FAPPROX(a,b,eps) \
|
||||
(fabs((a)-(b))<((eps)*fabs(b)))
|
||||
#define ABSAPPROX(a,b,eps) \
|
||||
(fabs((a)-(b))<(eps))
|
||||
#define IMAX(a,b) \
|
||||
(((a)>(b)) ? (a) : (b))
|
||||
#define IMIN(a,b) \
|
||||
|
@ -129,12 +107,16 @@ void util_free_ (void *ptr);
|
|||
#define SWAP(a,b,type) \
|
||||
do { type tmp_=(a); (a)=(b); (b)=tmp_; } while(0)
|
||||
|
||||
#define CHECK_STACK_ALIGN(align) \
|
||||
do { \
|
||||
double foo; \
|
||||
UTIL_WARN((((size_t)(&foo))&(align-1))==0, \
|
||||
"WARNING: stack not sufficiently aligned!"); \
|
||||
} while(0)
|
||||
/*! Returns an approximation of the current wall time (in seconds).
|
||||
The first available of the following timers will be used:
|
||||
<ul>
|
||||
<li> \a omp_get_wtime(), if OpenMP is available
|
||||
<li> \a MPI_Wtime(), if MPI is available
|
||||
<li> \a gettimeofday() otherwise
|
||||
</ul>
|
||||
\note Only useful for measuring time differences.
|
||||
\note This function has an execution time between 10 and 100 nanoseconds. */
|
||||
double sharp_wallTime(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
|
@ -28,7 +28,9 @@
|
|||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "libsharp/sharp_ylmgen_c.h"
|
||||
#include "c_utils/c_utils.h"
|
||||
#include "libsharp/sharp_utils.h"
|
||||
|
||||
#pragma GCC visibility push(hidden)
|
||||
|
||||
static inline void normalize (double *val, int *scale, double xfmax)
|
||||
{
|
||||
|
@ -252,3 +254,5 @@ double *sharp_Ylmgen_get_d1norm (int lmax)
|
|||
res[l] = (l<1) ? 0. : 0.5*sqrt(l*(l+1.)*(2*l+1.)/(4*pi));
|
||||
return res;
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "c_utils/memusage.h"
|
||||
#include "test/memusage.h"
|
||||
|
||||
double residentSetSize(void)
|
||||
{
|
|
@ -25,8 +25,8 @@
|
|||
* \author Martin Reinecke
|
||||
*/
|
||||
|
||||
#ifndef PLANCK_MEMUSAGE_H
|
||||
#define PLANCK_MEMUSAGE_H
|
||||
#ifndef SHARP_MEMUSAGE_H
|
||||
#define SHARP_MEMUSAGE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <complex.h>
|
||||
#ifdef USE_MPI
|
||||
#include "mpi.h"
|
||||
#include "libsharp/sharp_mpi.h"
|
||||
|
@ -34,11 +35,10 @@
|
|||
#include <omp.h>
|
||||
#endif
|
||||
#include "libsharp/sharp.h"
|
||||
#include "libsharp/sharp_internal.h"
|
||||
#include "libsharp/sharp_geomhelpers.h"
|
||||
#include "libsharp/sharp_almhelpers.h"
|
||||
#include "c_utils/c_utils.h"
|
||||
#include "c_utils/memusage.h"
|
||||
#include "libsharp/sharp_utils.h"
|
||||
#include "test/memusage.h"
|
||||
|
||||
static void OpenMP_status(void)
|
||||
{
|
Loading…
Add table
Add a link
Reference in a new issue