Commit 082f7eac authored by Swann Perarnau's avatar Swann Perarnau
Browse files

Merge branch 'document-style-consistency' into 'master'

Improve overall library API consistency

Closes #16

See merge request !44
parents b9b7efcd 09d7dc0e
Pipeline #6764 passed with stage
in 4 minutes and 4 seconds
......@@ -10,6 +10,7 @@
#include "aml.h"
#include "aml/area/linux.h"
#include "aml/tiling/2d.h"
#include <assert.h>
#include <errno.h>
#include <mkl.h>
......
......@@ -12,6 +12,8 @@
#include "aml/area/linux.h"
#include "aml/dma/linux-seq.h"
#include "aml/scratch/par.h"
#include "aml/tiling/1d.h"
#include "aml/tiling/2d.h"
#include <assert.h>
#include <errno.h>
#include <mkl.h>
......
......@@ -12,6 +12,7 @@
#include "aml/area/linux.h"
#include "aml/dma/linux-par.h"
#include "aml/scratch/seq.h"
#include "aml/tiling/1d.h"
#include <assert.h>
#include <errno.h>
#include <omp.h>
......
......@@ -12,6 +12,7 @@
#include "aml/area/linux.h"
#include "aml/dma/linux-seq.h"
#include "aml/scratch/par.h"
#include "aml/tiling/1d.h"
#include <assert.h>
#include <errno.h>
#include <omp.h>
......
......@@ -18,6 +18,7 @@
#include "aml/area/linux.h"
#include "aml/dma/linux-seq.h"
#include "aml/scratch/par.h"
#include "aml/tiling/1d.h"
#include "utils.h"
#define ITER 10
......
......@@ -2,7 +2,6 @@ include_HEADERS=aml.h
include_aml_areadir=$(includedir)/aml/area
include_aml_area_HEADERS = \
aml/area/area.h \
aml/area/linux.h
include_aml_dmadir=$(includedir)/aml/dma
......@@ -15,6 +14,11 @@ include_aml_scratch_HEADERS = \
aml/scratch/seq.h \
aml/scratch/par.h
include_aml_tilingdir=$(includedir)/aml/tiling
include_aml_tiling_HEADERS = \
aml/tiling/1d.h \
aml/tiling/2d.h
include_amlutilsdir=$(includedir)/aml/utils
include_amlutils_HEADERS = \
......
......@@ -63,12 +63,54 @@ int aml_finalize(void);
* This abstraction is meant to be implemented for several kind of devices,
* i.e the same function calls allocate different kinds of devices depending
* on the area implementation provided.
* List of aml area implementations each may provide additional functionnalities:
* List of aml area implementations each may provide additional functionalities:
* - <aml/area/linux.h>
**/
/* Implementation details of area building block */
#include "aml/area/area.h"
/* Opaque handle to areas data. Defined by implementations */
struct aml_area_data;
/** Implementation specific operations. **/
struct aml_area_ops {
/**
* Coarse grain allocator of virtual memory.
*
* "area_data": Opaque handle to implementation specific data.
* "ptr": A virtual address to be used by underlying implementation.
* Can be NULL.
* "size": The minimum size of allocation.
* Is greater than 0. Must not fail unless not enough
* memory is available, or ptr argument does not point to a
* suitable address.
* In case of failure, aml_errno must be set to an appropriate
* value.
*
* Returns a pointer to allocated memory object.
**/
void* (*mmap)(const struct aml_area_data *area_data,
void *ptr,
size_t size);
/**
* Unmapping of virtual memory mapped with map().
*
* "area_data": An opaque handle to implementation specific data.
* "ptr": Pointer to data mapped in physical memory. Cannot be NULL.
* "size": The size of data. Cannot be 0.
*
* Returns AML_AREA_* error code.
**/
int (*munmap)(const struct aml_area_data *area_data,
void *ptr,
size_t size);
};
struct aml_area {
/* Basic memory operations implementation */
struct aml_area_ops *ops;
/* Implementation specific data. Set to NULL at creation. */
struct aml_area_data *data;
};
/**
* Returns virtual memory from this area with at least queried size bytes.
......@@ -84,7 +126,7 @@ aml_area_mmap(const struct aml_area *area,
/**
* Release data provided with aml_area_mmap() and the same area.
* "area": A valid area implementing access to target memory.
* "ptr": A pointer to memory address provided with aml_area_mmap()
* "ptr": A pointer to memory address provided with aml_area_mmap()
* by same area and size.
**/
int
......@@ -290,92 +332,6 @@ int aml_tiling_vinit(struct aml_tiling *tiling, int type, va_list args);
*/
int aml_tiling_destroy(struct aml_tiling *tiling, int type);
/*******************************************************************************
* Tiling 1D:
******************************************************************************/
extern struct aml_tiling_ops aml_tiling_1d_ops;
extern struct aml_tiling_iterator_ops aml_tiling_iterator_1d_ops;
struct aml_tiling_1d_data {
size_t blocksize;
size_t totalsize;
};
struct aml_tiling_iterator_1d_data {
size_t i;
struct aml_tiling_1d_data *tiling;
};
#define AML_TILING_1D_DECL(name) \
struct aml_tiling_1d_data __ ##name## _inner_data; \
struct aml_tiling name = { \
&aml_tiling_1d_ops, \
(struct aml_tiling_data *)&__ ## name ## _inner_data, \
};
#define AML_TILING_ITERATOR_1D_DECL(name) \
struct aml_tiling_iterator_1d_data __ ##name## _inner_data; \
struct aml_tiling_iterator name = { \
&aml_tiling_iterator_1d_ops, \
(struct aml_tiling_iterator_data *)&__ ## name ## _inner_data, \
};
#define AML_TILING_1D_ALLOCSIZE (sizeof(struct aml_tiling_1d_data) + \
sizeof(struct aml_tiling))
#define AML_TILING_ITERATOR_1D_ALLOCSIZE \
(sizeof(struct aml_tiling_iterator_1d_data) + \
sizeof(struct aml_tiling_iterator))
/*******************************************************************************
* Tiling 2D:
* a contiguous memory area composed of contiguous tiles arranged in 2D grid.
******************************************************************************/
extern struct aml_tiling_ops aml_tiling_2d_rowmajor_ops;
extern struct aml_tiling_ops aml_tiling_2d_colmajor_ops;
extern struct aml_tiling_iterator_ops aml_tiling_iterator_2d_ops;
struct aml_tiling_2d_data {
size_t blocksize;
size_t totalsize;
size_t ndims[2]; /* # number of rows, # number of cols (in tiles) */
};
struct aml_tiling_iterator_2d_data {
size_t i;
struct aml_tiling_2d_data *tiling;
};
#define AML_TILING_2D_ROWMAJOR_DECL(name) \
struct aml_tiling_2d_data __ ##name## _inner_data; \
struct aml_tiling name = { \
&aml_tiling_2d_rowmajor_ops, \
(struct aml_tiling_data *)&__ ## name ## _inner_data, \
};
#define AML_TILING_2D_COLMAJOR_DECL(name) \
struct aml_tiling_2d_data __ ##name## _inner_data; \
struct aml_tiling name = { \
&aml_tiling_2d_colmajor_ops, \
(struct aml_tiling_data *)&__ ## name ## _inner_data, \
};
#define AML_TILING_ITERATOR_2D_DECL(name) \
struct aml_tiling_iterator_2d_data __ ##name## _inner_data; \
struct aml_tiling_iterator name = { \
&aml_tiling_iterator_2d_ops, \
(struct aml_tiling_iterator_data *)&__ ## name ## _inner_data, \
};
#define AML_TILING_2D_ALLOCSIZE (sizeof(struct aml_tiling_2d_data) + \
sizeof(struct aml_tiling))
#define AML_TILING_ITERATOR_2D_ALLOCSIZE \
(sizeof(struct aml_tiling_iterator_2d_data) + \
sizeof(struct aml_tiling_iterator))
/*******************************************************************************
* DMA:
* Management of low-level movement of memory.
......
/*******************************************************************************
* 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
*******************************************************************************/
#ifndef AML_AREA_H
#define AML_AREA_H
#include <aml/utils/bitmap.h>
/******************************************************************************
* Lower level area management.
* Implementations list:
* - <aml/area/*.h>
* - <aml/area/linux.h>
******************************************************************************/
/* Opaque handle to areas data. Defined by implementations */
struct aml_area_data;
/** Implementation specific operations. **/
struct aml_area_ops {
/**
* Coarse grain allocator of virtual memory.
*
* "area_data": Opaque handle to implementation specific data.
* "ptr": A virtual address to be used by nderlying implementation. Can be NULL.
* "size": The minimum size of allocation.
* Is greater than 0. Must not fail unless not enough
* memory is available, or ptr argument does not point to a suitable address.
* In case of failure, aml_errno must be set to an appropriate value.
*
* Returns a pointer to allocated memory object.
**/
void* (*mmap)(const struct aml_area_data *area_data,
void *ptr,
size_t size);
/**
* Unmapping of virtual memory mapped with map().
*
* "area_data": An opaque handle to implementation specific data.
* "ptr": Pointer to data mapped in physical memory. Cannot be NULL.
* "size": The size of data. Cannot be 0.
*
* Returns AML_AREA_* error code.
**/
int (*munmap)(const struct aml_area_data *area_data,
void *ptr,
size_t size);
};
struct aml_area {
/* Basic memory operations implementation */
struct aml_area_ops *ops;
/* Implmentation specific data. Set to NULL at creation. */
struct aml_area_data *data;
};
#endif //AML_AREA_H
......@@ -24,7 +24,9 @@
#define AML_AREA_LINUX_MMAP_FLAG_PRIVATE (MAP_PRIVATE | MAP_ANONYMOUS)
#define AML_AREA_LINUX_MMAP_FLAG_SHARED (MAP_SHARED | MAP_ANONYMOUS)
/** User data stored inside area **/
extern struct aml_area_ops aml_area_linux_ops;
/* User data stored inside area */
struct aml_area_linux_data {
/** numanodes to use **/
struct bitmask *nodeset;
......@@ -34,6 +36,21 @@ struct aml_area_linux_data {
int mmap_flags;
};
/* Default linux area with private mapping and no binding. */
extern const struct aml_area aml_area_linux;
#define AML_AREA_LINUX_DECL(name) \
struct aml_area_linux_data __ ##name## _inner_data; \
struct aml_area name = { \
&aml_area_linux_ops, \
(struct aml_area_data *)&__ ## name ## _inner_data, \
}
#define AML_AREA_LINUX_ALLOCSIZE \
(sizeof(struct aml_area_linux_data) + \
sizeof(struct aml_area))
/**
* Initialize area data with struct aml_area_linux_binding. Subsequent calls to
* aml_area_mmap() with this returned area will apply binding settings.
......@@ -90,14 +107,8 @@ aml_area_linux_mmap(const struct aml_area_data *area_data,
* error investigations.
**/
int
aml_area_linux_munmap(const struct aml_area_data *area_data,
void *ptr,
const size_t size);
/** linux area hooks. mmap hook will also bind data unlike header mmap hook. **/
extern struct aml_area_ops aml_area_linux_ops;
/** Default linux area with private mapping and no binding. **/
extern const struct aml_area aml_area_linux;
aml_area_linux_munmap(const struct aml_area_data* area_data,
void *ptr,
const size_t size);
#endif //AML_AREA_LINUX_NUMA_H
#endif //AML_AREA_LINUX_NUMA_H
......@@ -56,7 +56,7 @@ struct aml_dma_linux_par {
struct aml_dma name = { \
&aml_dma_linux_par_ops, \
(struct aml_dma_data *)&__ ## name ## _inner_data, \
};
}
#define AML_DMA_LINUX_PAR_ALLOCSIZE \
(sizeof(struct aml_dma_linux_par) + \
......
......@@ -46,7 +46,7 @@ struct aml_dma_linux_seq {
struct aml_dma name = { \
&aml_dma_linux_seq_ops, \
(struct aml_dma_data *)&__ ## name ## _inner_data, \
};
}
#define AML_DMA_LINUX_SEQ_ALLOCSIZE \
(sizeof(struct aml_dma_linux_seq) + \
......
......@@ -53,7 +53,7 @@ struct aml_scratch_par {
struct aml_scratch name = { \
&aml_scratch_par_ops, \
(struct aml_scratch_data *)&__ ## name ## _inner_data, \
};
}
#define AML_SCRATCH_PAR_ALLOCSIZE \
(sizeof(struct aml_scratch_par) + \
......
......@@ -54,7 +54,7 @@ struct aml_scratch_seq {
struct aml_scratch name = { \
&aml_scratch_seq_ops, \
(struct aml_scratch_data *)&__ ## name ## _inner_data, \
};
}
#define AML_SCRATCH_SEQ_ALLOCSIZE \
(sizeof(struct aml_scratch_seq) + \
......
/*******************************************************************************
* 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
*******************************************************************************/
#ifndef AML_TILING_1D_H
#define AML_TILING_1D_H 1
/*******************************************************************************
* Tiling 1D:
******************************************************************************/
extern struct aml_tiling_ops aml_tiling_1d_ops;
extern struct aml_tiling_iterator_ops aml_tiling_iterator_1d_ops;
struct aml_tiling_1d_data {
size_t blocksize;
size_t totalsize;
};
struct aml_tiling_iterator_1d_data {
size_t i;
struct aml_tiling_1d_data *tiling;
};
#define AML_TILING_1D_DECL(name) \
struct aml_tiling_1d_data __ ##name## _inner_data; \
struct aml_tiling name = { \
&aml_tiling_1d_ops, \
(struct aml_tiling_data *)&__ ## name ## _inner_data, \
}
#define AML_TILING_ITERATOR_1D_DECL(name) \
struct aml_tiling_iterator_1d_data __ ##name## _inner_data; \
struct aml_tiling_iterator name = { \
&aml_tiling_iterator_1d_ops, \
(struct aml_tiling_iterator_data *)&__ ## name ## _inner_data, \
}
#define AML_TILING_1D_ALLOCSIZE (sizeof(struct aml_tiling_1d_data) + \
sizeof(struct aml_tiling))
#define AML_TILING_ITERATOR_1D_ALLOCSIZE \
(sizeof(struct aml_tiling_iterator_1d_data) + \
sizeof(struct aml_tiling_iterator))
#endif /* AML_TILING_1D_H */
/*******************************************************************************
* 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
*******************************************************************************/
#ifndef AML_TILING_2D_H
#define AML_TILING_2D_H 1
/*******************************************************************************
* Tiling 2D:
* a contiguous memory area composed of contiguous tiles arranged in 2D grid.
******************************************************************************/
extern struct aml_tiling_ops aml_tiling_2d_rowmajor_ops;
extern struct aml_tiling_ops aml_tiling_2d_colmajor_ops;
extern struct aml_tiling_iterator_ops aml_tiling_iterator_2d_ops;
struct aml_tiling_2d_data {
size_t blocksize;
size_t totalsize;
size_t ndims[2]; /* # number of rows, # number of cols (in tiles) */
};
struct aml_tiling_iterator_2d_data {
size_t i;
struct aml_tiling_2d_data *tiling;
};
#define AML_TILING_2D_ROWMAJOR_DECL(name) \
struct aml_tiling_2d_data __ ##name## _inner_data; \
struct aml_tiling name = { \
&aml_tiling_2d_rowmajor_ops, \
(struct aml_tiling_data *)&__ ## name ## _inner_data, \
}
#define AML_TILING_2D_COLMAJOR_DECL(name) \
struct aml_tiling_2d_data __ ##name## _inner_data; \
struct aml_tiling name = { \
&aml_tiling_2d_colmajor_ops, \
(struct aml_tiling_data *)&__ ## name ## _inner_data, \
}
#define AML_TILING_ITERATOR_2D_DECL(name) \
struct aml_tiling_iterator_2d_data __ ##name## _inner_data; \
struct aml_tiling_iterator name = { \
&aml_tiling_iterator_2d_ops, \
(struct aml_tiling_iterator_data *)&__ ## name ## _inner_data, \
}
#define AML_TILING_2D_ALLOCSIZE (sizeof(struct aml_tiling_2d_data) + \
sizeof(struct aml_tiling))
#define AML_TILING_ITERATOR_2D_ALLOCSIZE \
(sizeof(struct aml_tiling_iterator_2d_data) + \
sizeof(struct aml_tiling_iterator))
#endif /* AML_TILING_2D_H */
......@@ -15,6 +15,9 @@ struct aml_bitmap {
unsigned long mask[AML_BITMAP_SIZE];
};
/* Not needed, here for consistency */
#define AML_BITMAP_DECL(name) struct aml_bitmap name
#define AML_BITMAP_ALLOCSIZE (sizeof(struct aml_bitmap))
/**
* On heap allocation of new empty bitmap.
**/
......
......@@ -22,8 +22,8 @@ struct aml_vector {
};
/* not needed, here for consistency */
#define AML_VECTOR_DECL(name) struct vector ##name;
#define AML_VECTOR_ALLOCSIZE (sizeof(struct vector))
#define AML_VECTOR_DECL(name) struct aml_vector name
#define AML_VECTOR_ALLOCSIZE (sizeof(struct aml_vector))
/*
* Provides the total number of elements in the vector, including currently
......
......@@ -11,7 +11,6 @@
#include <errno.h>
#include "aml.h"
#include "aml/area/area.h"
#include "aml/area/linux.h"
#define AML_AREA_LINUX_MBIND_FLAGS MPOL_MF_MOVE
......
......@@ -9,6 +9,8 @@
*******************************************************************************/
#include "aml.h"
#include "aml/tiling/1d.h"
#include "aml/tiling/2d.h"
#include <assert.h>
/*******************************************************************************
......
......@@ -9,6 +9,7 @@
*******************************************************************************/
#include "aml.h"
#include "aml/tiling/1d.h"
#include <assert.h>
/*******************************************************************************
......
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