/* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2016-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), 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. */ #include #include /* This example case follows the same pattern its native Fortran version nf_sched_ctx.f90 */ static void sched_ctx_cpu_func(void *descr[], void *cl_args) { (void)descr; int task_id; starpu_codelet_unpack_args(cl_args, &task_id); printf("task: %d, workerid: %d\n", task_id, starpu_worker_get_id()); } static struct starpu_codelet sched_ctx_codelet = { .cpu_funcs = {sched_ctx_cpu_func}, .model = NULL, .nbuffers = 0, .name = "sched_ctx" }; int main(void) { int ncpu; int nprocs1; int nprocs2; int *procs = NULL; int *procs1 = NULL; int *procs2 = NULL; int i; int n = 20; int ret = starpu_init(NULL); if (ret == -ENODEV) return 77; STARPU_CHECK_RETURN_VALUE(ret, "starpu_init"); ncpu = starpu_cpu_worker_get_count(); /* actually we really need at least 2 CPU workers such to allocate 2 * non overlapping contexts */ if (ncpu < 2) return 77; procs = calloc(ncpu, sizeof(int)); starpu_worker_get_ids_by_type(STARPU_CPU_WORKER, procs, ncpu); nprocs1 = ncpu / 2; procs1 = calloc(nprocs1, sizeof(int)); for (i=0; i