Commit d0ca9644 authored by THIBAULT Samuel's avatar THIBAULT Samuel
Browse files

Fix filtered simgrid execution

parent 38e4447c
......@@ -2,13 +2,14 @@ CC = gcc
CFLAGS += $(shell pkg-config --cflags starpu-1.3)
LDLIBS += $(shell pkg-config --libs starpu-1.3)
all: vector_scal_task_insert mult
all: vector_scal_task_insert vector_scal_task_insert_filter mult
#gemm/sgemm gemm/dgemm
%.o: %.cu
nvcc $(CFLAGS) $< -c -o $@
vector_scal_task_insert: vector_scal_task_insert.o vector_scal_cpu.o #vector_scal_cuda.o vector_scal_opencl.o
vector_scal_task_insert_filter: vector_scal_task_insert_filter.o vector_scal_cpu.o #vector_scal_cuda.o vector_scal_opencl.o
#vector_scal_task_insert: LDLIBS+=-lOpenCL
#vector_scal_task_insert: LDLIBS+=-lcudart -lstdc++
mult: mult.c
......
/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2010, 2011, 2012, 2013, 2014 Centre National de la Recherche Scientifique
* Copyright (C) 2010-2012, 2014 Université de Bordeaux 1
* Copyright (C) 2010-2012, 2014, 2019 Université de Bordeaux 1
*
* StarPU is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
......@@ -24,15 +24,26 @@
*/
#include <starpu.h>
#define NX 2048
#define NX 20480
extern void vector_scal_cpu(void *buffers[], void *_args);
extern void vector_scal_cuda(void *buffers[], void *_args);
extern void vector_scal_opencl(void *buffers[], void *_args);
static struct starpu_perfmodel perfmodel = {
.type = STARPU_NL_REGRESSION_BASED,
.symbol = "vector_scal"
};
static struct starpu_codelet cl = {
/* CPU implementation of the codelet */
.cpu_funcs = {vector_scal_cpu, NULL},
#ifdef STARPU_SIMGRID
/* CUDA pseudo-implementation of the codelet */
.cuda_funcs = {(void*) 1, NULL},
/* OpenCL pseudo-implementation of the codelet */
.opencl_funcs = {(void*) 1, NULL},
#else
#ifdef STARPU_USE_CUDA
/* CUDA implementation of the codelet */
.cuda_funcs = {vector_scal_cuda, NULL},
......@@ -40,9 +51,11 @@ static struct starpu_codelet cl = {
#ifdef STARPU_USE_OPENCL
/* OpenCL implementation of the codelet */
.opencl_funcs = {vector_scal_opencl, NULL},
#endif
#endif
.nbuffers = 1,
.modes = {STARPU_RW}
.modes = {STARPU_RW},
.model = &perfmodel,
};
#ifdef STARPU_USE_OPENCL
......@@ -54,6 +67,7 @@ int main(int argc, char **argv)
/* We consider a vector of float that is initialized just as any of C
* data */
float *vector;
double start_time;
unsigned i;
starpu_malloc((void**)&vector, NX * sizeof(vector[0]));
......@@ -89,15 +103,16 @@ int main(int argc, char **argv)
NX, sizeof(vector[0]));
#define N 10
struct starpu_data_filter filter;
memset(&filter, 0, sizeof(filter));
filter.filter_func = starpu_vector_filter_block;
filter.nchildren = N;
struct starpu_data_filter filter = {
.filter_func = starpu_vector_filter_block,
.nchildren = N,
};
starpu_data_partition(vector_handle, &filter);
float factor = 3.14;
start_time = starpu_timing_now();
for (i = 0; i < N; i++)
{
ret = starpu_insert_task(&cl,
......@@ -114,11 +129,17 @@ int main(int argc, char **argv)
/* Wait for tasks completion */
starpu_task_wait_for_all();
/* Collect the pieces */
starpu_data_unpartition(vector_handle, 0);
fprintf(stderr, "computation took %fµs\n", starpu_timing_now() - start_time);
/* StarPU does not need to manipulate the array anymore so we can stop
* monitoring it */
starpu_data_unpartition(vector_handle, 0);
starpu_data_unregister(vector_handle);
fprintf(stderr, "AFTER First element is %f\n", vector[0]);
starpu_free(vector);
#ifdef STARPU_USE_OPENCL
starpu_opencl_unload_opencl(&programs);
#endif
......@@ -126,7 +147,5 @@ int main(int argc, char **argv)
/* terminate StarPU, no task can be submitted after */
starpu_shutdown();
fprintf(stderr, "AFTER First element is %f\n", vector[0]);
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment