|
@@ -19,20 +19,20 @@
|
|
|
#endif
|
|
|
#include "multiformat_types.h"
|
|
|
|
|
|
-static struct struct_of_arrays global_struct_of_arrays;
|
|
|
-static starpu_data_handle global_struct_of_arrays_handle;
|
|
|
+static struct point array_of_structs[N_ELEMENTS];
|
|
|
+static starpu_data_handle array_of_structs_handle;
|
|
|
|
|
|
static void
|
|
|
multiformat_scal_cpu_func(void *buffers[], void *args)
|
|
|
{
|
|
|
- struct struct_of_arrays *s;
|
|
|
+ struct point *aos;
|
|
|
unsigned int n, i;
|
|
|
|
|
|
- s = STARPU_MULTIFORMAT_GET_PTR(buffers[0]);
|
|
|
+ aos = STARPU_MULTIFORMAT_GET_PTR(buffers[0]);
|
|
|
n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
- s->x[i] *= s->y[i];
|
|
|
+ aos[i].x *= aos[i].y;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -48,16 +48,16 @@ extern starpu_codelet opencl_to_cpu_cl;
|
|
|
|
|
|
static struct starpu_multiformat_data_interface_ops format_ops = {
|
|
|
#ifdef STARPU_USE_CUDA
|
|
|
- .cuda_elemsize = sizeof(struct point),
|
|
|
+ .cuda_elemsize = 2* sizeof(float),
|
|
|
.cpu_to_cuda_cl = &cpu_to_cuda_cl,
|
|
|
.cuda_to_cpu_cl = &cuda_to_cpu_cl,
|
|
|
#endif
|
|
|
#ifdef STARPU_USE_OPENCL
|
|
|
- .opencl_elemsize = sizeof(struct point),
|
|
|
+ .opencl_elemsize = 2 * sizeof(float),
|
|
|
.cpu_to_opencl_cl = &cpu_to_opencl_cl,
|
|
|
.opencl_to_cpu_cl = &opencl_to_cpu_cl,
|
|
|
#endif
|
|
|
- .cpu_elemsize = sizeof(global_struct_of_arrays),
|
|
|
+ .cpu_elemsize = sizeof(struct point),
|
|
|
|
|
|
};
|
|
|
|
|
@@ -74,7 +74,7 @@ static struct starpu_perfmodel_t conversion_model = {
|
|
|
};
|
|
|
|
|
|
static starpu_codelet cl = {
|
|
|
- .where = STARPU_CUDA | STARPU_OPENCL,
|
|
|
+ .where = STARPU_CPU | STARPU_CUDA | STARPU_OPENCL,
|
|
|
.cpu_func = multiformat_scal_cpu_func,
|
|
|
#ifdef STARPU_USE_CUDA
|
|
|
.cuda_func = multiformat_scal_cuda_func,
|
|
@@ -94,17 +94,17 @@ init_problem_data(void)
|
|
|
{
|
|
|
int i;
|
|
|
for (i = 0; i < N_ELEMENTS; i++) {
|
|
|
- global_struct_of_arrays.x[i] = 1.0f + i;
|
|
|
- global_struct_of_arrays.y[i] = 42.0;
|
|
|
+ array_of_structs[i].x = 1.0 + i;
|
|
|
+ array_of_structs[i].y = 42.0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static void
|
|
|
register_data(void)
|
|
|
{
|
|
|
- starpu_multiformat_data_register(&global_struct_of_arrays_handle,
|
|
|
+ starpu_multiformat_data_register(&array_of_structs_handle,
|
|
|
0,
|
|
|
- &global_struct_of_arrays,
|
|
|
+ &array_of_structs,
|
|
|
N_ELEMENTS,
|
|
|
&format_ops);
|
|
|
}
|
|
@@ -116,7 +116,7 @@ create_and_submit_tasks(void)
|
|
|
|
|
|
task->cl = &cl;
|
|
|
task->synchronous = 1;
|
|
|
- task->buffers[0].handle = global_struct_of_arrays_handle;
|
|
|
+ task->buffers[0].handle = array_of_structs_handle;
|
|
|
task->buffers[0].mode = STARPU_RW;
|
|
|
task->cl_arg = NULL;
|
|
|
task->cl_arg_size = 0;
|
|
@@ -125,7 +125,7 @@ create_and_submit_tasks(void)
|
|
|
struct starpu_task *task2 = starpu_task_create();
|
|
|
task2->cl = &cl;
|
|
|
task2->synchronous = 1;
|
|
|
- task2->buffers[0].handle = global_struct_of_arrays_handle;
|
|
|
+ task2->buffers[0].handle = array_of_structs_handle;
|
|
|
task2->buffers[0].mode = STARPU_RW;
|
|
|
task2->cl_arg = NULL;
|
|
|
task2->cl_arg_size = 0;
|
|
@@ -135,7 +135,7 @@ create_and_submit_tasks(void)
|
|
|
static void
|
|
|
unregister_data(void)
|
|
|
{
|
|
|
- starpu_data_unregister(global_struct_of_arrays_handle);
|
|
|
+ starpu_data_unregister(array_of_structs_handle);
|
|
|
}
|
|
|
|
|
|
static void
|
|
@@ -144,8 +144,8 @@ print_it(void)
|
|
|
int i;
|
|
|
for (i = 0; i < N_ELEMENTS; i++) {
|
|
|
fprintf(stderr, "(%.2f %.2f) ",
|
|
|
- global_struct_of_arrays.x[i],
|
|
|
- global_struct_of_arrays.y[i]);
|
|
|
+ array_of_structs[i].x,
|
|
|
+ array_of_structs[i].y);
|
|
|
}
|
|
|
fprintf(stderr, "\n");
|
|
|
}
|