public static void main(String[] _args) {

		final int NUMELEMENTS = 40;
		double[] inArray = new double[NUMELEMENTS];
		double[] outArray = new double[NUMELEMENTS];

		// initialize inArray
		for (int i=0; i<NUMELEMENTS; i++) {
			inArray[i] = (double)i;
		}
	
		String sourceFileName = "SquaresDbl.hsail";
		String squaresSource = null;
		try {
			squaresSource = new String(Files.readAllBytes(FileSystems.getDefault().getPath( sourceFileName)));
		}
		catch(IOException e) {
			e.printStackTrace();
			System.exit(-1);
		}

		OkraContext context = new OkraContext();
		if (!context.isValid()) {System.out.println("...unable to create context"); System.exit(-1);}
		OkraKernel kernel = new OkraKernel(context, squaresSource, "&run");
		if (!kernel.isValid()) {System.out.println("...unable to create kernel"); System.exit(-1);}
		
		kernel.setLaunchAttributes(NUMELEMENTS); // 1 dimension

		for (int j=1; j<=3; j++) {
			kernel.clearArgs();
			kernel.pushDoubleArrayArg(outArray);
			kernel.pushDoubleArrayArg(inArray);
			double adjustment = j * 0.123;
			kernel.pushDoubleArg(adjustment);
			
			kernel.dispatchKernelWaitComplete();

			boolean passed = true;
			for (int i=0; i<NUMELEMENTS; i++) {
				System.out.print(i + "->" +  outArray[i] + ",  ");
				if (outArray[i] != i*i + adjustment) passed = false;
			}
			System.out.println((passed ? "\nPASSED": "\nFAILED") + "\n");
		}
	}