123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #include <starpu.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <fpga.h>
- #include <starpu_scheduler.h>
- #include "../helper.h"
- //#include "StreamFMA.h"
- #include "MaxSLiCInterface.h"
- void cpu_func(void *buffers[], void *cl_arg)
- {
- (void)buffers;
- (void)cl_arg;
- printf("///******Hello world**********//////\n");
- }
- void fpga_mult(void *buffers[], void *cl_arg)
- {
- (void)buffers;
- (void)cl_arg;
- const int size = 384;
- int sizeBytes = size * sizeof(int32_t);
- int32_t *a = (int32_t*) malloc(sizeBytes);
- int32_t *b = (int32_t*) malloc(sizeBytes);
- int32_t *c = (int32_t*) malloc(sizeBytes);
- // TODO Generate input data
- for(int i = 0; i < size; ++i)
- {
- a[i] = random() % 100;
- b[i] = random() % 100;
- }
- //Implementation of a maxfile
- //max_file_t *maxfile = StreamFMA_init();
- //Implementation of an engine
- //max_engine_t *engine = max_load(maxfile, "*");
- //Actions to run on an engine
- //max_actions_t* act = max_actions_init(maxfile, NULL);
- //set the number of ticks for a kernel
- //max_set_ticks (act, "StreamFMAKernel", size);
- //add data to an input stream
- //max_queue_input(act, "a", a, sizeBytes);
- //max_queue_input(act, "b", b, sizeBytes);
- //max_queue_output(act,"output", c, sizeBytes);
- //run actions on the engine
- printf("Running on DFE using dynamic interface ...\n");
- printf("**** Run actions in non blocking mode **** \n");
- //run actions in non_blocking mode
- //max_run_t *run0= max_run_nonblock(engine, act);
- printf("*** wait for the actions on DFE to complete *** \n");
- //wait for the actions to complete
- //max_wait(run0);
- //deallocate the set of actions
- //max_actions_free(act);
- //unload and deallocate an engine obtained by way of max_load
- //max_unload(engine);
- }
- static struct starpu_codelet cl =
- {
- .cpu_funcs = {cpu_func},
- .cpu_funcs_name = {"cpu_func"},
- #ifdef STARPU_USE_FPGA
- .fpga_funcs = {fpga_mult},
- .fpga_funcs_name={"fpga_mult"},
- #endif
- .nbuffers = 1,
- .modes = {STARPU_W}
- };
- int main(int argc, char **argv)
- {
- /* Enable profiling */
- starpu_profiling_status_set(1);
- struct starpu_conf conf;
- starpu_data_handle_t handle;
- int ret;
- int size=1234;
- starpu_conf_init(&conf);
- conf.sched_policy_name = "eager";
- conf.calibrate = 0;
- ret = starpu_initialize(&conf, &argc, &argv);
- if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
- STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
- starpu_vector_data_register(&handle, -1, (uintptr_t)NULL, size, sizeof(int));
- struct starpu_task *task = starpu_task_create();
- task->cl = &cl;
- task->handles[0] = handle;
-
- task->synchronous = 1;
- task->destroy = 0;
- /* submit the task to StarPU */
- //starpu_task_destroy(task);
- starpu_task_submit(task);
- starpu_data_unregister(handle);
-
- starpu_shutdown();
- return EXIT_SUCCESS;
- }
|