1 /*
   2  * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package com.oracle.graal.compiler.hsail.test;
  25 
  26 import java.util.*;
  27 import org.junit.*;
  28 import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
  29 
  30 /**
  31  * Tests integer to long conversion.
  32  */
  33 public class IntLongConvertTest extends GraalKernelTester {
  34 
  35     static final int size = 128;
  36     static final int[] inputInt = new int[size];
  37     static final long[] inputLong = new long[size];
  38     @Result static final int[] outputInt = new int[size];
  39     @Result static final long[] outputLong = new long[size];
  40     static int[] seedInt = new int[size];
  41     {
  42         for (int i = 0; i < seedInt.length; i++) {
  43             seedInt[i] = (int) Math.random();
  44         }
  45     }
  46     static long[] seedLong = new long[size];
  47     {
  48         for (int i = 0; i < seedLong.length; i++) {
  49             seedLong[i] = (long) Math.random();
  50         }
  51     }
  52 
  53     public static void run(int[] inInt, long[] inLong, int[] outInt, long[] outLong, int gid) {
  54         outInt[gid] = (int) inLong[gid];
  55         outLong[gid] = inInt[gid];
  56     }
  57 
  58     @Override
  59     public void runTest() {
  60         System.arraycopy(seedLong, 0, inputLong, 0, seedLong.length);
  61         Arrays.fill(outputLong, 0);
  62         System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
  63         Arrays.fill(outputInt, 0);
  64         dispatchMethodKernel(64, inputInt, inputLong, outputInt, outputLong);
  65     }
  66 
  67     @Test
  68     public void test() {
  69         testGeneratedHsail();
  70     }
  71 }