Class JCudaUtils


  • public class JCudaUtils
    extends Object
    Adapted from JCuda examples: Reads a CUDA file, compiles it to a PTX file using NVCC, loads the PTX file as a module and executes the kernel function.
    • Constructor Detail

      • JCudaUtils

        public JCudaUtils()
    • Method Detail

      • preparePtxFile

        public static String preparePtxFile​(InputStream cuFileStream,
                                            String arch)
                                     throws IOException,
                                            URISyntaxException
        The extension of the given file name is replaced with "ptx". If the file with the resulting name does not exist, it is compiled from the given file using NVCC. The name of the PTX file is returned.
        Parameters:
        cuFileStream - The name of the .cu file
        arch - String specifying the architecture (see nvcc command, -arch argument). Examples are sm_12, sm_20, sm_30
        Returns:
        The name of the PTX file.
        Throws:
        IOException - Thrown if an I/O error occurs.
        URISyntaxException - Thrown if the cuFileURL cannot be converted to an URI.