Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
platform
samples
src
LICENSE
README.md
cppbuild.sh
cpu_features-android.patch
pom.xml

README.md

JavaCPP Presets for cpu_features

Introduction

This directory contains the JavaCPP Presets module for:

Please refer to the parent README.md file for more detailed information about the JavaCPP Presets.

Documentation

Java API documentation is available here:

Sample Usage

Here is a simple example of cpu_features ported to Java from this C source file:

We can use Maven 3 to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the pom.xml and SimpleExample.java source files below, simply execute on the command line:

 $ mvn compile exec:java

The pom.xml build file

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.bytedeco.cpu_features</groupId>
    <artifactId>simpleexample</artifactId>
    <version>1.5</version>
    <properties>
        <exec.mainClass>SimpleExample</exec.mainClass>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>cpu_features-platform</artifactId>
            <version>0.2.0-1.5</version>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>.</sourceDirectory>
    </build>
</project>

The SimpleExample.java source file

import org.bytedeco.javacpp.*;
import org.bytedeco.cpu_features.*;
import static org.bytedeco.cpu_features.global.cpu_features.*;

public class SimpleExample {

    static X86Features features = GetX86Info().features();

    static void Compute() {
        if (features.aes() != 0 && features.sse4_2() != 0) {
            System.out.println("Run optimized code.");
        } else {
            System.out.println("Run standard code.");
        }
    }

    public static void main(String args[]) {
        Compute();
    }
}
You can’t perform that action at this time.