1 /* 2 * Copyright (c) 2019, 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 25 package org.graalvm.compiler.hotspot.jdk9.test; 26 27 import static org.junit.Assume.assumeTrue; 28 29 import java.util.ArrayList; 30 import java.util.Collection; 31 import java.util.List; 32 33 import org.graalvm.compiler.api.test.Graal; 34 import org.graalvm.compiler.core.test.GraalCompilerTest; 35 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider; 36 import org.graalvm.compiler.runtime.RuntimeProvider; 37 import org.junit.Before; 38 import org.junit.Test; 39 import org.junit.runner.RunWith; 40 import org.junit.runners.Parameterized; 41 import org.junit.runners.Parameterized.Parameter; 42 import org.junit.runners.Parameterized.Parameters; 43 44 import jdk.vm.ci.amd64.AMD64; 45 46 @RunWith(Parameterized.class) 47 public final class MathDoubleFMATest extends GraalCompilerTest { 48 49 @Before 50 public void checkAMD64() { 51 assumeTrue("skipping AMD64 specific test", getTarget().arch instanceof AMD64); 52 HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class); 53 assumeTrue("skipping FMA specific test", rt.getVMConfig().useFMAIntrinsics); 54 } 55 56 @Parameters(name = "{0}, {1}, {2}") 57 public static Collection<Object[]> data() { 58 double[] inputs = {0.0d, 1.0d, 4.0d, -0.0d, -1.0d, -4.0d, Double.MIN_VALUE, Double.MAX_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 59 Double.NaN, Double.longBitsToDouble(0xfff0000000000001L)}; 60 61 List<Object[]> tests = new ArrayList<>(); 62 for (double a : inputs) { 63 for (double b : inputs) { 64 for (double c : inputs) { 65 tests.add(new Object[]{a, b, c}); 66 } 67 } 68 } 69 return tests; 70 } 71 72 @Parameter(value = 0) public double input0; 73 @Parameter(value = 1) public double input1; 74 @Parameter(value = 2) public double input2; 75 76 public static double fma(double a, double b, double c) { 77 return Math.fma(a, b, c); 78 } 79 80 @Test 81 public void testFMA() { 82 test("fma", input0, input1, input2); 83 } 84 85 }