All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.komputation.cuda.kernels.Kernel.kt Maven / Gradle / Ivy

Go to download

Komputation is a neural network framework for the JVM written in the Kotlin programming language.

There is a newer version: 0.12.5
Show newest version
package com.komputation.cuda.kernels

import jcuda.Pointer
import jcuda.driver.CUfunction
import jcuda.nvrtc.JNvrtc.nvrtcDestroyProgram
import jcuda.nvrtc.nvrtcProgram

class Kernel(
    private val computeCapabilities : Pair,
    private val sourceCode : String,
    private val name : String,
    private val nameExpression : String,
    private val headers : Array,
    private val includeNames : Array) {

    private val program = nvrtcProgram()
    private val kernel = CUfunction()

    init {

        compileKernel(this.program, this.computeCapabilities, this.sourceCode, this.name, arrayOf(this.nameExpression), this.headers, this.includeNames)

        loadKernel(this.kernel, this.program, this.nameExpression)

    }

    fun launch(pointerToParameters: Pointer, numberBlocksInXDimension : Int, numberBlocksInYDimension : Int, numberThreadsPerBlock : Int, sharedMemoryBytes : Int) =

        launchKernel(this.kernel, pointerToParameters, numberBlocksInXDimension, numberBlocksInYDimension, numberThreadsPerBlock, sharedMemoryBytes)

    fun destroy() {

        nvrtcDestroyProgram(this.program)

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy