...
 
Commits (4)
......@@ -28,6 +28,7 @@ make:generic:
- /^WIP.*/
script:
- ./autogen.sh
- export CFLAGS="-Wall -Wextra"
- mkdir build
- ./configure --prefix=`pwd`/build
- make
......
......@@ -33,7 +33,7 @@ extern int aml_errno;
* @param errno: the aml error number.
* Returns a static string describing the error.
**/
const char *aml_strerror(const int errno);
const char *aml_strerror(const int err);
/**
* Print error on standard error output.
......
......@@ -19,7 +19,8 @@ const char *aml_version_string = AML_VERSION_STRING;
int aml_errno;
int aml_init(int *argc, char **argv[])
int aml_init(__attribute__ ((unused)) int *argc,
__attribute__ ((unused)) char **argv[])
{
return 0;
}
......
......@@ -43,7 +43,7 @@ aml_area_linux_mbind(struct aml_area_linux_data *bind,
int
aml_area_linux_check_binding(struct aml_area_linux_data *area_data,
void *ptr,
size_t size)
__attribute__ ((unused)) size_t size)
{
int err, mode, i;
struct bitmask *nodeset;
......@@ -209,7 +209,6 @@ int aml_area_linux_init(struct aml_area *area, const int mmap_flags,
const int binding_flags)
{
struct aml_area_linux_data *data;
int err;
if (area == NULL)
return -AML_EINVAL;
......
......@@ -72,7 +72,7 @@ int aml_dma_linux_par_do_copy(struct aml_dma_linux_par_data *dma,
assert(req != NULL);
/* chunk memory */
size_t nbthreads = dma->nbthreads;
ssize_t nbthreads = dma->nbthreads;
size_t chunksize = req->size / nbthreads;
void *dest = (void *)((intptr_t)req->dest + tid * chunksize);
......@@ -125,7 +125,7 @@ int aml_dma_linux_par_create_request(struct aml_dma_data *d,
}
pthread_mutex_unlock(&dma->data.lock);
for (int i = 0; i < dma->data.nbthreads; i++) {
for (unsigned int i = 0; i < dma->data.nbthreads; i++) {
struct aml_dma_linux_par_thread_data *rd = &req->thread_data[i];
rd->req = req;
......@@ -149,7 +149,7 @@ int aml_dma_linux_par_destroy_request(struct aml_dma_data *d,
(struct aml_dma_request_linux_par *)r;
/* we cancel and join, instead of killing, for a cleaner result */
for (int i = 0; i < dma->data.nbthreads; i++) {
for (unsigned int i = 0; i < dma->data.nbthreads; i++) {
pthread_cancel(req->thread_data[i].thread);
pthread_join(req->thread_data[i].thread, NULL);
}
......@@ -172,7 +172,7 @@ int aml_dma_linux_par_wait_request(struct aml_dma_data *d,
struct aml_dma_request_linux_par *req =
(struct aml_dma_request_linux_par *)r;
for (int i = 0; i < dma->data.nbthreads; i++)
for (unsigned int i = 0; i < dma->data.nbthreads; i++)
pthread_join(req->thread_data[i].thread, NULL);
/* destroy a completed request */
......@@ -244,7 +244,7 @@ int aml_dma_linux_par_init(struct aml_dma *d, size_t nbreqs,
sizeof(struct aml_dma_request_linux_par),
offsetof(struct aml_dma_request_linux_par, type),
AML_DMA_REQUEST_TYPE_INVALID);
for (int i = 0; i < nbreqs; i++) {
for (unsigned int i = 0; i < nbreqs; i++) {
struct aml_dma_request_linux_par *req =
aml_vector_get(&dma->data.requests, i);
......@@ -262,7 +262,9 @@ void aml_dma_linux_par_fini(struct aml_dma *d)
if (d == NULL || d->data == NULL)
return;
dma = (struct aml_dma_linux_par *)d->data;
for (int i = 0; i < aml_vector_size(&dma->data.requests); i++) {
for (unsigned int i = 0;
i < aml_vector_size(&dma->data.requests);
i++) {
struct aml_dma_request_linux_par *req =
aml_vector_get(&dma->data.requests, i);
......
......@@ -58,6 +58,7 @@ void *aml_scratch_par_do_thread(void *arg)
aml_dma_copy(scratch->data.dma, scratch->data.tiling, req->dstptr,
req->dstid, scratch->data.tiling, req->srcptr, req->srcid);
return NULL;
}
struct aml_scratch_par_ops aml_scratch_par_inner_ops = {
......@@ -154,7 +155,7 @@ int aml_scratch_par_destroy_request(struct aml_scratch_data *d,
struct aml_scratch_request_par *req =
(struct aml_scratch_request_par *)r;
int *tile;
int *tile = NULL;
if (req->type != AML_SCRATCH_REQUEST_TYPE_NOOP) {
pthread_cancel(req->thread);
......@@ -169,7 +170,8 @@ int aml_scratch_par_destroy_request(struct aml_scratch_data *d,
tile = aml_vector_get(&scratch->data.tilemap, req->srcid);
else if (req->type == AML_SCRATCH_REQUEST_TYPE_PULL)
tile = aml_vector_get(&scratch->data.tilemap, req->dstid);
aml_vector_remove(&scratch->data.tilemap, tile);
if (tile)
aml_vector_remove(&scratch->data.tilemap, tile);
aml_vector_remove(&scratch->data.requests, req);
pthread_mutex_unlock(&scratch->data.lock);
return 0;
......
......@@ -158,7 +158,7 @@ int aml_scratch_seq_destroy_request(struct aml_scratch_data *d,
struct aml_scratch_request_seq *req =
(struct aml_scratch_request_seq *)r;
int *tile;
int *tile = NULL;
if (req->type != AML_SCRATCH_REQUEST_TYPE_NOOP)
aml_dma_cancel(scratch->data.dma, req->dma_req);
......@@ -170,7 +170,8 @@ int aml_scratch_seq_destroy_request(struct aml_scratch_data *d,
tile = aml_vector_get(&scratch->data.tilemap, req->srcid);
else if (req->type == AML_SCRATCH_REQUEST_TYPE_PULL)
tile = aml_vector_get(&scratch->data.tilemap, req->dstid);
aml_vector_remove(&scratch->data.tilemap, tile);
if (tile)
aml_vector_remove(&scratch->data.tilemap, tile);
aml_vector_remove(&scratch->data.requests, req);
pthread_mutex_unlock(&scratch->data.lock);
return 0;
......
......@@ -60,10 +60,10 @@ struct aml_tiling_iterator_ops aml_tiling_iterator_1d_ops = {
* 1D ops
******************************************************************************/
int aml_tiling_1d_tileid(const struct aml_tiling_data *t, va_list ap)
int
aml_tiling_1d_tileid(__attribute__ ((unused)) const struct aml_tiling_data *t,
va_list ap)
{
const struct aml_tiling_1d_data *data =
(const struct aml_tiling_1d_data *)t;
size_t x = va_arg(ap, size_t);
return x;
}
......@@ -99,12 +99,13 @@ int aml_tiling_1d_ndims(const struct aml_tiling_data *t, va_list ap)
size_t *x = va_arg(ap, size_t *);
*x = data->totalsize/data->blocksize;
if (data->totalsize % data->blocksize != 0)
*x++;
*x += 1;
return 0;
}
int aml_tiling_1d_init_iterator(struct aml_tiling_data *t,
struct aml_tiling_iterator *it, int flags)
struct aml_tiling_iterator *it,
__attribute__ ((unused)) int flags)
{
assert(it->data != NULL);
struct aml_tiling_iterator_1d_data *data =
......@@ -117,7 +118,8 @@ int aml_tiling_1d_init_iterator(struct aml_tiling_data *t,
}
int aml_tiling_1d_create_iterator(struct aml_tiling_data *t,
struct aml_tiling_iterator **it, int flags)
struct aml_tiling_iterator **it,
int flags)
{
intptr_t baseptr, dataptr;
struct aml_tiling_iterator *ret;
......@@ -133,13 +135,16 @@ int aml_tiling_1d_create_iterator(struct aml_tiling_data *t,
return 0;
}
int aml_tiling_1d_fini_iterator(struct aml_tiling_data *t,
struct aml_tiling_iterator *it)
int aml_tiling_1d_fini_iterator(__attribute__ ((unused))
struct aml_tiling_data *t,
__attribute__ ((unused))
struct aml_tiling_iterator *it)
{
return 0;
}
int aml_tiling_1d_destroy_iterator(struct aml_tiling_data *t,
int aml_tiling_1d_destroy_iterator(__attribute__ ((unused))
struct aml_tiling_data *t,
struct aml_tiling_iterator **it)
{
free(*it);
......@@ -197,7 +202,6 @@ int aml_tiling_1d_create(struct aml_tiling **t,
int aml_tiling_1d_init(struct aml_tiling *t,
size_t tilesize, size_t totalsize)
{
int err;
struct aml_tiling_1d_data *data;
if (t == NULL || t->data == NULL)
......@@ -212,7 +216,7 @@ int aml_tiling_1d_init(struct aml_tiling *t,
return 0;
}
void aml_tiling_1d_fini(struct aml_tiling *t)
void aml_tiling_1d_fini(__attribute__ ((unused)) struct aml_tiling *t)
{
/* nothing to do */
}
......
......@@ -92,7 +92,7 @@ size_t aml_tiling_2d_tilesize(const struct aml_tiling_data *t, int tileid)
const struct aml_tiling_2d_data *data =
(const struct aml_tiling_2d_data *)t;
if (tileid < 0 || tileid >= data->ndims[0]*data->ndims[1])
if (tileid < 0 || tileid >= (int) (data->ndims[0]*data->ndims[1]))
return 0;
else
return data->blocksize;
......@@ -105,7 +105,7 @@ void *aml_tiling_2d_tilestart(const struct aml_tiling_data *t,
(const struct aml_tiling_2d_data *)t;
intptr_t p = (intptr_t)ptr;
if (tileid < 0 || tileid >= data->ndims[0]*data->ndims[1])
if (tileid < 0 || tileid >= (int) (data->ndims[0]*data->ndims[1]))
return NULL;
else
return (void *)(p + tileid*data->blocksize);
......@@ -125,7 +125,8 @@ int aml_tiling_2d_ndims(const struct aml_tiling_data *t, va_list ap)
}
int aml_tiling_2d_init_iterator(struct aml_tiling_data *t,
struct aml_tiling_iterator *it, int flags)
struct aml_tiling_iterator *it,
__attribute__ ((unused)) int flags)
{
assert(it->data != NULL);
struct aml_tiling_iterator_2d_data *data =
......@@ -153,13 +154,16 @@ int aml_tiling_2d_create_iterator(struct aml_tiling_data *t,
return 0;
}
int aml_tiling_2d_fini_iterator(struct aml_tiling_data *t,
int aml_tiling_2d_fini_iterator(__attribute__ ((unused))
struct aml_tiling_data *t,
__attribute__ ((unused))
struct aml_tiling_iterator *it)
{
return 0;
}
int aml_tiling_2d_destroy_iterator(struct aml_tiling_data *t,
int aml_tiling_2d_destroy_iterator(__attribute__ ((unused))
struct aml_tiling_data *t,
struct aml_tiling_iterator **it)
{
free(*it);
......@@ -234,11 +238,11 @@ int aml_tiling_2d_create(struct aml_tiling **t, int type,
}
int aml_tiling_2d_init(struct aml_tiling *t, int type,
int aml_tiling_2d_init(struct aml_tiling *t,
__attribute__ ((unused)) int type,
size_t tilesize, size_t totalsize,
size_t rowsize, size_t colsize)
{
int err;
struct aml_tiling_2d_data *data;
if (t == NULL || t->data == NULL)
......@@ -255,7 +259,7 @@ int aml_tiling_2d_init(struct aml_tiling *t, int type,
return 0;
}
void aml_tiling_2d_fini(struct aml_tiling *t)
void aml_tiling_2d_fini(__attribute__ ((unused)) struct aml_tiling *t)
{
/* nothing to do */
}
......
This diff is collapsed.
......@@ -20,11 +20,11 @@ static const char * const aml_error_strings[] = {
[AML_ENOTSUP] = "Operation not supported",
};
const char *aml_strerror(const int errno)
const char *aml_strerror(const int err)
{
if (errno < 0 || errno < AML_ERROR_MAX)
if (err < 0 || err >= AML_ERROR_MAX)
return "Unknown error";
return aml_error_strings[errno];
return aml_error_strings[err];
}
void aml_perror(const char *msg)
......
......@@ -29,7 +29,7 @@ int aml_vector_resize(struct aml_vector *vec, size_t newsize)
vec->ptr = realloc(vec->ptr, newsize * vec->sz);
assert(vec->ptr != NULL);
for (int i = vec->nbelems; i < newsize; i++) {
for (unsigned int i = vec->nbelems; i < newsize; i++) {
int *k = AML_VECTOR_KEY_P(vec, i);
*k = vec->na;
}
......@@ -47,7 +47,7 @@ size_t aml_vector_size(const struct aml_vector *vec)
void *aml_vector_get(struct aml_vector *vec, int id)
{
assert(vec != NULL);
if (id != vec->na && id < vec->nbelems)
if (id != vec->na && id < (int) vec->nbelems)
return AML_VECTOR_ELT_P(vec, id);
else
return NULL;
......@@ -57,7 +57,7 @@ void *aml_vector_get(struct aml_vector *vec, int id)
int aml_vector_find(const struct aml_vector *vec, int key)
{
assert(vec != NULL);
for (int i = 0; i < vec->nbelems; i++) {
for (unsigned int i = 0; i < vec->nbelems; i++) {
int *k = AML_VECTOR_KEY_P(vec, i);
if (*k == key)
......@@ -135,7 +135,7 @@ int aml_vector_init(struct aml_vector *vec, size_t reserve, size_t size,
vec->na = na;
vec->nbelems = reserve;
vec->ptr = ptr;
for (int i = 0; i < vec->nbelems; i++) {
for (unsigned int i = 0; i < vec->nbelems; i++) {
int *k = AML_VECTOR_KEY_P(vec, i);
*k = na;
}
......
AM_COLOR_TESTS = yes
# add OpenMP to flags for test programs
AM_CFLAGS = -I$(top_srcdir)/include
AM_LDFLAGS = ../src/libaml.la
AM_CFLAGS=-I$(top_srcdir)/include
AM_LDFLAGS=../src/libaml.la
# valgrind support
if TEST_VALGRIND
......
......@@ -11,17 +11,17 @@
#include "aml/area/linux.h"
#include <assert.h>
void test_map(const struct aml_area *area){
void test_map(const struct aml_area *area)
{
assert(area != NULL);
assert(area->ops->mmap != NULL);
assert(area->ops->munmap != NULL);
void *ptr;
int err;
size_t s;
const size_t sizes[4] = {1, 32, 4096, 1<<20};
const size_t sizes[4] = { 1, 32, 4096, 1 << 20 };
for(s = 0; s<sizeof(sizes)/sizeof(*sizes); s++){
for (s = 0; s < sizeof(sizes) / sizeof(*sizes); s++) {
ptr = aml_area_mmap(area, &ptr, sizes[s]);
assert(ptr != NULL);
memset(ptr, 0, sizes[s]);
......@@ -29,11 +29,13 @@ void test_map(const struct aml_area *area){
}
}
void test_aml_area(struct aml_area *area){
void test_aml_area(struct aml_area *area)
{
test_map(area);
}
int main(int argc, char** argv){
int main(int argc, char **argv)
{
aml_init(&argc, &argv);
test_map(&aml_area_linux);
aml_finalize();
......
......@@ -12,49 +12,59 @@
#include <assert.h>
#include <string.h>
const size_t sizes[3] = {1, 1<<12, 1<<20};
const size_t sizes[3] = { 1, 1 << 12, 1 << 20 };
const int binding_flags[3] = {
AML_AREA_LINUX_BINDING_FLAG_BIND,
AML_AREA_LINUX_BINDING_FLAG_INTERLEAVE,
AML_AREA_LINUX_BINDING_FLAG_PREFERRED
};
const int mmap_flags[2] = {
AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
AML_AREA_LINUX_MMAP_FLAG_SHARED
};
void test_binding(struct aml_bitmap *bitmap){
void test_binding(struct aml_bitmap *bitmap)
{
void *ptr;
int err;
size_t s;
int bf, mf, i, nnodes, binding_flag, mmap_flag;
int binding_flag, mmap_flag;
struct aml_area *area;
for(bf=0; bf<sizeof(binding_flags)/sizeof(*binding_flags); bf++){
for (unsigned int bf = 0;
bf < sizeof(binding_flags) / sizeof(*binding_flags); bf++) {
binding_flag = binding_flags[bf];
for(mf=0; mf<sizeof(mmap_flags)/sizeof(*mmap_flags); mf++){
for (unsigned int mf = 0;
mf < sizeof(mmap_flags) / sizeof(*mmap_flags); mf++) {
mmap_flag = mmap_flags[mf];
for(s = 0; s<sizeof(sizes)/sizeof(*sizes); s++){
aml_area_linux_create(&area, mmap_flag, bitmap, binding_flag);
for (size_t s = 0;
s < sizeof(sizes) / sizeof(*sizes); s++) {
aml_area_linux_create(&area, mmap_flag, bitmap,
binding_flag);
assert(area != NULL);
ptr = area->ops->mmap((struct aml_area_data*)area->data,
NULL,
sizes[s]);
ptr = area->ops->mmap(
(struct aml_area_data *)area->data,
NULL, sizes[s]);
assert(ptr != NULL);
memset(ptr, 0, sizes[s]);
assert(aml_area_linux_check_binding((struct aml_area_linux_data*)area->data, ptr, sizes[s]) > 0);
assert(area->ops->munmap((struct aml_area_data*)area->data, ptr, sizes[s]) == AML_SUCCESS);
assert(aml_area_linux_check_binding(
(struct aml_area_linux_data *)area->data,
ptr, sizes[s]) > 0);
assert(area->ops->munmap(
(struct aml_area_data *)area->data,
ptr, sizes[s]) == AML_SUCCESS);
aml_area_linux_destroy(&area);
}
}
}
}
void test_bind(){
void test_bind(void)
{
struct bitmask *nodeset;
int i, num_nodes;
int i, num_nodes;
struct aml_bitmap bitmap;
struct aml_area *area;
......@@ -62,24 +72,25 @@ void test_bind(){
num_nodes = numa_bitmask_weight(nodeset);
aml_bitmap_fill(&bitmap);
if(aml_bitmap_last(&bitmap) > num_nodes){
assert(aml_area_linux_create(&area, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&bitmap,
AML_AREA_LINUX_BINDING_FLAG_PREFERRED) == -AML_EDOM);
if (aml_bitmap_last(&bitmap) > num_nodes) {
assert(aml_area_linux_create
(&area, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, &bitmap,
AML_AREA_LINUX_BINDING_FLAG_PREFERRED) == -AML_EDOM);
assert(area == NULL);
}
test_binding(NULL);
aml_bitmap_zero(&bitmap);
for(i = 0; i<num_nodes; i++){
for (i = 0; i < num_nodes; i++) {
aml_bitmap_set(&bitmap, i);
test_binding(&bitmap);
aml_bitmap_clear(&bitmap, i);
}
}
int main(int argc, char** argv){
int main(void)
{
test_bind();
return 0;
}
......@@ -21,41 +21,48 @@ int main(int argc, char *argv[])
{
AML_TILING_1D_DECL(tiling);
AML_DMA_LINUX_PAR_DECL(dma);
struct aml_bitmap nodemask;
struct aml_bitmap nodemask;
void *dst, *src;
/* library initialization */
aml_init(&argc, &argv);
/* initialize all the supporting struct */
assert(!aml_tiling_1d_init(&tiling, TILESIZE*_SC_PAGE_SIZE,
TILESIZE*_SC_PAGE_SIZE*NBTILES));
assert(!aml_tiling_1d_init(&tiling, TILESIZE * _SC_PAGE_SIZE,
TILESIZE * _SC_PAGE_SIZE * NBTILES));
aml_bitmap_zero(&nodemask);
aml_bitmap_set(&nodemask, 0);
size_t maxrequests = NBTILES;
size_t maxthreads = 4;
assert(!aml_dma_linux_par_init(&dma, maxrequests, maxthreads));
/* allocate some memory */
src = aml_area_mmap(&aml_area_linux, NULL, TILESIZE*_SC_PAGE_SIZE*NBTILES);
src =
aml_area_mmap(&aml_area_linux, NULL,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
assert(src != NULL);
dst = aml_area_mmap(&aml_area_linux, NULL, TILESIZE*_SC_PAGE_SIZE*NBTILES);
dst =
aml_area_mmap(&aml_area_linux, NULL,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
assert(dst != NULL);
memset(src, 42, TILESIZE*_SC_PAGE_SIZE*NBTILES);
memset(dst, 24, TILESIZE*_SC_PAGE_SIZE*NBTILES);
memset(src, 42, TILESIZE * _SC_PAGE_SIZE * NBTILES);
memset(dst, 24, TILESIZE * _SC_PAGE_SIZE * NBTILES);
/* move some stuff by copy */
for(int i = 0; i < NBTILES; i++)
for (int i = 0; i < NBTILES; i++)
aml_dma_copy(&dma, &tiling, dst, i, &tiling, src, i);
assert(!memcmp(src, dst, TILESIZE*_SC_PAGE_SIZE*NBTILES));
assert(!memcmp(src, dst, TILESIZE * _SC_PAGE_SIZE * NBTILES));
/* delete everything */
aml_dma_linux_par_fini(&dma);
aml_area_munmap(&aml_area_linux, dst, TILESIZE*_SC_PAGE_SIZE*NBTILES);
aml_area_munmap(&aml_area_linux, src, TILESIZE*_SC_PAGE_SIZE*NBTILES);
aml_area_munmap(&aml_area_linux, dst,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
aml_area_munmap(&aml_area_linux, src,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
aml_tiling_1d_fini(&tiling);
aml_finalize();
......
......@@ -28,33 +28,40 @@ int main(int argc, char *argv[])
aml_init(&argc, &argv);
/* initialize all the supporting struct */
assert(!aml_tiling_1d_init(&tiling, TILESIZE*_SC_PAGE_SIZE,
TILESIZE*_SC_PAGE_SIZE*NBTILES));
assert(!aml_tiling_1d_init(&tiling, TILESIZE * _SC_PAGE_SIZE,
TILESIZE * _SC_PAGE_SIZE * NBTILES));
aml_bitmap_zero(&nodemask);
aml_bitmap_set(&nodemask, 0);
size_t maxrequests = NBTILES;
assert(!aml_dma_linux_seq_init(&dma, maxrequests));
/* allocate some memory */
src = aml_area_mmap(&aml_area_linux, NULL, TILESIZE*_SC_PAGE_SIZE*NBTILES);
src =
aml_area_mmap(&aml_area_linux, NULL,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
assert(src != NULL);
dst = aml_area_mmap(&aml_area_linux, NULL, TILESIZE*_SC_PAGE_SIZE*NBTILES);
dst =
aml_area_mmap(&aml_area_linux, NULL,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
assert(dst != NULL);
memset(src, 42, TILESIZE*_SC_PAGE_SIZE*NBTILES);
memset(dst, 24, TILESIZE*_SC_PAGE_SIZE*NBTILES);
memset(src, 42, TILESIZE * _SC_PAGE_SIZE * NBTILES);
memset(dst, 24, TILESIZE * _SC_PAGE_SIZE * NBTILES);
/* move some stuff by copy */
for(int i = 0; i < NBTILES; i++)
for (int i = 0; i < NBTILES; i++)
aml_dma_copy(&dma, &tiling, dst, i, &tiling, src, i);
assert(!memcmp(src, dst, TILESIZE*_SC_PAGE_SIZE*NBTILES));
assert(!memcmp(src, dst, TILESIZE * _SC_PAGE_SIZE * NBTILES));
/* delete everything */
aml_dma_linux_seq_fini(&dma);
aml_area_munmap(&aml_area_linux, dst, TILESIZE*_SC_PAGE_SIZE*NBTILES);
aml_area_munmap(&aml_area_linux, src, TILESIZE*_SC_PAGE_SIZE*NBTILES);
aml_area_munmap(&aml_area_linux, dst,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
aml_area_munmap(&aml_area_linux, src,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
aml_tiling_1d_fini(&tiling);
aml_finalize();
......
......@@ -30,51 +30,57 @@ int main(int argc, char *argv[])
aml_init(&argc, &argv);
/* initialize all the supporting struct */
assert(!aml_tiling_1d_init(&tiling, TILESIZE*_SC_PAGE_SIZE,
TILESIZE*_SC_PAGE_SIZE*NBTILES));
assert(!aml_tiling_1d_init(&tiling, TILESIZE * _SC_PAGE_SIZE,
TILESIZE * _SC_PAGE_SIZE * NBTILES));
aml_bitmap_zero(&nodemask);
aml_bitmap_set(&nodemask, 0);
size_t maxrequests = NBTILES;
assert(!aml_dma_linux_seq_init(&dma, maxrequests));
/* allocate some memory */
src = aml_area_mmap(&aml_area_linux, NULL, TILESIZE*_SC_PAGE_SIZE*NBTILES);
src =
aml_area_mmap(&aml_area_linux, NULL,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
assert(src != NULL);
memset(src, 42, TILESIZE*_SC_PAGE_SIZE*NBTILES);
memset(src, 42, TILESIZE * _SC_PAGE_SIZE * NBTILES);
/* create scratchpad */
assert(!aml_scratch_par_init(&scratch, &aml_area_linux, &aml_area_linux, &dma, &tiling,
(size_t)NBTILES, (size_t)NBTILES));
assert(!aml_scratch_par_init
(&scratch, &aml_area_linux, &aml_area_linux, &dma, &tiling,
(size_t) NBTILES, (size_t) NBTILES));
dst = aml_scratch_baseptr(&scratch);
/* move some stuff */
for(int i = 0; i < NBTILES; i++)
{
for (int i = 0; i < NBTILES; i++) {
int di, si;
void *dp, *sp;
aml_scratch_pull(&scratch, dst, &di, src, i);
dp = aml_tiling_tilestart(&tiling, dst, di);
sp = aml_tiling_tilestart(&tiling, src, i);
assert(!memcmp(sp, dp, TILESIZE*_SC_PAGE_SIZE));
assert(!memcmp(sp, dp, TILESIZE * _SC_PAGE_SIZE));
memset(dp, 33, TILESIZE * _SC_PAGE_SIZE);
memset(dp, 33, TILESIZE*_SC_PAGE_SIZE);
aml_scratch_push(&scratch, src, &si, dst, di);
assert(si == i);
sp = aml_tiling_tilestart(&tiling, src, si);
assert(!memcmp(sp, dp, TILESIZE*_SC_PAGE_SIZE));
assert(!memcmp(sp, dp, TILESIZE * _SC_PAGE_SIZE));
}
/* delete everything */
aml_scratch_par_fini(&scratch);
aml_dma_linux_seq_fini(&dma);
aml_area_munmap(&aml_area_linux, dst, TILESIZE*_SC_PAGE_SIZE*NBTILES);
aml_area_munmap(&aml_area_linux, src, TILESIZE*_SC_PAGE_SIZE*NBTILES);
aml_area_munmap(&aml_area_linux, dst,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
aml_area_munmap(&aml_area_linux, src,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
aml_tiling_1d_fini(&tiling);
aml_finalize();
......
......@@ -30,52 +30,58 @@ int main(int argc, char *argv[])
aml_init(&argc, &argv);
/* initialize all the supporting struct */
assert(!aml_tiling_1d_init(&tiling, TILESIZE*_SC_PAGE_SIZE,
TILESIZE*_SC_PAGE_SIZE*NBTILES));
assert(!aml_tiling_1d_init(&tiling, TILESIZE * _SC_PAGE_SIZE,
TILESIZE * _SC_PAGE_SIZE * NBTILES));
aml_bitmap_zero(&nodemask);
aml_bitmap_set(&nodemask, 0);
size_t maxrequests = NBTILES;
size_t maxthreads = 4;
assert(!aml_dma_linux_par_init(&dma, maxrequests, maxthreads));
/* allocate some memory */
src = aml_area_mmap(&aml_area_linux, NULL, TILESIZE*_SC_PAGE_SIZE*NBTILES);
src =
aml_area_mmap(&aml_area_linux, NULL,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
assert(src != NULL);
memset(src, 42, TILESIZE*_SC_PAGE_SIZE*NBTILES);
memset(src, 42, TILESIZE * _SC_PAGE_SIZE * NBTILES);
/* create scratchpad */
assert(!aml_scratch_seq_init(&scratch, &aml_area_linux, &aml_area_linux, &dma, &tiling,
(size_t)NBTILES, (size_t)NBTILES));
assert(!aml_scratch_seq_init
(&scratch, &aml_area_linux, &aml_area_linux, &dma, &tiling,
(size_t) NBTILES, (size_t) NBTILES));
dst = aml_scratch_baseptr(&scratch);
/* move some stuff */
for(int i = 0; i < NBTILES; i++)
{
for (int i = 0; i < NBTILES; i++) {
int di, si;
void *dp, *sp;
aml_scratch_pull(&scratch, dst, &di, src, i);
dp = aml_tiling_tilestart(&tiling, dst, di);
sp = aml_tiling_tilestart(&tiling, src, i);
assert(!memcmp(sp, dp, TILESIZE*_SC_PAGE_SIZE));
assert(!memcmp(sp, dp, TILESIZE * _SC_PAGE_SIZE));
memset(dp, 33, TILESIZE * _SC_PAGE_SIZE);
memset(dp, 33, TILESIZE*_SC_PAGE_SIZE);
aml_scratch_push(&scratch, src, &si, dst, di);
assert(si == i);
sp = aml_tiling_tilestart(&tiling, src, si);
assert(!memcmp(sp, dp, TILESIZE*_SC_PAGE_SIZE));
assert(!memcmp(sp, dp, TILESIZE * _SC_PAGE_SIZE));
}
/* delete everything */
aml_scratch_seq_fini(&scratch);
aml_dma_linux_par_fini(&dma);
aml_area_munmap(&aml_area_linux, dst, TILESIZE*_SC_PAGE_SIZE*NBTILES);
aml_area_munmap(&aml_area_linux, src, TILESIZE*_SC_PAGE_SIZE*NBTILES);
aml_area_munmap(&aml_area_linux, dst,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
aml_area_munmap(&aml_area_linux, src,
TILESIZE * _SC_PAGE_SIZE * NBTILES);
aml_tiling_1d_fini(&tiling);
aml_finalize();
......
......@@ -16,44 +16,44 @@
#define TILESIZE 8192
#define NBTILES 4
int doit(struct aml_tiling *t, struct aml_tiling_iterator *it)
void doit(struct aml_tiling *t, struct aml_tiling_iterator *it)
{
size_t tilesize;
unsigned long i;
intptr_t ptr;
tilesize = aml_tiling_tilesize(t, 0);
assert(tilesize == TILESIZE);
/* actualy use the iterators */
for(aml_tiling_iterator_reset(it);
!aml_tiling_iterator_end(it);
aml_tiling_iterator_next(it))
{
for (aml_tiling_iterator_reset(it);
!aml_tiling_iterator_end(it); aml_tiling_iterator_next(it)) {
aml_tiling_iterator_get(it, &i);
}
assert(i == NBTILES -1);
assert(i == NBTILES - 1);
for(i = 0; i < NBTILES; i++)
{
for (i = 0; i < NBTILES; i++) {
ptr = (intptr_t) aml_tiling_tilestart(t, NULL, i);
assert(ptr == i*TILESIZE);
assert((intptr_t) ptr == (intptr_t) (i * TILESIZE));
}
}
int main(int argc, char *argv[])
{
struct aml_tiling *a;
AML_TILING_1D_DECL(b);
struct aml_tiling_iterator *ita;
AML_TILING_ITERATOR_1D_DECL(itb);
/* library initialization */
aml_init(&argc, &argv);
/* initialize the tilings */
aml_tiling_1d_create(&a, TILESIZE, TILESIZE*NBTILES);
aml_tiling_1d_init(&b, TILESIZE, TILESIZE*NBTILES);
aml_tiling_1d_create(&a, TILESIZE, TILESIZE * NBTILES);
aml_tiling_1d_init(&b, TILESIZE, TILESIZE * NBTILES);
/* initialize the iterators */
aml_tiling_create_iterator(a, &ita, 0);
......@@ -66,7 +66,6 @@ int main(int argc, char *argv[])
aml_tiling_destroy_iterator(a, &ita);
aml_tiling_fini_iterator(&b, &itb);
/* delete the tilings */
aml_tiling_1d_destroy(&a);
aml_tiling_1d_fini(&b);
......
......@@ -40,7 +40,7 @@ int main(int argc, char *argv[])
* +---+---+
* Matrices in memory:
*
* rowm/colm rowt/colt
* rowm/colm rowt/colt
* +---+---+---+---+---+ +---+---+---+---+---+---+
* | 0 | 1 | 2 | 4 | 5 | | 0 | 3 | 1 | 4 | 2 | 5 |
* +---+---+---+---+---+ +---+---+---+---+---+---+
......@@ -55,25 +55,26 @@ int main(int argc, char *argv[])
aml_init(&argc, &argv);
/* init matrices */
for(int i = 0; i < N*M; i++)
((int*)rowm)[i] = i;
for(int i = 0; i < M; i++)
for(int j = 0; j < N; j++)
for (int i = 0; i < N * M; i++)
((int *)rowm)[i] = i;
for (int i = 0; i < M; i++)
for (int j = 0; j < N; j++)
rowt[i][j] = rowm[j][i];
memcpy(colm, rowm, N*M*sizeof(int));
memcpy(colt, rowt, N*M*sizeof(int));
memcpy(colm, rowm, N * M * sizeof(int));
memcpy(colt, rowt, N * M * sizeof(int));
/* initialize the tilings */
aml_tiling_2d_init(&trm, AML_TILING_TYPE_2D_ROWMAJOR,
sizeof(int), N*M*sizeof(int), N, M);
sizeof(int), N * M * sizeof(int), N, M);
aml_tiling_2d_init(&trt, AML_TILING_TYPE_2D_ROWMAJOR,
sizeof(int), N*M*sizeof(int), M, N);
sizeof(int), N * M * sizeof(int), M, N);
aml_tiling_2d_init(&tcm, AML_TILING_TYPE_2D_COLMAJOR,
sizeof(int), N*M*sizeof(int), M, N);
sizeof(int), N * M * sizeof(int), M, N);
aml_tiling_2d_init(&tct, AML_TILING_TYPE_2D_COLMAJOR,
sizeof(int), N*M*sizeof(int), N, M);
sizeof(int), N * M * sizeof(int), N, M);
size_t ndims[2];
aml_tiling_ndims(&trm, &ndims[0], &ndims[1]);
assert(ndims[0] == N && ndims[1] == M);
aml_tiling_ndims(&tcm, &ndims[0], &ndims[1]);
......@@ -81,53 +82,52 @@ int main(int argc, char *argv[])
/* check that the tilings gives me the right ids */
num = 0;
for(int i = 0; i < N; i++)
for(int j = 0; j < M; j++)
{
for (int i = 0; i < N; i++)
for (int j = 0; j < M; j++) {
int irow = aml_tiling_tileid(&trm, i, j);
int icol = aml_tiling_tileid(&tcm, j, i);
assert(irow == icol && irow == num);
num++;
}
/* check that the tiling gives the right starts */
num = 0;
for(int i = 0; i < N; i++)
for(int j = 0; j < M; j++)
{
for (int i = 0; i < N; i++)
for (int j = 0; j < M; j++) {
int irow = aml_tiling_tileid(&trm, i, j);
int icol = aml_tiling_tileid(&tcm, j, i);
int *rm = aml_tiling_tilestart(&trm, &rowm, irow);
int *cm = aml_tiling_tilestart(&tcm, &colm, icol);
assert(*rm == num && *cm == num);
num++;
}
/* check that applying a column-major tiling on a row-major matrix gives
* us its transposition. */
for(int i = 0; i < N; i++)
for(int j = 0; j < M; j++)
{
for (int i = 0; i < N; i++)
for (int j = 0; j < M; j++) {
int icm = aml_tiling_tileid(&tcm, j, i);
int *cm = aml_tiling_tilestart(&tcm, &rowm, icm);
int irt = aml_tiling_tileid(&trt, j, i);
int *rt = aml_tiling_tilestart(&trt, &rowt, irt);
assert(*cm == *rt);
}
/* check that applying a row-major tiling on a col-major matrix gives
* us its transposition. */
for(int i = 0; i < M; i++)
for(int j = 0; j < N; j++)
{
for (int i = 0; i < M; i++)
for (int j = 0; j < N; j++) {
int irm = aml_tiling_tileid(&trm, j, i);
int *rm = aml_tiling_tilestart(&trm, &colm, irm);
int ict = aml_tiling_tileid(&tct, j, i);
int *ct = aml_tiling_tilestart(&tct, &rowt, ict);
assert(*rm == *ct);
}
/* delete the tilings */
aml_tiling_2d_fini(&trm);
aml_tiling_2d_fini(&trt);
......
......@@ -15,7 +15,7 @@ static const unsigned long is[8] = {
0,
AML_BITMAP_NBITS / 4,
3 * AML_BITMAP_NBITS / 4,
AML_BITMAP_NBITS - 1,
AML_BITMAP_NBITS - 1,
AML_BITMAP_NBITS,
AML_BITMAP_NBITS + AML_BITMAP_NBITS / 4,
AML_BITMAP_NBITS + 3 * AML_BITMAP_NBITS / 4,
......@@ -24,77 +24,80 @@ static const unsigned long is[8] = {
static const int nis = sizeof(is) / sizeof(*is);
void test_bitmap_fill(){
unsigned long i;
void test_bitmap_fill(void)
{
struct aml_bitmap b;
aml_bitmap_fill(&b);
for(i = 0; i < nis; i++)
for (int i = 0; i < nis; i++)
assert(aml_bitmap_isset(&b, is[i]));
assert(aml_bitmap_nset(&b) == AML_BITMAP_MAX);
}
void test_bitmap_zero(){
unsigned long i;
void test_bitmap_zero(void)
{
struct aml_bitmap b;
aml_bitmap_zero(&b);
for(i = 0; i < nis; i++)
for (int i = 0; i < nis; i++)
assert(!aml_bitmap_isset(&b, is[i]));
assert(aml_bitmap_nset(&b) == 0);
}
void test_bitmap_set(){
unsigned long i,j;
void test_bitmap_set(void)
{
struct aml_bitmap b;
aml_bitmap_zero(&b);
for(i = 0; i < nis; i++){
for (int i = 0; i < nis; i++) {
aml_bitmap_set(&b, is[i]);
assert(aml_bitmap_isset(&b, is[i]));
for(j = 0; j < is[i]; j++)
for (unsigned int j = 0; j < is[i]; j++)
assert(!aml_bitmap_isset(&b, j));
for(j = is[i]+1; j < AML_BITMAP_MAX; j++)
for (unsigned int j = is[i] + 1; j < AML_BITMAP_MAX; j++)
assert(!aml_bitmap_isset(&b, j));
assert(aml_bitmap_nset(&b) == 1);
aml_bitmap_clear(&b, is[i]);
assert(!aml_bitmap_isset(&b, is[i]));
}
}
void test_bitmap_string_conversion(const char * bitmap_str){
void test_bitmap_string_conversion(const char *bitmap_str)
{
struct aml_bitmap b, c;
char * cstr;
char *cstr;
assert(aml_bitmap_from_string(&b, bitmap_str) == 0);
if(bitmap_str == NULL ||
!strcasecmp(bitmap_str, "none") ||
!strcasecmp(bitmap_str, "zero") ||
!strcasecmp(bitmap_str, "empty")){
if (bitmap_str == NULL ||
!strcasecmp(bitmap_str, "none") ||
!strcasecmp(bitmap_str, "zero") ||
!strcasecmp(bitmap_str, "empty")) {
assert(aml_bitmap_iszero(&b));
}
else if(!strcasecmp(bitmap_str, "all") ||
!strcasecmp(bitmap_str, "full") ||
!strcasecmp(bitmap_str, "fill")){
} else if (!strcasecmp(bitmap_str, "all") ||
!strcasecmp(bitmap_str, "full") ||
!strcasecmp(bitmap_str, "fill")) {
assert(aml_bitmap_isfull(&b));
}
cstr = aml_bitmap_to_string(&b);
assert(cstr != NULL);
assert(aml_bitmap_from_string(&c, cstr) == 0);
assert(aml_bitmap_isequal(&b,&c));
assert(aml_bitmap_isequal(&b, &c));
free(cstr);
}
void test_bitmap_string(){
void test_bitmap_string(void)
{
const size_t int_len = 16;
char *bstr, *next;
char *bstr;
int i;
const size_t max_len = int_len * (1+nis);
const size_t max_len = int_len * (1 + nis);
size_t len = 0;
struct aml_bitmap b;
assert(aml_bitmap_from_string(&b, "unapropriate string") == -1);
test_bitmap_string_conversion("all");
......@@ -104,95 +107,100 @@ void test_bitmap_string(){
test_bitmap_string_conversion("empty");
test_bitmap_string_conversion("none");
test_bitmap_string_conversion(NULL);
bstr = malloc(int_len);
for(i = 0; i<nis; i++){
memset(bstr, 0 , int_len);
for (i = 0; i < nis; i++) {
memset(bstr, 0, int_len);
snprintf(bstr, int_len, "%lu", is[i]);
test_bitmap_string_conversion(bstr);
assert(aml_bitmap_from_string(&b, bstr) == 0);
assert(aml_bitmap_isset(&b, is[i]));
}
free(bstr);
bstr = malloc(max_len);
next = bstr;
memset(bstr, 0 , max_len);
for(i = 0; i<nis; i++){
len += snprintf(bstr+len, max_len-len, "%lu", is[i]);
if(i+1 < nis){
memset(bstr, 0, max_len);
for (i = 0; i < nis; i++) {
len += snprintf(bstr + len, max_len - len, "%lu", is[i]);
if (i + 1 < nis) {
bstr[len] = ',';
len++;
}
}
test_bitmap_string_conversion(bstr);
assert(aml_bitmap_from_string(&b, bstr) == 0);
for(i = 0; i<nis; i++)
for (i = 0; i < nis; i++)
assert(aml_bitmap_isset(&b, is[i]));
free(bstr);
}
void test_bitmap_clear(){
unsigned long i,j;
void test_bitmap_clear(void)
{
struct aml_bitmap b;
aml_bitmap_fill(&b);
for(i = 0; i < nis; i++){
for (int i = 0; i < nis; i++) {
aml_bitmap_clear(&b, is[i]);
assert(!aml_bitmap_isset(&b, is[i]));
for(j = 0; j < is[i]; j++)
for (unsigned int j = 0; j < is[i]; j++)
assert(aml_bitmap_isset(&b, j));
for(j = is[i]+1; j < AML_BITMAP_MAX; j++)
for (unsigned int j = is[i] + 1; j < AML_BITMAP_MAX; j++)
assert(aml_bitmap_isset(&b, j));
assert(aml_bitmap_nset(&b) == (AML_BITMAP_MAX-1));
assert(aml_bitmap_nset(&b) == (AML_BITMAP_MAX - 1));
aml_bitmap_set(&b, is[i]);
assert(aml_bitmap_isset(&b, is[i]));
}
}
void test_bitmap_set_range(){
unsigned long i, ii, j;
void test_bitmap_set_range(void)
{
struct aml_bitmap b;
aml_bitmap_zero(&b);
for(i = 0; i < nis; i++){
for(ii = i; ii < nis; ii++){
for (int i = 0; i < nis; i++) {
for (int ii = i; ii < nis; ii++) {
assert(aml_bitmap_set_range(&b, is[i], is[ii]) == 0);
assert(aml_bitmap_nset(&b) == (1 + is[ii] - is[i]));
for(j = 0; j < is[i]; j++)
for (unsigned int j = 0; j < is[i]; j++)
assert(!aml_bitmap_isset(&b, j));
for(j = is[i]; j <= is[ii]; j++)
for (unsigned int j = is[i]; j <= is[ii]; j++)
assert(aml_bitmap_isset(&b, j));
for(j = is[ii]+1; j < AML_BITMAP_MAX; j++)
for (unsigned int j = is[ii] + 1; j < AML_BITMAP_MAX;
j++)
assert(!aml_bitmap_isset(&b, j));
aml_bitmap_zero(&b);
}
}
}
void test_bitmap_clear_range(){
unsigned long i, ii, j;
void test_bitmap_clear_range(void)
{
struct aml_bitmap b;
aml_bitmap_fill(&b);
for(i = 0; i < nis; i++){
for(ii = i; ii < nis; ii++){
for (int i = 0; i < nis; i++) {
for (int ii = i; ii < nis; ii++) {
assert(aml_bitmap_clear_range(&b, is[i], is[ii]) == 0);
assert(aml_bitmap_nset(&b) == (AML_BITMAP_MAX - is[ii] + is[i] - 1));
for(j = 0; j < is[i]; j++)
assert(aml_bitmap_nset(&b) ==
(AML_BITMAP_MAX - is[ii] + is[i] - 1));
for (unsigned int j = 0; j < is[i]; j++)
assert(aml_bitmap_isset(&b, j));
for(j = is[i]; j <= is[ii]; j++)
for (unsigned int j = is[i]; j <= is[ii]; j++)
assert(!aml_bitmap_isset(&b, j));
for(j = is[ii]+1; j < AML_BITMAP_MAX; j++)
for (unsigned int j = is[ii] + 1; j < AML_BITMAP_MAX;
j++)
assert(aml_bitmap_isset(&b, j));
aml_bitmap_fill(&b);
}
}
}
int main(){
int main(void)
{
test_bitmap_fill();
test_bitmap_zero();
test_bitmap_set();
......@@ -202,4 +210,3 @@ int main(){
test_bitmap_string();
return 0;
}
......@@ -11,7 +11,7 @@
#include "aml.h"
#include <assert.h>
int main(int argc, char *argv[])
int main(void)
{
struct aml_vector v;
......@@ -31,6 +31,7 @@ int main(int argc, char *argv[])
/* add an element and look for some */
struct test *e = aml_vector_get(&v, 0);
assert(e != NULL);
e->unused = 42;
e->key = 24;
......@@ -39,6 +40,7 @@ int main(int argc, char *argv[])
/* add a second element, trigger a resize, and check it */
struct test *f = aml_vector_add(&v);
assert(f != NULL && f->key == -1);
assert(aml_vector_find(&v, 42) == -1);
assert(aml_vector_find(&v, -1) == 1);
......
......@@ -11,7 +11,7 @@
#include "aml.h"
#include <assert.h>
int main(int argc, char *argv[])
int main(void)
{
assert(aml_version_major == AML_VERSION_MAJOR);
assert(aml_version_minor == AML_VERSION_MINOR);
......@@ -19,4 +19,3 @@ int main(int argc, char *argv[])
assert(!strcmp(aml_version_string, AML_VERSION_STRING));
return 0;
}