#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));
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;
}
int acc_exec = 0, acc_emul = 0;
int ret = ORC_TEST_OK;
int bad = 0;
+ int misalignment;
ORC_DEBUG ("got here");
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);
}
OrcProfile prof;
double ave, std;
OrcTarget *target;
+ int misalignment;
ORC_DEBUG ("got here");
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);
}