Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001, Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2.1 of the GNU Lesser General Public License 00007 as published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this program; if not, write the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00023 USA. 00024 00025 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00026 Mountain View, CA 94043, or: 00027 00028 http://www.sgi.com 00029 00030 For further information regarding this notice, see: 00031 00032 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00033 00034 */ 00035 00036 00037 00038 #pragma ident "@(#) libf/fio/setstride.c 92.2 06/21/99 10:37:55" 00039 00040 #include <fortran.h> 00041 #include <memory.h> 00042 #include <cray/nassert.h> 00043 #include <cray/portdefs.h> 00044 #if defined(__mips) || defined(_LITTLE_ENDIAN) 00045 struct eightby { int w[2]; }; 00046 struct sixteenby { int w[4]; }; 00047 struct thirtytwoby { int w[8]; }; 00048 #else 00049 struct biword { long w[2]; }; 00050 00051 struct quadword { long w[4]; }; 00052 #endif 00053 #define BYTE unsigned char 00054 00055 #if defined(__mips) || defined(_LITTLE_ENDIAN) 00056 #define EIGHTBWORD struct eightby 00057 #define DOUBLEWORD struct sixteenby 00058 #define QUADWORD struct thirtytwoby 00059 #else 00060 #define WORD int64 00061 #ifdef _CRAYMPP /* Temporary until `long double' is implemented */ 00062 #define DOUBLEWORD struct biword 00063 #elif !defined(_WORD32) 00064 #define DOUBLEWORD long double 00065 #else 00066 #define DOUBLEWORD long long 00067 #endif 00068 00069 #define QUADWORD struct quadword 00070 #endif 00071 00072 #define XFER_CASE(TYPE) \ 00073 { \ 00074 register TYPE datum; \ 00075 TYPE *data; \ 00076 datum = *(TYPE *)src; \ 00077 data = (TYPE *)dest; \ 00078 for (i = 0; i < count; i++) \ 00079 data[i*inc] = datum; \ 00080 } \ 00081 00082 /* 00083 * _set_stride Copies an item consisting of a contiguous chunk of 00084 * bytes into a strided vector of items. This is a 00085 * generalized version of memcpy() and memwcpy(), with 00086 * support for striding and item sizes of greater than 00087 * one byte or one word. 00088 */ 00089 void 00090 _set_stride( 00091 void *dest, /* Destination address */ 00092 void *src, /* Source address */ 00093 long count, /* Number of items to transfer */ 00094 int elsize, /* Size of each item, in bytes */ 00095 long stride) /* Stride between items (bytes) */ 00096 { 00097 register int i; 00098 register long inc; /* Stride between items (in elsize units) */ 00099 00100 /* Assertions */ 00101 00102 assert (dest != NULL); 00103 assert (src != NULL); 00104 assert (count > 0); 00105 assert (elsize > 0); 00106 00107 inc = stride / elsize; 00108 00109 switch (elsize) { 00110 00111 case 1: 00112 XFER_CASE(BYTE) /* does not vectorize */ 00113 break; 00114 00115 #ifdef _F_INT2 00116 case 2: 00117 XFER_CASE(short) /* Temporary until _f_int2 */ 00118 break; 00119 #endif 00120 00121 #ifdef _F_INT4 00122 case 4: 00123 XFER_CASE(_f_int4) 00124 break; 00125 #endif 00126 00127 case 8: 00128 #if defined(__mips) || defined(_LITTLE_ENDIAN) 00129 XFER_CASE(EIGHTBWORD) 00130 #else 00131 XFER_CASE(_f_int8) /* vectorizes! */ 00132 #endif 00133 break; 00134 00135 case 16: 00136 XFER_CASE(DOUBLEWORD) /* vectorizes! */ 00137 break; 00138 00139 case 32: 00140 XFER_CASE(QUADWORD) /* should vectorize with CC 4.0 (?) */ 00141 break; 00142 00143 default: 00144 for (i = 0; i < count; i++) 00145 (void) memcpy((char *)dest + i*inc, src, elsize); 00146 } /* switch */ 00147 00148 return; 00149 }