Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "f90_intrinsic.h"
00039
00040 void
00041 _TRANS(
00042 DopeVectorType *result,
00043 DopeVectorType *matrix)
00044 {
00045 char * result_p, * result_b ;
00046 char * matrix_p, * matrix_b ;
00047
00048 size_t src_extent [MAX_NARY_DIMS] ;
00049 size_t src_stride [MAX_NARY_DIMS] ;
00050 size_t src_offset [MAX_NARY_DIMS] ;
00051 size_t counter[MAX_NARY_DIMS] ;
00052
00053 size_t res_stride [MAX_NARY_DIMS] ;
00054 size_t res_extent [MAX_NARY_DIMS] ;
00055 size_t res_offset [MAX_NARY_DIMS] ;
00056
00057 int32_t j,ii;
00058 char *rp, *ap ;
00059 int32_t res_rank ;
00060 int32_t src_rank = GET_RANK_FROM_DESC(matrix) - 1;
00061
00062 size_t typ_sz = GET_ELEMENT_SZ_FROM_DESC(matrix);
00063
00064 size_t a_size,a_stride,r_stride, i,k ;
00065 int8_t zero_szd_source = FALSE;
00066 int8_t byte_aligned = FALSE;
00067
00068 int32_t ddim ;
00069
00070 size_t num_trues ;
00071 int32_t local_alloc ;
00072 size_t tot_ext ;
00073 size_t str_sz ;
00074
00075 size_t src_size ;
00076
00077 size_t res_sz;
00078 size_t xfer_sz;
00079 size_t tot_sz;
00080
00081 for ( j = 0 ; j <= src_rank ; j ++ ) {
00082 src_extent[j] = GET_EXTENT_FROM_DESC(matrix,j) ;
00083 src_stride[j] = GET_STRIDE_FROM_DESC(matrix,j) ;
00084 counter[j] = 0 ;
00085 zero_szd_source = zero_szd_source || (src_extent[j] == 0) ;
00086 }
00087
00088 byte_aligned = GET_BYTEALIGNED_FROM_DESC(matrix) ;
00089
00090 if (!GET_ASSOCIATED_FROM_DESC(result)) {
00091
00092 size_t nbytes ;
00093 size_t ext ;
00094 char *p ;
00095
00096 SET_ADDRESS_IN_DESC(result,NULL);
00097 SET_ORIG_BS_IN_DESC(result,NULL) ;
00098 SET_ORIG_SZ_IN_DESC(result,0) ;
00099
00100 p = NULL ;
00101 tot_ext = 1 ;
00102 nbytes = typ_sz ;
00103 str_sz = MK_STRIDE(byte_aligned,typ_sz);
00104
00105 for ( i = 0 ; i <= src_rank ; i ++) {
00106 ext = GET_EXTENT_FROM_DESC(matrix,src_rank-i) ;
00107 SET_LBOUND_IN_DESC(result,i,1);
00108 SET_EXTENT_IN_DESC(result,i,ext);
00109 SET_STRMULT_IN_DESC(result,i,tot_ext * str_sz );
00110 tot_ext *= ext;
00111 nbytes *= ext;
00112 }
00113
00114 if (nbytes > 0) {
00115 p = (void *) malloc (nbytes);
00116 if (p == NULL)
00117 ERROR(_LELVL_ABORT, FENOMEMY);
00118
00119 SET_ADDRESS_IN_DESC(result,p);
00120 }
00121
00122 SET_CONTIG_IN_DESC(result);
00123 SET_ASSOCIATED_IN_DESC(result);
00124 if (GET_DV_ASCII_FROM_DESC(matrix)) {
00125 SET_CHARPTR_IN_DESC(result,p,typ_sz);
00126 }
00127 SET_ORIG_BS_IN_DESC(result,p) ;
00128 SET_ORIG_SZ_IN_DESC(result,nbytes * 8) ;
00129 }
00130
00131 for ( j = 0 ; j <= src_rank ; j ++ ) {
00132 res_stride [j] = GET_STRIDE_FROM_DESC(result,src_rank - j) ;
00133 }
00134
00135 for ( j = 1 ; j <= src_rank ; j ++ ) {
00136 src_offset[j-1] = src_stride[j] - (src_stride [j-1] * (src_extent[j-1])) ;
00137 res_offset[j-1] = res_stride[j] - (res_stride [j-1] * (src_extent[j-1])) ;
00138 }
00139
00140 if (zero_szd_source)
00141 return ;
00142
00143 a_size = src_extent[0] ;
00144 a_stride = src_stride[0] ;
00145 r_stride = res_stride[0] ;
00146 matrix_p = GET_ADDRESS_FROM_DESC(matrix);
00147 result_p = GET_ADDRESS_FROM_DESC(result);
00148
00149 {
00150 while (counter[src_rank] < src_extent[src_rank] ) {
00151 for ( i = 0 ; i < a_size ; i ++ ) {
00152 ap = matrix_p ;
00153 rp = result_p ;
00154 if (typ_sz > BIGDEFAULTSZ)
00155 (void) memcpy (rp, ap, typ_sz);
00156 else
00157 for (j = 0 ; j < typ_sz ; j ++) *rp++ = *ap ++ ;
00158 matrix_p += a_stride ;
00159 result_p += r_stride ;
00160 }
00161 counter[0] = a_size ;
00162 j = 0 ;
00163 while ((counter[j] == src_extent[j]) && (j < src_rank)) {
00164 matrix_p += src_offset[j] ;
00165 result_p += res_offset[j] ;
00166 counter[j+1]++ ;
00167 counter[j] = 0 ;
00168 j ++ ;
00169 }
00170
00171 }
00172 }
00173 }