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.graalvm.compiler.test.AddExports; 38 import org.junit.Before; 39 import org.junit.Test; 40 import org.junit.runner.RunWith; 41 import org.junit.runners.Parameterized; 42 import org.junit.runners.Parameterized.Parameter; 43 import org.junit.runners.Parameterized.Parameters; 44 45 import jdk.vm.ci.amd64.AMD64; 46 47 @AddExports({"java.base/java.lang"}) 48 @RunWith(Parameterized.class) 49 public final class MathDoubleFMATest extends GraalCompilerTest { 50 51 @Before 52 public void checkAMD64() { 53 assumeTrue("skipping AMD64 specific test", getTarget().arch instanceof AMD64); 54 HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class); 55 assumeTrue("skipping FMA specific test", rt.getVMConfig().useFMAIntrinsics); 56 } 57 58 @Parameters(name = "{0}, {1}, {2}") 59 public static Collection<Object[]> data() { 60 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, 61 Double.NaN, Double.longBitsToDouble(0xfff0000000000001L)}; 62 63 List<Object[]> tests = new ArrayList<>(); 64 for (double a : inputs) { 65 for (double b : inputs) { 66 for (double c : inputs) { 67 tests.add(new Object[]{a, b, c}); 68 } 69 } 70 } 71 return tests; 72 } 73 74 @Parameter(value = 0) public double input0; 75 @Parameter(value = 1) public double input1; 76 @Parameter(value = 2) public double input2; 77 78 public static double fma(double a, double b, double c) { 79 return Math.fma(a, b, c); 80 } 81 82 @Test 83 public void testFMA() { 84 test("fma", input0, input1, input2); 85 } 86 87 }