1/* 2 * Copyright (c) 2014 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8 */ 9#include <bomp_internal.h> 10 11struct omp_icv_device g_omp_icv_device_default; 12struct omp_icv_global g_omp_icv_global_default; 13struct omp_icv_task g_omp_icv_task_default; 14 15void bomp_icv_init_default(coreid_t nthreads) 16{ 17 /* Global Control Variables */ 18 struct omp_icv_global *icv_glob = &g_omp_icv_global_default; 19 icv_glob->thread_limit = nthreads; 20 icv_glob->time_start = rdtsc(); 21 22 /* Device Control Variables */ 23 struct omp_icv_device *icv_dev = &g_omp_icv_device_default; 24 icv_dev->dev_sched = 0; 25 icv_dev->stack_size = OMP_STACKSIZE; 26 icv_dev->wait_policy = OMP_WAIT_POLICY; 27 icv_dev->max_active_levels = OMP_MAX_ACTIVE_LEVELS; 28#if OMP_VERSION >= OMP_VERSION_40 29 icv_dev->cancel = OMP_CANCELLATION; 30#endif 31 32 struct omp_icv_task *icv_task = &g_omp_icv_task_default; 33 /* Task Control Variables */ 34 icv_task->dynamic = OMP_DYNAMIC; 35 icv_task->nested = OMP_NESTED; 36 icv_task->nthreads = nthreads; 37 icv_task->thread_limit = nthreads; 38 icv_task->place_partition = OMP_PLACES; 39 icv_task->active_levels = 0; 40 icv_task->levels=0; 41 icv_task->run_sched = OMP_SCHEDULE; 42 icv_task->run_sched_modifier = 0; 43#if OMP_VERSION >= OMP_VERSION_40 44 icv_task->bind = OMP_PROC_BIND; 45 icv_task->default_device = OMP_DEFAULT_DEVICE; 46#endif 47} 48 49/** 50 * \brief allocated an initializes a new task ICV set 51 * 52 * \returns pointer to the ICV task struct 53 * 54 * The struct is initialized based on the parent 55 */ 56struct omp_icv_task *bomp_icv_task_new(void) 57{ 58 struct omp_icv_task *icv = calloc(1, sizeof(*icv)); 59 if (icv == NULL) { 60 return icv; 61 } 62 63 memcpy(icv, &g_omp_icv_task_default, sizeof(*icv)); 64 65 return icv; 66} 67