aboutsummaryrefslogtreecommitdiffstats
path: root/include/nvgpu/nvlink.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/nvgpu/nvlink.h')
0 files changed, 0 insertions, 0 deletions
f='#n36'>36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
/*
  This program is part of the TACLeBench benchmark suite.
  Version V 1.x

  Name: ndes

  Author: unknown

  Function: A lot of bit manipulation, shifts, array and matrix calculations.

  Source:

  Changes: no major functional changes

  License: May be used, modified, and re-distributed freely.

*/

/* A read from this address will result in an known value of 1 */
#include "extra.h"
#define KNOWN_VALUE 1
#define NDES_WORSTCASE 1
/*
  Declaration of global variables
*/

typedef struct NDES_IMMENSE {
  unsigned long l, r;
} ndes_immense;
typedef struct NDES_GREAT {
  unsigned long l, c, r;
} ndes_great;

unsigned long ndes_bit[33];
ndes_immense ndes_inp, ndes_key, ndes_out;
int ndes_newkey, ndes_isw;

static ndes_immense ndes_icd;
static char ndes_ipc1[57];
static char ndes_ipc2[49];


#ifdef NDES_WORSTCASE
int ndes_value = 1;
#else
int ndes_value = 0;
#endif

/* Forward funtion prototypes */

void ndes_des( ndes_immense inp, ndes_immense key, int *newkey, int isw,
               ndes_immense *out );
void ndes_cyfun( unsigned long ir, ndes_great k, unsigned long *iout );
unsigned long ndes_getbit( ndes_immense source, int bitno, int nbits );
void ndes_ks( /*immense key, */int n, ndes_great *kn );
void ndes_init( void );
int ndes_return( void );
void ndes_main( void );
//int main( void );

/*
   Initialization
*/
void ndes_init()
{
  unsigned int i;
  volatile char ndes_ipc1_tmp[57] = {
    0, 57, 49, 41, 33, 25, 17, 9, 1, 58, 50,
    42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60,
    52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38,
    30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
  };
  volatile char ndes_ipc2_tmp[49] = {
    0, 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21,
    10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31,
    37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34,
    53, 46, 42, 50, 36, 29, 32
  };
  for ( i = 0; i < 57; i++ )
    ndes_ipc1[i] = ndes_ipc1_tmp[i];
  for ( i = 0; i < 49; i++ )
    ndes_ipc2[i] = ndes_ipc2_tmp[i];

  ndes_inp.l = KNOWN_VALUE * 35;
  ndes_inp.r = KNOWN_VALUE * 26;
  ndes_key.l = KNOWN_VALUE * 2;
  ndes_key.r = KNOWN_VALUE * 16;

  ndes_newkey = ndes_value;
  ndes_isw = ndes_value;
}
/*
   Arithmetic functions
*/
void ndes_des( ndes_immense inp, ndes_immense key, int *newkey, int isw,
               ndes_immense *out )
{
  volatile char ip[65] = {
    0, 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36,
    28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40,
    32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35,
    27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39,
    31, 23, 15, 7
  };

  volatile char ipm[65] = {
    0, 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15,
    55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13,
    53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11,
    51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9,
    49, 17, 57, 25
  };
  static ndes_great kns[17];

  #ifdef NDES_WORSTCASE
  static int initflag = 1;
  #else
  static int initflag = 0;
  #endif

  int ii, i, j, k;
  unsigned long ic, shifter;
  ndes_immense itmp;
  ndes_great pg;

  if ( initflag ) {
    initflag = 0;
    ndes_bit[1] = shifter = 1L;

    _Pragma( "loopbound min 31 max 31" )
    for ( j = 2; j <= 32; j++ )
      ndes_bit[j] = ( shifter <<= 1 );
  }

  if ( *newkey ) {
    *newkey = 0;
    ndes_icd.r = ndes_icd.l = 0L;

    _Pragma( "loopbound min 28 max 28" )
    for ( j = 28, k = 56; j >= 1; j--, k-- ) {
      ndes_icd.r = ( ndes_icd.r << 1 ) | ndes_getbit( key, ndes_ipc1[j], 32 );
      ndes_icd.l = ndes_icd.l << 1;
      ndes_icd.l = ( ndes_icd.l ) | ndes_getbit( key, ndes_ipc1[k], 32 );
    }

    _Pragma( "loopbound min 16 max 16" )
    for ( i = 1; i <= 16; i++ ) {
      pg = kns[i];
      ndes_ks( /* key,*/ i, &pg );
      kns[i] = pg;
    }
  }

  itmp.r = itmp.l = 0L;

  _Pragma( "loopbound min 32 max 32" )
  for ( j = 32, k = 64; j >= 1; j--, k-- ) {
	itmp.r = itmp.r << 1;
    itmp.r = ( itmp.r ) | ndes_getbit( inp, ip[j], 32 );
	itmp.l = itmp.l << 1;
	itmp.l = ( itmp.l ) | ndes_getbit( inp, ip[k], 32 );
  }
  _Pragma( "loopbound min 16 max 16" )
  for ( i = 1; i <= 16; i++ ) {
    ii = ( isw == 1 ? 17 - i : i );
    ndes_cyfun( itmp.l, kns[ii], &ic );
    ic ^= itmp.r;
    itmp.r = itmp.l;
    itmp.l = ic;
  }

  ic = itmp.r;
  itmp.r = itmp.l;
  itmp.l = ic;
  ( *out ).r = ( *out ).l = 0L;

  _Pragma( "loopbound min 32 max 32" )
  for ( j = 32, k = 64; j >= 1; j--, k-- ) {
	( *out ).r = ( *out ).r << 1;