/* StarPURM --- StarPU Resource Management Layer. * * Copyright (C) 2017 Inria * * 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 * the Free Software Foundation; either version 2.1 of the License, or (at * your option) any later version. * * StarPU is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU Lesser General Public License in COPYING.LGPL for more details. */ /* This example shows a basic StarPU vector scale app on top of StarPURM with a nVidia CUDA kernel */ #include #include #include #include #include static int rm_cpu_type_id = -1; static int rm_nb_cpu_units = 0; static void test1(); static void init_rm_infos(void); static int global_nb_tasks = 100; static const int nb_random_tests = 10; /* vector scale codelet */ static void work_func(void *cl_buffers[], void *cl_arg) { double timestamp = starpu_timing_now(); double timestamp2; do { timestamp2 = starpu_timing_now(); } while ((timestamp2 - timestamp) < 1e6); } static struct starpu_codelet work_cl = { .cpu_funcs = {work_func}, }; /* main routines */ static void test1() { int i; for (i=0; i 1) { global_nb_tasks = atoi(argv[1]); } starpurm_initialize(); init_rm_infos(); printf("using default units\n"); disp_selected_cpuset(); test1(); if (rm_nb_cpu_units > 1) { const int nb_cpus = rm_nb_cpu_units; const int half_nb_cpus = nb_cpus/2; printf("nb_cpu_units = %d\n", nb_cpus); starpurm_set_drs_enable(NULL); drs_enabled = starpurm_drs_enabled_p(); assert(drs_enabled != 0); printf("withdrawing %d cpus from StarPU\n", half_nb_cpus); starpurm_withdraw_cpus_from_starpu(NULL, half_nb_cpus); disp_selected_cpuset(); test1(); printf("assigning %d cpus to StarPU\n", half_nb_cpus); starpurm_assign_cpus_to_starpu(NULL, half_nb_cpus); disp_selected_cpuset(); test1(); int i; for (i=0; i