Commit 66c571d6 authored by george's avatar george
Browse files

Update and new test routines for testing QT performance. The lapse execution...

Update and new test routines for testing QT performance. The lapse execution time is measured as difference between the unix date after and before the run. For correct results, supply a tab-delimited file containing the transpose of the QT

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2782 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 6a6d24e5
# $Id: Makefile 531 2005-11-30 13:49:48Z kamenik $
# Copyright 2005, Ondra Kamenik
DEBUG = yes
#DEBUG = yes
#LD_LIBS := -llapack -lcblas -lf77blas -latlas -lg2c
CC_FLAGS := -DMATLAB -DWINDOWS -DNO_BLAS_H -DNO_LAPACK_H \
-Wall -I../cc -I../sylv/cc -I../cc \
-Wall -I../cc -I../../sylv/cc -I../cc \
-Ic:/"Program Files"/MATLAB_SV71/extern/include #-pg
ifeq ($(DEBUG),yes)
......@@ -14,8 +14,8 @@ ifeq ($(DEBUG),yes)
# CC_FLAGS := -DTIMING_LOOP -DDEBUG $(CC_FLAGS) -g
KALMANLIB := kalmanlib_dbg.a
else
# CC_FLAGS := $(CC_FLAGS) -O2
CC_FLAGS := -DTIMING_LOOP $(CC_FLAGS) -O2
# CC_FLAGS := $(CC_FLAGS) -O3
CC_FLAGS := -DTIMING_LOOP $(CC_FLAGS) -O3
KALMANLIB := kalmanlib.a
endif
......@@ -53,11 +53,19 @@ dummy.ch:
%.o: %.cpp $(hsource) $(cppsource)
c++ $(CC_FLAGS) -c $*.cpp
dgemvm_exe.exe: dgemvm_exe.o $(qtobjs) $(hsource) $(cppsource)
gcc $(CC_FLAGS) -o dgemvm_exe.exe dgemvm_exe.o ascii_array.o \
$(qtobjs) $(LD_LIBS)
qtamvm_exe.exe: qtamvm_exe.o $(qtobjs) $(hsource) $(cppsource)
gcc $(CC_FLAGS) -o qtamvm_exe.exe qtamvm_exe.o ascii_array.o \
$(qtobjs) $(LD_LIBS)
all: $(objects) qtamvm_exe.exe # $(cppsource) $(hsource) $(kalmanhsource) $(kalmancppsource)
qtvmvm_exe.exe: qtvmvm_exe.o $(qtobjs) $(hsource) $(cppsource)
gcc $(CC_FLAGS) -o qtvmvm_exe.exe qtvmvm_exe.o ascii_array.o \
$(qtobjs) $(LD_LIBS)
all: $(objects) dgemvm_exe.exe qtvmvm_exe.exe qtamvm_exe.exe # $(cppsource) $(hsource) $(kalmanhsource) $(kalmancppsource)
clear:
rm -f *.o
......
/*
* Copyright (C) 2008-2009 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
/******************************************************
%
% This provides an interface to BLAS dgemv f90 library function
% to multiply Quasi trinagular matrix (T) with a vector a
%
% function [a] = dgevm(QT,a)
%
% use:
% dgemvm_exe QTt_file a_file size [loops - if enabled]
%
% NOTE: due to fortran matrix orientation, input matrices need to be passed
% as transposed so QTt instead QT
%
% 1. Ta = dgemv(Ld;a;n)+TV(T1;a;n).
%
% INPUTS
% T [double] mm*mm transition matrix of the state equation.
% a [double] mm state vector.
%
% OUTPUTS
% a update [double] mm vector of the state equation.
% as file: a_file_out
**********************************************************/
#include "cppblas.h"
#include <stdio.h>
#include <math.h>
#include "ascii_array.h"
#include <iostream>
#include <stdexcept>
#include <malloc.h>
int main(int argc, char* argv[])
{
if (argc < 3 )
{
printf("Must have min 2 input parameters.\n");
exit(1);
}
try
{
// make input matrices
int n=atoi(argv[3]);
double *Ta ;
AsciiNumberArray QT, a;
QT.GetMX(argv[1],n,n);
a.GetMX(argv[2],n,1);
const double alpha=1.0;
const double beta=0.0;
int inc =1;
//alpha=1.0;beta=0.0;
// create output and upload output data
Ta=(double *)calloc(n, sizeof(double));
#ifdef TIMING_LOOP
int loops=1;//000;
if (argc >3 )
loops = atoi(argv[4]);
for (int tt=0;tt<loops;++tt)
{
#endif
#ifdef DEBUG
// QT.print();
#endif
// 1. T1 = QT2T(QT;n) and Ld = QT2Ld(QT;n);
// void BLAS_dgemv(BLCHAR trans, CONST_BLINT m, CONST_BLINT n, CONST_BLDOU alpha,
// CONST_BLDOU a, CONST_BLINT lda, CONST_BLDOU x, CONST_BLINT incx,
// CONST_BLDOU beta, BLDOU y, CONST_BLINT incy);
BLAS_dgemv("N", &n, &n, &alpha, QT.data, &n, a.data, &inc, &beta, Ta, &inc);
#ifdef TIMING_LOOP
}
printf("QT array mvm: finished: %d loops\n",loops);
#endif
// create output and upload output data
WriteMX(argv[2], Ta,n,1);
free(Ta);
}
catch (std::exception e)
{
std::cout <<"Error" << std::endl;
}
}; //main
......@@ -77,7 +77,7 @@ int main(int argc, char* argv[])
#ifdef TIMING_LOOP
int loops=1;//000;
if (argc >3 )
loops = atoi(argv[2]);
loops = atoi(argv[4]);
for (int tt=0;tt<loops;++tt)
{
#endif
......
/*
* Copyright (C) 2008-2009 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
/******************************************************
%
% This provides an interface to QT f90 library by Andrea Pagano
% to multiply Quasi trinagular matrix (T) with a vector a
%
% function [a] = qtvmvm(QT,a)
%
% use:
% qtvmvm_exe QTt_file a_file size [loops - if enabled]
%
% NOTE: due to fortran matrix orientation, input matrices need to be passed
% as transposed so QTt instead QT
%
% 2. Ta = QTV(T1;a;n).
%
% INPUTS
% T [double] mm*mm transition matrix of the state equation.
% a [double] mm state vector.
%
% OUTPUTS
% a update [double] mm vector of the state equation.
% as file: a_file_out
**********************************************************/
#include "qt.h"
#include <stdio.h>
#include <math.h>
#include "ascii_array.h"
#include <iostream>
#include <stdexcept>
#include <malloc.h>
int main(int argc, char* argv[])
{
if (argc < 3 )
{
printf("Must have min 2 input parameters.\n");
exit(1);
}
try
{
// make input matrices
int n=atoi(argv[3]);
double *Ta ;
AsciiNumberArray QT, a;
QT.GetMX(argv[1],n,n);
a.GetMX(argv[2],n,1);
// create output and upload output data
Ta=(double *)calloc(n, sizeof(double));
#ifdef TIMING_LOOP
int loops=1;//000;
if (argc >3 )
loops = atoi(argv[4]);
for (int tt=0;tt<loops;++tt)
{
#endif
#ifdef DEBUG
// QT.print();
#endif
// 1. T1 = QT2T(QT;n) and Ld = QT2Ld(QT;n);
qtv_(Ta, QT.data, a.data, &n) ;
#ifdef TIMING_LOOP
}
printf("QT array mvm: finished: %d loops\n",loops);
#endif
// create output and upload output data
WriteMX(argv[2], Ta,n,1);
free(Ta);
}
catch (std::exception e)
{
std::cout <<"Error" << std::endl;
}
}; //main
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