/*****************************************************************************/ /* */ /* Copyright (c) 2008, 2009, 2010 */ /* Computer Architecture Group (CAG) */ /* University of A Coruña, Spain */ /* (http://gac.des.udc.es) */ /* Galicia Supercomputing Center (CESGA) */ /* (http://www.cesga.es) */ /* Hewlett-Packard Spain (HP) */ /* (http://www.hp.es) */ /* */ /* This file is part of UPC Operations Microbenchmarking Suite (UOMS). */ /* */ /* UOMS 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 3 of the License, or */ /* (at your option) any later version. */ /* */ /* UOMS 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 for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with UOMS. If not, see . */ /* */ /*****************************************************************************/ /*****************************************************************************/ /* */ /* FUNDING: This development has been funded by Hewlett-Packard Spain */ /* */ /* Project Name: */ /* UPCHACO (2008-2011) */ /* Subproject: */ /* Improving UPC Usability and Performance in Constellation Systems: */ /* Implementation/Extensions of UPC Libraries. */ /* (UPCPUProject -> UPC Performance and Usability Project) */ /* */ /*****************************************************************************/ /***************************************************************************** For further documentation, see [1] Files under doc/ ******************************************************************************/ #include #include #include #include #include "headers.h" #include "defines.h" /* Affinity related functions */ extern FILE *unit; extern int minsize, maxsize; void UOMS_coreaffinity_info(int core0, int core1, long total){ int i; char *smask0; char *smask1; cpu_set_t mask0, mask1; CPU_ZERO(&mask0); CPU_ZERO(&mask1); CPU_SET(core0 + 0*(core1-core0),&mask0); CPU_SET(core0 + 1*(core1-core0),&mask1); smask0 = malloc(sizeof(char)*(total+1)); smask1 = malloc(sizeof(char)*(total+1)); for(i=0;i= 4){ for(i = 1; i<=num_cores/2; i*=2){ //First part core0 = 0; core1 = i; CPU_ZERO(&mask); if (!MYTHREAD) UOMS_coreaffinity_info(core0,core1,num_cores); cpu = core0 + MYTHREAD*(core1-core0); CPU_SET(cpu,&mask); sched_setaffinity(0,sizeof(cpu_set_t),&mask); bench(operation_code); //Second part core0 = num_cores/2; core1 = core0 + i; if(core1 >= num_cores) continue; CPU_ZERO(&mask); if (!MYTHREAD) UOMS_coreaffinity_info(core0,core1,num_cores); cpu = core0 + MYTHREAD*(core1-core0); CPU_SET(cpu,&mask); sched_setaffinity(0,sizeof(cpu_set_t),&mask); bench(operation_code); } } else{ /* For completition, this code test mono and dual-core machines */ core0 = 0; if(num_cores < 2) core1 = 0; else core1 = 1; CPU_ZERO(&mask); if (!MYTHREAD) UOMS_coreaffinity_info(core0,core1,num_cores); cpu = core0 + MYTHREAD*core1; CPU_SET(cpu,&mask); sched_setaffinity(0,sizeof(cpu_set_t),&mask); bench(operation_code); } }