Commit cec4b3f3 authored by German Leon's avatar German Leon
Browse files

Initial commit

parents
# TK 1sudo cat /sys/kernel/debug/clock/gbus/rate
sudo cat /sys/devices/57000000.gpu/devfreq/57000000.gpu/cur_freq
#min sudo cat /sys/devices/57000000.gpu/devfreq/57000000.gpu/min_freq
#max sudo cat /sys/devices/57000000.gpu/devfreq/57000000.gpu/max_freq
sudo bash -c "echo ${1}000 > /sys/devices/57000000.gpu/devfreq/57000000.gpu/min_freq"
sudo bash -c "echo ${1}000 > /sys/devices/57000000.gpu/devfreq/57000000.gpu/max_freq"
#################TK1###################
#echo ${1}000 > /sys/kernel/debug/clock/override.gbus/rate
# sudo echo $1 > /sys/kernel/debug/clock/override.gbus/rate
#/usr/local/cuda/samples/1_Utilities/deviceQuery/deviceQuery
#echo "before:" >> /home/happy/rodinia/lud/rad/results/res.out
#cat /sys/kernel/debug/clock/override.gbus/rate >> /home/happy/rodinia/lud/rad/results/res.out
#sudo bash -c "cat /sys/kernel/debug/clock/gbus/max > /sys/kernel/debug/clock/override.gbus/rate"
#echo "After:" >> /home/happy/rodinia/lud/rad/results/res.out
#cat /sys/kernel/debug/clock/gbus/max >> /home/happy/rodinia/lud/rad/results/res.out
#sudo bash -c "echo 1 > /sys/kernel/debug/clock/override.gbus/state"
#sudo /home/happy/bin/a.out $1
#sudo bash -c "echo $1 > /sys/kernel/debug/clock/override.gbus/rate"
## TK1 echo ${1}000 > /sys/kernel/debug/clock/override.gbus/rate
#echo ${1}000 > /sys/kernel/debug/clock/override.gbus/rate
#echo "after:" >> /home/happy/rodinia/lud/rad/results/res.out
#cat /sys/kernel/debug/clock/override.gbus/rate >> /home/happy/rodinia/lud/rad/results/res.out
#echo "before:" >> /home/happy/rodinia/lud/rad/results/res.out
#cat /sys/kernel/debug/clock/override.gbus/state >> /home/happy/rodinia/lud/rad/results/res.out
#sudo bash -c "echo 1 > /sys/kernel/debug/clock/override.gbus/state"
## TK1 echo 1 > /sys/kernel/debug/clock/override.gbus/state
#echo "after:" >> /home/happy/rodinia/lud/rad/results/res.out
#cat /sys/kernel/debug/clock/override.gbus/state >> /home/happy/rodinia/lud/rad/results/res.out
#TK1 sudo cut -d'(' -f1 /sys/kernel/debug/clock/gbus/possible_rates
sudo cat /sys/devices/57000000.gpu/devfreq/57000000.gpu/available_frequencies
File added
#!/bin/bash
#for i in min.sh #max.sh #medio.sh
for i in test.sh
do
grid=$(cat $i|cut -d"-" -f2 | cut -d"=" -f2 |cut -d" " -f1 )
blk=$(cat $i|cut -d"-" -f3 | cut -d"=" -f2 | cut -d" " -f1)
nop=$(cat $i|cut -d"-" -f4 | cut -d"=" -f2)
nop=$(( $nop / 1000 ))
BENCH=$(cat $i|cut -d"-" -f5 | cut -d"=" -f2|cut -d" " -f1)
cmd=$(cat $i)
# cmd=$(cat $i|sed "s/\$BENCH/${BENCH}/")
echo "==== "$cmd" ========== "
#echo "Eventos"
#nvprof --events all $cmd 2> $i.events.log
echo "Metricas"
# salida=$(" ")
nvprof --log-file res_${BENCH}_${grid}_${blk}_${nop}m.csv --csv -m $(cat metricas3) -f /home/happy/microbench/micro/$cmd > res_${BENCH}_${grid}_${blk}_${nop}m.log 2>&1
# nvprof -m all -f /home/happy/microbench/micro/$cmd > res_${BENCH}_${grid}_${blk}_${nop}m.log 2>&1
# nvprof --csv -m ipc -f /home/happy/microbench/micro/$cmd > res_${BENCH}_${grid}_${blk}_${nop}m.log 2>&1
# nvprof -m all -f $cmd > ${i}-${BENCH}.metrics.log 2>&1
#echo "TimeLine"
#nvprof --export-profile timeline-$i.nvprof -f $cmd
#echo "Metricas paran vvp"
#nvprof --metrics achieved_occupancy,executed_ipc -o metrics-$i.nvprof -f $cmd
#echo "Analisi del kernel"
#nvprof --kernels microKernel --analysis-metrics -o analysis-$i.nvprof -f $cmd
#echo "Print GPU TRACE"
nvprof $cmd 2> datos-${i}-_${BENCH}_${grid}_${blk}_${nop}m.log
#echo "Ejecucción normal"
#time $cmd >> datos-${i}-${BENCH}.log
#echo $cmd >> datos-${i}-${BENCH}.log
done
// iisalive.cpp
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h> // for watchdog timer
#include <unistd.h> // needed only if close() is used to close watchdog timer
#include <sys/ioctl.h> // for watchdog timer
#include <linux/watchdog.h> // for watchdog timer
#include <time.h>
int main(int argc, char*argv[]) {
FILE *fdf;
int valor,millamperes;
char buffer[100];
char name[50];
int i;
struct watchdog_info ident;
int fd, ret;
int timeout = 0;
int timeslice=10;
int retfinal;
printf("Entrado en iamlive....\r\n");
while (1) {
sleep (timeslice);
time_t t = time(NULL);
struct tm tm = *localtime(&t);
fprintf(stdout, "alive: %d-%02d-%02d %02d:%02d:%02d Temp:",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
for(i=0; i<6;i++) {
sprintf(buffer,"/sys/devices/virtual/thermal/thermal_zone%d/temp",i);
fdf=fopen(buffer,"r");
fscanf (fdf,"%d",&valor);
fprintf(stdout,"%.1f,",valor/1000.0);
}
for(i=0; i<3;i++) {
sprintf(buffer,"/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/rail_name_%d",i);
fdf=fopen(buffer,"r");
fscanf (fdf,"%s",name);
fclose(fdf);
sprintf(buffer,"/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/in_power%d_input",i);
fdf=fopen(buffer,"r");
fscanf (fdf,"%d",&millamperes);
fclose(fdf);
fprintf(stdout,"%s:%.3fW ",name+7,((float)millamperes)/1.0e3);
}
fprintf (stdout,"\r\n");
} // end while
return 0;
}
// iisalive.cpp
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h> // for watchdog timer
#include <unistd.h> // needed only if close() is used to close watchdog timer
#include <sys/ioctl.h> // for watchdog timer
#include <linux/watchdog.h> // for watchdog timer
#include <time.h>
int main(int argc, char*argv[]) {
FILE *fdf, *fdl;
int valor,millamperes;
char buffer[100];
char name[50];
int i;
struct watchdog_info ident;
int fd, ret, fw;
int timeout = 0;
int timeslice=10;
int retfinal;
char *nom;
/* open WDT0 device (WDT0 enables itself automatically) */
fd = open("/dev/watchdog0", O_RDWR);
if (fd<0) {
fprintf(stderr, "Open watchdog device failed!\r\n");
return -1;
}
/* Enviorment monitor*/
ret = ioctl(fd, WDIOC_GETSUPPORT, &ident);
if (ret){
fprintf(stderr, "Kick watchdog failed!\n");
}
//printf ("Identidad %s Version %d Codigo %8x \n", ident.identity,ident.firmware_version,ident.options );
timeout = 60;
if (argc > 1) timeout=atoi(argv[1]);
if (argc > 2) timeslice=atoi(argv[2]);
/* WDT0 is counting now,check the default timeout value */
ret = ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
if(ret) {
fprintf(stderr, "Set watchdog timeout value failed!\r\n");
return -1;
}
fprintf(stdout, "Initial Watchdog timeout value: %d\r\n", timeout);
/* set new timeout value 60s */
/* Note the value should be within [5, 1000] */
/* Enviorment monitor*/
ret = ioctl(fd, WDIOC_GETSUPPORT, &ident);
if (ret){
fprintf(stderr, "Kick watchdog failed!\r\n");
}
//tdout, "/printf ("Identidad %s Version %d Codigo %d \n", ident.identity,ident.firmware_version,ident.options );
retfinal=ident.options & 0xff;
//printf ("retfinal: %d-%8x \n", retfinal,ident.options);
fprintf(stdout, "Last error ?");
switch (retfinal)
{
case WDIOF_OVERHEAT: fprintf(stdout," Reset due to CPU overheat \r\n");break;
case WDIOF_FANFAULT: fprintf(stdout, " Fan failed \r\n");break;
case WDIOF_EXTERN1: fprintf(stdout, " External relay 1 \r\n");break;
case WDIOF_EXTERN2: fprintf(stdout, " External relay 2 \r\n");break;
case WDIOF_POWERUNDER: fprintf(stdout, " Power bad/power fault \r\n");break;
case WDIOF_CARDRESET: fprintf(stdout, " Card previously reset the CPU \r\n");break;
case WDIOF_POWEROVER: fprintf(stdout, " Power over voltage \r\n");break;
case WDIOF_SETTIMEOUT: fprintf(stdout, " Set timeout (in seconds) \r\n");break;
default:
fprintf(stdout,"Code: %d \r\n", ident.options);
}
while (1) {
nom=getenv("MYHOME");
if (nom==NULL)
sprintf(buffer,"./watchdog.log");
else
sprintf(buffer,"%s/watchdog.log",nom);
if ( (fdl = fopen(buffer, "a") ) == NULL ) {
printf("Error! opening watchog.log file\n");
}
sleep (timeslice);
ret = ioctl(fd, WDIOC_KEEPALIVE, &ident);
if (ret<0) {
fprintf(stderr, "Kick watchdog failed!\r\n");
return -1;
}
time_t t = time(NULL);
struct tm tm = *localtime(&t);
fprintf(stdout, "alive: %d-%02d-%02d %02d:%02d:%02d Temperaturas:",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
fprintf(fdl, "alive: %d-%02d-%02d %02d:%02d:%02d \n",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
fflush(fdl);
for(i=0; i<6;i++) {
sprintf(buffer,"/sys/devices/virtual/thermal/thermal_zone%d/temp",i);
fdf=fopen(buffer,"r");
fscanf (fdf,"%d",&valor);
fprintf(stdout,"%.1f,",valor/1000.0);
}
for(i=0; i<3;i++) {
sprintf(buffer,"/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/rail_name_%d",i);
fdf=fopen(buffer,"r");
fscanf (fdf,"%s",name);
fclose(fdf);
sprintf(buffer,"/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/in_power%d_input",i);
fdf=fopen(buffer,"r");
fscanf (fdf,"%d",&millamperes);
fclose(fdf);
fprintf(stdout,"%s:%.3fW ",name+7,((float)millamperes)/1.0e3);
}
fprintf (stdout,"\r\n");
fclose(fdl);
} // end while
close(fd);
if (ret<0) {
fprintf(stderr, "Failed to close watchdog device.");
return -1;
}
printf ("+1\n");
return 0;
}
################################################################################
#
# Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
#
# NOTICE TO USER:
#
# This source code is subject to NVIDIA ownership rights under U.S. and
# international Copyright laws.
#
# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
# CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
# IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
# IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
# OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
# OR PERFORMANCE OF THIS SOURCE CODE.
#
# U.S. Government End Users. This source code is a "commercial item" as
# that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
# "commercial computer software" and "commercial computer software
# documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
# and is provided to the U.S. Government only as a commercial end item.
# Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
# 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
# source code with only those rights set forth herein.
#
################################################################################
#
# Makefile project only supported on Mac OS X and Linux Platforms)
#
################################################################################
# Location of the CUDA Toolkit
CUDA_PATH ?= /usr/local/cuda
##############################
# start deprecated interface #
##############################
ifeq ($(x86_64),1)
$(info WARNING - x86_64 variable has been deprecated)
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
TARGET_ARCH ?= x86_64
endif
ifeq ($(ARMv7),1)
$(info WARNING - ARMv7 variable has been deprecated)
$(info WARNING - please use TARGET_ARCH=armv7l instead)
TARGET_ARCH ?= armv7l
endif
ifeq ($(aarch64),1)
$(info WARNING - aarch64 variable has been deprecated)
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
TARGET_ARCH ?= aarch64
endif
ifeq ($(ppc64le),1)
$(info WARNING - ppc64le variable has been deprecated)
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
TARGET_ARCH ?= ppc64le
endif
ifneq ($(GCC),)
$(info WARNING - GCC variable has been deprecated)
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
HOST_COMPILER ?= $(GCC)
endif
ifneq ($(abi),)
$(error ERROR - abi variable has been removed)
endif
############################
# end deprecated interface #
############################
# architecture
HOST_ARCH := $(shell uname -m)
TARGET_ARCH ?= $(HOST_ARCH)
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 sbsa ppc64le armv7l))
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 sbsa ppc64le))
TARGET_SIZE := 64
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
TARGET_SIZE := 32
endif
else
TARGET_SIZE := $(shell getconf LONG_BIT)
endif
else
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
endif
# sbsa and aarch64 systems look similar. Need to differentiate them at host level for now.
ifeq ($(HOST_ARCH),aarch64)
ifeq ($(CUDA_PATH)/targets/sbsa-linux,$(shell ls -1d $(CUDA_PATH)/targets/sbsa-linux 2>/dev/null))
HOST_ARCH := sbsa
TARGET_ARCH := sbsa
endif
endif
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-sbsa x86_64-ppc64le))
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
endif
endif
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
TARGET_ARCH = armv7l
endif
# operating system
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
TARGET_OS ?= $(HOST_OS)
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
endif
# host compiler
ifeq ($(TARGET_OS),darwin)
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
HOST_COMPILER ?= clang++
endif
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
ifeq ($(TARGET_OS),linux)
HOST_COMPILER ?= arm-linux-gnueabihf-g++
else ifeq ($(TARGET_OS),qnx)
ifeq ($(QNX_HOST),)
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
endif
ifeq ($(QNX_TARGET),)
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
endif
export QNX_HOST
export QNX_TARGET
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
else ifeq ($(TARGET_OS),android)
HOST_COMPILER ?= arm-linux-androideabi-g++
endif
else ifeq ($(TARGET_ARCH),aarch64)
ifeq ($(TARGET_OS), linux)
HOST_COMPILER ?= aarch64-linux-gnu-g++
else ifeq ($(TARGET_OS),qnx)
ifeq ($(QNX_HOST),)
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
endif
ifeq ($(QNX_TARGET),)
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
endif
export QNX_HOST
export QNX_TARGET
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/q++
else ifeq ($(TARGET_OS), android)
HOST_COMPILER ?= aarch64-linux-android-clang++
endif
else ifeq ($(TARGET_ARCH),sbsa)
HOST_COMPILER ?= aarch64-linux-gnu-g++
else ifeq ($(TARGET_ARCH),ppc64le)
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
endif
endif
#HOST_COMPILER ?= g++
HOST_COMPILER ?= g++
NVCC := $(CUDA_PATH)/bin/nvcc #-ccbin $(HOST_COMPILER)
# internal flags
NVCCFLAGS := -m${TARGET_SIZE} -Xptxas -dlcm=ca #--use_fast_math
CCFLAGS :=
LDFLAGS :=
# build flags
ifeq ($(TARGET_OS),darwin)
LDFLAGS += -rpath $(CUDA_PATH)/lib
CCFLAGS += -arch $(HOST_ARCH)
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
CCFLAGS += -mfloat-abi=hard
else ifeq ($(TARGET_OS),android)
LDFLAGS += -pie
CCFLAGS += -fpie -fpic -fexceptions
endif
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
ifneq ($(TARGET_FS),)
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
ifeq ($(GCCVERSIONLTEQ46),1)
CCFLAGS += --sysroot=$(TARGET_FS)
endif
LDFLAGS += --sysroot=$(TARGET_FS)
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
endif
endif
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
ifneq ($(TARGET_FS),)
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
ifeq ($(GCCVERSIONLTEQ46),1)
CCFLAGS += --sysroot=$(TARGET_FS)
endif
LDFLAGS += --sysroot=$(TARGET_FS)
LDFLAGS += -rpath-link=$(TARGET_FS)/lib -L$(TARGET_FS)/lib
LDFLAGS += -rpath-link=$(TARGET_FS)/lib/aarch64-linux-gnu -L$(TARGET_FS)/lib/aarch64-linux-gnu
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib -L$(TARGET_FS)/usr/lib
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/aarch64-linux-gnu -L$(TARGET_FS)/usr/lib/aarch64-linux-gnu
LDFLAGS += --unresolved-symbols=ignore-in-shared-libs
CCFLAGS += -isystem=$(TARGET_FS)/usr/include -I$(TARGET_FS)/usr/include
CCFLAGS += -isystem=$(TARGET_FS)/usr/include/aarch64-linux-gnu -I$(TARGET_FS)/usr/include/aarch64-linux-gnu
endif
endif
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
NVCCFLAGS += --qpp-config 5.4.0,gcc_ntoaarch64le
CCFLAGS += -DWIN_INTERFACE_CUSTOM -I/usr/include/aarch64-qnx-gnu
LDFLAGS += -lsocket
LDFLAGS += -L/usr/lib/aarch64-qnx-gnu
CCFLAGS += "-Wl\,-rpath-link\,/usr/lib/aarch64-qnx-gnu"
ifdef TARGET_OVERRIDE
LDFLAGS += -lslog2
endif
ifneq ($(TARGET_FS),)
LDFLAGS += -L$(TARGET_FS)/usr/lib
CCFLAGS += "-Wl\,-rpath-link\,$(TARGET_FS)/usr/lib"
LDFLAGS += -L$(TARGET_FS)/usr/libnvidia
CCFLAGS += "-Wl\,-rpath-link\,$(TARGET_FS)/usr/libnvidia"
endif
endif
endif
ifdef TARGET_OVERRIDE # cuda toolkit targets override
NVCCFLAGS += -target-dir $(TARGET_OVERRIDE)
endif
# Install directory of different arch
CUDA_INSTALL_TARGET_DIR :=
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),sbsa-linux)
CUDA_INSTALL_TARGET_DIR = targets/sbsa-linux/
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
else ifeq ($(TARGET_ARCH),ppc64le)
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
endif
# Debug build flags
ifeq ($(dbg),1)
NVCCFLAGS += -g -G
BUILD_TYPE := debug
else
BUILD_TYPE := release
endif
ALL_CCFLAGS :=
ALL_CCFLAGS += $(NVCCFLAGS)
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
SAMPLE_ENABLED := 1
ALL_LDFLAGS :=
ALL_LDFLAGS += $(ALL_CCFLAGS)
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
# Common includes and paths for CUDA
INCLUDES := -I$(CUDA_PATH)/samples/common/inc
LIBRARIES :=
################################################################################
# Gencode arguments
SMS ?= 53
#SMS ?= 35 37 50 52 60 61 70 75 80 86
ifeq ($(SMS),)
$(info >>> WARNING - no SM architectures have been specified - waiving sample <<<)
SAMPLE_ENABLED := 0
endif
ifeq ($(GENCODE_FLAGS),)
# Generate SASS code for each SM architecture listed in $(SMS)
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
HIGHEST_SM := $(lastword $(sort $(SMS)))
ifneq ($(HIGHEST_SM),)
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
endif
endif
ifeq ($(SAMPLE_ENABLED),0)
EXEC ?= @echo "[@]"
endif
################################################################################
# Target rules
all: build
build: micro
check.deps:
ifeq ($(SAMPLE_ENABLED),0)
@echo "Sample will be waived due to the above missing dependencies"
else
@echo "Sample is ready - all dependencies have been met"
endif
micro.o: micro.cu
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
micro: micro.o
$(EXEC) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES)
# $(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
# $(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
run: build
$(EXEC) ./micro
clean:
rm -f micro micro.o
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/micro
clobber: clean
This diff is collapsed.
cd /home/happy/microbench/micro
# posibles valores de $1 = shm, glb, reg
bench=$1
comun="-nop=145000 -bench=$bench -time=0.5"
#: '
echo "./micro -grid=1 -blk=1 $comun " > test.sh
chmod +x test.sh
/home/happy/bin/profile_micro.sh
echo "./micro -grid=1 -blk=32 $comun "> test.sh
chmod +x test.sh
/home/happy/bin/profile_micro.sh
echo "./micro -grid=1 -blk=64 $comun "> test.sh
chmod +x test.sh
/home/happy/bin/profile_micro.sh
echo "./micro -grid=1 -blk=128 $comun "> test.sh
chmod +x test.sh
/home/happy/bin/profile_micro.sh
echo "./micro -grid=1 -blk=1024 $comun" > test.sh
chmod +x test.sh
/home/happy/bin/profile_micro.sh
echo "./micro -grid=2 -blk=1024 $comun "> test.sh
chmod +x test.sh
/home/happy/bin/profile_micro.sh
#'
echo "./micro -grid=32 -blk=64 $comun" > test.sh
chmod +x test.sh
/home/happy/bin/profile_micro.sh
#: '
echo "./micro -grid=32 -blk=128 $comun "> test.sh
chmod +x test.sh
/home/happy/bin/profile_micro.sh
echo "./micro -grid=64 -blk=32 $comun " > test.sh
chmod +x test.sh
/home/happy/bin/profile_micro.sh
'
./micro -grid=1 -blk=1024 -nop=1000000 -bench=shm
/**
* Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and related documentation outside the terms of the EULA
* is strictly prohibited.
*
*/
/**
* Matrix multiplication: C = A * B.
* Host code.
*
* This sample implements matrix multiplication which makes use of shared memory
* to ensure data reuse, the matrix multiplication is done using tiling approach.
* It has been written for clarity of exposition to illustrate various CUDA programming
* principles, not with the goal of providing the most performant generic kernel for matrix multiplication.
* See also:
* V. Volkov and J. Demmel, "Benchmarking GPUs to tune dense linear algebra,"
* in Proc. 2008 ACM/IEEE Conf. on Supercomputing (SC '08),
* Piscataway, NJ: IEEE Press, 2008, pp. Art. 31:1-11.
*/
// System includes
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>
#include "jetson_nano.h"
// CUDA runtime
#include <cuda_runtime.h>
// Helper functions and utilities to work with CUDA
#include <helper_functions.h>
#include <helper_cuda.h>
#include <cuda_fp16.h>
#include "input_device.h"
#define FREQ 921600000
#define T 1
#define BITSNOSIGNIFICATIVOS 16
#define CYCLES (T*(FREQ) >> BITSNOSIGNIFICATIVOS)
#define QUATUMINTERACIONES 1000
#define SIZEROW 1
typedef int btype;
typedef btype *btypePtr;
#define myclock() (int) (clock64() >> BITSNOSIGNIFICATIVOS)
/**
* Micro Kernel that performs the computation using only registers
*/
__global__ void microKernel_reg_iter (unsigned int nit, char *vadd) {
btype regin, regout, local;
btype id = (blockIdx.x*blockDim.x + threadIdx.x+1);
regin = id;
local = id;
#pragma unroll 2
for (int op = 0; op < nit; ++op) {
regout = regin*local + id;
local = (regout-local)/regin;
}
vadd[(int) id - 1] = (local == id);
}
/**
* Micro Kernel that performs the computation using only registers
*/
__global__ void microKernel_reg_time (unsigned int cycles, char *vadd) {
//long long
unsigned int fin,ahora;
//clock_t start,ahora;
btype regin, regout, local;
btype id = (blockIdx.x*blockDim.x + threadIdx.x+1);
ahora=myclock();
regin = id;
local = id;
//fin=ahora+CYCLES;
fin=ahora+cycles;
while (ahora < fin )
{
ahora=myclock();
#pragma unroll 2
for (unsigned int op=0; op< QUATUMINTERACIONES;++op){
regout = regin*local + id;
local = (regout-local)/regin;
}
}
vadd[(int) id - 1] = (local == id);
}
/**
* Micro Kernel that performs the computation using global memory (and cache)
*/
__global__ void microKernel_global_iter(int nit, char *vadd, volatile btype *global) {
btype regin, regout;
btype id = (blockIdx.x*blockDim.x + threadIdx.x+1);
int idInt = SIZEROW*(int) id;
regin = id;
global[idInt] = id;
#pragma unroll 2
for (int op = 0; op < nit; ++op) {
regout = regin*global[idInt] + id;
global[idInt] = (regout-global[idInt])/regin;
}
vadd[(int) id - 1] = ( global[idInt] == id );
}
__global__ void microKernel_global_time(unsigned int cycles, char *vadd, volatile btype *global) {
unsigned int fin,ahora;
btype regin, regout;
btype id = (blockIdx.x*blockDim.x + threadIdx.x+1);
volatile int idInt = SIZEROW*(int) id;
ahora=myclock();
regin = id;
fin=ahora+cycles;
global[idInt] = id;
while (ahora < fin )
{
ahora=myclock();
#pragma unroll 2
for (unsigned int op = 0; op < QUATUMINTERACIONES; ++op) {
regout = regin*global[idInt] + id;
global[idInt] = (regout-global[idInt])/regin;
}
}
vadd[(int) id - 1] = ( global[idInt] == id );
}
/**
* Micro Kernel that performs the computation using shared memory
*/
__global__ void microKernel_shared_iter(unsigned int nit, char *vadd) {
btype regin, regout;
volatile btype id = (btype) (blockIdx.x*blockDim.x + threadIdx.x + 1);
volatile extern __shared__ btype sh[];
regin = id;
sh[threadIdx.x] = id;
#pragma unroll 2
for (unsigned int op = 0; op < nit; ++op) {
regout = regin*sh[threadIdx.x] + id;
sh[threadIdx.x] = (regout-sh[threadIdx.x])/regin;
}
vadd[(int) id - 1 ] = (sh[threadIdx.x] == id);
}
__global__ void microKernel_shared_time (unsigned int cycles, char *vadd) {
unsigned int fin,ahora;
btype regin, regout;
volatile btype id = (btype) (blockIdx.x*blockDim.x + threadIdx.x + 1);
volatile extern __shared__ btype sh[];
ahora=myclock();
regin = id;
sh[threadIdx.x] = id;
//fin=ahora+CYCLES;
fin=ahora+cycles;
while (ahora < fin )
{
ahora=myclock();
#pragma unroll 2
for (int op = 0; op < QUATUMINTERACIONES; ++op) {
regout = regin*sh[threadIdx.x] + id;
sh[threadIdx.x] = (regout-sh[threadIdx.x])/regin;
}
}
vadd[(int) id - 1 ] = (sh[threadIdx.x] == id);
}
bool check_error(char *h_vadd, int vsize) {
int sum = 0;
for (int i = 0; i < vsize; i++)
sum += h_vadd[i];
return (sum == vsize);
}
/**
* Run microKernel
*/
int launch_kernel(char *bench, int grid, int blk, unsigned int nitocycles,int time) {
char *h_vadd;
char *d_vadd;
btypePtr d_global;
int vsize = grid*blk;
// Allocate CUDA events that we'll use for timing
cudaEvent_t start, stop;
checkCudaErrors(cudaEventCreate(&start));
checkCudaErrors(cudaEventCreate(&stop));
h_vadd = (char *) malloc(vsize*sizeof(char));
checkCudaErrors(cudaMalloc(&d_vadd, vsize*sizeof(char)));
checkCudaErrors(cudaDeviceSynchronize());
// Record the start event
checkCudaErrors(cudaEventRecord(start));
// Execute the kernel
if (!strcmp(bench, "shm") ) {
printf("shm");
if(time) {
printf("time \n");
microKernel_shared_time <<<grid, blk, blk*sizeof(btype)>>>(nitocycles, d_vadd);
}
else {
printf("iterations\n");
microKernel_shared_iter <<<grid, blk, blk*sizeof(btype)>>>(nitocycles, d_vadd);
}
} else if (!strcmp(bench, "glb") ) {
printf("glb");
checkCudaErrors(cudaMalloc(&d_global, SIZEROW*vsize*sizeof(btype)));
if(time) {
printf("time\n");
microKernel_global_time <<<grid, blk, blk*sizeof(btype)>>>(nitocycles, d_vadd, d_global);
}
else {
printf("iterations\n");
microKernel_global_iter <<<grid, blk, blk*sizeof(btype)>>>(nitocycles, d_vadd, d_global);
}
} else if (!strcmp(bench, "reg") ) {
printf("reg");
if(time) {
printf("time\n");
microKernel_reg_time <<<grid, blk, blk*sizeof(btype)>>>(nitocycles, d_vadd);
}
else {
printf("iterations\n");
microKernel_reg_iter <<<grid, blk, blk*sizeof(btype)>>>(nitocycles, d_vadd);
}
}
// Record the stop event
checkCudaErrors(cudaDeviceSynchronize());
checkCudaErrors(cudaEventRecord(stop));
// Wait for the stop event to complete
checkCudaErrors(cudaEventSynchronize(stop));
float msecTotal = 0.0f;
checkCudaErrors(cudaEventElapsedTime(&msecTotal, start, stop));
// Compute and print the performance
printf( "Elapsed time= %.2f\n", msecTotal);
//checkCudaErrors(cudaDeviceSynchronize());
checkCudaErrors( cudaMemcpy(h_vadd, d_vadd, vsize*sizeof(char), cudaMemcpyDeviceToHost) );
printf("Checking computed result for correctness:\n ");
bool correct = check_error(h_vadd, vsize);
// Clean up memory
checkCudaErrors(cudaEventDestroy(start));
checkCudaErrors(cudaEventDestroy(stop));
checkCudaErrors(cudaFree(d_vadd));
if (!strcmp(bench, "glb") ) {
checkCudaErrors(cudaFree(d_global));
}
free(h_vadd);
return correct;
/*
if (correct) {
return EXIT_SUCCESS;
} else {
return EXIT_FAILURE;
}
*/
}
/**
* Program main
*/
int a;
long int b;
long long int c;
char *buffer,*buffer2;
int main(int argc, char **argv) {
unsigned int grid, blk, nitocycles;
long int frec;
char *bench = (char *) malloc(4);
bool time;
unsigned long int long_nitocycles;
if (checkCmdLineFlag(argc, (const char **)argv, "help") ||
checkCmdLineFlag(argc, (const char **)argv, "?")) {
printf("Usage -bench=bench_name ('shm', 'glb', 'reg')\n");
printf(" -grid=grid_size (Grid size)\n");
printf(" -blk=block_size (Thread block size)\n");
printf(" -nit=number_its (number of iterations)\n");
printf(" -time=time (time to run the microbenchark)\n");
exit(EXIT_SUCCESS);
}
/*
if (checkCmdLineFlag(argc, (const char **)argv, "nit")) {
nitocycles = getCmdLineArgumentInt(argc, (const char **)argv, "nit");}
if (checkCmdLineFlag(argc, (const char **)argv, "nit")) {
getCmdLineArgumentString(argc, (const char **)argv, "nit",&buffer);}
printf ("Valor entero %d y cadena %s, long convertido de string %lu", nitocycles,buffer,strtol(buffer,&buffer2,10));
*/
frec=frec_now(); // Get current frequency to compute time from cycles
printf("GPU frequency: %lu \n", frec);
if (checkCmdLineFlag(argc, (const char **)argv, "bench")) {
getCmdLineArgumentString(argc, (const char **)argv, "bench", &bench);
}
else
printf ("FAIL: bench\n");
// Grid size
if (checkCmdLineFlag(argc, (const char **)argv, "grid")) {
grid = getCmdLineArgumentInt(argc, (const char **)argv, "grid");
}
// Thread block size
if (checkCmdLineFlag(argc, (const char **)argv, "blk")) {
blk = getCmdLineArgumentInt(argc, (const char **)argv, "blk");
}
else
printf ("FAIL: blk\n");
time=false;
// Kernel time
if (checkCmdLineFlag(argc, (const char **)argv, "time")) {
long_nitocycles = ((long int) (frec * getCmdLineArgumentFloat(argc, (const char **)argv, "time")));
nitocycles=(unsigned int) (long_nitocycles >> BITSNOSIGNIFICATIVOS);
time=true;
}
else // Number of iterations
if (checkCmdLineFlag(argc, (const char **)argv, "nit")) {
nitocycles = getCmdLineArgumentInt(argc, (const char **)argv, "nit");
}
else
printf ("FAIL:nit and/or time\n");
printf("microKernel=%s, grid: %u, blk: %u, nit o cycles: %u\n", bench, grid, blk, nitocycles);
int kernel_result = launch_kernel(bench, grid, blk, nitocycles,time);
printf("Launch result: %d\n", kernel_result);
exit(!kernel_result);
}
./micro -grid=4 -blk=1024 -nop=100000 -bench=$BENCH -t=5 -t=5
#!/usr/bin/python
import csv
import sys
import re
patron=re.compile('(^[^=](.*)$)',re.M)
fields=['Metric Name']
for i in range(1,len(sys.argv)):
a=sys.argv[i]
a=a.split('_')
a=a[2]+'_'+a[3]
fields.append(a)
metricas=[]
print(metricas)
file=open(sys.argv[1])
contents=file.read()
with open("tmpxx","w") as filetmp:
for m in patron.findall(contents):
#print(m)
filetmp.write((m[0]+"\n"))
with open("tmpxx") as csvtmp:
dst=csv.DictReader(csvtmp)
for row in dst:
metricas.append(row['Metric Name'])
#print ("====================")
#print (metricas)
with open('total.csv','w') as csvdstfile:
writer=csv.DictWriter(csvdstfile,fieldnames=fields);
writer.writeheader()
dw={}
ix=0;
for account in ['grid size','thread block size']:
#print("M",account)
dw['Metric Name']=account
for f in fields[1:]:
a=f.split('_')
dw[f]=a[ix]
ix=ix+1
writer.writerow(dw)
dw={}
for m in metricas:
dw={}
dw['Metric Name']=m
#print ("Metr", m)
for i in range(1,len(sys.argv)):
print(sys.argv[i])
file=open(sys.argv[i])
contents=file.read()
with open("tmpxx","w") as filetmp:
for my in patron.findall(contents):
filetmp.write(my[0])
filetmp.write("\n")
with open("tmpxx") as csvtmp:
dst=csv.DictReader(csvtmp)
#print(dst)
for row in dst:
#print("Row",row['Metric Name'], " y mi m es ",m,"\n")
if (row['Metric Name']==m):
#print("Entro")
dw[fields[i]]=row['Avg'].replace(".",",")
print (dw)
writer.writerow(dw)
#! /usr/bin/python
import sys, os, subprocess, random, time, datetime
import pexpect, re
import os.path
from os import path
import fnmatch
import serial
import config
from config import *
def configurate_serie():
#os.system("sudo stop ttyS0")
Puerto=0
try:
serie = serial.Serial(Puerto, 115200)
serie.timeout=1;
except serial.SerialException:
#-- Error al abrir el puerto serie
sys.stderr.write("Error al abrir puerto (%s)\n" % str(Puerto))
return serie
#mantener vivos los watdog softwre y hardware
def KeepWatchdog():
os.system("/home/ubuntu/bin/refresh_watchdog > watchsoft.test")
os.system("touch watchsoft.test")
def writeOutput(serie, output, elapsedTime, outputFileName, fileName):
# if verbose:
# print("\n***Elapsed time: %s ms. ***\n" % (elapsedTime))
serie.write("\n***Elapsed time: %s ms. ***\n" % (elapsedTime))
if verbose:
print("%s " % (output) )
serie.write("%s " % (output) )
output += "\n\n***Elapsed time: " + `elapsedTime` + " ms. ***\n\n"
outputFile = open(outputFileName, "w")
outputFile.write(output)
outputFile.flush()
outputFile.close()
# os.system("tar -rvf results/" + fileName + ".tar " + outputFileName)
# os.system("rm " + outputFileName)
def runBenchmark(fiIni, fileName, tIni):
serie=configurate_serie()
numTimeouts = 0
if (totalFiNumber == -1): # bucle infinito
forever = True
else:
forever = False
stdLogFile = open("results/"+fileName+"_"+tIni+".log", "w")
fiNumber = fiIni - 1
while forever or ( (fiNumber+1) < totalFiNumber+1):
fiNumber = fiNumber + 1
KeepWatchdog()
try:
x = datetime.datetime.now()
outputFileName = "results/"+fileName + x.strftime("_%H%M%S.err")
ti = x.strftime("%m/%d/%Y %H:%M:%S")
# Measure execution time
startTime = time.time()
# os.system("sudo /home/ubuntu/bin/gpufreq-info")
# os.system("cpufreq-info | grep 'current CPU' | cut -d's' -f2 | cut -d'(' -f1")
# os.system("/home/ubuntu/bin/gpufreq-info >> /home/ubuntu/rodinia/lud/rad/results/res.out")
p = pexpect.spawn("./"+exeFile+" "+inputParameters, timeout=timeout)
p.expect(pexpect.EOF)
# Process elspased time
elapsedTime = 1000*(time.time() - startTime)
p.close()
if (p.exitstatus == 0):
if verbose:
print("(%d) %s; PASS in %.2f ms. " % (fiNumber, ti, elapsedTime) )
print(p.before)
sys.stdout.flush()
stdLogFile.write("(%d) %s; PASS in %.2f ms.\n" % (fiNumber, ti, elapsedTime) )
stdLogFile.write("%s" % (p.before) )
stdLogFile.flush()
serie.write("(%d) %s; PASS in %.2f ms.\n\r" % (fiNumber, ti, elapsedTime) )
serie.write("%s" % (p.before) )
elif (p.exitstatus == 1):
if verbose:
print("(%d) %s; FAIL in %.2f ms." % (fiNumber, ti, elapsedTime) )
sys.stdout.flush()
stdLogFile.write("(%d) %s; FAIL in %.2f ms.; %s\n" % (fiNumber, ti, elapsedTime, outputFileName) )
stdLogFile.write("%s" % (p.before) )
stdLogFile.flush()
serie.write("(%d) %s; FAIL in %.2f ms.; %s\n\r" % (fiNumber, ti, elapsedTime, outputFileName) )
writeOutput(serie, p.before, elapsedTime, outputFileName, fileName+"_"+tIni)
else:
if verbose:
print("(%d) %s; Exit status: %d in %.2f ms." % (fiNumber, ti, p.exitstatus, elapsedTime) )
sys.stdout.flush()
stdLogFile.write("(%d) %s; Exit status: %d in %.2f ms.\n" % (fiNumber, ti, p.exitstatus, elapsedTime) )
stdLogFile.write("%s" % (p.before) )
stdLogFile.flush()
serie.write("(%d) %s; Exit status: %d in %.2f ms.\n\r" % (fiNumber, ti, p.exitstatus, elapsedTime) )
writeOutput(serie, p.before, elapsedTime, outputFileName, fileName+"_"+tIni)
stdLogFile.flush()
numTimeouts = 0
except KeyboardInterrupt:
print("KeyboardInterrupt")
sys.stdout.flush()
lastFile = open("lastFiNumber", "w")
lastFile.write("%d" % fiNumber)
lastFile.flush()
lastFile.close()
stdLogFile.close()
stdLogFile.flush()
sys.exit(2)
except pexpect.EOF, e:
print("Fin de archivo")
except pexpect.TIMEOUT, e:
terminated = p.terminate(force=True)
elapsedTime = time.time() - startTime
if verbose:
print("(%d) %s; Timeout after %.2f s." % (fiNumber, ti, elapsedTime) )
sys.stdout.flush()
stdLogFile.write("(%d) %s; Timeout after %.2f s.\n" % (fiNumber, ti, elapsedTime) )
stdLogFile.write("%s" % (p.before) )
stdLogFile.flush()
serie.write("(%d) %s; Timeout after %.2f s.\n\r" % (fiNumber, ti, elapsedTime) )
sys.stdout.flush()
# stdLogFile.close()
numTimeouts += 1
# Si se dan 3 timeouts seguidos, suponemoe que no se recuperara y rearrancamos la Jetson
lastFile = open("lastFiNumber", "w")
if (numTimeouts == 3):
fiNumber = fiNumber - 2 # contamos los tres ultimos timeouts consecutivos como un solo error no recuperable
lastFile.write("%d" % fiNumber)
lastFile.flush()
lastFile.close()
time.sleep(2)
sys.exit(3)
else:
lastFile.write("%d" % fiNumber)
lastFile.flush()
lastFile.close()
finally:
lastFile = open("lastFiNumber", "w")
lastFile.write("%d" % fiNumber)
lastFile.flush()
lastFile.close()
time.sleep(1)
# end while
stdLogFile.close()
#end runBenchmark
def main(argv):
fileName = sys.argv[1]
fiIni = int( sys.argv[2] )
tIni = sys.argv[3]
runBenchmark(fiIni, fileName, tIni)
##############################################################################
#main()
if __name__ == "__main__":
main(sys.argv)
!/bin/bash
dir=`grep ^"dir = " config.py | cut -d"\"" -f2`
name=`grep ^"exeFile = " config.py | cut -d"\"" -f2`
size=`grep ^"size = " config.py | cut -d"\"" -f2`
#blk=`grep ^"blk =" config.py | cut -d"\"" -f2`
totalFiNumber=`grep ^"totalFiNumber = " config.py | cut -d"=" -f2`
cpufreq=`grep ^"cpufreq = " config.py | cut -d"=" -f2`
gpufreq=`grep ^"gpufreq = " config.py | cut -d"=" -f2`
PATH=${MYHOME}/bin:$PATH
rm -f goldens
ln -s ${dir}/goldens goldens
rm -f ${name}
ln -s ${dir}/${name} ${name}
echo >> results/res.out
echo "==================================" >> results/res.out
echo `date` >> results/res.out
echo "Experiment: " $name " size: " $size " cpufreq: " $cpufreq "gpufreq: " $gpufreq >> results/res.out
echo "==================================" >> results/res.out
echo >> results/res.out
if [ ${cpufreq} -ne -1 ]
then
# echo "initial CPUfreq: " `cpufreq-info | grep "current CPU" | cut -d"s" -f2 | cut -d"(" -f1` > ./results/res.out
sudo cpufreq-set -c 0 -d ${cpufreq} -u ${cpufreq}
echo "CPUfreq set to: " `cpufreq-info | grep "current CPU" | cut -d"s" -f2 | cut -d"(" -f1` >> results/res.out
echo "CPUfreq set to: " `cpufreq-info | grep "current CPU" | cut -d"s" -f2 | cut -d"(" -f1` > /dev/ttyS0
fi
if [ ${gpufreq} -ne -1 ]
then
# echo "initial GPUfreq: " `/home/buntu/bin/gpufreq-info` >> ./results/res.out
echo "Setting GPUFreq to: " ${gpufreq} >> results/res.out
sudo ${MYHOME}/bin/gpufreq-set ${gpufreq}
echo "GPUfreq set to: " `gpufreq-info` >> results/res.out
fi
if [ -f "lastFiNumber" ]
then # por si hemos rearrancado el test.sh sin acabar el anterior
fiNumber=$((`cat lastFiNumber` + 1))
else
fiNumber=1
fi
#if [ -f "lastFiNumber" ]
#then
# rm lastFiNumber
#fi
sudo killall iamalive_ini
sudo ${MYHOME}/bin/iamalive > /dev/ttyS0 &
if [ $totalFiNumber -eq -1 ]
then
forever=1
else
forever=0
fi
tIni=`date +%H%M%S`
########### WARMING, WARMING ################
./${name} -s ${size} -v
########### WARMING, WARMING ################
if [ ${gpufreq} -ne -1 ]
then
# echo "initial GPUfreq: " `/home/ubuntu/bin/gpufreq-info` >> ./results/res.out
echo "After warming. Setting GPUFreq to: " ${gpufreq} >> results/res.out
sudo ${MYHOME}/bin/gpufreq-set ${gpufreq}
echo "GPUfreq set to: " `gpufreq-info` >> results/res.out
fi
while [ $forever -eq 1 ] || [ $fiNumber -le $totalFiNumber ]
do
tIni=`date +%H%M%S`
if [ $gpufreq -eq -1 ]
then
sufix=""
else
g=`${MYHOME}/bin/gpufreq-info`
sufix="_"${g%"000000"}
fi
fileName=${name}"_"${size}${sufix}
echo $fileName >> results/res.out
echo "===========" >> results/res.out
# fileName=${name}"_"${size}"_b"${blk}
# gzip -f results/*.log
# gzip -f results/*.tar
if [ $# -eq 1 ] # parametro gdb
then
./test_gdb.py $fileName $fiNumber $tIni #| tee ./results/${fileName}_${tIni}.out
else
./test.py $fileName $fiNumber $tIni #| tee ./results/${fileName}_${tIni}.out
fi
echo "GPUfreq after test: " `gpufreq-info` >> results/res.out
echo "===========" >> results/res.out
status=$?
if [ $status -eq 3 ] # tres timeouts seguidos
then
sudo reboot now
sleep 30
sudo reboot now
exit 1
elif [ $status -eq 2 ] # interrupcion por teclado del test
then
fiNumber=$totalFiNumber + 1 # provocar el fin del test
forever=0
else
fiNumber=$((`cat lastFiNumber` + 1))
# pgrep $name
# kill -9 `pgrep $name`
# echo "Relaunching test after " $fiNumber " iterations."
fi
done # end while
if [ $cpufreq -ne -1 ]
then
# coloca la CPU a la maxima frecuencia
sudo cpufreq-set -c 0 -d 2065500 -u 2065500
fi
sudo killall iamalive
sudo iamalive_ini 120 10 &
sudo killall -2 reset
echo "Status after while loop: " $status
if [ -f "lastFiNumber" ]
then
echo "Delete lastFiNumber. Reset index" > /dev/ttyS0
sudo rm lastFiNumber
fi
#if [ $status != 2 ] # si no se ha interrumpido por teclado
#then
mv ${MYHOME}/startup_script.sh ${MYHOME}/startup_script_noactivo.sh
#fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment