diff --git a/LIKWID-DINF.txt b/LIKWID-DINF.txt new file mode 100644 index 0000000000000000000000000000000000000000..4126e8e249a1c8ca206c56cef8d561b590f14741 --- /dev/null +++ b/LIKWID-DINF.txt @@ -0,0 +1,65 @@ +===== GUIA DE CONFIGURAÇÃO DO LINUX PARA USO DO LIKWID NO DINF =============== + +1. Acrescentar linhas abaixo em '${HOME}/.bashrc': + + export LIKWID_HOME="/home/soft/likwid" + + if [ -d "${LIKWID_HOME}" ] ; then + PATH="$PATH:${LIKWID_HOME}/bin:${LIKWID_HOME}/sbin" + export LIKWID_LIB="${LIKWID_HOME}/lib" + export LIKWID_INCLUDE="${LIKWID_HOME}/include" + export LIKWID_MAN="${LIKWID_HOME}/man" + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${LIKWID_LIB}" + export MANPATH="$MANPATH:${LIKWID_MAN}" + fi + + +2. Opções para compilação de programas: + + gcc -DLIKWID_PERFMON -I${LIKWID_INCLUDE} -c <prog.c> + gcc -o <prog> <prog.o> -L${LIKWID_LIB} -llikwid + + + * Nos códigos-fonte deve-se colocar + + #include <likwid.h> + + +===== GUIA DE CONFIGURAÇÃO DE FREQUENCIA DE RELÓGIO EM LINUX =============== + +1. Execute a seguinte linha de comando: + + echo "performance" > /sys/devices/system/cpu/cpufreq/policy3/scaling_governor + +2. Para retornar à frequencia original + + echo "powersave" > /sys/devices/system/cpu/cpufreq/policy3/scaling_governor + + + +===== GUIA DE ACESSO REMOTO ÀS MÁQUINAS DOS LABORATÓRIOS DINF =============== + +Nos acessos abaixo, sempre use seu login/senha nas máquinas do DINF + +1. Copiar seus arquivos locais para a máquina 'macalan': + + scp -rp <sua_pasta_com_exercicio> <user_dinf>@macalan.c3sl.ufpr.br:. + +2. Acessar 'macalan' com + + ssh <user_dinf>@macalan.c3sl.ufpr.br + +3. Uma vez na 'macalan' + + ssh <maq_LAB_DINF> + + onde <maq_LAB_DINF> = {h2, h4, h6, h7, h9, h11, h14, h16, h18, h19} [LAB12] + = {h21, h23, h26, h28, h29, h31, h33, h35, h38} [LAB12] + = {h21, h23, h26, h28, h29, h31, h33, h35, h38} [LAB12] + = {h40, h41, h44, h47, h49, h50, h52, h54, h56} [LAB12] + = {h57, h59} [LAB12] + +4. ATENÇÃO: Lembre-se de RECOMPILAR SEUS PROGRAMAS em <maq_LAB_DINF> + + + diff --git a/gnuplot/gnuplot.pdf b/gnuplot/gnuplot.pdf deleted file mode 100644 index 3ff8881440946a4c547aa774e198174262999f94..0000000000000000000000000000000000000000 Binary files a/gnuplot/gnuplot.pdf and /dev/null differ diff --git a/gnuplot/plot.gp b/gnuplot/plot.gp deleted file mode 100755 index 01797ddfa17d9b85f160a038331528cf60955d1c..0000000000000000000000000000000000000000 --- a/gnuplot/plot.gp +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/gnuplot -c -set grid -set style data point -set style function line -set style line 1 lc 3 pt 7 ps 0.3 -set boxwidth 1 -set xtics -set xrange ["0":] -set xlabel "N (bytes)" - -# -# ALTERNATIVA 1: Tabelas em arquivos separados (2 colunas) -# -set ylabel "<metrica 1>" -set title "<campo[marcador 1]>" -set terminal qt 0 title "<campo[marcador 1]>" -plot 'plot_exemplo-01.dat' title "<sem otimização>" with linespoints, \ - 'plot_exemplo-02.dat' title "<com otimização>" with linespoints - -# -# ALTERNATIVA 2: Tabela com 3 colunas -# -set ylabel "<metrica 1>" -set title "<campo[marcador 1]>" -set terminal qt 1 title "<campo[marcador 1]>" -plot 'plot_exemplo-03.dat' using 1:2 title "<sem otimização>" with linespoints, \ - '' using 1:3 title "<com otimização>" with linespoints - -pause mouse - -# Gerando figura PNG -set terminal png -set output "funcao__NxMetrica.png" -plot 'plot_exemplo-03.dat' using 1:2 title "<sem otimização>" with linespoints, \ - '' using 1:3 title "<com otimização>" with linespoints -replot -unset output - diff --git a/gnuplot/plot_exemplo-01.dat b/gnuplot/plot_exemplo-01.dat deleted file mode 100644 index 80be8a97aa032c88f76a50600b4a4a2857c9ba46..0000000000000000000000000000000000000000 --- a/gnuplot/plot_exemplo-01.dat +++ /dev/null @@ -1,7 +0,0 @@ -# Marcador "matPtrVet" -# n <METRICA 1> (sem otimização) -64 0.5 -100 50.433210629261 -128 25.798359943835 -2000 27.337482595053 -2048 18.873424079086 diff --git a/gnuplot/plot_exemplo-02.dat b/gnuplot/plot_exemplo-02.dat deleted file mode 100644 index d5c852b1b620a8975b0a50487ffd5704d8832612..0000000000000000000000000000000000000000 --- a/gnuplot/plot_exemplo-02.dat +++ /dev/null @@ -1,7 +0,0 @@ -# Marcador "matPtrVet" -# n <METRICA 1> (com otimização) -64 0.5 -100 45.433210629261 -128 21.798359943835 -2000 21.337482595053 -2048 14.873424079086 diff --git a/gnuplot/plot_exemplo-03.dat b/gnuplot/plot_exemplo-03.dat deleted file mode 100644 index 48cda506b929acc0ff78a9317b3a9c38e43175af..0000000000000000000000000000000000000000 --- a/gnuplot/plot_exemplo-03.dat +++ /dev/null @@ -1,7 +0,0 @@ -# Marcador "matRowVet" <METRICA 1> -# n sem_otimz. com_otimiz. -64 0.7 0.7 -100 50.433210629261 45.433210629261 -128 25.798359943835 21.798359943835 -2000 27.337482595053 21.337482595053 -2048 18.873424079086 14.873424079086 diff --git a/matmult.c b/matmult.c index 7c89509a45371cfba8d3f9042ef5cccfd5976251..53207800e022fcb7d3194facc8461453b93dc349 100644 --- a/matmult.c +++ b/matmult.c @@ -2,6 +2,7 @@ #include <stdlib.h> /* exit, malloc, calloc, etc. */ #include <string.h> #include <getopt.h> /* getopt */ +#include <time.h> #include "matriz.h" @@ -29,9 +30,9 @@ int main (int argc, char *argv[]) { int c, n=DEF_SIZE; - MatPtr mPtr_1, mPtr_2, resMatPtr; + MatPtr mPtr_1, mPtr_2, mPtrRow_1, mPtrRow_2, resMatPtr, resMatPtrRow; MatRow mRow_1, mRow_2, resMatRow; - Vetor vet, resPtr, resRow; + Vetor vet, resPtr, resPtrRow, resRow; /* =============== TRATAMENTO DE LINHA DE COMANDO =============== */ @@ -49,24 +50,31 @@ int main (int argc, char *argv[]) /* ================ FIM DO TRATAMENTO DE LINHA DE COMANDO ========= */ - srand(20202); + srand(time(NULL)); resPtr = (double *) calloc (n, sizeof(double)); + resPtrRow = (double *) calloc (n, sizeof(double)); resRow = (double *) calloc (n, sizeof(double)); resMatPtr = geraMatPtr(n, n, 1); + resMatPtrRow = geraMatPtrRow(n, n, 1); resMatRow = geraMatRow(n, n, 1); mPtr_1 = geraMatPtr (n, n, 0); mPtr_2 = geraMatPtr (n, n, 0); + mPtrRow_1 = geraMatPtrRow (n, n, 0); + mPtrRow_2 = geraMatPtrRow (n, n, 0); + mRow_1 = geraMatRow (n, n, 0); mRow_2 = geraMatRow (n, n, 0); vet = geraVetor (n, 0); - + #ifdef DEBUG prnMatPtr (mPtr_1, n, n); prnMatPtr (mPtr_2, n, n); + prnMatPtr (mPtrRow_1, n, n); + prnMatPtr (mPtrRow_2, n, n); prnMatRow (mRow_1, n, n); prnMatRow (mRow_2, n, n); prnVetor (vet, n); @@ -74,23 +82,32 @@ int main (int argc, char *argv[]) #endif /* DEBUG */ multMatPtrVet (mPtr_1, vet, n, n, resPtr); + + multMatPtrVet (mPtrRow_1, vet, n, n, resPtrRow); multMatRowVet (mRow_1, vet, n, n, resRow); multMatMatPtr (mPtr_1, mPtr_2, n, resMatPtr); + + multMatMatPtr (mPtrRow_1, mPtrRow_2, n, resMatPtrRow); multMatMatRow (mRow_1, mRow_2, n, resMatRow); #ifdef DEBUG prnVetor (resPtr, n); + prnVetor (resPtrRow, n); prnVetor (resRow, n); prnMatRow (resMatRow, n, n); prnMatPtr (resMatPtr, n, n); + prnMatPtr (resMatPtrRow, n, n); #endif /* DEBUG */ liberaMatPtr (mPtr_1, n); liberaMatPtr (mPtr_2, n); + liberaMatPtrRow (mPtrRow_1, n); + liberaMatPtrRow (mPtrRow_2, n); liberaMatPtr (resMatPtr, n); + liberaMatPtrRow (resMatPtrRow, n); liberaVetor ((void*)mRow_1); liberaVetor ((void*)mRow_2); liberaVetor ((void*)resMatRow); @@ -98,6 +115,7 @@ int main (int argc, char *argv[]) free(resRow); free(resPtr); + free(resPtrRow); return 0; } diff --git a/matriz.c b/matriz.c index 006686886385491598d6a88a442b0ab04cb45dac..afcee467627c077b86aafeaeb4303def4425be93 100644 --- a/matriz.c +++ b/matriz.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <math.h> #include "matriz.h" @@ -60,6 +61,42 @@ MatPtr geraMatPtr (int m, int n, int zerar) return (matriz); } + +/** + * Funcao geraMatPtrRow: gera matriz como vetor de ponteiros para um array + * + * @param m número de linhas da matriz + * @param n número de colunas da matriz + * @param zerar se 0, matriz tem valores aleatórios, caso contrário, + * matriz tem valores todos nulos + * @return ponteiro para a matriz gerada + * + */ + +MatPtr geraMatPtrRow (int m, int n, int zerar) +{ + MatPtr matriz = (double **) malloc(m * sizeof(double *)); + + if (matriz) { + if (matriz[0] = (double *) malloc(m * n * sizeof(double))) { + for (int i=1; i < m; ++i) matriz[i] = matriz[i-1] + n; + + for (int i=0; i < m; ++i) { + for (int j=0; j < n; ++j) { + if (zerar) matriz[i][j] = 0.0; + else matriz[i][j] = generateRandomA(i, j); + } + } + } + else { + free (matriz); + return NULL; + } + } + + return (matriz); +} + /** * \brief: libera matriz alocada como vetor de ponteiros para as suas linhas * @@ -78,6 +115,22 @@ void liberaMatPtr (MatPtr matriz, int m) +/** + * \brief: libera matriz alocada como vetor de ponteiros para vetor + * + * @param ponteiro para matriz + * + */ +void liberaMatPtrRow (MatPtr matriz, int m) +{ + if (matriz) { + if (matriz[0]) free (matriz[0]); + free (matriz); + } +} + + + /** * Funcao geraMatRow: gera matriz como vetor único, 'row-oriented' * diff --git a/matriz.h b/matriz.h index a468bbd126b8d5a6faf814ebb03cb2e5786d1d51..1fcf4ab99ad7388f770515f0269bb968ea2a2cfd 100644 --- a/matriz.h +++ b/matriz.h @@ -18,10 +18,12 @@ typedef double * Vetor; /* ----------- FUNÇÕES ---------------- */ MatPtr geraMatPtr (int m, int n, int zerar); +MatPtr geraMatPtrRow (int m, int n, int zerar); MatRow geraMatRow (int m, int n, int zerar); Vetor geraVetor (int n, int zerar); void liberaMatPtr (MatPtr mPtr, int n); +void liberaMatPtrRow (MatPtr mPtr, int n); void liberaVetor (void *vet); void multMatPtrVet (MatPtr mat, Vetor v, int m, int n, Vetor res);