Austin Schuh | 9a24b37 | 2018-01-28 16:12:29 -0800 | [diff] [blame] | 1 | /************************************************************************************************** |
| 2 | * * |
| 3 | * This file is part of BLASFEO. * |
| 4 | * * |
| 5 | * BLASFEO -- BLAS For Embedded Optimization. * |
| 6 | * Copyright (C) 2016-2017 by Gianluca Frison. * |
| 7 | * Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * |
| 8 | * All rights reserved. * |
| 9 | * * |
| 10 | * HPMPC is free software; you can redistribute it and/or * |
| 11 | * modify it under the terms of the GNU Lesser General Public * |
| 12 | * License as published by the Free Software Foundation; either * |
| 13 | * version 2.1 of the License, or (at your option) any later version. * |
| 14 | * * |
| 15 | * HPMPC is distributed in the hope that it will be useful, * |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
| 18 | * See the GNU Lesser General Public License for more details. * |
| 19 | * * |
| 20 | * You should have received a copy of the GNU Lesser General Public * |
| 21 | * License along with HPMPC; if not, write to the Free Software * |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
| 23 | * * |
| 24 | * Author: Gianluca Frison, giaf (at) dtu.dk * |
| 25 | * gianluca.frison (at) imtek.uni-freiburg.de * |
| 26 | * * |
| 27 | **************************************************************************************************/ |
| 28 | |
| 29 | |
| 30 | #ifdef __cplusplus |
| 31 | extern "C" { |
| 32 | #endif |
| 33 | |
| 34 | |
| 35 | |
| 36 | #ifndef BLASFEO_COMMON |
| 37 | #define BLASFEO_COMMON |
| 38 | |
| 39 | |
| 40 | |
| 41 | #if defined(LA_HIGH_PERFORMANCE) |
| 42 | |
| 43 | #include "blasfeo_block_size.h" |
| 44 | |
| 45 | // matrix structure |
| 46 | struct d_strmat |
| 47 | { |
| 48 | int m; // rows |
| 49 | int n; // cols |
| 50 | int pm; // packed number or rows |
| 51 | int cn; // packed number or cols |
| 52 | double *pA; // pointer to a pm*pn array of doubles, the first is aligned to cache line size |
| 53 | double *dA; // pointer to a min(m,n) (or max???) array of doubles |
| 54 | int use_dA; // flag to tell if dA can be used |
| 55 | int memory_size; // size of needed memory |
| 56 | }; |
| 57 | |
| 58 | struct s_strmat |
| 59 | { |
| 60 | int m; // rows |
| 61 | int n; // cols |
| 62 | int pm; // packed number or rows |
| 63 | int cn; // packed number or cols |
| 64 | float *pA; // pointer to a pm*pn array of floats, the first is aligned to cache line size |
| 65 | float *dA; // pointer to a min(m,n) (or max???) array of floats |
| 66 | int use_dA; // flag to tell if dA can be used |
| 67 | int memory_size; // size of needed memory |
| 68 | }; |
| 69 | |
| 70 | // vector structure |
| 71 | struct d_strvec |
| 72 | { |
| 73 | int m; // size |
| 74 | int pm; // packed size |
| 75 | double *pa; // pointer to a pm array of doubles, the first is aligned to cache line size |
| 76 | int memory_size; // size of needed memory |
| 77 | }; |
| 78 | |
| 79 | struct s_strvec |
| 80 | { |
| 81 | int m; // size |
| 82 | int pm; // packed size |
| 83 | float *pa; // pointer to a pm array of floats, the first is aligned to cache line size |
| 84 | int memory_size; // size of needed memory |
| 85 | }; |
| 86 | |
| 87 | #define DMATEL_LIBSTR(sA,ai,aj) ((sA)->pA[((ai)-((ai)&(D_PS-1)))*(sA)->cn+(aj)*D_PS+((ai)&(D_PS-1))]) |
| 88 | #define SMATEL_LIBSTR(sA,ai,aj) ((sA)->pA[((ai)-((ai)&(S_PS-1)))*(sA)->cn+(aj)*S_PS+((ai)&(S_PS-1))]) |
| 89 | #define DVECEL_LIBSTR(sa,ai) ((sa)->pa[ai]) |
| 90 | #define SVECEL_LIBSTR(sa,ai) ((sa)->pa[ai]) |
| 91 | |
| 92 | #elif defined(LA_BLAS) | defined(LA_REFERENCE) |
| 93 | |
| 94 | // matrix structure |
| 95 | struct d_strmat |
| 96 | { |
| 97 | int m; // rows |
| 98 | int n; // cols |
| 99 | double *pA; // pointer to a m*n array of doubles |
| 100 | double *dA; // pointer to a min(m,n) (or max???) array of doubles |
| 101 | int use_dA; // flag to tell if dA can be used |
| 102 | int memory_size; // size of needed memory |
| 103 | }; |
| 104 | |
| 105 | struct s_strmat |
| 106 | { |
| 107 | int m; // rows |
| 108 | int n; // cols |
| 109 | float *pA; // pointer to a m*n array of floats |
| 110 | float *dA; // pointer to a min(m,n) (or max???) array of floats |
| 111 | int use_dA; // flag to tell if dA can be used |
| 112 | int memory_size; // size of needed memory |
| 113 | }; |
| 114 | |
| 115 | // vector structure |
| 116 | struct d_strvec |
| 117 | { |
| 118 | int m; // size |
| 119 | double *pa; // pointer to a m array of doubles, the first is aligned to cache line size |
| 120 | int memory_size; // size of needed memory |
| 121 | }; |
| 122 | |
| 123 | struct s_strvec |
| 124 | { |
| 125 | int m; // size |
| 126 | float *pa; // pointer to a m array of floats, the first is aligned to cache line size |
| 127 | int memory_size; // size of needed memory |
| 128 | }; |
| 129 | |
| 130 | #define DMATEL_LIBSTR(sA,ai,aj) ((sA)->pA[(ai)+(aj)*(sA)->m]) |
| 131 | #define SMATEL_LIBSTR(sA,ai,aj) ((sA)->pA[(ai)+(aj)*(sA)->m]) |
| 132 | #define DVECEL_LIBSTR(sa,ai) ((sa)->pa[ai]) |
| 133 | #define SVECEL_LIBSTR(sa,ai) ((sa)->pa[ai]) |
| 134 | |
| 135 | #else |
| 136 | |
| 137 | #error : wrong LA choice |
| 138 | |
| 139 | #endif |
| 140 | |
| 141 | #endif // BLASFEO_COMMON |
| 142 | |
| 143 | |
| 144 | #ifdef __cplusplus |
| 145 | } |
| 146 | #endif |