jcuda / jcuda-main

Summarizes the main JCuda libraries
MIT License
99 stars 20 forks source link

For the USAGE.md #46

Closed AvalonXD closed 2 years ago

AvalonXD commented 2 years ago

I had to update the gradle section to this

// Methods to determine the operating system (OS) and architecture (Arch) of the system.
// These strings are used to determine the classifier of the artifact that contains the
// native libaries. For example, when the operating system is "windows" and the
// architecture is "x86_64", then the classifier will be "windows-x86_64", and thus,
// the JAR file containing the native libraries will be
// jcuda-natives-windows-x86_64-11.0.0.jar
// These methods are taken from
// https://github.com/jcuda/jcuda/blob/master/JCudaJava/src/main/java/jcuda/LibUtils.java
def static getOsString() {
    String vendor = System.getProperty("java.vendor");
    if ("The Android Project" == vendor) {
        return "android";
    } else {
        String osName = System.getProperty("os.name");
        osName = osName.toLowerCase(Locale.ENGLISH);
        if (osName.startsWith("windows")) {
            return "windows";
        } else if (osName.startsWith("mac os")) {
            return "apple";
        } else if (osName.startsWith("linux")) {
            return "linux";
        } else if (osName.startsWith("sun")) {
            return "sun"
        }
        return "unknown"
    }
}

def static getArchString() {
    String osArch = System.getProperty("os.arch");
    osArch = osArch.toLowerCase(Locale.ENGLISH);
    if ("i386" == osArch || "x86" == osArch || "i686" == osArch) {
        return "x86";
    } else if (osArch.startsWith("amd64") || osArch.startsWith("x86_64")) {
        return "x86_64";
    } else if (osArch.startsWith("arm64")) {
        return "arm64";
    } else if (osArch.startsWith("arm")) {
        return "arm";
    } else if ("ppc" == osArch || "powerpc" == osArch) {
        return "ppc";
    } else if (osArch.startsWith("ppc")) {
        return "ppc_64";
    } else if (osArch.startsWith("sparc")) {
        return "sparc";
    } else if (osArch.startsWith("mips64")) {
        return "mips64";
    } else if (osArch.startsWith("mips")) {
        return "mips";
    } else if (osArch.contains("risc")) {
        return "risc";
    }
    return "unknown";
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    // Add your other dependencies here:

    // JCuda dependencies are below

    def classifier = getOsString() + "-" + getArchString()

    // Set JCuda version here, or if multiple modules use JCuda,
    // you should set a global variable like so:
    //
    // ext {
    //  jCudaVersion = "11.0.0"
    // }
    //
    // In your *top level* build gradle, and use
    // rootProject.ext.jCudaVersion instead of jCudaVersion when you need to access it

    def jCudaVersion = "11.0.0"

    // JCuda Java libraries

    implementation(group: 'org.jcuda', name: 'jcuda', version: jCudaVersion) {
        transitive = false
    }
    implementation(group: 'org.jcuda', name: 'jcublas', version: jCudaVersion) {
        transitive = false
    }
    implementation(group: 'org.jcuda', name: 'jcufft', version: jCudaVersion) {
        transitive = false
    }
    implementation(group: 'org.jcuda', name: 'jcusparse', version: jCudaVersion) {
        transitive = false
    }
    implementation(group: 'org.jcuda', name: 'jcurand', version: jCudaVersion) {
        transitive = false
    }
    implementation(group: 'org.jcuda', name: 'jcusolver', version: jCudaVersion) {
        transitive = false
    }
    implementation(group: 'org.jcuda', name: 'jcudnn', version: jCudaVersion) {
        transitive = false
    }

    // JCuda native libraries

    implementation group: 'org.jcuda', name: 'jcuda-natives',
            classifier: classifier, version: jCudaVersion
    implementation group: 'org.jcuda', name: 'jcublas-natives',
            classifier: classifier, version: jCudaVersion
    implementation group: 'org.jcuda', name: 'jcufft-natives',
            classifier: classifier, version: jCudaVersion
    implementation group: 'org.jcuda', name: 'jcusparse-natives',
            classifier: classifier, version: jCudaVersion
    implementation group: 'org.jcuda', name: 'jcurand-natives',
            classifier: classifier, version: jCudaVersion
    implementation group: 'org.jcuda', name: 'jcusolver-natives',
            classifier: classifier, version: jCudaVersion
    implementation group: 'org.jcuda', name: 'jcudnn-natives',
            classifier: classifier, version: jCudaVersion
}

To get the code to work with the latest deprecations. Not sure if it's important just wanted to notify you guys.

jcuda commented 2 years ago

Thanks. I usually don't use Gradle, so am not familiar with any updates there. The info in the USAGE.md is just what others have provided, in the hope that it will be helpful for others as well. I updated it accordingly in https://github.com/jcuda/jcuda-main/commit/32d21a81ecce26d33aa51dc58f6b90567f423326