test_tiling.c 1.49 KB
Newer Older
Swann Perarnau's avatar
Swann Perarnau committed
1 2 3 4 5 6 7 8 9 10
/*******************************************************************************
 * 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
*******************************************************************************/

11
#include "aml.h"
12 13
#include "aml/tiling/1d.h"
#include "aml/tiling/2d.h"
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#include <assert.h>

#define TILESIZE 8192
#define NBTILES 4

int 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))
	{
		aml_tiling_iterator_get(it, &i);
	}
	assert(i == NBTILES -1);

	for(i = 0; i < NBTILES; i++)
	{
		ptr = (intptr_t) aml_tiling_tilestart(t, NULL, i);
Swann Perarnau's avatar
Swann Perarnau committed
39
		assert(ptr == (intptr_t)i*TILESIZE);
40
	}
Swann Perarnau's avatar
Swann Perarnau committed
41
	return 0;
42 43 44 45 46
}

int main(int argc, char *argv[])
{
	struct aml_tiling *a;
47
	struct aml_tiling_iterator *it;
48 49 50 51 52

	/* library initialization */
	aml_init(&argc, &argv);

	/* initialize the tilings */
53
	aml_tiling_1d_create(&a, TILESIZE, TILESIZE*NBTILES);
54 55

	/* initialize the iterators */
56
	aml_tiling_create_iterator(a, &it, 0);
57

58
	doit(a, it);
59 60

	/* delete the iterators */
61
	aml_tiling_destroy_iterator(a, &it);
62 63

	/* delete the tilings */
64
	aml_tiling_1d_destroy(&a);
65 66 67 68

	aml_finalize();
	return 0;
}