Commit 2ad4488c authored by Nicolas Denoyelle's avatar Nicolas Denoyelle Committed by Swann Perarnau
Browse files

[refactor] reorganize repository

- create one directory per building block in src and include
- keep one directory for tests, \
  otherwise automake make them "test suites"
- move to AC_OPENMP, which is from autoconf 2.62 (2008)
parent 2b0d9e28
Pipeline #6871 passed with stage
in 9 minutes and 41 seconds
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
# automake # automake
Makefile.in Makefile.in
Makefile Makefile
**/.dirstamp
# autoconf # autoconf
/autom4te.cache /autom4te.cache
...@@ -51,8 +52,8 @@ stamp-h1 ...@@ -51,8 +52,8 @@ stamp-h1
/stamp-h1 /stamp-h1
# autotest # autotest
tests/*.trs tests/**/*.trs
tests/*.log tests/**/*.log
*.test.* *.test.*
# libtool # libtool
......
...@@ -2,3 +2,4 @@ Swann Perarnau <swann@anl.gov> ...@@ -2,3 +2,4 @@ Swann Perarnau <swann@anl.gov>
Kamil Iskra <iskra@mcs.anl.gov> Kamil Iskra <iskra@mcs.anl.gov>
Brian Suchy <briansuchy2022@u.northwestern.edu> Brian Suchy <briansuchy2022@u.northwestern.edu>
Valentin Reis <fre@freux.fr> Valentin Reis <fre@freux.fr>
Nicolas Denoyelle <ndenoyelle@anl.gov>
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
SUBDIRS = jemalloc src tests SUBDIRS = jemalloc src include tests
if ADD_BENCHMARKS if ADD_BENCHMARKS
SUBDIRS += benchmarks SUBDIRS += benchmarks
......
AM_CFLAGS = -I$(top_srcdir)/src -I. @OPENMP_FLAG@ AM_CFLAGS = -I$(top_srcdir)/include -I. $(OPENMP_CFLAGS)
AM_LDFLAGS = ../src/libaml.la @OPENMP_FLAG@ AM_LDFLAGS = ../src/libaml.la $(OPENMP_CFLAGS)
noinst_LIBRARIES = libutils.a noinst_LIBRARIES = libutils.a
libutils_a_SOURCES = utils.c utils.h libutils_a_SOURCES = utils.c utils.h
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/ *******************************************************************************/
#include <aml.h> #include "aml.h"
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <mkl.h> #include <mkl.h>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/ *******************************************************************************/
#include <aml.h> #include "aml.h"
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <mkl.h> #include <mkl.h>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/ *******************************************************************************/
#include <aml.h> #include "aml.h"
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <mkl.h> #include <mkl.h>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <omp.h> #include <omp.h>
#include <aml.h> #include "aml.h"
#include <stdlib.h> #include <stdlib.h>
#define ITER 10 #define ITER 10
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/ *******************************************************************************/
#include <aml.h> #include "aml.h"
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <omp.h> #include <omp.h>
...@@ -42,7 +42,6 @@ int main(int argc, char *argv[]) ...@@ -42,7 +42,6 @@ int main(int argc, char *argv[])
AML_ARENA_JEMALLOC_DECL(arns); AML_ARENA_JEMALLOC_DECL(arns);
AML_ARENA_JEMALLOC_DECL(arnf); AML_ARENA_JEMALLOC_DECL(arnf);
AML_DMA_LINUX_PAR_DECL(dma); AML_DMA_LINUX_PAR_DECL(dma);
unsigned long nodemask[AML_NODEMASK_SZ];
struct bitmask *slowb, *fastb; struct bitmask *slowb, *fastb;
aml_init(&argc, &argv); aml_init(&argc, &argv);
assert(argc == 4); assert(argc == 4);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/ *******************************************************************************/
#include <aml.h> #include "aml.h"
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <omp.h> #include <omp.h>
...@@ -72,7 +72,6 @@ int main(int argc, char *argv[]) ...@@ -72,7 +72,6 @@ int main(int argc, char *argv[])
AML_ARENA_JEMALLOC_DECL(arns); AML_ARENA_JEMALLOC_DECL(arns);
AML_ARENA_JEMALLOC_DECL(arnf); AML_ARENA_JEMALLOC_DECL(arnf);
AML_DMA_LINUX_SEQ_DECL(dma); AML_DMA_LINUX_SEQ_DECL(dma);
unsigned long nodemask[AML_NODEMASK_SZ];
struct bitmask *slowb, *fastb; struct bitmask *slowb, *fastb;
aml_init(&argc, &argv); aml_init(&argc, &argv);
assert(argc == 4); assert(argc == 4);
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/ *******************************************************************************/
#include <aml.h>
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <omp.h> #include <omp.h>
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
#include "aml.h"
#include "utils.h" #include "utils.h"
#define ITER 10 #define ITER 10
...@@ -79,7 +79,6 @@ int main(int argc, char *argv[]) ...@@ -79,7 +79,6 @@ int main(int argc, char *argv[])
AML_BINDING_SINGLE_DECL(binding); AML_BINDING_SINGLE_DECL(binding);
AML_ARENA_JEMALLOC_DECL(arena); AML_ARENA_JEMALLOC_DECL(arena);
AML_DMA_LINUX_SEQ_DECL(dma); AML_DMA_LINUX_SEQ_DECL(dma);
unsigned long nodemask[AML_NODEMASK_SZ];
struct bitmask *slowb, *fastb; struct bitmask *slowb, *fastb;
aml_init(&argc, &argv); aml_init(&argc, &argv);
assert(argc == 4); assert(argc == 4);
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
/* program constitutes acceptance of these licensing restrictions. */ /* program constitutes acceptance of these licensing restrictions. */
/* 5. Absolutely no warranty is expressed or implied. */ /* 5. Absolutely no warranty is expressed or implied. */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
# include <aml.h> # include "aml.h"
# include <stdio.h> # include <stdio.h>
# include <unistd.h> # include <unistd.h>
# include <math.h> # include <math.h>
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
AC_INIT([aml],[0.0.1],[swann@anl.gov]) AC_INIT([aml],[0.0.1],[swann@anl.gov])
# are we in the right source dir ? # are we in the right source dir ?
AC_CONFIG_SRCDIR([src/aml.h]) AC_CONFIG_SRCDIR([include/aml.h])
# build artefacts in separate dir # build artefacts in separate dir
AC_CONFIG_AUX_DIR([m4]) AC_CONFIG_AUX_DIR([m4])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
# automake should fail on any error # automake should fail on any error
AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.12]) AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects 1.12])
AM_PROG_AR AM_PROG_AR
# check for libtool # check for libtool
...@@ -19,6 +19,7 @@ LT_INIT ...@@ -19,6 +19,7 @@ LT_INIT
AC_LANG([C]) AC_LANG([C])
AC_PROG_CC AC_PROG_CC
AC_PROG_CC_STDC AC_PROG_CC_STDC
AM_PROG_CC_C_O
AC_PROG_CPP AC_PROG_CPP
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_TYPE_INTPTR_T AC_TYPE_INTPTR_T
...@@ -42,7 +43,7 @@ AC_ARG_ENABLE(benchmarks, ...@@ -42,7 +43,7 @@ AC_ARG_ENABLE(benchmarks,
[benchmarks=true],[benchmarks=false]) [benchmarks=true],[benchmarks=false])
if [[ "x$benchmarks" = xtrue ]]; then if [[ "x$benchmarks" = xtrue ]]; then
AX_OPENMP([AC_SUBST(OPENMP_FLAG, $OPENMP_CFLAGS)]) AC_OPENMP
AC_CHECK_LIB(m, sqrt) AC_CHECK_LIB(m, sqrt)
fi fi
AM_CONDITIONAL([ADD_BENCHMARKS],[test "x$benchmarks" = xtrue]) AM_CONDITIONAL([ADD_BENCHMARKS],[test "x$benchmarks" = xtrue])
...@@ -70,6 +71,14 @@ AC_CONFIG_HEADERS([src/config.h]) ...@@ -70,6 +71,14 @@ AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
src/Makefile src/Makefile
src/area/Makefile
src/dma/Makefile
src/tiling/Makefile
src/binding/Makefile
src/scratch/Makefile
src/arena/Makefile
src/utils/Makefile
include/Makefile
tests/Makefile tests/Makefile
benchmarks/Makefile benchmarks/Makefile
aml.pc]) aml.pc])
......
include_HEADERS=aml.h
include_amlutilsdir=$(includedir)/aml/utils
include_amlutils_HEADERS = \
aml/utils/vector.h
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#ifndef AML_H #ifndef AML_H
#define AML_H 1 #define AML_H 1
#include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include <numa.h> #include <numa.h>
#include <numaif.h> #include <numaif.h>
...@@ -28,6 +29,8 @@ ...@@ -28,6 +29,8 @@
#define PAGE_SIZE 4096 #define PAGE_SIZE 4096
#endif #endif
#include <aml/utils/vector.h>
/******************************************************************************* /*******************************************************************************
* Forward Declarations: * Forward Declarations:
...@@ -36,96 +39,6 @@ ...@@ -36,96 +39,6 @@
struct aml_area; struct aml_area;
struct aml_binding; struct aml_binding;
/*******************************************************************************
* Generic vector type:
* Vector of nbelems, each of size sz, with a comparison key at offset off
******************************************************************************/
/* Pointer to the key within element "e" of a vector "v". */
#define AML_VECTOR_ELTKEY_P(v,e) ((int *)(((intptr_t) e) + v->off))
/* Pointer to the key within element index "i" of a vector "v". */
#define AML_VECTOR_KEY_P(v,i) ((int *)(((intptr_t) v->ptr) + i*v->sz + v->off))
/* Pointer to the element index "i" of a vector "v". */
#define AML_VECTOR_ELT_P(v,i) ((void *)(((intptr_t) v->ptr) + i*v->sz))
struct aml_vector {
int na;
size_t nbelems;
size_t sz;
size_t off;
void *ptr;
};
/* not needed, here for consistency */
#define AML_VECTOR_DECL(name) struct vector ##name;
#define AML_VECTOR_ALLOCSIZE (sizeof(struct vector))
/*
* Provides the total number of elements in the vector, including currently
* unused ones.
* "vector": an initialized vector structure.
* Returns the number of elements in the vector.
*/
size_t aml_vector_size(const struct aml_vector *vector);
/*
* Provides a pointer of element with index "index" within the vector.
* "vector": an initialized vector structure.
* "index": a valid index within "vector". The index must not equal "na" and
* must be lower than the size of the vector.
* Returns a pointer to the requested element.
*/
void *aml_vector_get(struct aml_vector *vector, int index);
/*
* Find the first element with a particular key.
* "vector": an initialized vector structure.
* "key": the key to look for.
* Returns the index of the found element or "na" if not found.
*/
int aml_vector_find(const struct aml_vector *vector, int key);
/*
* Resizes the vector. The keys of the newly allocated elements are set to the
* "na" value.
* "vector": an initialized vector structure.
* "newsize": a new vector size. Only sizes greater than the current one will
* be honored; smaller sizes will result in a no-op.
* Returns 0 if successful; an error code otherwise.
*/
int aml_vector_resize(struct aml_vector *vector, size_t newsize);
/*
* Provides the pointer to the first unused element. If the vector is full,
* it automatically gets enlarged.
* "vector": an initialized vector structure.
* Returns the pointer to the first unused element.
*/
void *aml_vector_add(struct aml_vector *vector);
/*
* Removes an element from the vector. The key of the element is set to the
* "na" value.
* "vector": an initialized vector structure.
* "elem": an element within the vector.
*/
void aml_vector_remove(struct aml_vector *vector, void *elem);
/*
* Initializes a vector. Allocates elements and sets their keys to the "na"
* value.
* "vector": an allocated vector structure.
* "num": the number of elements to allocate.
* "size": the size of each individual element.
* "key": the offset within each element where the key (of type int) is stored.
* "na": a "null" key value used to indicate an unused element.
* Returns 0 if successful; an error code otherwise.
*/
int aml_vector_init(struct aml_vector *vector, size_t num, size_t size,
size_t key, int na);
/*
* Tears down an initialized vector. Releases the memory buffer holding the
* elements.
* "vector": an initialized vector structure.
* Returns 0 if successful; an error code otherwise.
*/
int aml_vector_destroy(struct aml_vector *vector);
/******************************************************************************* /*******************************************************************************
* Arenas: * Arenas:
* In-memory allocator implementation. Dispatches actual memory mappings back to * In-memory allocator implementation. Dispatches actual memory mappings back to
......
#ifndef AML_VECTOR_H
#define AML_VECTOR_H
/*******************************************************************************
* Generic vector type:
* Vector of nbelems, each of size sz, with a comparison key at offset off
******************************************************************************/
/* Pointer to the key within element "e" of a vector "v". */
#define AML_VECTOR_ELTKEY_P(v,e) ((int *)(((intptr_t) e) + v->off))
/* Pointer to the key within element index "i" of a vector "v". */
#define AML_VECTOR_KEY_P(v,i) ((int *)(((intptr_t) v->ptr) + i*v->sz + v->off))
/* Pointer to the element index "i" of a vector "v". */
#define AML_VECTOR_ELT_P(v,i) ((void *)(((intptr_t) v->ptr) + i*v->sz))
struct aml_vector {
int na;
size_t nbelems;
size_t sz;
size_t off;
void *ptr;
};
/* not needed, here for consistency */
#define AML_VECTOR_DECL(name) struct vector ##name;
#define AML_VECTOR_ALLOCSIZE (sizeof(struct vector))
/*
* Provides the total number of elements in the vector, including currently
* unused ones.
* "vector": an initialized vector structure.
* Returns the number of elements in the vector.
*/
size_t aml_vector_size(const struct aml_vector *vector);
/*
* Provides a pointer of element with index "index" within the vector.
* "vector": an initialized vector structure.
* "index": a valid index within "vector". The index must not equal "na" and
* must be lower than the size of the vector.
* Returns a pointer to the requested element.
*/
void *aml_vector_get(struct aml_vector *vector, int index);
/*
* Find the first element with a particular key.
* "vector": an initialized vector structure.
* "key": the key to look for.
* Returns the index of the found element or "na" if not found.
*/
int aml_vector_find(const struct aml_vector *vector, int key);
/*
* Resizes the vector. The keys of the newly allocated elements are set to the
* "na" value.
* "vector": an initialized vector structure.
* "newsize": a new vector size. Only sizes greater than the current one will
* be honored; smaller sizes will result in a no-op.
* Returns 0 if successful; an error code otherwise.
*/
int aml_vector_resize(struct aml_vector *vector, size_t newsize);
/*
* Provides the pointer to the first unused element. If the vector is full,
* it automatically gets enlarged.
* "vector": an initialized vector structure.
* Returns the pointer to the first unused element.
*/
void *aml_vector_add(struct aml_vector *vector);
/*
* Removes an element from the vector. The key of the element is set to the
* "na" value.
* "vector": an initialized vector structure.
* "elem": an element within the vector.
*/
void aml_vector_remove(struct aml_vector *vector, void *elem);
/*
* Initializes a vector. Allocates elements and sets their keys to the "na"
* value.
* "vector": an allocated vector structure.
* "num": the number of elements to allocate.
* "size": the size of each individual element.
* "key": the offset within each element where the key (of type int) is stored.
* "na": a "null" key value used to indicate an unused element.
* Returns 0 if successful; an error code otherwise.
*/
int aml_vector_init(struct aml_vector *vector, size_t num, size_t size,
size_t key, int na);
/*
* Tears down an initialized vector. Releases the memory buffer holding the
* elements.
* "vector": an initialized vector structure.
* Returns 0 if successful; an error code otherwise.
*/
int aml_vector_destroy(struct aml_vector *vector);
#endif //AML_VECTOR_H
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_openmp.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_OPENMP([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro tries to find out how to compile programs that use OpenMP a
# standard API and set of compiler directives for parallel programming
# (see http://www-unix.mcs/)
#
# On success, it sets the OPENMP_CFLAGS/OPENMP_CXXFLAGS/OPENMP_F77FLAGS
# output variable to the flag (e.g. -omp) used both to compile *and* link
# OpenMP programs in the current language.
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also link it with them as well.
#
# If you want to compile everything with OpenMP, you should set:
#
# CFLAGS="$CFLAGS $OPENMP_CFLAGS"
# #OR# CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
# #OR# FFLAGS="$FFLAGS $OPENMP_FFLAGS"
#
# (depending on the selected language).
#
# The user can override the default choice by setting the corresponding
# environment variable (e.g. OPENMP_CFLAGS).
#
# ACTION-IF-FOUND is a list of shell commands to run if an OpenMP flag is
# found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is
# not found. If ACTION-IF-FOUND is not specified, the default action will
# define HAVE_OPENMP.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2015 John W. Peterson <jwpeterson@gmail.com>
# Copyright (c) 2016 Nick R. Papior <nickpapior@gmail.com>
#
# This program 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 3 of the License, or (at your
# option) any later version.
#
# This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 13
AC_DEFUN([AX_OPENMP], [
AC_PREREQ([2.69]) dnl for _AC_LANG_PREFIX
AC_CACHE_CHECK([for OpenMP flag of _AC_LANG compiler], ax_cv_[]_AC_LANG_ABBREV[]_openmp, [save[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
ax_cv_[]_AC_LANG_ABBREV[]_openmp=unknown
# Flags to try: -fopenmp (gcc), -mp (SGI & PGI),
# -qopenmp (icc>=15), -openmp (icc),
# -xopenmp (Sun), -omp (Tru64),
# -qsmp=omp (AIX),
# none
ax_openmp_flags="-fopenmp -openmp -qopenmp -mp -xopenmp -omp -qsmp=omp none"
if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then
ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags"
fi
for ax_openmp_flag in $ax_openmp_flags; do
case $ax_openmp_flag in
none) []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[] ;;
*) []_AC_LANG_PREFIX[]FLAGS="$save[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flag" ;;
esac
AC_LINK_IFELSE([AC_LANG_SOURCE([[
@%:@include <omp.h>
static void
parallel_fill(int * data, int n)
{
int i;
@%:@pragma omp parallel for
for (i = 0; i < n; ++i)
data[i] = i;
}
int
main()
{
int arr[100000];
omp_set_num_threads(2);
parallel_fill(arr, 100000);
return 0;
}
]])],[ax_cv_[]_AC_LANG_ABBREV[]_openmp=$ax_openmp_flag; break],[])
done
[]_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[]FLAGS
])
if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" = "xunknown"; then
m4_default([$2],:)
else
if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" != "xnone"; then
OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ax_cv_[]_AC_LANG_ABBREV[]_openmp
fi