1 /*
  2  * Copyright (c) 2021, 2022, 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 compiler.vectorapi.reshape.tests;
 25 
 26 import compiler.lib.ir_framework.IR;
 27 import compiler.lib.ir_framework.Run;
 28 import compiler.lib.ir_framework.Test;
 29 import jdk.incubator.foreign.MemorySegment;
 30 
 31 import static compiler.vectorapi.reshape.utils.VectorReshapeHelper.*;
 32 
 33 /**
 34  *  This class contains method to ensure a resizing reinterpretation operations work as
 35  *  intended.
 36  *
 37  *  In each test, the ReinterpretNode is expected to appear exactly once.
 38  */
 39 public class TestVectorExpandShrink {
 40     @Test
 41     @IR(counts = {REINTERPRET_NODE, "1"})
 42     public static void testB64toB128(MemorySegment input, MemorySegment output) {
 43         vectorExpandShrink(BSPEC64, BSPEC128, input, output);
 44     }
 45 
 46     @Run(test = "testB64toB128")
 47     public static void runB64toB128() throws Throwable {
 48         runExpandShrinkHelper(BSPEC64, BSPEC128);
 49     }
 50 
 51     @Test
 52     @IR(counts = {REINTERPRET_NODE, "1"})
 53     public static void testB64toB256(MemorySegment input, MemorySegment output) {
 54         vectorExpandShrink(BSPEC64, BSPEC256, input, output);
 55     }
 56 
 57     @Run(test = "testB64toB256")
 58     public static void runB64toB256() throws Throwable {
 59         runExpandShrinkHelper(BSPEC64, BSPEC256);
 60     }
 61 
 62     @Test
 63     @IR(counts = {REINTERPRET_NODE, "1"})
 64     public static void testB64toB512(MemorySegment input, MemorySegment output) {
 65         vectorExpandShrink(BSPEC64, BSPEC512, input, output);
 66     }
 67 
 68     @Run(test = "testB64toB512")
 69     public static void runB64toB512() throws Throwable {
 70         runExpandShrinkHelper(BSPEC64, BSPEC512);
 71     }
 72 
 73     @Test
 74     @IR(counts = {REINTERPRET_NODE, "1"})
 75     public static void testB128toB64(MemorySegment input, MemorySegment output) {
 76         vectorExpandShrink(BSPEC128, BSPEC64, input, output);
 77     }
 78 
 79     @Run(test = "testB128toB64")
 80     public static void runB128toB64() throws Throwable {
 81         runExpandShrinkHelper(BSPEC128, BSPEC64);
 82     }
 83 
 84     @Test
 85     @IR(counts = {REINTERPRET_NODE, "1"})
 86     public static void testB128toB256(MemorySegment input, MemorySegment output) {
 87         vectorExpandShrink(BSPEC128, BSPEC256, input, output);
 88     }
 89 
 90     @Run(test = "testB128toB256")
 91     public static void runB128toB256() throws Throwable {
 92         runExpandShrinkHelper(BSPEC128, BSPEC256);
 93     }
 94 
 95     @Test
 96     @IR(counts = {REINTERPRET_NODE, "1"})
 97     public static void testB128toB512(MemorySegment input, MemorySegment output) {
 98         vectorExpandShrink(BSPEC128, BSPEC512, input, output);
 99     }
100 
101     @Run(test = "testB128toB512")
102     public static void runB128toB512() throws Throwable {
103         runExpandShrinkHelper(BSPEC128, BSPEC512);
104     }
105 
106     @Test
107     @IR(counts = {REINTERPRET_NODE, "1"})
108     public static void testB256toB64(MemorySegment input, MemorySegment output) {
109         vectorExpandShrink(BSPEC256, BSPEC64, input, output);
110     }
111 
112     @Run(test = "testB256toB64")
113     public static void runB256toB64() throws Throwable {
114         runExpandShrinkHelper(BSPEC256, BSPEC64);
115     }
116 
117     @Test
118     @IR(counts = {REINTERPRET_NODE, "1"})
119     public static void testB256toB128(MemorySegment input, MemorySegment output) {
120         vectorExpandShrink(BSPEC256, BSPEC128, input, output);
121     }
122 
123     @Run(test = "testB256toB128")
124     public static void runB256toB128() throws Throwable {
125         runExpandShrinkHelper(BSPEC256, BSPEC128);
126     }
127 
128     @Test
129     @IR(counts = {REINTERPRET_NODE, "1"})
130     public static void testB256toB512(MemorySegment input, MemorySegment output) {
131         vectorExpandShrink(BSPEC256, BSPEC512, input, output);
132     }
133 
134     @Run(test = "testB256toB512")
135     public static void runB256toB512() throws Throwable {
136         runExpandShrinkHelper(BSPEC256, BSPEC512);
137     }
138 
139     @Test
140     @IR(counts = {REINTERPRET_NODE, "1"})
141     public static void testB512toB64(MemorySegment input, MemorySegment output) {
142         vectorExpandShrink(BSPEC512, BSPEC64, input, output);
143     }
144 
145     @Run(test = "testB512toB64")
146     public static void runB512toB64() throws Throwable {
147         runExpandShrinkHelper(BSPEC512, BSPEC64);
148     }
149 
150     @Test
151     @IR(counts = {REINTERPRET_NODE, "1"})
152     public static void testB512toB128(MemorySegment input, MemorySegment output) {
153         vectorExpandShrink(BSPEC512, BSPEC128, input, output);
154     }
155 
156     @Run(test = "testB512toB128")
157     public static void runB512toB128() throws Throwable {
158         runExpandShrinkHelper(BSPEC512, BSPEC128);
159     }
160 
161     @Test
162     @IR(counts = {REINTERPRET_NODE, "1"})
163     public static void testB512toB256(MemorySegment input, MemorySegment output) {
164         vectorExpandShrink(BSPEC512, BSPEC256, input, output);
165     }
166 
167     @Run(test = "testB512toB256")
168     public static void runB512toB256() throws Throwable {
169         runExpandShrinkHelper(BSPEC512, BSPEC256);
170     }
171 }
--- EOF ---