/** Lists all available OpenCL implementations. */ public static CLPlatform[] listPlatforms() { Pointer<Integer> pCount = allocateInt(); error(getPlatformIDs(0, null, pCount)); int nPlats = pCount.get(); if (nPlats == 0) return new CLPlatform[0]; Pointer<cl_platform_id> ids = allocateTypedPointers(cl_platform_id.class, nPlats); error(getPlatformIDs(nPlats, ids, null)); CLPlatform[] platforms = new CLPlatform[nPlats]; for (int i = 0; i < nPlats; i++) { platforms[i] = new CLPlatform(ids.get(i)); } return platforms; }
public boolean isValid() { Pointer<Integer> pCount = allocateInt(); int err; try { err = clIcdGetPlatformIDsKHR(0, null, pCount); } catch (Throwable th) { try { err = clGetPlatformIDs(0, null, pCount); } catch (Throwable th2) { return false; } } return err == OpenCLLibrary.CL_SUCCESS && pCount.get() > 0; }