summaryrefslogtreecommitdiff
path: root/orc-test
diff options
context:
space:
mode:
Diffstat (limited to 'orc-test')
-rw-r--r--orc-test/orcarray.c17
-rw-r--r--orc-test/orcarray.h2
-rw-r--r--orc-test/orctest.c26
3 files changed, 34 insertions, 11 deletions
diff --git a/orc-test/orcarray.c b/orc-test/orcarray.c
index 4c21be2..552575a 100644
--- a/orc-test/orcarray.c
+++ b/orc-test/orcarray.c
@@ -18,10 +18,15 @@
#define isnan(x) _isnan(x)
#endif
+#define ALIGNMENT 64
+#define MISALIGNMENT 0
+
OrcArray *
-orc_array_new (int n, int m, int element_size)
+orc_array_new (int n, int m, int element_size, int misalignment)
{
OrcArray *ar;
+ void *data;
+ int ret;
ar = malloc (sizeof(OrcArray));
memset (ar, 0, sizeof(OrcArray));
@@ -31,10 +36,14 @@ orc_array_new (int n, int m, int element_size)
ar->element_size = element_size;
ar->stride = (n*element_size + EXTEND_STRIDE);
- ar->alloc_len = ar->stride * (m+2*EXTEND_ROWS);
- ar->alloc_data = malloc (ar->alloc_len);
+ ar->stride = (ar->stride + (ALIGNMENT-1)) & (~(ALIGNMENT-1));
+ ar->alloc_len = ar->stride * (m+2*EXTEND_ROWS) + (ALIGNMENT * element_size);
+
+ ret = posix_memalign (&data, ALIGNMENT, ar->alloc_len);
+ ar->alloc_data = data;
- ar->data = ORC_PTR_OFFSET (ar->alloc_data, ar->stride * EXTEND_ROWS);
+ ar->data = ORC_PTR_OFFSET (ar->alloc_data,
+ ar->stride * EXTEND_ROWS + element_size * misalignment);
return ar;
}
diff --git a/orc-test/orcarray.h b/orc-test/orcarray.h
index 6b26141..60d3d23 100644
--- a/orc-test/orcarray.h
+++ b/orc-test/orcarray.h
@@ -20,7 +20,7 @@ struct _OrcArray {
int alloc_len;
};
-OrcArray *orc_array_new (int n, int m, int element_size);
+OrcArray *orc_array_new (int n, int m, int element_size, int misalignment);
void orc_array_free (OrcArray *array);
void orc_array_set_pattern (OrcArray *array, int value);
diff --git a/orc-test/orctest.c b/orc-test/orctest.c
index 85e715f..bcf2b36 100644
--- a/orc-test/orctest.c
+++ b/orc-test/orctest.c
@@ -508,6 +508,7 @@ orc_test_compare_output_full (OrcProgram *program, int flags)
int acc_exec = 0, acc_emul = 0;
int ret = ORC_TEST_OK;
int bad = 0;
+ int misalignment;
ORC_DEBUG ("got here");
@@ -547,17 +548,23 @@ orc_test_compare_output_full (OrcProgram *program, int flags)
orc_executor_set_m (ex, m);
ORC_DEBUG("size %d %d", ex->n, ex->params[ORC_VAR_A1]);
+ misalignment = 0;
for(i=0;i<ORC_N_VARIABLES;i++){
if (program->vars[i].name == NULL) continue;
if (program->vars[i].vartype == ORC_VAR_TYPE_SRC) {
- src[i-ORC_VAR_S1] = orc_array_new (n, m, program->vars[i].size);
+ src[i-ORC_VAR_S1] = orc_array_new (n, m, program->vars[i].size,
+ misalignment);
orc_array_set_random (src[i-ORC_VAR_S1], &rand_context);
+ misalignment++;
} else if (program->vars[i].vartype == ORC_VAR_TYPE_DEST) {
- dest_exec[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size);
+ dest_exec[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size,
+ misalignment);
orc_array_set_pattern (dest_exec[i], ORC_OOB_VALUE);
- dest_emul[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size);
+ dest_emul[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size,
+ misalignment);
orc_array_set_pattern (dest_emul[i], ORC_OOB_VALUE);
+ misalignment++;
} else if (program->vars[i].vartype == ORC_VAR_TYPE_PARAM) {
orc_executor_set_param (ex, i, 2);
}
@@ -826,6 +833,7 @@ orc_test_performance_full (OrcProgram *program, int flags,
OrcProfile prof;
double ave, std;
OrcTarget *target;
+ int misalignment;
ORC_DEBUG ("got here");
@@ -864,17 +872,23 @@ orc_test_performance_full (OrcProgram *program, int flags,
orc_executor_set_m (ex, m);
ORC_DEBUG("size %d %d", ex->n, ex->params[ORC_VAR_A1]);
+ misalignment = 0;
for(i=0;i<ORC_N_VARIABLES;i++){
if (program->vars[i].name == NULL) continue;
if (program->vars[i].vartype == ORC_VAR_TYPE_SRC) {
- src[i-ORC_VAR_S1] = orc_array_new (n, m, program->vars[i].size);
+ src[i-ORC_VAR_S1] = orc_array_new (n, m, program->vars[i].size,
+ misalignment);
orc_array_set_random (src[i-ORC_VAR_S1], &rand_context);
+ misalignment++;
} else if (program->vars[i].vartype == ORC_VAR_TYPE_DEST) {
- dest_exec[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size);
+ dest_exec[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size,
+ misalignment);
orc_array_set_pattern (dest_exec[i], ORC_OOB_VALUE);
- dest_emul[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size);
+ dest_emul[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size,
+ misalignment);
orc_array_set_pattern (dest_emul[i], ORC_OOB_VALUE);
+ misalignment++;
} else if (program->vars[i].vartype == ORC_VAR_TYPE_PARAM) {
orc_executor_set_param (ex, i, 2);
}