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
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
/*******************************************************************************
......
AM_CFLAGS=-I$(top_srcdir)/include
AM_CPPFLAGS=$(AM_CFLAGS)
noinst_LTLIBRARIES=libamltiling.la
libamltiling_la_SOURCES=\
tiling.c \
tiling_1d.c \
tiling_2d.c
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
/*******************************************************************************
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
/*******************************************************************************
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
/*******************************************************************************
......
AM_CFLAGS=-I$(top_srcdir)/include
AM_CPPFLAGS=$(AM_CFLAGS)
noinst_LTLIBRARIES=libamlutils.la
libamlutils_la_SOURCES=\
vector.c
libamlutils_la_CFLAGS=$(AM_CFLAGS)
libamlutils_la_LDFLAGS=
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#include <errno.h>
......
AM_COLOR_TESTS = yes
# add OpenMP to flags for test programs
AM_CFLAGS = -I$(top_srcdir)/src
AM_CFLAGS = -I$(top_srcdir)/include
AM_LDFLAGS = ../src/libaml.la
# valgrind support
......@@ -9,27 +9,27 @@ if TEST_VALGRIND
TESTS_ENVIRONMENT= @LIBTOOL@ --mode=execute @VALGRIND@ --tool=memcheck -q --leak-check=full
endif
UTILS_TESTS = vector
UTILS_TESTS = utils/test_vector
ARENA_JEMALLOC_TESTS = arena_jemalloc
ARENA_JEMALLOC_TESTS = arena/test_jemalloc
AREA_LINUX_TESTS = \
linux_mmap \
linux_manager \
area_linux
area/test_mmap \
area/test_manager \
area/test_linux
AREA_POSIX_TESTS = area_posix
AREA_POSIX_TESTS = area/test_posix
TILING_TESTS = tiling \
tiling_2d
TILING_TESTS = tiling/test_tiling \
tiling/test_tiling_2d
BINDING_TESTS = binding
BINDING_TESTS = binding/test_binding
DMA_LINUX_TESTS = dma_linux_seq \
dma_linux_par
DMA_LINUX_TESTS = dma/test_dma_linux_seq \
dma/test_dma_linux_par
SCRATCH_TESTS = scratch_seq \
scratch_par
SCRATCH_TESTS = scratch/test_scratch_seq \
scratch/test_scratch_par
# unit tests
UNIT_TESTS = $(ARENA_JEMALLOC_TESTS) \
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#include <numa.h>
#include <numaif.h>
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
void doit(struct aml_area_linux_manager_data *data,
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#include <inttypes.h>
#include <numa.h>
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
int main(int argc, char *argv[])
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#define TILESIZE (2)
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#define TILESIZE (2)
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#define TILESIZE (2)
......
/*******************************************************************************
* Copyright 2019 UChicago Argonne, LLC.
* (c.f. AUTHORS, LICENSE)
*
* This file is part of the AML project.
* For more info, see https://xgitlab.cels.anl.gov/argo/aml
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include <assert.h>
#include <numa.h>
#include <numaif.h>
#include <stdio.h>
#include <sys/mman.h>
#define PAGE_SIZE 4096
#define ALLOC_SIZE (1<<20)
#define ALLOC_PAGES (ALLOC_SIZE/PAGE_SIZE)
/* some of that should probably end up in the lib itself */
#define __NBITS (8*sizeof(unsigned long))
#define __ELT(i) ((i) / __NBITS)
#define __MASK(i) ((unsigned long) 1 << ((i) % __NBITS))
#define BIT(mask, i) (mask[__ELT(i)] & __MASK(i))
/* validate that each page is on an authorized node */
void checkpages(void *ptr, unsigned long *mask)
{
int i;
void *pages[ALLOC_PAGES];
int status[ALLOC_PAGES];
for(i = 0; i < ALLOC_PAGES; i++)
pages[i] = (void *)((char *)ptr + PAGE_SIZE);
move_pages(0, ALLOC_PAGES, pages, NULL, status, 0);
for(i = 0; i < ALLOC_PAGES; i++)
assert(BIT(mask, status[i]));
}
void doit(struct aml_area_linux_mbind_data *config,
struct aml_area_linux_mbind_ops *ops,
int policy, unsigned long *mask)
{
int err, mode;
void *ptr;
unsigned long rmask[AML_NODEMASK_SZ];
err = ops->pre_bind(config);
assert(err == 0);
/* MAP_POPULATE is necessary to ensure our bindings are enforced in case
* mempolicy is used internally.
*
* Our bindings should resist those issues.
*/
ptr = mmap(NULL, ALLOC_SIZE, PROT_READ|PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
assert(ptr != MAP_FAILED);
err = ops->post_bind(config, ptr, ALLOC_SIZE);
assert(err == 0);
/* touch all pages */
for(char *p = ptr; p < (char*)ptr + ALLOC_SIZE; p += PAGE_SIZE)
*p = 0;
/* Retrieve the current policy for that alloc and compare.
* get_mempolicy does not return the right policy if it was set using
* set_mempolicy binding methods. As a result, we only check the mode
* and mask if a mode different form MPOL_DEFAULT is returned.
*/
get_mempolicy(&mode, rmask, AML_MAX_NUMA_NODES, ptr, MPOL_F_ADDR);
if(mode != MPOL_DEFAULT) {
assert(mode == policy);
assert(!memcmp(rmask, mask, AML_NODEMASK_BYTES));
}
checkpages(ptr, mask);
munmap(ptr, ALLOC_SIZE);
}
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
struct aml_area_linux_mbind_ops *tocheck[] = {
&aml_area_linux_mbind_regular_ops,
//&aml_area_linux_mbind_mempolicy_ops,
};
int main(int argc, char *argv[])
{
struct aml_area_linux_mbind_data config;
unsigned long nodemask[AML_NODEMASK_SZ];
struct bitmask *allowed;
int mode;
/* library initialization */
aml_init(&argc, &argv);
/* retrieve the current nodemask:
* while in theory we can retrieve that info for get_mempolicy, the
* default binding policy returns an empty nodemask, so it doesn't
* really help us. We use the numa library directly instead.*/
allowed = numa_get_mems_allowed();
/* select the first numa node as the one used for this test. */
AML_NODEMASK_ZERO(nodemask);
for(int i = 0; i < AML_MAX_NUMA_NODES; i++)
if(numa_bitmask_isbitset(allowed, i))
{
AML_NODEMASK_SET(nodemask, i);
break;
}
/* use MPOL_BIND for checks, and make sure init worked. */
aml_area_linux_mbind_init(&config, MPOL_BIND, nodemask);
assert(config.policy == MPOL_BIND);
assert(config.nodemask[0] == nodemask[0]);
for(int i = 0; i < ARRAY_SIZE(tocheck); i++)
doit(&config, tocheck[i], MPOL_BIND, nodemask);
aml_area_linux_mbind_destroy(&config);
aml_finalize();
return 0;
}
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#define TILESIZE (2)
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#define TILESIZE (2)
......
......@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include <aml.h>
#include "aml.h"
#include <assert.h>
#define TILESIZE 8192
......
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