Commit 4c95507b authored by sebastien's avatar sebastien
Browse files

v4: unified build system for MEX files


git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1519 ac1d8469-bf42-47a9-8791-bf33cf982152
parent c4e78163
% Build file for Dynare MEX Librairies
% Copyright Dynare Team (2007)
% GNU Public License
MATLAB = ver('matlab');
% FIXME:
% It's not satisfactory to convert string versions into numbers, and to
% compare these numbers:
% - conversion will fail if version = 1.2.3
% - it will give 7.10 < 7.9
VERSION = str2num(MATLAB.Version);
MATLAB_PATH = matlabroot;
COMPILE_OPTIONS = '';
if strcmpi('GLNX86', computer) || strcmpi('GLNXA64', computer) % GNU/Linux (i386)
if strcmpi('GLNXA64', computer) % 64 bits ?
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -largeArrayDims' ];
end
LAPACK_PATH = '-lmwlapack';
if VERSION <= 7.4
BLAS_PATH = LAPACK_PATH; % On <= 7.4, BLAS in included in LAPACK
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DNO_BLAS_H' ];
else
BLAS_PATH = '-lmwblas';
end
elseif strcmpi('PCWIN', computer) % Windows (32 bits)
LAPACK_PATH = 'libmwlapack.lib';
if VERSION <= 7.4
BLAS_PATH = LAPACK_PATH; % On <= 7.4, BLAS in included in LAPACK
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DMWTYPES_NOT_DEFINED -DNO_BLAS_H' ];
else
BLAS_PATH = 'libmwblas.lib';
end
else
error('Unsupported platform')
end
if VERSION <= 7.4
OUTPUT_DIR = '../2007a';
else
OUTPUT_DIR = '../2007b';
end
% Comment next line to suppress compilation debugging info
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -v' ]
COMPILE_COMMAND = [ 'mex ' COMPILE_OPTIONS ' -outdir ' OUTPUT_DIR ' ' ];
disp('Compiling mjdgges...')
system([ COMPILE_COMMAND ' mjdgges/mjdgges.c ' LAPACK_PATH ]);
disp('Compiling sparse_hessian_times_B_kronecker_C...')
system([ COMPILE_COMMAND ' kronecker/sparse_hessian_times_B_kronecker_C.cc ' BLAS_PATH ]);
disp('Compiling A_times_B_kronecker_C...')
system([ COMPILE_COMMAND ' kronecker/A_times_B_kronecker_C.cc ' BLAS_PATH ]);
disp('Compiling gensylv...')
system([ COMPILE_COMMAND ' -DMATLAB -Igensylv/cc gensylv/matlab/gensylv.cpp gensylv/cc/*.cpp ' BLAS_PATH ' ' LAPACK_PATH ]);
......@@ -14,12 +14,20 @@
#ifdef MWTYPES_NOT_DEFINED
typedef unsigned int mwIndex;
typedef unsigned int mwSize;
// dgemm(transpose, transpose, &mA, &nC, &mC, &B[mB*col+row], &A[ka], &mA, &C[0], &mC, &one, &D[kd], &mA);
#endif
#ifdef NO_BLAS_H
# if defined(__linux__)
# define DGEMM dgemm_
# else
# define DGEMM dgemm
# endif
extern "C"{
int dgemm(char*, char*, mwSize*, mwSize*, mwSize*, double*, double*, mwSize*, double*, mwSize*, double*, double*, mwSize*);
int DGEMM(char*, char*, mwSize*, mwSize*, mwSize*, double*, double*, mwSize*, double*, mwSize*, double*, double*, mwSize*);
}
#else
#include "blas.h"
# include "blas.h"
# define DGEMM dgemm
#endif
void full_A_times_kronecker_B_C(double *A, double *B, double *C, double *D,
......@@ -35,7 +43,7 @@ void full_A_times_kronecker_B_C(double *A, double *B, double *C, double *D,
ka = 0 ;
for(unsigned long int row=0; row<mB; row++)
{
dgemm(transpose, transpose, (int*)&mA, (int*)&nC, (int*)&mC, &B[mB*col+row], &A[ka], (int*)&mA, &C[0], (int*)&mC, &one, &D[kd], (int*)&mA);
DGEMM(transpose, transpose, (int*)&mA, (int*)&nC, (int*)&mC, &B[mB*col+row], &A[ka], (int*)&mA, &C[0], (int*)&mC, &one, &D[kd], (int*)&mA);
ka += shiftA;
}
kd += shiftD;
......@@ -55,7 +63,7 @@ void full_A_times_kronecker_B_B(double *A, double *B, double *D, mwSize mA, mwSi
ka = 0 ;
for(unsigned long int row=0; row<mB; row++)
{
dgemm(transpose, transpose, (int*)&mA, (int*)&nB, (int*)&mB, &B[mB*col+row], &A[ka], (int*)&mA, &B[0], (int*)&mB, &one, &D[kd], (int*)&mA);
DGEMM(transpose, transpose, (int*)&mA, (int*)&nB, (int*)&mB, &B[mB*col+row], &A[ka], (int*)&mA, &B[0], (int*)&mB, &one, &D[kd], (int*)&mA);
ka += shiftA;
}
kd += shiftD;
......
#include <string.h>
#include "mex.h"
#if defined(__linux__)
# define DGGES dgees_
#else
# define DGGES dgees
#endif
/* GAUSS interface */
void mjdgges(double *a, double *b, double *z, double *n, double *sdim, double *eval_r, double *eval_i, double *info);
......@@ -28,7 +35,7 @@ void mjdgges(double *a, double *b, double *z, double *n, double *sdim, double *e
/* made necessary by bug in Lapack */
junk = mxCalloc(i_n*i_n,sizeof(double));
dgges_( "N", "V", "S", (int *)my_criteria, &i_n, a, &i_n, b, &i_n, &i_sdim, alphar, alphai, beta, junk, &i_n, z, &i_n, work, &lwork, bwork, &i_info );
DGGES( "N", "V", "S", (int *)my_criteria, &i_n, a, &i_n, b, &i_n, &i_sdim, alphar, alphai, beta, junk, &i_n, z, &i_n, work, &lwork, bwork, &i_info );
*sdim = i_sdim;
*info = i_info;
......
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