/**
 * Copyright (c) 2016 - 2018 Syncleus, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.aparapi.runtime;

import com.aparapi.Kernel;
import com.aparapi.Range;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class IntArray2DTest {
    @Test
    public void test() {
        int size = 1048576;
        final int count = 3;
        final int[][] V = new int[count][size];

        //lets fill in V randomly...
        for (int j = 0; j < count; j++) {
            for (int i = 0; i < size; i++) {
                //random number either 0, 1, or 2
                V[j][i] = (int) (Math.random() * 3);
            }
        }

        Kernel sumConstantKernel= null;
        final int totals[][] = V;
        try {
            sumConstantKernel = new Kernel() {
                @Override
                public void run() {
                    int gid = getGlobalId();
                    for(int index = 0; index < count; index++) {
                        totals[index][gid] += gid + 1;
                    }
                }
            };
            sumConstantKernel.execute(Range.create(size));
        } finally {
            sumConstantKernel.dispose();
        }

        for (int index = 0; index < count; index++) {
            for (int gid = 0; gid < size; gid++) {
                assertEquals(V[index][gid] + gid + 1, totals[index][gid]);
            }
        }
    }
}
@@ -845,14 +845,10 @@
  = 1
-048576
+28
 ;%0A  

Simplify test for issue #152 (refs #153)