/** * Extracts resources using the {@link ClassLoader} of the caller class, * and returns the cached {@link File} objects. * * @param name of the resources passed to {@link #findResources(Class, String)} * @see #cacheResources(Class, String) */ public static File[] cacheResources(String name) throws IOException { Class cls = getCallerClass(2); return cacheResources(cls, name); } /**
/** * Extracts by name resources using the {@link ClassLoader} of the caller. * * @param name of the resources passed to {@link #findResources(Class, String)} * @see #extractResources(Class, String, File, String, String) */ public static File[] extractResources(String name, File directory, String prefix, String suffix) throws IOException { Class cls = getCallerClass(2); return extractResources(cls, name, directory, prefix, suffix); } /**
/** * Extracts a resource using the {@link ClassLoader} of the caller class, * and returns the cached {@link File}. * * @param name the name of the resource passed to {@link Class#getResource(String)} * @see #cacheResource(Class, String) */ public static File cacheResource(String name) throws IOException { Class cls = getCallerClass(2); return cacheResource(cls, name); } /**
/** * Extracts by name a resource using the {@link ClassLoader} of the caller. * * @param name the name of the resource passed to {@link Class#getResource(String)} * @see #extractResource(URL, File, String, String) */ public static File extractResource(String name, File directory, String prefix, String suffix) throws IOException { Class cls = getCallerClass(2); return extractResource(cls, name, directory, prefix, suffix); } /**
/** Returns {@code load(getCallerClass(2), loadProperties(), Loader.pathsFirst)}. */ public static String load() { return load(getCallerClass(2), loadProperties(), Loader.pathsFirst); } /**
/** * Loads native libraries associated with the {@link Class} of the caller. * * @param pathsFirst search the paths first before bundled resources * @return {@code load(getCallerClass(2), loadProperties(), pathsFirst) } * @see #getCallerClass(int) * @see #load(Class, Properties, boolean) */ public static String load(boolean pathsFirst) { Class cls = getCallerClass(2); return load(cls, loadProperties(), pathsFirst); } /** Returns {@code load(cls, loadProperties(), Loader.pathsFirst)}. */
public CLKernel buildKernel(String resourceNames, String kernelName) { return buildKernels(fastCompilerOptions, Loader.getCallerClass(2), resourceNames, kernelName)[0]; } public CLKernel buildKernel(String compilerOptions, String resourceNames, String kernelName) {
public CLKernel buildKernel(String compilerOptions, String resourceNames, String kernelName) { return buildKernels(compilerOptions, Loader.getCallerClass(2), resourceNames, kernelName)[0]; }
public CLKernel[] buildKernels(String compilerOptions, Class resourceClass, String resourceNames, String ... kernelNames) { try { //load and compile program for the chosen device InputStream s; String[] a = resourceNames.split(":"); if (a.length == 1) { s = resourceClass.getResourceAsStream(a[0]); } else { Vector<InputStream> vs = new Vector<InputStream>(a.length); for (String name : a) { vs.addElement(resourceClass.getResourceAsStream(name)); } s = new SequenceInputStream(vs.elements()); } CLProgram program = context.createProgram(s); //System.out.println("Building " + resourceNames + "..."); program.build(compilerOptions); //System.out.println(program.getBuildLog()); assert program.isExecutable(); // create kernel and set function parameters CLKernel[] kernels = new CLKernel[kernelNames.length]; for (int i = 0; i < kernelNames.length; i++) { kernels[i] = program.createCLKernel(kernelNames[i]); } return kernels; } catch(IOException ex) { throw (Error)new LinkageError(ex.toString()).initCause(ex); } }