public static void main(String[] _args) {

		final int NUMELEMENTS = 40;
		Point[] inArray = new Point[NUMELEMENTS];
		float[] outArray = new float[NUMELEMENTS];

		String sourceFileName = "ooparray.hsail";
		String source = null;
		try {
			source = 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, source, "&run");
		if (!kernel.isValid()) {System.out.println("...unable to create kernel"); System.exit(-1);}

		// initialize inArray
		for (int i=0; i<NUMELEMENTS; i++) {
			inArray[i] = new Point(i, i+1, i+2);
			// System.out.println("ref=" + inArray[i]);
			// context.registerObjectMemory(inArray[i], 64);
			// inArray[i].show();
		}
		
		kernel.clearArgs();
		kernel.pushFloatArrayArg(outArray);
		kernel.pushObjectArrayArg(inArray);

		kernel.setLaunchAttributes(NUMELEMENTS); // 1 dimension

		kernel.dispatchKernelWaitComplete();

		boolean passed = true;
		for (int i=0; i<NUMELEMENTS; i++) {
			System.out.print(i + "->" +  showFloat(outArray[i]) + ",  ");
			if (i%5 == 4) System.out.println();
			float expected = (float)Math.sqrt(i*i + (i+1)*(i+1) + (i+2)*(i+2));
			if (outArray[i] != expected) {
				passed = false;
			}
		}
		System.out.println((passed ? "PASSED": "FAILED") + "\n");
	}