diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6221054c2..7b0eb2ee0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -64,6 +64,20 @@ jobs: node_type: "gpu-l4-latest-1" run_script: "ci/build_go.sh" sha: ${{ inputs.sha }} + java-build: + needs: cpp-build + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 + with: + build_type: ${{ inputs.build_type || 'branch' }} + branch: ${{ inputs.branch }} + arch: "amd64" + date: ${{ inputs.date }} + container_image: "rapidsai/ci-conda:latest" + node_type: "gpu-l4-latest-1" + run_script: "ci/build_java.sh" + file_to_upload: "java/cuvs-java/target/" + sha: ${{ inputs.sha }} python-build: needs: [cpp-build] secrets: inherit diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 66499f251..cbe9d3ee8 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -20,6 +20,7 @@ jobs: - conda-cpp-checks - conda-python-build - conda-python-tests + - conda-java-tests - docs-build - rust-build - go-build @@ -73,6 +74,18 @@ jobs: - '!rust/**' - '!go/**' - '!thirdparty/LICENSES/**' + test_java: + - '**' + - '!.devcontainer/**' + - '!.pre-commit-config.yaml' + - '!README.md' + - '!docs/**' + - '!img/**' + - '!notebooks/**' + - '!python/**' + - '!rust/**' + - '!go/**' + - '!thirdparty/LICENSES/**' test_notebooks: - '**' - '!.devcontainer/**' @@ -134,6 +147,18 @@ jobs: if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request + conda-java-tests: + needs: [conda-cpp-build, changed-files] + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 + if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_java + with: + build_type: pull-request + node_type: "gpu-l4-latest-1" + arch: "amd64" + container_image: "rapidsai/ci-conda:latest" + run_script: "ci/test_java.sh" + file_to_upload: "java/cuvs-java/target/" docs-build: needs: conda-python-build secrets: inherit diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8e1dc631a..5c2192daa 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -43,6 +43,18 @@ jobs: branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} + conda-java-tests: + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 + with: + build_type: ${{ inputs.build_type }} + branch: ${{ inputs.branch }} + date: ${{ inputs.date }} + sha: ${{ inputs.sha }} + node_type: "gpu-l4-latest-1" + arch: "amd64" + container_image: "rapidsai/ci-conda:latest" + run_script: "ci/test_java.sh" wheel-tests-cuvs: secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.06 diff --git a/ci/build_java.sh b/ci/build_java.sh new file mode 100755 index 000000000..ee2f7c592 --- /dev/null +++ b/ci/build_java.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Copyright (c) 2025, NVIDIA CORPORATION. + +set -euo pipefail + +. /opt/conda/etc/profile.d/conda.sh + +rapids-logger "Downloading artifacts from previous jobs" +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) + +rapids-logger "Generate Java testing dependencies" + +ENV_YAML_DIR="$(mktemp -d)" + +rapids-dependency-file-generator \ + --output conda \ + --file-key java \ + --prepend-channel "${CPP_CHANNEL}" \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee "${ENV_YAML_DIR}/env.yaml" + +rapids-mamba-retry env create --yes -f "${ENV_YAML_DIR}/env.yaml" -n java + +export CMAKE_GENERATOR=Ninja + +# Temporarily allow unbound variables for conda activation. +set +u +conda activate java +set -u + +rapids-print-env + +rapids-logger "Check GPU usage" +nvidia-smi + +EXITCODE=0 +trap "EXITCODE=1" ERR +set +e + +rapids-logger "Run Java build and tests" + +bash ./build.sh java + +rapids-logger "Test script exiting with value: $EXITCODE" +exit ${EXITCODE} diff --git a/ci/test_java.sh b/ci/test_java.sh new file mode 100755 index 000000000..9237098ff --- /dev/null +++ b/ci/test_java.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Copyright (c) 2022-2025, NVIDIA CORPORATION. + +set -euo pipefail + +. /opt/conda/etc/profile.d/conda.sh + +rapids-logger "Downloading artifacts from previous jobs" +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) + +rapids-logger "Generate Java testing dependencies" + +ENV_YAML_DIR="$(mktemp -d)" + +rapids-dependency-file-generator \ + --output conda \ + --file-key test_java \ + --prepend-channel "${CPP_CHANNEL}" \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee "${ENV_YAML_DIR}/env.yaml" + +rapids-mamba-retry env create --yes -f "${ENV_YAML_DIR}/env.yaml" -n test + +export CMAKE_GENERATOR=Ninja + +# Temporarily allow unbound variables for conda activation. +set +u +conda activate test +set -u + +rapids-print-env + +rapids-logger "Check GPU usage" +nvidia-smi + +EXITCODE=0 +trap "EXITCODE=1" ERR +set +e + +rapids-logger "Run Java build and tests" + +bash ./build.sh java +if [[ $? -ne 0 ]]; then + rapids-logger "Initial Java build & test failed. Retrying with 'mvn clean verify -X'" + pushd java/cuvs-java/ + mvn clean verify -X + popd + DUMP_DIR="/__w/cuvs/cuvs/java/cuvs-java/target/failsafe-reports" + for file in "$DUMP_DIR"/*.dumpstream; do + if [ -f "$file" ]; then + echo "======= Dump file: $file =======" + cat "$file" + echo "======= End of dump file =======" + fi + done +fi + +rapids-logger "Test script exiting with value: $EXITCODE" +exit ${EXITCODE} diff --git a/dependencies.yaml b/dependencies.yaml index baf4987cc..8c7b3f9b1 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -64,6 +64,14 @@ files: - depends_on_libcuvs - depends_on_cuvs - depends_on_cuvs_bench + test_java: + output: none + includes: + - cuda + - cuda_version + - rapids_build + - depends_on_libcuvs + - java checks: output: none includes: @@ -111,6 +119,14 @@ files: - depends_on_libcuvs - depends_on_libraft - depends_on_nccl + java: + output: none + includes: + - cuda + - cuda_version + - rapids_build + - depends_on_libcuvs + - java py_build_libcuvs: output: pyproject pyproject_dir: python/libcuvs @@ -563,6 +579,14 @@ dependencies: - output_types: [conda, requirements, pyproject] packages: - scikit-learn + java: + common: + - output_types: conda + packages: + - *cmake_ver + - maven + - openjdk=22.* + - boost bench: common: - output_types: [conda, pyproject, requirements] diff --git a/java/.gitignore b/java/.gitignore new file mode 100644 index 000000000..19115ac15 --- /dev/null +++ b/java/.gitignore @@ -0,0 +1,19 @@ +# cuvs-java +/cuvs-java/target/ +/cuvs-java/bin/ +/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/ +/cuvs-java/*.cag +# internal +/internal/.ninja_deps +/internal/.ninja_log +/internal/CMakeCache.txt +/internal/CMakeFiles/ +/internal/CPM_modules/ +/internal/_deps/ +/internal/build.ninja +/internal/cmake/ +/internal/cmake_install.cmake +/internal/cpm-package-lock.cmake +/internal/Makefile +# examples +/examples/target/ diff --git a/java/README.md b/java/README.md index e5676146a..c032fa36f 100644 --- a/java/README.md +++ b/java/README.md @@ -1,14 +1,27 @@ -Prerequisites -------------- +# CuVS Java API -* JDK 22 -* Maven 3.9.6 or later -To build this API, please do `./build.sh java` in the top level directory. Since this API is dependent on `libcuvs` it must be noted that `libcuvs` gets built automatically before building this API. +CuVS Java API provides a Java based simple, efficient, and a robust vector search API. -Alternatively, please build libcuvs (`./build.sh libcuvs` from top level directory) before building the Java API with `./build.sh` from this directory. +> [!CAUTION] +> CuVS 25.06 contains an experimental version and updates to this API are expected in the coming release. -Building --------- +## Prerequisites -`./build.sh` will generate the `libcuvs_java.so` file in the `internal/` directory, and then build the final jar file for the cuVS Java API in the `cuvs-java/` directory. +- [CuVS libraries](https://docs.rapids.ai/api/cuvs/stable/build/#build-from-source) +- [maven 3.9.6 or above](https://maven.apache.org/download.cgi) +- [JDK 22](https://openjdk.org/projects/jdk/22/) +- [jextract for JDK 22](https://jdk.java.net/jextract/) (If not already installed, the build script downloads it) + + +## Building + +The libcuvs C and C++ libraries are needed for this API. If libcuvs libraries have not been built and installed, use `./build.sh libcuvs java` in the top level directory to build this API. + +Alternatively, if libcuvs libraries are already built and you just want to build this API, please +do `./build.sh java` in the top level directory or just do `./build.sh` in this directory. + + +## Examples + +A few starter examples of CAGRA, HNSW, and Bruteforce index are provided in the `examples` directory. diff --git a/java/build.sh b/java/build.sh index 34c7ae83e..022746d79 100755 --- a/java/build.sh +++ b/java/build.sh @@ -6,6 +6,17 @@ if [ -z "$CMAKE_PREFIX_PATH" ]; then export CMAKE_PREFIX_PATH=`pwd`/../cpp/build fi +# Generate Panama FFM API bindings and update (if any of them changed) +/bin/bash panama-bindings/generate-bindings.sh + +BINDINGS_GENERATION_RETURN_VALUE=$? +if [ $BINDINGS_GENERATION_RETURN_VALUE != 0 ] +then + echo "Bindings generation did not complete normally (returned value ${BINDINGS_GENERATION_RETURN_VALUE})" + echo "Forcing this build process to abort" + exit 1 +fi + cd internal && cmake . && cmake --build . \ && cd .. \ && mvn install:install-file -DgroupId=$GROUP_ID -DartifactId=cuvs-java-internal -Dversion=$VERSION -Dpackaging=so -Dfile=$SO_FILE_PATH/libcuvs_java.so \ diff --git a/java/cuvs-java/.gitignore b/java/cuvs-java/.gitignore deleted file mode 100644 index b83d22266..000000000 --- a/java/cuvs-java/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 835fb6eaf..0c65b14a2 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -62,7 +62,6 @@ 22 UTF-8 UTF-8 - ${GPG_PASSPHRASE} @@ -258,7 +257,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.11.2 attach-javadocs @@ -271,20 +270,6 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - org.sonatype.plugins nexus-staging-maven-plugin @@ -298,7 +283,4 @@ - - - diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndex.java index e09c0228f..511d4279f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndex.java @@ -16,13 +16,12 @@ package com.nvidia.cuvs; -import com.nvidia.cuvs.spi.CuVSProvider; - import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Path; import java.util.Objects; -import java.util.UUID; + +import com.nvidia.cuvs.spi.CuVSProvider; /** * diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java index 019e27dcd..f99fca11a 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java @@ -40,7 +40,7 @@ public class BruteForceQuery { * @param queryVectors 2D float query vector array * @param mapping an instance of ID mapping * @param topK the top k results to return - * @param prefilter the prefilter data to use while searching the BRUTEFORCE + * @param prefilters the prefilters data to use while searching the BRUTEFORCE * index * @param numDocs Maximum of bits in each prefilter, representing number of documents in this index. * Used only when prefilter(s) is/are passed. diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java index f92d97edd..d0d7b5ceb 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java @@ -20,7 +20,6 @@ import java.io.OutputStream; import java.nio.file.Path; import java.util.Objects; -import java.util.UUID; import com.nvidia.cuvs.spi.CuVSProvider; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java index 11b4f4b90..6959938ce 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java @@ -29,6 +29,7 @@ public class CagraIndexParams { private final int graphDegree; private final int nnDescentNiter; private final int numWriterThreads; + private final CuVSIvfPqParams cuVSIvfPqParams; /** * Enum that denotes which ANN algorithm is used to build CAGRA graph. @@ -158,15 +159,106 @@ private CuvsDistanceType(int value) { } - private CagraIndexParams(int intermediateGraphDegree, int graphDegree, - CagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter, int writerThreads, - CuvsDistanceType cuvsDistanceType) { + /** + * Enum that denotes codebook gen options. + */ + public enum CodebookGen { + + PER_SUBSPACE(0), + + PER_CLUSTER(1); + + /** + * The value for the enum choice. + */ + public final int value; + + private CodebookGen(int value) { + this.value = value; + } + } + + /** + * Enum that denotes cuda datatypes. + */ + public enum CudaDataType { + + CUDA_R_16F(2), + + CUDA_C_16F(6), + + CUDA_R_16BF(14), + + CUDA_C_16BF(15), + + CUDA_R_32F(0), + + CUDA_C_32F(4), + + CUDA_R_64F(1), + + CUDA_C_64F(5), + + CUDA_R_4I(16), + + CUDA_C_4I(17), + + CUDA_R_4U(18), + + CUDA_C_4U(19), + + CUDA_R_8I(3), + + CUDA_C_8I(7), + + CUDA_R_8U(8), + + CUDA_C_8U(9), + + CUDA_R_16I(20), + + CUDA_C_16I(21), + + CUDA_R_16U(22), + + CUDA_C_16U(23), + + CUDA_R_32I(10), + + CUDA_C_32I(11), + + CUDA_R_32U(12), + + CUDA_C_32U(13), + + CUDA_R_64I(24), + + CUDA_C_64I(25), + + CUDA_R_64U(26), + + CUDA_C_64U(27), + + CUDA_R_8F_E4M3(28), + + CUDA_R_8F_E5M2(29); + + public final int value; + + private CudaDataType(int value) { + this.value = value; + } + } + + private CagraIndexParams(int intermediateGraphDegree, int graphDegree, CagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, + int nnDescentNiter, int writerThreads, CuvsDistanceType cuvsDistanceType, CuVSIvfPqParams cuVSIvfPqParams) { this.intermediateGraphDegree = intermediateGraphDegree; this.graphDegree = graphDegree; this.cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo; this.nnDescentNiter = nnDescentNiter; this.numWriterThreads = writerThreads; this.cuvsDistanceType = cuvsDistanceType; + this.cuVSIvfPqParams = cuVSIvfPqParams; } /** @@ -216,11 +308,19 @@ public int getNumWriterThreads() { return numWriterThreads; } + /** + * Gets the IVF_PQ parameters. + */ + public CuVSIvfPqParams getCuVSIvfPqParams() { + return cuVSIvfPqParams; + } + @Override public String toString() { return "CagraIndexParams [cuvsCagraGraphBuildAlgo=" + cuvsCagraGraphBuildAlgo + ", cuvsDistanceType=" + cuvsDistanceType + ", intermediateGraphDegree=" + intermediateGraphDegree + ", graphDegree=" + graphDegree - + ", nnDescentNiter=" + nnDescentNiter + ", numWriterThreads=" + numWriterThreads + "]"; + + ", nnDescentNiter=" + nnDescentNiter + ", numWriterThreads=" + numWriterThreads + ", cuVSIvfPqParams=" + + cuVSIvfPqParams + "]"; } /** @@ -234,8 +334,10 @@ public static class Builder { private int graphDegree = 64; private int nnDescentNumIterations = 20; private int numWriterThreads = 2; + private CuVSIvfPqParams cuVSIvfPqParams = new CuVSIvfPqParams.Builder().build(); - public Builder() { } + public Builder() { + } /** * Sets the degree of input graph for pruning. @@ -305,14 +407,25 @@ public Builder withNumWriterThreads(int numWriterThreads) { return this; } + /** + * Sets the IVF_PQ index parameters. + * + * @param cuVSIvfPqParams the IVF_PQ index parameters + * @return an instance of Builder + */ + public Builder withCuVSIvfPqParams(CuVSIvfPqParams cuVSIvfPqParams) { + this.cuVSIvfPqParams = cuVSIvfPqParams; + return this; + } + /** * Builds an instance of {@link CagraIndexParams}. * * @return an instance of {@link CagraIndexParams} */ public CagraIndexParams build() { - return new CagraIndexParams(intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, - nnDescentNumIterations, numWriterThreads, cuvsDistanceType); + return new CagraIndexParams(intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, nnDescentNumIterations, + numWriterThreads, cuvsDistanceType, cuVSIvfPqParams); } } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSIvfPqIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSIvfPqIndexParams.java new file mode 100644 index 000000000..1ce1d9656 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSIvfPqIndexParams.java @@ -0,0 +1,513 @@ +/* + * Copyright (c) 2025, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.nvidia.cuvs; + +import com.nvidia.cuvs.CagraIndexParams.CodebookGen; +import com.nvidia.cuvs.CagraIndexParams.CuvsDistanceType; + +public class CuVSIvfPqIndexParams { + + /** Distance type. */ + private final CuvsDistanceType metric; + + /** How PQ codebooks are created. */ + private final CodebookGen codebookKind; + + /** The argument used by some distance metrics. */ + private final float metricArg; + + /** The fraction of data to use during iterative kmeans building. */ + private final double kmeansTrainsetFraction; + + /** + * The number of inverted lists (clusters) + * + * Hint: the number of vectors per cluster (`n_rows/n_lists`) should be + * approximately 1,000 to 10,000. + */ + private final int nLists; + + /** The number of iterations searching for kmeans centers (index building). */ + private final int kmeansNIters; + + /** + * The bit length of the vector element after compression by PQ. + * + * Possible values: [4, 5, 6, 7, 8]. + * + * Hint: the smaller the 'pq_bits', the smaller the index size and the better + * the search performance, but the lower the recall. + */ + private final int pqBits; + + /** + * The dimensionality of the vector after compression by PQ. When zero, an + * optimal value is selected using a heuristic. + * + * NB: `pq_dim * pq_bits` must be a multiple of 8. + * + * Hint: a smaller 'pq_dim' results in a smaller index size and better search + * performance, but lower recall. If 'pq_bits' is 8, 'pq_dim' can be set to any + * number, but multiple of 8 are desirable for good performance. If 'pq_bits' is + * not 8, 'pq_dim' should be a multiple of 8. For good performance, it is + * desirable that 'pq_dim' is a multiple of 32. Ideally, 'pq_dim' should be also + * a divisor of the dataset dim. + */ + private final int pqDim; + + /** + * Whether to add the dataset content to the index, i.e.: + * + * - `true` means the index is filled with the dataset vectors and ready to + * search after calling `build`. - `false` means `build` only trains the + * underlying model (e.g. quantizer or clustering), but the index is left empty; + * you'd need to call `extend` on the index afterwards to populate it. + */ + private final boolean addDataOnBuild; + + /** + * Apply a random rotation matrix on the input data and queries even if `dim % + * pq_dim == 0`. + * + * Note: if `dim` is not multiple of `pq_dim`, a random rotation is always + * applied to the input data and queries to transform the working space from + * `dim` to `rot_dim`, which may be slightly larger than the original space and + * and is a multiple of `pq_dim` (`rot_dim % pq_dim == 0`). However, this + * transform is not necessary when `dim` is multiple of `pq_dim` (`dim == + * rot_dim`, hence no need in adding "extra" data columns / features). + * + * By default, if `dim == rot_dim`, the rotation transform is initialized with + * the identity matrix. When `force_random_rotation == true`, a random + * orthogonal transform matrix is generated regardless of the values of `dim` + * and `pq_dim`. + */ + private final boolean forceRandomRotation; + + /** + * By default, the algorithm allocates more space than necessary for individual + * clusters (`list_data`). This allows to amortize the cost of memory allocation + * and reduce the number of data copies during repeated calls to `extend` + * (extending the database). + * + * The alternative is the conservative allocation behavior; when enabled, the + * algorithm always allocates the minimum amount of memory required to store the + * given number of records. Set this flag to `true` if you prefer to use as + * little GPU memory for the database as possible. + */ + private final boolean conservativeMemoryAllocation; + + /** + * The max number of data points to use per PQ code during PQ codebook training. + * Using more data points per PQ code may increase the quality of PQ codebook + * but may also increase the build time. The parameter is applied to both PQ + * codebook generation methods, i.e., PER_SUBSPACE and PER_CLUSTER. In both + * cases, we will use `pq_book_size * max_train_points_per_pq_code` training + * points to train each codebook. + */ + private final int maxTrainPointsPerPqCode; + + private CuVSIvfPqIndexParams(CuvsDistanceType metric, CodebookGen codebookKind, float metricArg, + double kmeansTrainsetFraction, int nLists, int kmeansNIters, int pqBits, int pqDim, boolean addDataOnBuild, + boolean forceRandomRotation, boolean conservativeMemoryAllocation, int maxTrainPointsPerPqCode) { + super(); + this.metric = metric; + this.codebookKind = codebookKind; + this.metricArg = metricArg; + this.kmeansTrainsetFraction = kmeansTrainsetFraction; + this.nLists = nLists; + this.kmeansNIters = kmeansNIters; + this.pqBits = pqBits; + this.pqDim = pqDim; + this.addDataOnBuild = addDataOnBuild; + this.forceRandomRotation = forceRandomRotation; + this.conservativeMemoryAllocation = conservativeMemoryAllocation; + this.maxTrainPointsPerPqCode = maxTrainPointsPerPqCode; + } + + /** + * Gets the distance type. + * + * @return the distance type + */ + public CuvsDistanceType getMetric() { + return metric; + } + + /** + * Gets how PQ codebooks are created + * + * @return how PQ codebooks are created + */ + public CodebookGen getCodebookKind() { + return codebookKind; + } + + /** + * Gets the argument used by some distance metrics + * + * @return the argument used by some distance metrics + */ + public float getMetricArg() { + return metricArg; + } + + /** + * Gets the fraction of data to use during iterative kmeans building + * + * @return the fraction of data to use during iterative kmeans building + */ + public double getKmeansTrainsetFraction() { + return kmeansTrainsetFraction; + } + + /** + * Gets the number of inverted lists (clusters) + * + * @return the number of inverted lists (clusters) + */ + public int getnLists() { + return nLists; + } + + /** + * Gets the number of iterations searching for kmeans centers + * + * @return the number of iterations searching for kmeans centers + */ + public int getKmeansNIters() { + return kmeansNIters; + } + + /** + * Gets the bit length of the vector element after compression by PQ + * + * @return the bit length of the vector element after compression by PQ + */ + public int getPqBits() { + return pqBits; + } + + /** + * Gets the dimensionality of the vector after compression by PQ + * + * @return the dimensionality of the vector after compression by PQ + */ + public int getPqDim() { + return pqDim; + } + + /** + * Gets whether the dataset content is added to the index + * + * @return whether the dataset content is added to the index + */ + public boolean isAddDataOnBuild() { + return addDataOnBuild; + } + + /** + * Gets the random rotation matrix on the input data and queries + * + * @return the random rotation matrix on the input data and queries + */ + public boolean isForceRandomRotation() { + return forceRandomRotation; + } + + /** + * Gets if conservative allocation behavior is set + * + * @return if conservative allocation behavior is set + */ + public boolean isConservativeMemoryAllocation() { + return conservativeMemoryAllocation; + } + + /** + * Gets whether max number of data points to use per PQ code during PQ codebook + * training is set + * + * @return whether max number of data points to use per PQ code during PQ + * codebook training is set + */ + public int getMaxTrainPointsPerPqCode() { + return maxTrainPointsPerPqCode; + } + + @Override + public String toString() { + return "CuVSIvfPqIndexParams [metric=" + metric + ", codebookKind=" + codebookKind + ", metricArg=" + metricArg + + ", kmeansTrainsetFraction=" + kmeansTrainsetFraction + ", nLists=" + nLists + ", kmeansNIters=" + kmeansNIters + + ", pqBits=" + pqBits + ", pqDim=" + pqDim + ", addDataOnBuild=" + addDataOnBuild + ", forceRandomRotation=" + + forceRandomRotation + ", conservativeMemoryAllocation=" + conservativeMemoryAllocation + + ", maxTrainPointsPerPqCode=" + maxTrainPointsPerPqCode + "]"; + } + + /** + * Builder configures and creates an instance of {@link CuVSIvfPqIndexParams}. + */ + public static class Builder { + + /** Distance type. */ + private CuvsDistanceType metric = CuvsDistanceType.L2Expanded; + + /** How PQ codebooks are created. */ + private CodebookGen codebookKind = CodebookGen.PER_SUBSPACE; + + /** The argument used by some distance metrics. */ + private float metricArg = 2.0f; + + /** The fraction of data to use during iterative kmeans building. */ + private double kmeansTrainsetFraction = 0.5; + + /** + * The number of inverted lists (clusters) + * + * Hint: the number of vectors per cluster (`n_rows/n_lists`) should be + * approximately 1,000 to 10,000. + */ + private int nLists = 1024; + + /** The number of iterations searching for kmeans centers (index building). */ + private int kmeansNIters = 20; + + /** + * The bit length of the vector element after compression by PQ. + * + * Possible values: [4, 5, 6, 7, 8]. + * + * Hint: the smaller the 'pq_bits', the smaller the index size and the better + * the search performance, but the lower the recall. + */ + private int pqBits = 8; + + /** + * The dimensionality of the vector after compression by PQ. When zero, an + * optimal value is selected using a heuristic. + * + * NB: `pq_dim * pq_bits` must be a multiple of 8. + * + * Hint: a smaller 'pq_dim' results in a smaller index size and better search + * performance, but lower recall. If 'pq_bits' is 8, 'pq_dim' can be set to any + * number, but multiple of 8 are desirable for good performance. If 'pq_bits' is + * not 8, 'pq_dim' should be a multiple of 8. For good performance, it is + * desirable that 'pq_dim' is a multiple of 32. Ideally, 'pq_dim' should be also + * a divisor of the dataset dim. + */ + private int pqDim = 0; + + /** + * Whether to add the dataset content to the index, i.e.: + * + * - `true` means the index is filled with the dataset vectors and ready to + * search after calling `build`. - `false` means `build` only trains the + * underlying model (e.g. quantizer or clustering), but the index is left empty; + * you'd need to call `extend` on the index afterwards to populate it. + */ + private boolean addDataOnBuild = true; + + /** + * Apply a random rotation matrix on the input data and queries even if `dim % + * pq_dim == 0`. + * + * Note: if `dim` is not multiple of `pq_dim`, a random rotation is always + * applied to the input data and queries to transform the working space from + * `dim` to `rot_dim`, which may be slightly larger than the original space and + * and is a multiple of `pq_dim` (`rot_dim % pq_dim == 0`). However, this + * transform is not necessary when `dim` is multiple of `pq_dim` (`dim == + * rot_dim`, hence no need in adding "extra" data columns / features). + * + * By default, if `dim == rot_dim`, the rotation transform is initialized with + * the identity matrix. When `force_random_rotation == true`, a random + * orthogonal transform matrix is generated regardless of the values of `dim` + * and `pq_dim`. + */ + private boolean forceRandomRotation = false; + + /** + * By default, the algorithm allocates more space than necessary for individual + * clusters (`list_data`). This allows to amortize the cost of memory allocation + * and reduce the number of data copies during repeated calls to `extend` + * (extending the database). + * + * The alternative is the conservative allocation behavior; when enabled, the + * algorithm always allocates the minimum amount of memory required to store the + * given number of records. Set this flag to `true` if you prefer to use as + * little GPU memory for the database as possible. + */ + private boolean conservativeMemoryAllocation = false; + + /** + * The max number of data points to use per PQ code during PQ codebook training. + * Using more data points per PQ code may increase the quality of PQ codebook + * but may also increase the build time. The parameter is applied to both PQ + * codebook generation methods, i.e., PER_SUBSPACE and PER_CLUSTER. In both + * cases, we will use `pq_book_size * max_train_points_per_pq_code` training + * points to train each codebook. + */ + private int maxTrainPointsPerPqCode = 256; + + public Builder() { + } + + /** + * Sets the distance type. + * + * @param metric distance type + * @return an instance of Builder + */ + public Builder withMetric(CuvsDistanceType metric) { + this.metric = metric; + return this; + } + + /** + * Sets the argument used by some distance metrics. + * + * @param metricArg argument used by some distance metrics + * @return an instance of Builder + */ + public Builder withMetricArg(float metricArg) { + this.metricArg = metricArg; + return this; + } + + /** + * Sets whether to add the dataset content to the index. + * + * @param addDataOnBuild whether to add the dataset content to the index + * @return an instance of Builder + */ + public Builder withAddDataOnBuild(boolean addDataOnBuild) { + this.addDataOnBuild = addDataOnBuild; + return this; + } + + /** + * Sets the number of inverted lists (clusters) + * + * @param nLists number of inverted lists (clusters) + * @return an instance of Builder + */ + public Builder withNLists(int nLists) { + this.nLists = nLists; + return this; + } + + /** + * Sets the number of iterations searching for kmeans centers + * + * @param kmeansNIters number of iterations searching for kmeans centers + * @return an instance of Builder + */ + public Builder withKmeansNIters(int kmeansNIters) { + this.kmeansNIters = kmeansNIters; + return this; + } + + /** + * Sets the fraction of data to use during iterative kmeans building. + * + * @param kmeansTrainsetFraction fraction of data to use during iterative kmeans + * building + * @return an instance of Builder + */ + public Builder withKmeansTrainsetFraction(double kmeansTrainsetFraction) { + this.kmeansTrainsetFraction = kmeansTrainsetFraction; + return this; + } + + /** + * Sets the bit length of the vector element after compression by PQ. + * + * @param pqBits bit length of the vector element after compression by PQ + * @return an instance of Builder + */ + public Builder withPqBits(int pqBits) { + this.pqBits = pqBits; + return this; + } + + /** + * Sets the dimensionality of the vector after compression by PQ. + * + * @param pqDim dimensionality of the vector after compression by PQ + * @return an instance of Builder + */ + public Builder withPqDim(int pqDim) { + this.pqDim = pqDim; + return this; + } + + /** + * Sets how PQ codebooks are created. + * + * @param codebookKind how PQ codebooks are created + * @return an instance of Builder + */ + public Builder withCodebookKind(CodebookGen codebookKind) { + this.codebookKind = codebookKind; + return this; + } + + /** + * Sets the random rotation matrix on the input data and queries. + * + * @param forceRandomRotation random rotation matrix on the input data and + * queries + * @return an instance of Builder + */ + public Builder withForceRandomRotation(boolean forceRandomRotation) { + this.forceRandomRotation = forceRandomRotation; + return this; + } + + /** + * Sets the conservative allocation behavior + * + * @param conservativeMemoryAllocation conservative allocation behavior + * @return an instance of Builder + */ + public Builder withConservativeMemoryAllocation(boolean conservativeMemoryAllocation) { + this.conservativeMemoryAllocation = conservativeMemoryAllocation; + return this; + } + + /** + * Sets the max number of data points to use per PQ code during PQ codebook + * training + * + * @param maxTrainPointsPerPqCode max number of data points to use per PQ code + * during PQ codebook training + * @return an instance of Builder + */ + public Builder withMaxTrainPointsPerPqCode(int maxTrainPointsPerPqCode) { + this.maxTrainPointsPerPqCode = maxTrainPointsPerPqCode; + return this; + } + + /** + * Builds an instance of {@link CuVSIvfPqIndexParams}. + * + * @return an instance of {@link CuVSIvfPqIndexParams} + */ + public CuVSIvfPqIndexParams build() { + return new CuVSIvfPqIndexParams(metric, codebookKind, metricArg, kmeansTrainsetFraction, nLists, kmeansNIters, + pqBits, pqDim, addDataOnBuild, forceRandomRotation, conservativeMemoryAllocation, maxTrainPointsPerPqCode); + } + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSIvfPqParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSIvfPqParams.java new file mode 100644 index 000000000..1b6dfca14 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSIvfPqParams.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2025, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.nvidia.cuvs; + +public class CuVSIvfPqParams { + + /** CuVS IVF_PQ index parameters */ + private final CuVSIvfPqIndexParams indexParams; + + /** CuVS IVF_PQ search parameters */ + private final CuVSIvfPqSearchParams searchParams; + + /** refinement rate */ + private final float refinementRate; + + private CuVSIvfPqParams(CuVSIvfPqIndexParams indexParams, CuVSIvfPqSearchParams searchParams, float refinementRate) { + super(); + this.indexParams = indexParams; + this.searchParams = searchParams; + this.refinementRate = refinementRate; + } + + /** + * + * @return + */ + public CuVSIvfPqIndexParams getIndexParams() { + return indexParams; + } + + /** + * + * @return + */ + public CuVSIvfPqSearchParams getSearchParams() { + return searchParams; + } + + /** + * + * @return + */ + public float getRefinementRate() { + return refinementRate; + } + + @Override + public String toString() { + return "CuVSIvfPqParams [indexParams=" + indexParams + ", searchParams=" + searchParams + ", refinementRate=" + + refinementRate + "]"; + } + + /** + * Builder configures and creates an instance of {@link CuVSIvfPqParams}. + */ + public static class Builder { + + /** CuVS IVF_PQ index parameters */ + private CuVSIvfPqIndexParams cuVSIvfPqIndexParams = new CuVSIvfPqIndexParams.Builder().build(); + + /** CuVS IVF_PQ search parameters */ + private CuVSIvfPqSearchParams cuVSIvfPqSearchParams = new CuVSIvfPqSearchParams.Builder().build(); + + /** refinement rate */ + private float refinementRate = 2.0f; + + public Builder() { + } + + /** + * Sets the CuVS IVF_PQ index parameters. + * + * @param cuVSIvfPqIndexParams the CuVS IVF_PQ index parameters + * @return an instance of Builder + */ + public Builder withCuVSIvfPqIndexParams(CuVSIvfPqIndexParams cuVSIvfPqIndexParams) { + this.cuVSIvfPqIndexParams = cuVSIvfPqIndexParams; + return this; + } + + /** + * Sets the CuVS IVF_PQ search parameters. + * + * @param cuVSIvfPqSearchParams the CuVS IVF_PQ search parameters + * @return an instance of Builder + */ + public Builder withCuVSIvfPqSearchParams(CuVSIvfPqSearchParams cuVSIvfPqSearchParams) { + this.cuVSIvfPqSearchParams = cuVSIvfPqSearchParams; + return this; + } + + /** + * Sets the refinement rate, default 2.0. + * + * @param refinementRate the refinement rate + * @return an instance of Builder + */ + public Builder withRefinementRate(float refinementRate) { + this.refinementRate = refinementRate; + return this; + } + + /** + * Builds an instance of {@link CuVSIvfPqParams}. + * + * @return an instance of {@link CuVSIvfPqParams} + */ + public CuVSIvfPqParams build() { + return new CuVSIvfPqParams(cuVSIvfPqIndexParams, cuVSIvfPqSearchParams, refinementRate); + } + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSIvfPqSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSIvfPqSearchParams.java new file mode 100644 index 000000000..2dab8dcb3 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSIvfPqSearchParams.java @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2025, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.nvidia.cuvs; + +import com.nvidia.cuvs.CagraIndexParams.CudaDataType; + +public class CuVSIvfPqSearchParams { + + /** The number of clusters to search. */ + private final int nProbes; + + /** + * Data type of look up table to be created dynamically at search time. + * + * Possible values: [CUDA_R_32F, CUDA_R_16F, CUDA_R_8U] + * + * The use of low-precision types reduces the amount of shared memory required + * at search time, so fast shared memory kernels can be used even for datasets + * with large dimansionality. Note that the recall is slightly degraded when + * low-precision type is selected. + */ + private final CudaDataType lutDtype; + + /** + * Storage data type for distance/similarity computed at search time. + * + * Possible values: [CUDA_R_16F, CUDA_R_32F] + * + * If the performance limiter at search time is device memory access, selecting + * FP16 will improve performance slightly. + */ + private final CudaDataType internalDistanceDtype; + + /** + * Preferred fraction of SM's unified memory / L1 cache to be used as shared + * memory. + * + * Possible values: [0.0 - 1.0] as a fraction of the + * `sharedMemPerMultiprocessor`. + * + * One wants to increase the carveout to make sure a good GPU occupancy for the + * main search kernel, but not to keep it too high to leave some memory to be + * used as L1 cache. Note, this value is interpreted only as a hint. Moreover, a + * GPU usually allows only a fixed set of cache configurations, so the provided + * value is rounded up to the nearest configuration. Refer to the NVIDIA tuning + * guide for the target GPU architecture. + * + * Note, this is a low-level tuning parameter that can have drastic negative + * effects on the search performance if tweaked incorrectly. + */ + private final double preferredShmemCarveout; + + private CuVSIvfPqSearchParams(int nProbes, CudaDataType lutDtype, CudaDataType internalDistanceDtype, + double preferredShmemCarveout) { + super(); + this.nProbes = nProbes; + this.lutDtype = lutDtype; + this.internalDistanceDtype = internalDistanceDtype; + this.preferredShmemCarveout = preferredShmemCarveout; + } + + /** + * Gets the number of clusters to search + * + * @return the number of clusters to search + */ + public int getnProbes() { + return nProbes; + } + + /** + * Gets the data type of look up table to be created dynamically at search time + * + * @return the data type of look up table to be created dynamically at search + * time + */ + public CudaDataType getLutDtype() { + return lutDtype; + } + + /** + * Gets the storage data type for distance/similarity computed at search time + * + * @return the storage data type for distance/similarity computed at search time + */ + public CudaDataType getInternalDistanceDtype() { + return internalDistanceDtype; + } + + /** + * Gets the preferred fraction of SM's unified memory / L1 cache to be used as + * shared memory + * + * @return the preferred fraction of SM's unified memory / L1 cache to be used + * as shared memory + */ + public double getPreferredShmemCarveout() { + return preferredShmemCarveout; + } + + @Override + public String toString() { + return "CuVSIvfPqSearchParams [nProbes=" + nProbes + ", lutDtype=" + lutDtype + ", internalDistanceDtype=" + + internalDistanceDtype + ", preferredShmemCarveout=" + preferredShmemCarveout + "]"; + } + + /** + * Builder configures and creates an instance of {@link CuVSIvfPqSearchParams}. + */ + public static class Builder { + + /** The number of clusters to search. */ + private int nProbes = 20; + + /** + * Data type of look up table to be created dynamically at search time. + * + * Possible values: [CUDA_R_32F, CUDA_R_16F, CUDA_R_8U] + * + * The use of low-precision types reduces the amount of shared memory required + * at search time, so fast shared memory kernels can be used even for datasets + * with large dimansionality. Note that the recall is slightly degraded when + * low-precision type is selected. + */ + private CudaDataType lutDtype = CudaDataType.CUDA_R_32F; + + /** + * Storage data type for distance/similarity computed at search time. + * + * Possible values: [CUDA_R_16F, CUDA_R_32F] + * + * If the performance limiter at search time is device memory access, selecting + * FP16 will improve performance slightly. + */ + private CudaDataType internalDistanceDtype = CudaDataType.CUDA_R_32F; + + /** + * Preferred fraction of SM's unified memory / L1 cache to be used as shared + * memory. + * + * Possible values: [0.0 - 1.0] as a fraction of the + * `sharedMemPerMultiprocessor`. + * + * One wants to increase the carveout to make sure a good GPU occupancy for the + * main search kernel, but not to keep it too high to leave some memory to be + * used as L1 cache. Note, this value is interpreted only as a hint. Moreover, a + * GPU usually allows only a fixed set of cache configurations, so the provided + * value is rounded up to the nearest configuration. Refer to the NVIDIA tuning + * guide for the target GPU architecture. + * + * Note, this is a low-level tuning parameter that can have drastic negative + * effects on the search performance if tweaked incorrectly. + */ + private double preferredShmemCarveout = 1.0; + + public Builder() { + } + + /** + * Sets the number of clusters to search. + * + * @param nProbes the number of clusters to search + * @return an instance of Builder + */ + public Builder withNProbes(int nProbes) { + this.nProbes = nProbes; + return this; + } + + /** + * Sets the the data type of look up table to be created dynamically at search + * time. + * + * @param lutDtype the data type of look up table to be created dynamically at + * search time + * @return an instance of Builder + */ + public Builder withLutDtype(CudaDataType lutDtype) { + this.lutDtype = lutDtype; + return this; + } + + /** + * Sets the storage data type for distance/similarity computed at search time. + * + * @param internalDistanceDtype storage data type for distance/similarity + * computed at search time + * @return an instance of Builder + */ + public Builder withInternalDistanceDtype(CudaDataType internalDistanceDtype) { + this.internalDistanceDtype = internalDistanceDtype; + return this; + } + + /** + * Sets the preferred fraction of SM's unified memory / L1 cache to be used as + * shared memory. + * + * @param preferredShmemCarveout preferred fraction of SM's unified memory / L1 + * cache to be used as shared memory + * @return an instance of Builder + */ + public Builder withPreferredShmemCarveout(double preferredShmemCarveout) { + this.preferredShmemCarveout = preferredShmemCarveout; + return this; + } + + /** + * Builds an instance of {@link CuVSIvfPqSearchParams}. + * + * @return an instance of {@link CuVSIvfPqSearchParams} + */ + public CuVSIvfPqSearchParams build() { + return new CuVSIvfPqSearchParams(nProbes, lutDtype, internalDistanceDtype, preferredShmemCarveout); + } + } +} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/BruteForceIndexImpl.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/BruteForceIndexImpl.java index decb13133..a96f633ff 100644 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/BruteForceIndexImpl.java +++ b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/BruteForceIndexImpl.java @@ -16,6 +16,13 @@ package com.nvidia.cuvs.internal; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_FLOAT; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_LONG; +import static com.nvidia.cuvs.internal.common.LinkerHelper.downcallHandle; +import static com.nvidia.cuvs.internal.common.Util.checkError; +import static java.lang.foreign.ValueLayout.ADDRESS; + import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; @@ -26,11 +33,8 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.invoke.MethodHandle; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; import java.util.BitSet; import java.util.Objects; import java.util.UUID; @@ -41,14 +45,7 @@ import com.nvidia.cuvs.CuVSResources; import com.nvidia.cuvs.SearchResults; import com.nvidia.cuvs.internal.common.Util; -import com.nvidia.cuvs.internal.panama.CuVSBruteForceIndex; - -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_FLOAT; -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT; -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_LONG; -import static com.nvidia.cuvs.internal.common.LinkerHelper.downcallHandle; -import static com.nvidia.cuvs.internal.common.Util.checkError; -import static java.lang.foreign.ValueLayout.ADDRESS; +import com.nvidia.cuvs.internal.panama.cuvsBruteForceIndex; /** * @@ -173,7 +170,6 @@ public SearchResults search(BruteForceQuery cuvsQuery) throws Throwable { long numQueries = cuvsQuery.getQueryVectors().length; long numBlocks = cuvsQuery.getTopK() * numQueries; int vectorDimension = numQueries > 0 ? cuvsQuery.getQueryVectors()[0].length : 0; - long numRows = dataset != null ? dataset.length : 0; SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, C_LONG); SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, C_FLOAT); @@ -366,7 +362,7 @@ protected static class IndexReference { * Constructs CagraIndexReference and allocate the MemorySegment. */ protected IndexReference(CuVSResourcesImpl resources) { - memorySegment = CuVSBruteForceIndex.allocate(resources.getArena()); + memorySegment = cuvsBruteForceIndex.allocate(resources.getArena()); } /** diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CagraIndexImpl.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CagraIndexImpl.java index 0577276d3..778835402 100644 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CagraIndexImpl.java +++ b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CagraIndexImpl.java @@ -16,6 +16,13 @@ package com.nvidia.cuvs.internal; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_FLOAT; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_LONG; +import static com.nvidia.cuvs.internal.common.LinkerHelper.downcallHandle; +import static com.nvidia.cuvs.internal.common.Util.checkError; +import static java.lang.foreign.ValueLayout.ADDRESS; + import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; @@ -34,22 +41,19 @@ import com.nvidia.cuvs.CagraCompressionParams; import com.nvidia.cuvs.CagraIndex; import com.nvidia.cuvs.CagraIndexParams; +import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; import com.nvidia.cuvs.CagraQuery; import com.nvidia.cuvs.CagraSearchParams; import com.nvidia.cuvs.CuVSResources; import com.nvidia.cuvs.SearchResults; import com.nvidia.cuvs.internal.common.Util; -import com.nvidia.cuvs.internal.panama.CuVSCagraCompressionParams; -import com.nvidia.cuvs.internal.panama.CuVSCagraIndex; -import com.nvidia.cuvs.internal.panama.CuVSCagraIndexParams; -import com.nvidia.cuvs.internal.panama.CuVSCagraSearchParams; - -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_FLOAT; -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT; -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_LONG; -import static com.nvidia.cuvs.internal.common.LinkerHelper.downcallHandle; -import static com.nvidia.cuvs.internal.common.Util.checkError; -import static java.lang.foreign.ValueLayout.ADDRESS; +import com.nvidia.cuvs.internal.panama.cuvsCagraCompressionParams; +import com.nvidia.cuvs.internal.panama.cuvsCagraIndex; +import com.nvidia.cuvs.internal.panama.cuvsCagraIndexParams; +import com.nvidia.cuvs.internal.panama.cuvsCagraSearchParams; +import com.nvidia.cuvs.internal.panama.cuvsIvfPqIndexParams; +import com.nvidia.cuvs.internal.panama.cuvsIvfPqParams; +import com.nvidia.cuvs.internal.panama.cuvsIvfPqSearchParams; /** * {@link CagraIndex} encapsulates a CAGRA index, along with methods to interact @@ -374,13 +378,13 @@ public CuVSResourcesImpl getCuVSResources() { * Allocates the configured compression parameters in the MemorySegment. */ private MemorySegment segmentFromCompressionParams(CagraCompressionParams params) { - MemorySegment seg = CuVSCagraCompressionParams.allocate(resources.getArena()); - CuVSCagraCompressionParams.pq_bits(seg, params.getPqBits()); - CuVSCagraCompressionParams.pq_dim(seg, params.getPqDim()); - CuVSCagraCompressionParams.vq_n_centers(seg, params.getVqNCenters()); - CuVSCagraCompressionParams.kmeans_n_iters(seg, params.getKmeansNIters()); - CuVSCagraCompressionParams.vq_kmeans_trainset_fraction(seg, params.getVqKmeansTrainsetFraction()); - CuVSCagraCompressionParams.pq_kmeans_trainset_fraction(seg, params.getPqKmeansTrainsetFraction()); + MemorySegment seg = cuvsCagraCompressionParams.allocate(resources.getArena()); + cuvsCagraCompressionParams.pq_bits(seg, params.getPqBits()); + cuvsCagraCompressionParams.pq_dim(seg, params.getPqDim()); + cuvsCagraCompressionParams.vq_n_centers(seg, params.getVqNCenters()); + cuvsCagraCompressionParams.kmeans_n_iters(seg, params.getKmeansNIters()); + cuvsCagraCompressionParams.vq_kmeans_trainset_fraction(seg, params.getVqKmeansTrainsetFraction()); + cuvsCagraCompressionParams.pq_kmeans_trainset_fraction(seg, params.getPqKmeansTrainsetFraction()); return seg; } @@ -388,12 +392,44 @@ private MemorySegment segmentFromCompressionParams(CagraCompressionParams params * Allocates the configured index parameters in the MemorySegment. */ private MemorySegment segmentFromIndexParams(CagraIndexParams params) { - MemorySegment seg = CuVSCagraIndexParams.allocate(resources.getArena()); - CuVSCagraIndexParams.intermediate_graph_degree(seg, params.getIntermediateGraphDegree()); - CuVSCagraIndexParams.graph_degree(seg, params.getGraphDegree()); - CuVSCagraIndexParams.build_algo(seg, params.getCagraGraphBuildAlgo().value); - CuVSCagraIndexParams.nn_descent_niter(seg, params.getNNDescentNumIterations()); - CuVSCagraIndexParams.metric(seg, params.getCuvsDistanceType().value); + MemorySegment seg = cuvsCagraIndexParams.allocate(resources.getArena()); + cuvsCagraIndexParams.intermediate_graph_degree(seg, params.getIntermediateGraphDegree()); + cuvsCagraIndexParams.graph_degree(seg, params.getGraphDegree()); + cuvsCagraIndexParams.build_algo(seg, params.getCagraGraphBuildAlgo().value); + cuvsCagraIndexParams.nn_descent_niter(seg, params.getNNDescentNumIterations()); + cuvsCagraIndexParams.metric(seg, params.getCuvsDistanceType().value); + + + if (params.getCagraGraphBuildAlgo().equals(CagraGraphBuildAlgo.IVF_PQ)) { + + MemorySegment ivfpqIndexParamsMemorySegment = cuvsIvfPqIndexParams.allocate(resources.getArena()); + cuvsIvfPqIndexParams.metric(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().getMetric().value); + cuvsIvfPqIndexParams.metric_arg(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().getMetricArg()); + cuvsIvfPqIndexParams.add_data_on_build(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().isAddDataOnBuild()); + cuvsIvfPqIndexParams.n_lists(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().getnLists()); + cuvsIvfPqIndexParams.kmeans_n_iters(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().getKmeansNIters()); + cuvsIvfPqIndexParams.kmeans_trainset_fraction(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().getKmeansTrainsetFraction()); + cuvsIvfPqIndexParams.pq_bits(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().getPqBits()); + cuvsIvfPqIndexParams.pq_dim(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().getPqDim()); + cuvsIvfPqIndexParams.codebook_kind(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().getCodebookKind().value); + cuvsIvfPqIndexParams.force_random_rotation(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().isForceRandomRotation()); + cuvsIvfPqIndexParams.conservative_memory_allocation(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().isConservativeMemoryAllocation()); + cuvsIvfPqIndexParams.max_train_points_per_pq_code(ivfpqIndexParamsMemorySegment, params.getCuVSIvfPqParams().getIndexParams().getMaxTrainPointsPerPqCode()); + + MemorySegment ivfpqSearchParamsMemorySegment = cuvsIvfPqSearchParams.allocate(resources.getArena()); + cuvsIvfPqSearchParams.n_probes(ivfpqSearchParamsMemorySegment, params.getCuVSIvfPqParams().getSearchParams().getnProbes()); + cuvsIvfPqSearchParams.lut_dtype(ivfpqSearchParamsMemorySegment, params.getCuVSIvfPqParams().getSearchParams().getLutDtype().value); + cuvsIvfPqSearchParams.internal_distance_dtype(ivfpqSearchParamsMemorySegment, params.getCuVSIvfPqParams().getSearchParams().getInternalDistanceDtype().value); + cuvsIvfPqSearchParams.preferred_shmem_carveout(ivfpqSearchParamsMemorySegment, params.getCuVSIvfPqParams().getSearchParams().getPreferredShmemCarveout()); + + MemorySegment cuvsIvfPqParamsMemorySegment = cuvsIvfPqParams.allocate(resources.getArena()); + cuvsIvfPqParams.ivf_pq_build_params(cuvsIvfPqParamsMemorySegment, ivfpqIndexParamsMemorySegment); + cuvsIvfPqParams.ivf_pq_search_params(cuvsIvfPqParamsMemorySegment, ivfpqSearchParamsMemorySegment); + cuvsIvfPqParams.refinement_rate(cuvsIvfPqParamsMemorySegment, params.getCuVSIvfPqParams().getRefinementRate()); + + cuvsCagraIndexParams.graph_build_params(seg, cuvsIvfPqParamsMemorySegment); + } + return seg; } @@ -401,23 +437,23 @@ private MemorySegment segmentFromIndexParams(CagraIndexParams params) { * Allocates the configured search parameters in the MemorySegment. */ private MemorySegment segmentFromSearchParams(CagraSearchParams params) { - MemorySegment seg = CuVSCagraSearchParams.allocate(resources.getArena()); - CuVSCagraSearchParams.max_queries(seg, params.getMaxQueries()); - CuVSCagraSearchParams.itopk_size(seg, params.getITopKSize()); - CuVSCagraSearchParams.max_iterations(seg, params.getMaxIterations()); + MemorySegment seg = cuvsCagraSearchParams.allocate(resources.getArena()); + cuvsCagraSearchParams.max_queries(seg, params.getMaxQueries()); + cuvsCagraSearchParams.itopk_size(seg, params.getITopKSize()); + cuvsCagraSearchParams.max_iterations(seg, params.getMaxIterations()); if (params.getCagraSearchAlgo() != null) { - CuVSCagraSearchParams.algo(seg, params.getCagraSearchAlgo().value); + cuvsCagraSearchParams.algo(seg, params.getCagraSearchAlgo().value); } - CuVSCagraSearchParams.team_size(seg, params.getTeamSize()); - CuVSCagraSearchParams.search_width(seg, params.getSearchWidth()); - CuVSCagraSearchParams.min_iterations(seg, params.getMinIterations()); - CuVSCagraSearchParams.thread_block_size(seg, params.getThreadBlockSize()); + cuvsCagraSearchParams.team_size(seg, params.getTeamSize()); + cuvsCagraSearchParams.search_width(seg, params.getSearchWidth()); + cuvsCagraSearchParams.min_iterations(seg, params.getMinIterations()); + cuvsCagraSearchParams.thread_block_size(seg, params.getThreadBlockSize()); if (params.getHashMapMode() != null) { - CuVSCagraSearchParams.hashmap_mode(seg, params.getHashMapMode().value); + cuvsCagraSearchParams.hashmap_mode(seg, params.getHashMapMode().value); } - CuVSCagraSearchParams.hashmap_max_fill_rate(seg, params.getHashMapMaxFillRate()); - CuVSCagraSearchParams.num_random_samplings(seg, params.getNumRandomSamplings()); - CuVSCagraSearchParams.rand_xor_mask(seg, params.getRandXORMask()); + cuvsCagraSearchParams.hashmap_max_fill_rate(seg, params.getHashMapMaxFillRate()); + cuvsCagraSearchParams.num_random_samplings(seg, params.getNumRandomSamplings()); + cuvsCagraSearchParams.rand_xor_mask(seg, params.getRandXORMask()); return seg; } @@ -489,7 +525,7 @@ protected static class IndexReference { * Constructs CagraIndexReference and allocate the MemorySegment. */ protected IndexReference(CuVSResourcesImpl resources) { - memorySegment = CuVSCagraIndex.allocate(resources.getArena()); + memorySegment = cuvsCagraIndex.allocate(resources.getArena()); } /** diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/HnswIndexImpl.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/HnswIndexImpl.java index bb9553e25..97dab9f27 100644 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/HnswIndexImpl.java +++ b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/HnswIndexImpl.java @@ -16,6 +16,13 @@ package com.nvidia.cuvs.internal; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_FLOAT; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_LONG; +import static com.nvidia.cuvs.internal.common.LinkerHelper.downcallHandle; +import static com.nvidia.cuvs.internal.common.Util.checkError; +import static java.lang.foreign.ValueLayout.ADDRESS; + import java.io.FileOutputStream; import java.io.InputStream; import java.lang.foreign.Arena; @@ -36,16 +43,9 @@ import com.nvidia.cuvs.HnswSearchParams; import com.nvidia.cuvs.SearchResults; import com.nvidia.cuvs.internal.common.Util; -import com.nvidia.cuvs.internal.panama.CuVSHnswIndex; -import com.nvidia.cuvs.internal.panama.CuVSHnswIndexParams; -import com.nvidia.cuvs.internal.panama.CuVSHnswSearchParams; - -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_FLOAT; -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT; -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_LONG; -import static com.nvidia.cuvs.internal.common.LinkerHelper.downcallHandle; -import static com.nvidia.cuvs.internal.common.Util.checkError; -import static java.lang.foreign.ValueLayout.ADDRESS; +import com.nvidia.cuvs.internal.panama.cuvsHnswIndex; +import com.nvidia.cuvs.internal.panama.cuvsHnswIndexParams; +import com.nvidia.cuvs.internal.panama.cuvsHnswSearchParams; /** * {@link HnswIndex} encapsulates a HNSW index, along with methods to interact @@ -187,9 +187,9 @@ private IndexReference deserialize(InputStream inputStream, int bufferLength) th * Allocates the configured search parameters in the MemorySegment. */ private MemorySegment segmentFromIndexParams(HnswIndexParams params) { - MemorySegment seg = CuVSHnswIndexParams.allocate(resources.getArena()); - CuVSHnswIndexParams.ef_construction(seg, params.getEfConstruction()); - CuVSHnswIndexParams.num_threads(seg, params.getNumThreads()); + MemorySegment seg = cuvsHnswIndexParams.allocate(resources.getArena()); + cuvsHnswIndexParams.ef_construction(seg, params.getEfConstruction()); + cuvsHnswIndexParams.num_threads(seg, params.getNumThreads()); return seg; } @@ -197,9 +197,9 @@ private MemorySegment segmentFromIndexParams(HnswIndexParams params) { * Allocates the configured search parameters in the MemorySegment. */ private MemorySegment segmentFromSearchParams(HnswSearchParams params) { - MemorySegment seg = CuVSHnswSearchParams.allocate(resources.getArena()); - CuVSHnswSearchParams.ef(seg, params.ef()); - CuVSHnswSearchParams.num_threads(seg, params.numThreads()); + MemorySegment seg = cuvsHnswSearchParams.allocate(resources.getArena()); + cuvsHnswSearchParams.ef(seg, params.ef()); + cuvsHnswSearchParams.num_threads(seg, params.numThreads()); return seg; } @@ -277,7 +277,7 @@ protected static class IndexReference { * Constructs CagraIndexReference and allocate the MemorySegment. */ protected IndexReference(CuVSResourcesImpl resources) { - memorySegment = CuVSHnswIndex.allocate(resources.getArena()); + memorySegment = cuvsHnswIndex.allocate(resources.getArena()); } /** diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/common/Util.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/common/Util.java index bc8f3bbcc..ddf1ea4d7 100644 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/common/Util.java +++ b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/common/Util.java @@ -16,6 +16,13 @@ package com.nvidia.cuvs.internal.common; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_CHAR; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_FLOAT; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT; +import static com.nvidia.cuvs.internal.common.LinkerHelper.C_LONG; +import static com.nvidia.cuvs.internal.common.LinkerHelper.downcallHandle; +import static java.lang.foreign.ValueLayout.ADDRESS; + import java.lang.foreign.Arena; import java.lang.foreign.FunctionDescriptor; import java.lang.foreign.MemoryLayout; @@ -25,36 +32,29 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.VarHandle; import java.util.ArrayList; -import java.util.Arrays; import java.util.BitSet; import java.util.List; import com.nvidia.cuvs.GPUInfo; -import com.nvidia.cuvs.internal.panama.GpuInfo; - -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_CHAR; -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_FLOAT; -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT; -import static com.nvidia.cuvs.internal.common.LinkerHelper.C_LONG; -import static com.nvidia.cuvs.internal.common.LinkerHelper.downcallHandle; -import static java.lang.foreign.ValueLayout.ADDRESS; +import com.nvidia.cuvs.internal.panama.gpuInfo; public class Util { public static final int CUVS_SUCCESS = 1; private static final MethodHandle getGpuInfoMethodHandle = downcallHandle("get_gpu_info", - FunctionDescriptor.ofVoid(ADDRESS, ADDRESS, ADDRESS)); + FunctionDescriptor.ofVoid(ADDRESS, ADDRESS, ADDRESS)); private static final MethodHandle getLastErrorTextMethodHandle = downcallHandle("cuvsGetLastErrorText", - FunctionDescriptor.of(ADDRESS)); + FunctionDescriptor.of(ADDRESS)); - private Util() {} + private Util() { + } /** * Checks the result value of a native method handle call. * - * @param value the return value + * @param value the return value * @param caller the native method handle that was called */ public static void checkError(int value, String caller) { @@ -123,31 +123,31 @@ public static List availableGPUs() throws Throwable { * before the function is invoked as cudaGetDeviceCount is inside the * get_gpu_info function. */ - MemorySegment GpuInfoArrayMemorySegment = GpuInfo.allocateArray(1024, localArena); + MemorySegment GpuInfoArrayMemorySegment = gpuInfo.allocateArray(1024, localArena); getGpuInfoMethodHandle.invokeExact(returnValueMemorySegment, numGpuMemorySegment, GpuInfoArrayMemorySegment); int numGPUs = numGpuMemorySegment.get(ValueLayout.JAVA_INT, 0); - MemoryLayout ml = MemoryLayout.sequenceLayout(numGPUs, GpuInfo.layout()); + MemoryLayout ml = MemoryLayout.sequenceLayout(numGPUs, gpuInfo.layout()); for (int i = 0; i < numGPUs; i++) { VarHandle gpuIdVarHandle = ml.varHandle(PathElement.sequenceElement(i), PathElement.groupElement("gpu_id")); VarHandle freeMemoryVarHandle = ml.varHandle(PathElement.sequenceElement(i), - PathElement.groupElement("free_memory")); + PathElement.groupElement("free_memory")); VarHandle totalMemoryVarHandle = ml.varHandle(PathElement.sequenceElement(i), - PathElement.groupElement("total_memory")); + PathElement.groupElement("total_memory")); VarHandle ComputeCapabilityVarHandle = ml.varHandle(PathElement.sequenceElement(i), - PathElement.groupElement("compute_capability")); + PathElement.groupElement("compute_capability")); StringBuilder gpuName = new StringBuilder(); char b = 1; int p = 0; while (b != 0x00) { VarHandle gpuNameVarHandle = ml.varHandle(PathElement.sequenceElement(i), PathElement.groupElement("name"), - PathElement.sequenceElement(p++)); + PathElement.sequenceElement(p++)); b = (char) (byte) gpuNameVarHandle.get(GpuInfoArrayMemorySegment, 0L); gpuName.append(b); } results.add(new GPUInfo((int) gpuIdVarHandle.get(GpuInfoArrayMemorySegment, 0L), gpuName.toString().trim(), - (long) freeMemoryVarHandle.get(GpuInfoArrayMemorySegment, 0L), - (long) totalMemoryVarHandle.get(GpuInfoArrayMemorySegment, 0L), - (float) ComputeCapabilityVarHandle.get(GpuInfoArrayMemorySegment, 0L))); + (long) freeMemoryVarHandle.get(GpuInfoArrayMemorySegment, 0L), + (long) totalMemoryVarHandle.get(GpuInfoArrayMemorySegment, 0L), + (float) ComputeCapabilityVarHandle.get(GpuInfoArrayMemorySegment, 0L))); } return results; } @@ -206,8 +206,7 @@ public static MemorySegment buildMemorySegment(Arena arena, float[][] data) { MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows * cols, C_FLOAT); MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); for (int r = 0; r < rows; r++) { - MemorySegment.copy(data[r], 0, dataMemorySegment, C_FLOAT, (r * cols * C_FLOAT.byteSize()), - (int) cols); + MemorySegment.copy(data[r], 0, dataMemorySegment, C_FLOAT, (r * cols * C_FLOAT.byteSize()), (int) cols); } return dataMemorySegment; } diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/BruteForceH.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/BruteForceH.java deleted file mode 100644 index 0e34eb2cf..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/BruteForceH.java +++ /dev/null @@ -1,1912 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.ValueLayout.JAVA_BYTE; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.PaddingLayout; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.StructLayout; -import java.lang.foreign.SymbolLookup; -import java.lang.foreign.ValueLayout; -import java.lang.foreign.ValueLayout.OfByte; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.lang.foreign.ValueLayout.OfShort; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class BruteForceH { - - BruteForceH() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) - : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int DLPACK_VERSION = (int) 80L; - - /** - * {@snippet lang = c : * #define DLPACK_VERSION 80 - * } - */ - public static int DLPACK_VERSION() { - return DLPACK_VERSION; - } - - private static final int DLPACK_ABI_VERSION = (int) 1L; - - /** - * {@snippet lang = c : * #define DLPACK_ABI_VERSION 1 - * } - */ - public static int DLPACK_ABI_VERSION() { - return DLPACK_ABI_VERSION; - } - - private static final int _STDINT_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - - private static final int _FEATURES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - - private static final int _DEFAULT_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - - private static final int __GLIBC_USE_ISOC2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - - private static final int __USE_ISOC11 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - - private static final int __USE_ISOC99 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - - private static final int __USE_ISOC95 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - - private static final int __USE_POSIX_IMPLICITLY = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - - private static final int _POSIX_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - - private static final int __USE_POSIX = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - - private static final int __USE_POSIX2 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - - private static final int __USE_POSIX199309 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - - private static final int __USE_POSIX199506 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - - private static final int __USE_XOPEN2K = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - - private static final int __USE_XOPEN2K8 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - - private static final int _ATFILE_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - - private static final int __WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - - private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; - - /** - * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - - private static final int __SYSCALL_WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - - private static final int __USE_MISC = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - - private static final int __USE_ATFILE = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - - private static final int __USE_FORTIFY_LEVEL = (int) 0L; - - /** - * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - - private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - - private static final int _STDC_PREDEF_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - - private static final int __STDC_IEC_559__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - - private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - - private static final int __GNU_LIBRARY__ = (int) 6L; - - /** - * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - - private static final int __GLIBC__ = (int) 2L; - - /** - * {@snippet lang = c : * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - - private static final int __GLIBC_MINOR__ = (int) 35L; - - /** - * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - - private static final int _SYS_CDEFS_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - - private static final int __glibc_c99_flexarr_available = (int) 1L; - - /** - * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; - - /** - * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - - private static final int __HAVE_GENERIC_SELECTION = (int) 1L; - - /** - * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - - private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - - private static final int _BITS_TYPES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - - private static final int _BITS_TYPESIZES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - - private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - - private static final int __INO_T_MATCHES_INO64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - - private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - - private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - - private static final int __FD_SETSIZE = (int) 1024L; - - /** - * {@snippet lang = c : * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - - private static final int _BITS_TIME64_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - - private static final int _BITS_WCHAR_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - - private static final int _BITS_STDINT_INTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - - private static final int _BITS_STDINT_UINTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - - /** - * {@snippet lang = c : * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = BruteForceH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = BruteForceH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = BruteForceH.C_SHORT; - /** - * {@snippet lang = c : * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = BruteForceH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = BruteForceH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off_t - * } - */ - public static final OfLong __off_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef long __time_t - * } - */ - public static final OfLong __time_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef int __key_t - * } - */ - public static final OfInt __key_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = BruteForceH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = BruteForceH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = BruteForceH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = BruteForceH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = BruteForceH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = BruteForceH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = BruteForceH.C_INT; - /** - * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = BruteForceH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = BruteForceH.C_LONG; - /** - * {@snippet lang = c : * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = BruteForceH.C_INT; - private static final int kDLCPU = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - - private static final int kDLCUDA = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - - private static final int kDLCUDAHost = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - - private static final int kDLOpenCL = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - - private static final int kDLVulkan = (int) 7L; - - /** - * {@snippet lang = c : * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - - private static final int kDLMetal = (int) 8L; - - /** - * {@snippet lang = c : * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - - private static final int kDLVPI = (int) 9L; - - /** - * {@snippet lang = c : * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - - private static final int kDLROCM = (int) 10L; - - /** - * {@snippet lang = c : * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - - private static final int kDLROCMHost = (int) 11L; - - /** - * {@snippet lang = c : * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - - private static final int kDLExtDev = (int) 12L; - - /** - * {@snippet lang = c : * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - - private static final int kDLCUDAManaged = (int) 13L; - - /** - * {@snippet lang = c : * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - - private static final int kDLOneAPI = (int) 14L; - - /** - * {@snippet lang = c : * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - - private static final int kDLWebGPU = (int) 15L; - - /** - * {@snippet lang = c : * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - - private static final int kDLHexagon = (int) 16L; - - /** - * {@snippet lang = c : * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - - private static final int kDLInt = (int) 0L; - - /** - * {@snippet lang = c : * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - - private static final int kDLUInt = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - - private static final int kDLFloat = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - - private static final int kDLOpaqueHandle = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - - private static final int kDLBfloat = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - - private static final int kDLComplex = (int) 5L; - - /** - * {@snippet lang = c : * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - - private static final int kDLBool = (int) 6L; - - /** - * {@snippet lang = c : * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - - /** - * {@snippet lang = c : * typedef cuvsBruteForceIndex *cuvsBruteForceIndex_t - * } - */ - public static final AddressLayout cuvsBruteForceIndex_t = BruteForceH.C_POINTER; - private static final long _POSIX_C_SOURCE = 200809L; - - /** - * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - - private static final int __TIMESIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - - private static final long __STDC_IEC_60559_BFP__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - - private static final long __STDC_ISO_10646__ = 201706L; - - /** - * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - - private static final int __WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - - private static final int __WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - - private static final int INT8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - - private static final int INT16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - - private static final int INT32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - - private static final long INT64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - - private static final int INT8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - - private static final int INT16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - - private static final int INT32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - - private static final long INT64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - - private static final int UINT8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - - private static final int UINT16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - - private static final int UINT32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - - private static final long UINT64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - - private static final int INT_LEAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - - private static final int INT_LEAST16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - - private static final int INT_LEAST32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - - private static final long INT_LEAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - - private static final int INT_LEAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - - private static final int INT_LEAST16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - - private static final int INT_LEAST32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - - private static final long INT_LEAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - - private static final int UINT_LEAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - - private static final int UINT_LEAST16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - - private static final int UINT_LEAST32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - - private static final long UINT_LEAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - - private static final int INT_FAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - - private static final long INT_FAST16_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - - private static final long INT_FAST32_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - - private static final long INT_FAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - - private static final int INT_FAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - - private static final long INT_FAST16_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - - private static final long INT_FAST32_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - - private static final long INT_FAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - - private static final int UINT_FAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - - private static final long UINT_FAST16_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - - private static final long UINT_FAST32_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - - private static final long UINT_FAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - - private static final long INTPTR_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - - private static final long INTPTR_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - - private static final long UINTPTR_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - - private static final long INTMAX_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - - private static final long INTMAX_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - - private static final long UINTMAX_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - - private static final long PTRDIFF_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - - private static final long PTRDIFF_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - - private static final int SIG_ATOMIC_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - - private static final int SIG_ATOMIC_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - - private static final long SIZE_MAX = -1L; - - /** - * {@snippet lang = c : * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - - private static final int WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - - private static final int WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - - private static final int WINT_MIN = (int) 0L; - - /** - * {@snippet lang = c : * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - - private static final int WINT_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - - /** - * {@snippet lang = c : * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CagraH.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CagraH.java deleted file mode 100644 index 82ecbdc34..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CagraH.java +++ /dev/null @@ -1,2298 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.ValueLayout.JAVA_BYTE; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.PaddingLayout; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.StructLayout; -import java.lang.foreign.SymbolLookup; -import java.lang.foreign.ValueLayout; -import java.lang.foreign.ValueLayout.OfByte; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.lang.foreign.ValueLayout.OfShort; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class CagraH { - - CagraH() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) - : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int DLPACK_VERSION = (int) 80L; - - /** - * {@snippet lang = c : * #define DLPACK_VERSION 80 - * } - */ - public static int DLPACK_VERSION() { - return DLPACK_VERSION; - } - - private static final int DLPACK_ABI_VERSION = (int) 1L; - - /** - * {@snippet lang = c : * #define DLPACK_ABI_VERSION 1 - * } - */ - public static int DLPACK_ABI_VERSION() { - return DLPACK_ABI_VERSION; - } - - private static final int _STDINT_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - - private static final int _FEATURES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - - private static final int _DEFAULT_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - - private static final int __GLIBC_USE_ISOC2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - - private static final int __USE_ISOC11 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - - private static final int __USE_ISOC99 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - - private static final int __USE_ISOC95 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - - private static final int __USE_POSIX_IMPLICITLY = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - - private static final int _POSIX_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - - private static final int __USE_POSIX = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - - private static final int __USE_POSIX2 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - - private static final int __USE_POSIX199309 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - - private static final int __USE_POSIX199506 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - - private static final int __USE_XOPEN2K = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - - private static final int __USE_XOPEN2K8 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - - private static final int _ATFILE_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - - private static final int __WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - - private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; - - /** - * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - - private static final int __SYSCALL_WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - - private static final int __USE_MISC = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - - private static final int __USE_ATFILE = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - - private static final int __USE_FORTIFY_LEVEL = (int) 0L; - - /** - * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - - private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - - private static final int _STDC_PREDEF_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - - private static final int __STDC_IEC_559__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - - private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - - private static final int __GNU_LIBRARY__ = (int) 6L; - - /** - * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - - private static final int __GLIBC__ = (int) 2L; - - /** - * {@snippet lang = c : * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - - private static final int __GLIBC_MINOR__ = (int) 35L; - - /** - * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - - private static final int _SYS_CDEFS_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - - private static final int __glibc_c99_flexarr_available = (int) 1L; - - /** - * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; - - /** - * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - - private static final int __HAVE_GENERIC_SELECTION = (int) 1L; - - /** - * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - - private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - - private static final int _BITS_TYPES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - - private static final int _BITS_TYPESIZES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - - private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - - private static final int __INO_T_MATCHES_INO64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - - private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - - private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - - private static final int __FD_SETSIZE = (int) 1024L; - - /** - * {@snippet lang = c : * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - - private static final int _BITS_TIME64_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - - private static final int _BITS_WCHAR_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - - private static final int _BITS_STDINT_INTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - - private static final int _BITS_STDINT_UINTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - - private static final int true_ = (int) 1L; - - /** - * {@snippet lang = c : * #define true 1 - * } - */ - public static int true_() { - return true_; - } - - private static final int false_ = (int) 0L; - - /** - * {@snippet lang = c : * #define false 0 - * } - */ - public static int false_() { - return false_; - } - - private static final int __bool_true_false_are_defined = (int) 1L; - - /** - * {@snippet lang = c : * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - - private static final int L2Expanded = (int) 0L; - - /** - * {@snippet lang = c : * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - - private static final int L2SqrtExpanded = (int) 1L; - - /** - * {@snippet lang = c : * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - - private static final int CosineExpanded = (int) 2L; - - /** - * {@snippet lang = c : * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - - private static final int L1 = (int) 3L; - - /** - * {@snippet lang = c : * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - - private static final int L2Unexpanded = (int) 4L; - - /** - * {@snippet lang = c : * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - - private static final int L2SqrtUnexpanded = (int) 5L; - - /** - * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - - private static final int InnerProduct = (int) 6L; - - /** - * {@snippet lang = c : * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - - private static final int Linf = (int) 7L; - - /** - * {@snippet lang = c : * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - - private static final int Canberra = (int) 8L; - - /** - * {@snippet lang = c : * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - - private static final int LpUnexpanded = (int) 9L; - - /** - * {@snippet lang = c : * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - - private static final int CorrelationExpanded = (int) 10L; - - /** - * {@snippet lang = c : * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - - private static final int JaccardExpanded = (int) 11L; - - /** - * {@snippet lang = c : * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - - private static final int HellingerExpanded = (int) 12L; - - /** - * {@snippet lang = c : * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - - private static final int Haversine = (int) 13L; - - /** - * {@snippet lang = c : * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - - private static final int BrayCurtis = (int) 14L; - - /** - * {@snippet lang = c : * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - - private static final int JensenShannon = (int) 15L; - - /** - * {@snippet lang = c : * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - - private static final int HammingUnexpanded = (int) 16L; - - /** - * {@snippet lang = c : * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - - private static final int KLDivergence = (int) 17L; - - /** - * {@snippet lang = c : * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - - private static final int RusselRaoExpanded = (int) 18L; - - /** - * {@snippet lang = c : * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - - private static final int DiceExpanded = (int) 19L; - - /** - * {@snippet lang = c : * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - - private static final int Precomputed = (int) 100L; - - /** - * {@snippet lang = c : * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - - /** - * {@snippet lang = c : * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = CagraH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = CagraH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = CagraH.C_SHORT; - /** - * {@snippet lang = c : * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = CagraH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = CagraH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off_t - * } - */ - public static final OfLong __off_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef long __time_t - * } - */ - public static final OfLong __time_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef int __key_t - * } - */ - public static final OfInt __key_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = CagraH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = CagraH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = CagraH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = CagraH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = CagraH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = CagraH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = CagraH.C_INT; - /** - * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = CagraH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = CagraH.C_LONG; - /** - * {@snippet lang = c : * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = CagraH.C_INT; - private static final int kDLCPU = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - - private static final int kDLCUDA = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - - private static final int kDLCUDAHost = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - - private static final int kDLOpenCL = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - - private static final int kDLVulkan = (int) 7L; - - /** - * {@snippet lang = c : * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - - private static final int kDLMetal = (int) 8L; - - /** - * {@snippet lang = c : * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - - private static final int kDLVPI = (int) 9L; - - /** - * {@snippet lang = c : * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - - private static final int kDLROCM = (int) 10L; - - /** - * {@snippet lang = c : * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - - private static final int kDLROCMHost = (int) 11L; - - /** - * {@snippet lang = c : * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - - private static final int kDLExtDev = (int) 12L; - - /** - * {@snippet lang = c : * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - - private static final int kDLCUDAManaged = (int) 13L; - - /** - * {@snippet lang = c : * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - - private static final int kDLOneAPI = (int) 14L; - - /** - * {@snippet lang = c : * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - - private static final int kDLWebGPU = (int) 15L; - - /** - * {@snippet lang = c : * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - - private static final int kDLHexagon = (int) 16L; - - /** - * {@snippet lang = c : * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - - private static final int kDLInt = (int) 0L; - - /** - * {@snippet lang = c : * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - - private static final int kDLUInt = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - - private static final int kDLFloat = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - - private static final int kDLOpaqueHandle = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - - private static final int kDLBfloat = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - - private static final int kDLComplex = (int) 5L; - - /** - * {@snippet lang = c : * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - - private static final int kDLBool = (int) 6L; - - /** - * {@snippet lang = c : * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - - private static final int AUTO_SELECT = (int) 0L; - - /** - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 - * } - */ - public static int AUTO_SELECT() { - return AUTO_SELECT; - } - - private static final int IVF_PQ = (int) 1L; - - /** - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 - * } - */ - public static int IVF_PQ() { - return IVF_PQ; - } - - private static final int NN_DESCENT = (int) 2L; - - /** - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 - * } - */ - public static int NN_DESCENT() { - return NN_DESCENT; - } - - /** - * {@snippet lang = c : - * typedef struct cuvsCagraCompressionParams { - * uint32_t pq_bits; - * uint32_t pq_dim; - * uint32_t vq_n_centers; - * uint32_t kmeans_n_iters; - * double vq_kmeans_trainset_fraction; - * double pq_kmeans_trainset_fraction; - * } *cuvsCagraCompressionParams_t - * } - */ - public static final AddressLayout cuvsCagraCompressionParams_t = CagraH.C_POINTER; - /** - * {@snippet lang = c : - * typedef struct cuvsCagraIndexParams { - * cuvsDistanceType metric; - * long intermediate_graph_degree; - * long graph_degree; - * enum cuvsCagraGraphBuildAlgo build_algo; - * long nn_descent_niter; - * cuvsCagraCompressionParams_t compression; - * } *cuvsCagraIndexParams_t - * } - */ - public static final AddressLayout cuvsCagraIndexParams_t = CagraH.C_POINTER; - private static final int SINGLE_CTA = (int) 0L; - - /** - * {@snippet lang = c : * enum cuvsCagraSearchAlgo.SINGLE_CTA = 0 - * } - */ - public static int SINGLE_CTA() { - return SINGLE_CTA; - } - - private static final int MULTI_CTA = (int) 1L; - - /** - * {@snippet lang = c : * enum cuvsCagraSearchAlgo.MULTI_CTA = 1 - * } - */ - public static int MULTI_CTA() { - return MULTI_CTA; - } - - private static final int MULTI_KERNEL = (int) 2L; - - /** - * {@snippet lang = c : * enum cuvsCagraSearchAlgo.MULTI_KERNEL = 2 - * } - */ - public static int MULTI_KERNEL() { - return MULTI_KERNEL; - } - - private static final int AUTO = (int) 3L; - - /** - * {@snippet lang = c : * enum cuvsCagraSearchAlgo.AUTO = 3 - * } - */ - public static int AUTO() { - return AUTO; - } - - private static final int HASH = (int) 0L; - - /** - * {@snippet lang = c : * enum cuvsCagraHashMode.HASH = 0 - * } - */ - public static int HASH() { - return HASH; - } - - private static final int SMALL = (int) 1L; - - /** - * {@snippet lang = c : * enum cuvsCagraHashMode.SMALL = 1 - * } - */ - public static int SMALL() { - return SMALL; - } - - private static final int AUTO_HASH = (int) 2L; - - /** - * {@snippet lang = c : * enum cuvsCagraHashMode.AUTO_HASH = 2 - * } - */ - public static int AUTO_HASH() { - return AUTO_HASH; - } - - /** - * {@snippet lang = c : - * typedef struct cuvsCagraSearchParams { - * long max_queries; - * long itopk_size; - * long max_iterations; - * enum cuvsCagraSearchAlgo algo; - * long team_size; - * long search_width; - * long min_iterations; - * long thread_block_size; - * enum cuvsCagraHashMode hashmap_mode; - * long hashmap_min_bitlen; - * float hashmap_max_fill_rate; - * uint32_t num_random_samplings; - * uint64_t rand_xor_mask; - * } *cuvsCagraSearchParams_t - * } - */ - public static final AddressLayout cuvsCagraSearchParams_t = CagraH.C_POINTER; - /** - * {@snippet lang = c : * typedef cuvsCagraIndex *cuvsCagraIndex_t - * } - */ - public static final AddressLayout cuvsCagraIndex_t = CagraH.C_POINTER; - private static final long _POSIX_C_SOURCE = 200809L; - - /** - * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - - private static final int __TIMESIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - - private static final long __STDC_IEC_60559_BFP__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - - private static final long __STDC_ISO_10646__ = 201706L; - - /** - * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - - private static final int __WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - - private static final int __WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - - private static final int INT8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - - private static final int INT16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - - private static final int INT32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - - private static final long INT64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - - private static final int INT8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - - private static final int INT16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - - private static final int INT32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - - private static final long INT64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - - private static final int UINT8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - - private static final int UINT16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - - private static final int UINT32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - - private static final long UINT64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - - private static final int INT_LEAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - - private static final int INT_LEAST16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - - private static final int INT_LEAST32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - - private static final long INT_LEAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - - private static final int INT_LEAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - - private static final int INT_LEAST16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - - private static final int INT_LEAST32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - - private static final long INT_LEAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - - private static final int UINT_LEAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - - private static final int UINT_LEAST16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - - private static final int UINT_LEAST32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - - private static final long UINT_LEAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - - private static final int INT_FAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - - private static final long INT_FAST16_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - - private static final long INT_FAST32_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - - private static final long INT_FAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - - private static final int INT_FAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - - private static final long INT_FAST16_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - - private static final long INT_FAST32_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - - private static final long INT_FAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - - private static final int UINT_FAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - - private static final long UINT_FAST16_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - - private static final long UINT_FAST32_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - - private static final long UINT_FAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - - private static final long INTPTR_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - - private static final long INTPTR_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - - private static final long UINTPTR_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - - private static final long INTMAX_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - - private static final long INTMAX_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - - private static final long UINTMAX_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - - private static final long PTRDIFF_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - - private static final long PTRDIFF_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - - private static final int SIG_ATOMIC_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - - private static final int SIG_ATOMIC_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - - private static final long SIZE_MAX = -1L; - - /** - * {@snippet lang = c : * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - - private static final int WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - - private static final int WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - - private static final int WINT_MIN = (int) 0L; - - /** - * {@snippet lang = c : * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - - private static final int WINT_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - - /** - * {@snippet lang = c : * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSBruteForceIndex.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSBruteForceIndex.java deleted file mode 100644 index 0a1ac29e2..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSBruteForceIndex.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct { - * uintptr_t addr; - * DLDataType dtype; - * } - * } - */ -public class CuVSBruteForceIndex { - - CuVSBruteForceIndex() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(BruteForceH.C_LONG.withName("addr"), - DLDataType.layout().withName("dtype"), MemoryLayout.paddingLayout(4)).withName("$anon$22:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong addr$LAYOUT = (OfLong) $LAYOUT.select(groupElement("addr")); - - /** - * Layout for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static final OfLong addr$layout() { - return addr$LAYOUT; - } - - private static final long addr$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static final long addr$offset() { - return addr$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static long addr(MemorySegment struct) { - return struct.get(addr$LAYOUT, addr$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static void addr(MemorySegment struct, long fieldValue) { - struct.set(addr$LAYOUT, addr$OFFSET, fieldValue); - } - - private static final GroupLayout dtype$LAYOUT = (GroupLayout) $LAYOUT.select(groupElement("dtype")); - - /** - * Layout for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static final GroupLayout dtype$layout() { - return dtype$LAYOUT; - } - - private static final long dtype$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static final long dtype$offset() { - return dtype$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static MemorySegment dtype(MemorySegment struct) { - return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static void dtype(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraCompressionParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraCompressionParams.java deleted file mode 100644 index 923287fe4..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraCompressionParams.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfDouble; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct cuvsCagraCompressionParams { - * uint32_t pq_bits; - * uint32_t pq_dim; - * uint32_t vq_n_centers; - * uint32_t kmeans_n_iters; - * double vq_kmeans_trainset_fraction; - * double pq_kmeans_trainset_fraction; - * } - * } - */ -public class CuVSCagraCompressionParams { - - CuVSCagraCompressionParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(CagraH.C_INT.withName("pq_bits"), - CagraH.C_INT.withName("pq_dim"), CagraH.C_INT.withName("vq_n_centers"), - CagraH.C_INT.withName("kmeans_n_iters"), CagraH.C_DOUBLE.withName("vq_kmeans_trainset_fraction"), - CagraH.C_DOUBLE.withName("pq_kmeans_trainset_fraction")).withName("cuvsCagraCompressionParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt pq_bits$LAYOUT = (OfInt) $LAYOUT.select(groupElement("pq_bits")); - - /** - * Layout for field: - * {@snippet lang = c : * uint32_t pq_bits - * } - */ - public static final OfInt pq_bits$layout() { - return pq_bits$LAYOUT; - } - - private static final long pq_bits$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * uint32_t pq_bits - * } - */ - public static final long pq_bits$offset() { - return pq_bits$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * uint32_t pq_bits - * } - */ - public static int pq_bits(MemorySegment struct) { - return struct.get(pq_bits$LAYOUT, pq_bits$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * uint32_t pq_bits - * } - */ - public static void pq_bits(MemorySegment struct, int fieldValue) { - struct.set(pq_bits$LAYOUT, pq_bits$OFFSET, fieldValue); - } - - private static final OfInt pq_dim$LAYOUT = (OfInt) $LAYOUT.select(groupElement("pq_dim")); - - /** - * Layout for field: - * {@snippet lang = c : * uint32_t pq_dim - * } - */ - public static final OfInt pq_dim$layout() { - return pq_dim$LAYOUT; - } - - private static final long pq_dim$OFFSET = 4; - - /** - * Offset for field: - * {@snippet lang = c : * uint32_t pq_dim - * } - */ - public static final long pq_dim$offset() { - return pq_dim$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * uint32_t pq_dim - * } - */ - public static int pq_dim(MemorySegment struct) { - return struct.get(pq_dim$LAYOUT, pq_dim$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * uint32_t pq_dim - * } - */ - public static void pq_dim(MemorySegment struct, int fieldValue) { - struct.set(pq_dim$LAYOUT, pq_dim$OFFSET, fieldValue); - } - - private static final OfInt vq_n_centers$LAYOUT = (OfInt) $LAYOUT.select(groupElement("vq_n_centers")); - - /** - * Layout for field: - * {@snippet lang = c : * uint32_t vq_n_centers - * } - */ - public static final OfInt vq_n_centers$layout() { - return vq_n_centers$LAYOUT; - } - - private static final long vq_n_centers$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang = c : * uint32_t vq_n_centers - * } - */ - public static final long vq_n_centers$offset() { - return vq_n_centers$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * uint32_t vq_n_centers - * } - */ - public static int vq_n_centers(MemorySegment struct) { - return struct.get(vq_n_centers$LAYOUT, vq_n_centers$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * uint32_t vq_n_centers - * } - */ - public static void vq_n_centers(MemorySegment struct, int fieldValue) { - struct.set(vq_n_centers$LAYOUT, vq_n_centers$OFFSET, fieldValue); - } - - private static final OfInt kmeans_n_iters$LAYOUT = (OfInt) $LAYOUT.select(groupElement("kmeans_n_iters")); - - /** - * Layout for field: - * {@snippet lang = c : * uint32_t kmeans_n_iters - * } - */ - public static final OfInt kmeans_n_iters$layout() { - return kmeans_n_iters$LAYOUT; - } - - private static final long kmeans_n_iters$OFFSET = 12; - - /** - * Offset for field: - * {@snippet lang = c : * uint32_t kmeans_n_iters - * } - */ - public static final long kmeans_n_iters$offset() { - return kmeans_n_iters$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * uint32_t kmeans_n_iters - * } - */ - public static int kmeans_n_iters(MemorySegment struct) { - return struct.get(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * uint32_t kmeans_n_iters - * } - */ - public static void kmeans_n_iters(MemorySegment struct, int fieldValue) { - struct.set(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET, fieldValue); - } - - private static final OfDouble vq_kmeans_trainset_fraction$LAYOUT = (OfDouble) $LAYOUT - .select(groupElement("vq_kmeans_trainset_fraction")); - - /** - * Layout for field: - * {@snippet lang = c : * double vq_kmeans_trainset_fraction - * } - */ - public static final OfDouble vq_kmeans_trainset_fraction$layout() { - return vq_kmeans_trainset_fraction$LAYOUT; - } - - private static final long vq_kmeans_trainset_fraction$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang = c : * double vq_kmeans_trainset_fraction - * } - */ - public static final long vq_kmeans_trainset_fraction$offset() { - return vq_kmeans_trainset_fraction$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * double vq_kmeans_trainset_fraction - * } - */ - public static double vq_kmeans_trainset_fraction(MemorySegment struct) { - return struct.get(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * double vq_kmeans_trainset_fraction - * } - */ - public static void vq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { - struct.set(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET, fieldValue); - } - - private static final OfDouble pq_kmeans_trainset_fraction$LAYOUT = (OfDouble) $LAYOUT - .select(groupElement("pq_kmeans_trainset_fraction")); - - /** - * Layout for field: - * {@snippet lang = c : * double pq_kmeans_trainset_fraction - * } - */ - public static final OfDouble pq_kmeans_trainset_fraction$layout() { - return pq_kmeans_trainset_fraction$LAYOUT; - } - - private static final long pq_kmeans_trainset_fraction$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang = c : * double pq_kmeans_trainset_fraction - * } - */ - public static final long pq_kmeans_trainset_fraction$offset() { - return pq_kmeans_trainset_fraction$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * double pq_kmeans_trainset_fraction - * } - */ - public static double pq_kmeans_trainset_fraction(MemorySegment struct) { - return struct.get(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * double pq_kmeans_trainset_fraction - * } - */ - public static void pq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { - struct.set(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraIndex.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraIndex.java deleted file mode 100644 index 7ea435ba0..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraIndex.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct { - * uintptr_t addr; - * DLDataType dtype; - * } - * } - */ -public class CuVSCagraIndex { - - CuVSCagraIndex() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(CagraH.C_LONG.withName("addr"), - DLDataType.layout().withName("dtype"), MemoryLayout.paddingLayout(4)).withName("$anon$175:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong addr$LAYOUT = (OfLong) $LAYOUT.select(groupElement("addr")); - - /** - * Layout for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static final OfLong addr$layout() { - return addr$LAYOUT; - } - - private static final long addr$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static final long addr$offset() { - return addr$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static long addr(MemorySegment struct) { - return struct.get(addr$LAYOUT, addr$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static void addr(MemorySegment struct, long fieldValue) { - struct.set(addr$LAYOUT, addr$OFFSET, fieldValue); - } - - private static final GroupLayout dtype$LAYOUT = (GroupLayout) $LAYOUT.select(groupElement("dtype")); - - /** - * Layout for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static final GroupLayout dtype$layout() { - return dtype$LAYOUT; - } - - private static final long dtype$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static final long dtype$offset() { - return dtype$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static MemorySegment dtype(MemorySegment struct) { - return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static void dtype(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraIndexParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraIndexParams.java deleted file mode 100644 index ffe88effa..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraIndexParams.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct cuvsCagraIndexParams { - * cuvsDistanceType metric; - * long intermediate_graph_degree; - * long graph_degree; - * enum cuvsCagraGraphBuildAlgo build_algo; - * long nn_descent_niter; - * cuvsCagraCompressionParams_t compression; - * } - * } - */ -public class CuVSCagraIndexParams { - - CuVSCagraIndexParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout - .structLayout(CagraH.C_INT.withName("metric"), MemoryLayout.paddingLayout(4), - CagraH.C_LONG.withName("intermediate_graph_degree"), CagraH.C_LONG.withName("graph_degree"), - CagraH.C_INT.withName("build_algo"), MemoryLayout.paddingLayout(4), - CagraH.C_LONG.withName("nn_descent_niter"), CagraH.C_POINTER.withName("compression")) - .withName("cuvsCagraIndexParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt metric$LAYOUT = (OfInt) $LAYOUT.select(groupElement("metric")); - - /** - * Layout for field: - * {@snippet lang = c : * cuvsDistanceType metric - * } - */ - public static final OfInt metric$layout() { - return metric$LAYOUT; - } - - private static final long metric$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * cuvsDistanceType metric - * } - */ - public static final long metric$offset() { - return metric$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * cuvsDistanceType metric - * } - */ - public static int metric(MemorySegment struct) { - return struct.get(metric$LAYOUT, metric$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * cuvsDistanceType metric - * } - */ - public static void metric(MemorySegment struct, int fieldValue) { - struct.set(metric$LAYOUT, metric$OFFSET, fieldValue); - } - - private static final OfLong intermediate_graph_degree$LAYOUT = (OfLong) $LAYOUT - .select(groupElement("intermediate_graph_degree")); - - /** - * Layout for field: - * {@snippet lang = c : * long intermediate_graph_degree - * } - */ - public static final OfLong intermediate_graph_degree$layout() { - return intermediate_graph_degree$LAYOUT; - } - - private static final long intermediate_graph_degree$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang = c : * long intermediate_graph_degree - * } - */ - public static final long intermediate_graph_degree$offset() { - return intermediate_graph_degree$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long intermediate_graph_degree - * } - */ - public static long intermediate_graph_degree(MemorySegment struct) { - return struct.get(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long intermediate_graph_degree - * } - */ - public static void intermediate_graph_degree(MemorySegment struct, long fieldValue) { - struct.set(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET, fieldValue); - } - - private static final OfLong graph_degree$LAYOUT = (OfLong) $LAYOUT.select(groupElement("graph_degree")); - - /** - * Layout for field: - * {@snippet lang = c : * long graph_degree - * } - */ - public static final OfLong graph_degree$layout() { - return graph_degree$LAYOUT; - } - - private static final long graph_degree$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang = c : * long graph_degree - * } - */ - public static final long graph_degree$offset() { - return graph_degree$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long graph_degree - * } - */ - public static long graph_degree(MemorySegment struct) { - return struct.get(graph_degree$LAYOUT, graph_degree$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long graph_degree - * } - */ - public static void graph_degree(MemorySegment struct, long fieldValue) { - struct.set(graph_degree$LAYOUT, graph_degree$OFFSET, fieldValue); - } - - private static final OfInt build_algo$LAYOUT = (OfInt) $LAYOUT.select(groupElement("build_algo")); - - /** - * Layout for field: - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static final OfInt build_algo$layout() { - return build_algo$LAYOUT; - } - - private static final long build_algo$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static final long build_algo$offset() { - return build_algo$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static int build_algo(MemorySegment struct) { - return struct.get(build_algo$LAYOUT, build_algo$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static void build_algo(MemorySegment struct, int fieldValue) { - struct.set(build_algo$LAYOUT, build_algo$OFFSET, fieldValue); - } - - private static final OfLong nn_descent_niter$LAYOUT = (OfLong) $LAYOUT.select(groupElement("nn_descent_niter")); - - /** - * Layout for field: - * {@snippet lang = c : * long nn_descent_niter - * } - */ - public static final OfLong nn_descent_niter$layout() { - return nn_descent_niter$LAYOUT; - } - - private static final long nn_descent_niter$OFFSET = 32; - - /** - * Offset for field: - * {@snippet lang = c : * long nn_descent_niter - * } - */ - public static final long nn_descent_niter$offset() { - return nn_descent_niter$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long nn_descent_niter - * } - */ - public static long nn_descent_niter(MemorySegment struct) { - return struct.get(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long nn_descent_niter - * } - */ - public static void nn_descent_niter(MemorySegment struct, long fieldValue) { - struct.set(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET, fieldValue); - } - - private static final AddressLayout compression$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("compression")); - - /** - * Layout for field: - * {@snippet lang = c : * cuvsCagraCompressionParams_t compression - * } - */ - public static final AddressLayout compression$layout() { - return compression$LAYOUT; - } - - private static final long compression$OFFSET = 40; - - /** - * Offset for field: - * {@snippet lang = c : * cuvsCagraCompressionParams_t compression - * } - */ - public static final long compression$offset() { - return compression$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * cuvsCagraCompressionParams_t compression - * } - */ - public static MemorySegment compression(MemorySegment struct) { - return struct.get(compression$LAYOUT, compression$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * cuvsCagraCompressionParams_t compression - * } - */ - public static void compression(MemorySegment struct, MemorySegment fieldValue) { - struct.set(compression$LAYOUT, compression$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraSearchParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraSearchParams.java deleted file mode 100644 index 2a1efbfd7..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraSearchParams.java +++ /dev/null @@ -1,644 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfFloat; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct cuvsCagraSearchParams { - * long max_queries; - * long itopk_size; - * long max_iterations; - * enum cuvsCagraSearchAlgo algo; - * long team_size; - * long search_width; - * long min_iterations; - * long thread_block_size; - * enum cuvsCagraHashMode hashmap_mode; - * long hashmap_min_bitlen; - * float hashmap_max_fill_rate; - * uint32_t num_random_samplings; - * uint64_t rand_xor_mask; - * } - * } - */ -public class CuVSCagraSearchParams { - - CuVSCagraSearchParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout - .structLayout(CagraH.C_LONG.withName("max_queries"), CagraH.C_LONG.withName("itopk_size"), - CagraH.C_LONG.withName("max_iterations"), CagraH.C_INT.withName("algo"), MemoryLayout.paddingLayout(4), - CagraH.C_LONG.withName("team_size"), CagraH.C_LONG.withName("search_width"), - CagraH.C_LONG.withName("min_iterations"), CagraH.C_LONG.withName("thread_block_size"), - CagraH.C_INT.withName("hashmap_mode"), MemoryLayout.paddingLayout(4), - CagraH.C_LONG.withName("hashmap_min_bitlen"), CagraH.C_FLOAT.withName("hashmap_max_fill_rate"), - CagraH.C_INT.withName("num_random_samplings"), CagraH.C_LONG.withName("rand_xor_mask")) - .withName("cuvsCagraSearchParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong max_queries$LAYOUT = (OfLong) $LAYOUT.select(groupElement("max_queries")); - - /** - * Layout for field: - * {@snippet lang = c : * long max_queries - * } - */ - public static final OfLong max_queries$layout() { - return max_queries$LAYOUT; - } - - private static final long max_queries$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * long max_queries - * } - */ - public static final long max_queries$offset() { - return max_queries$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long max_queries - * } - */ - public static long max_queries(MemorySegment struct) { - return struct.get(max_queries$LAYOUT, max_queries$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long max_queries - * } - */ - public static void max_queries(MemorySegment struct, long fieldValue) { - struct.set(max_queries$LAYOUT, max_queries$OFFSET, fieldValue); - } - - private static final OfLong itopk_size$LAYOUT = (OfLong) $LAYOUT.select(groupElement("itopk_size")); - - /** - * Layout for field: - * {@snippet lang = c : * long itopk_size - * } - */ - public static final OfLong itopk_size$layout() { - return itopk_size$LAYOUT; - } - - private static final long itopk_size$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang = c : * long itopk_size - * } - */ - public static final long itopk_size$offset() { - return itopk_size$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long itopk_size - * } - */ - public static long itopk_size(MemorySegment struct) { - return struct.get(itopk_size$LAYOUT, itopk_size$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long itopk_size - * } - */ - public static void itopk_size(MemorySegment struct, long fieldValue) { - struct.set(itopk_size$LAYOUT, itopk_size$OFFSET, fieldValue); - } - - private static final OfLong max_iterations$LAYOUT = (OfLong) $LAYOUT.select(groupElement("max_iterations")); - - /** - * Layout for field: - * {@snippet lang = c : * long max_iterations - * } - */ - public static final OfLong max_iterations$layout() { - return max_iterations$LAYOUT; - } - - private static final long max_iterations$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang = c : * long max_iterations - * } - */ - public static final long max_iterations$offset() { - return max_iterations$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long max_iterations - * } - */ - public static long max_iterations(MemorySegment struct) { - return struct.get(max_iterations$LAYOUT, max_iterations$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long max_iterations - * } - */ - public static void max_iterations(MemorySegment struct, long fieldValue) { - struct.set(max_iterations$LAYOUT, max_iterations$OFFSET, fieldValue); - } - - private static final OfInt algo$LAYOUT = (OfInt) $LAYOUT.select(groupElement("algo")); - - /** - * Layout for field: - * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo - * } - */ - public static final OfInt algo$layout() { - return algo$LAYOUT; - } - - private static final long algo$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo - * } - */ - public static final long algo$offset() { - return algo$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo - * } - */ - public static int algo(MemorySegment struct) { - return struct.get(algo$LAYOUT, algo$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo - * } - */ - public static void algo(MemorySegment struct, int fieldValue) { - struct.set(algo$LAYOUT, algo$OFFSET, fieldValue); - } - - private static final OfLong team_size$LAYOUT = (OfLong) $LAYOUT.select(groupElement("team_size")); - - /** - * Layout for field: - * {@snippet lang = c : * long team_size - * } - */ - public static final OfLong team_size$layout() { - return team_size$LAYOUT; - } - - private static final long team_size$OFFSET = 32; - - /** - * Offset for field: - * {@snippet lang = c : * long team_size - * } - */ - public static final long team_size$offset() { - return team_size$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long team_size - * } - */ - public static long team_size(MemorySegment struct) { - return struct.get(team_size$LAYOUT, team_size$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long team_size - * } - */ - public static void team_size(MemorySegment struct, long fieldValue) { - struct.set(team_size$LAYOUT, team_size$OFFSET, fieldValue); - } - - private static final OfLong search_width$LAYOUT = (OfLong) $LAYOUT.select(groupElement("search_width")); - - /** - * Layout for field: - * {@snippet lang = c : * long search_width - * } - */ - public static final OfLong search_width$layout() { - return search_width$LAYOUT; - } - - private static final long search_width$OFFSET = 40; - - /** - * Offset for field: - * {@snippet lang = c : * long search_width - * } - */ - public static final long search_width$offset() { - return search_width$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long search_width - * } - */ - public static long search_width(MemorySegment struct) { - return struct.get(search_width$LAYOUT, search_width$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long search_width - * } - */ - public static void search_width(MemorySegment struct, long fieldValue) { - struct.set(search_width$LAYOUT, search_width$OFFSET, fieldValue); - } - - private static final OfLong min_iterations$LAYOUT = (OfLong) $LAYOUT.select(groupElement("min_iterations")); - - /** - * Layout for field: - * {@snippet lang = c : * long min_iterations - * } - */ - public static final OfLong min_iterations$layout() { - return min_iterations$LAYOUT; - } - - private static final long min_iterations$OFFSET = 48; - - /** - * Offset for field: - * {@snippet lang = c : * long min_iterations - * } - */ - public static final long min_iterations$offset() { - return min_iterations$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long min_iterations - * } - */ - public static long min_iterations(MemorySegment struct) { - return struct.get(min_iterations$LAYOUT, min_iterations$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long min_iterations - * } - */ - public static void min_iterations(MemorySegment struct, long fieldValue) { - struct.set(min_iterations$LAYOUT, min_iterations$OFFSET, fieldValue); - } - - private static final OfLong thread_block_size$LAYOUT = (OfLong) $LAYOUT.select(groupElement("thread_block_size")); - - /** - * Layout for field: - * {@snippet lang = c : * long thread_block_size - * } - */ - public static final OfLong thread_block_size$layout() { - return thread_block_size$LAYOUT; - } - - private static final long thread_block_size$OFFSET = 56; - - /** - * Offset for field: - * {@snippet lang = c : * long thread_block_size - * } - */ - public static final long thread_block_size$offset() { - return thread_block_size$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long thread_block_size - * } - */ - public static long thread_block_size(MemorySegment struct) { - return struct.get(thread_block_size$LAYOUT, thread_block_size$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long thread_block_size - * } - */ - public static void thread_block_size(MemorySegment struct, long fieldValue) { - struct.set(thread_block_size$LAYOUT, thread_block_size$OFFSET, fieldValue); - } - - private static final OfInt hashmap_mode$LAYOUT = (OfInt) $LAYOUT.select(groupElement("hashmap_mode")); - - /** - * Layout for field: - * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static final OfInt hashmap_mode$layout() { - return hashmap_mode$LAYOUT; - } - - private static final long hashmap_mode$OFFSET = 64; - - /** - * Offset for field: - * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static final long hashmap_mode$offset() { - return hashmap_mode$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static int hashmap_mode(MemorySegment struct) { - return struct.get(hashmap_mode$LAYOUT, hashmap_mode$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static void hashmap_mode(MemorySegment struct, int fieldValue) { - struct.set(hashmap_mode$LAYOUT, hashmap_mode$OFFSET, fieldValue); - } - - private static final OfLong hashmap_min_bitlen$LAYOUT = (OfLong) $LAYOUT.select(groupElement("hashmap_min_bitlen")); - - /** - * Layout for field: - * {@snippet lang = c : * long hashmap_min_bitlen - * } - */ - public static final OfLong hashmap_min_bitlen$layout() { - return hashmap_min_bitlen$LAYOUT; - } - - private static final long hashmap_min_bitlen$OFFSET = 72; - - /** - * Offset for field: - * {@snippet lang = c : * long hashmap_min_bitlen - * } - */ - public static final long hashmap_min_bitlen$offset() { - return hashmap_min_bitlen$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long hashmap_min_bitlen - * } - */ - public static long hashmap_min_bitlen(MemorySegment struct) { - return struct.get(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long hashmap_min_bitlen - * } - */ - public static void hashmap_min_bitlen(MemorySegment struct, long fieldValue) { - struct.set(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET, fieldValue); - } - - private static final OfFloat hashmap_max_fill_rate$LAYOUT = (OfFloat) $LAYOUT - .select(groupElement("hashmap_max_fill_rate")); - - /** - * Layout for field: - * {@snippet lang = c : * float hashmap_max_fill_rate - * } - */ - public static final OfFloat hashmap_max_fill_rate$layout() { - return hashmap_max_fill_rate$LAYOUT; - } - - private static final long hashmap_max_fill_rate$OFFSET = 80; - - /** - * Offset for field: - * {@snippet lang = c : * float hashmap_max_fill_rate - * } - */ - public static final long hashmap_max_fill_rate$offset() { - return hashmap_max_fill_rate$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * float hashmap_max_fill_rate - * } - */ - public static float hashmap_max_fill_rate(MemorySegment struct) { - return struct.get(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * float hashmap_max_fill_rate - * } - */ - public static void hashmap_max_fill_rate(MemorySegment struct, float fieldValue) { - struct.set(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET, fieldValue); - } - - private static final OfInt num_random_samplings$LAYOUT = (OfInt) $LAYOUT.select(groupElement("num_random_samplings")); - - /** - * Layout for field: - * {@snippet lang = c : * uint32_t num_random_samplings - * } - */ - public static final OfInt num_random_samplings$layout() { - return num_random_samplings$LAYOUT; - } - - private static final long num_random_samplings$OFFSET = 84; - - /** - * Offset for field: - * {@snippet lang = c : * uint32_t num_random_samplings - * } - */ - public static final long num_random_samplings$offset() { - return num_random_samplings$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * uint32_t num_random_samplings - * } - */ - public static int num_random_samplings(MemorySegment struct) { - return struct.get(num_random_samplings$LAYOUT, num_random_samplings$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * uint32_t num_random_samplings - * } - */ - public static void num_random_samplings(MemorySegment struct, int fieldValue) { - struct.set(num_random_samplings$LAYOUT, num_random_samplings$OFFSET, fieldValue); - } - - private static final OfLong rand_xor_mask$LAYOUT = (OfLong) $LAYOUT.select(groupElement("rand_xor_mask")); - - /** - * Layout for field: - * {@snippet lang = c : * uint64_t rand_xor_mask - * } - */ - public static final OfLong rand_xor_mask$layout() { - return rand_xor_mask$LAYOUT; - } - - private static final long rand_xor_mask$OFFSET = 88; - - /** - * Offset for field: - * {@snippet lang = c : * uint64_t rand_xor_mask - * } - */ - public static final long rand_xor_mask$offset() { - return rand_xor_mask$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * uint64_t rand_xor_mask - * } - */ - public static long rand_xor_mask(MemorySegment struct) { - return struct.get(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * uint64_t rand_xor_mask - * } - */ - public static void rand_xor_mask(MemorySegment struct, long fieldValue) { - struct.set(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSFilter.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSFilter.java deleted file mode 100644 index dceaca994..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSFilter.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct { - * uintptr_t addr; - * enum cuvsFilterType type; - * } - * } - */ -public class CuVSFilter { - - CuVSFilter() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - BruteForceH.C_LONG.withName("addr"), - BruteForceH.C_INT.withName("type"), - MemoryLayout.paddingLayout(4) - ).withName("$anon$50:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong addr$LAYOUT = (OfLong)$LAYOUT.select(groupElement("addr")); - - /** - * Layout for field: - * {@snippet lang=c : - * uintptr_t addr - * } - */ - public static final OfLong addr$layout() { - return addr$LAYOUT; - } - - private static final long addr$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * uintptr_t addr - * } - */ - public static final long addr$offset() { - return addr$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uintptr_t addr - * } - */ - public static long addr(MemorySegment struct) { - return struct.get(addr$LAYOUT, addr$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uintptr_t addr - * } - */ - public static void addr(MemorySegment struct, long fieldValue) { - struct.set(addr$LAYOUT, addr$OFFSET, fieldValue); - } - - private static final OfInt type$LAYOUT = (OfInt)$LAYOUT.select(groupElement("type")); - - /** - * Layout for field: - * {@snippet lang=c : - * enum cuvsFilterType type - * } - */ - public static final OfInt type$layout() { - return type$LAYOUT; - } - - private static final long type$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * enum cuvsFilterType type - * } - */ - public static final long type$offset() { - return type$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * enum cuvsFilterType type - * } - */ - public static int type(MemorySegment struct) { - return struct.get(type$LAYOUT, type$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * enum cuvsFilterType type - * } - */ - public static void type(MemorySegment struct, int fieldValue) { - struct.set(type$LAYOUT, type$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswExtendParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswExtendParams.java deleted file mode 100644 index 83358e233..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswExtendParams.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct cuvsHnswExtendParams { - * int num_threads; - * } - * } - */ -public class CuVSHnswExtendParams { - - CuVSHnswExtendParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(HnswH.C_INT.withName("num_threads")) - .withName("cuvsHnswExtendParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt num_threads$LAYOUT = (OfInt) $LAYOUT.select(groupElement("num_threads")); - - /** - * Layout for field: - * {@snippet lang = c : * int num_threads - * } - */ - public static final OfInt num_threads$layout() { - return num_threads$LAYOUT; - } - - private static final long num_threads$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * int num_threads - * } - */ - public static final long num_threads$offset() { - return num_threads$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int num_threads - * } - */ - public static int num_threads(MemorySegment struct) { - return struct.get(num_threads$LAYOUT, num_threads$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int num_threads - * } - */ - public static void num_threads(MemorySegment struct, int fieldValue) { - struct.set(num_threads$LAYOUT, num_threads$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswIndex.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswIndex.java deleted file mode 100644 index aa12e4400..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswIndex.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct { - * uintptr_t addr; - * DLDataType dtype; - * } - * } - */ -public class CuVSHnswIndex { - - CuVSHnswIndex() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(HnswH.C_LONG.withName("addr"), - DLDataType.layout().withName("dtype"), MemoryLayout.paddingLayout(4)).withName("$anon$66:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong addr$LAYOUT = (OfLong) $LAYOUT.select(groupElement("addr")); - - /** - * Layout for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static final OfLong addr$layout() { - return addr$LAYOUT; - } - - private static final long addr$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static final long addr$offset() { - return addr$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static long addr(MemorySegment struct) { - return struct.get(addr$LAYOUT, addr$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * uintptr_t addr - * } - */ - public static void addr(MemorySegment struct, long fieldValue) { - struct.set(addr$LAYOUT, addr$OFFSET, fieldValue); - } - - private static final GroupLayout dtype$LAYOUT = (GroupLayout) $LAYOUT.select(groupElement("dtype")); - - /** - * Layout for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static final GroupLayout dtype$layout() { - return dtype$LAYOUT; - } - - private static final long dtype$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static final long dtype$offset() { - return dtype$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static MemorySegment dtype(MemorySegment struct) { - return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang = c : * DLDataType dtype - * } - */ - public static void dtype(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswIndexParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswIndexParams.java deleted file mode 100644 index d6b06872f..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswIndexParams.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct cuvsHnswIndexParams { - * cuvsHnswHierarchy hierarchy; - * int ef_construction; - * int num_threads; - * } - * } - */ -public class CuVSHnswIndexParams { - - CuVSHnswIndexParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(HnswH.C_INT.withName("hierarchy"), - HnswH.C_INT.withName("ef_construction"), HnswH.C_INT.withName("num_threads")).withName("cuvsHnswIndexParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt hierarchy$LAYOUT = (OfInt) $LAYOUT.select(groupElement("hierarchy")); - - /** - * Layout for field: - * {@snippet lang = c : * cuvsHnswHierarchy hierarchy - * } - */ - public static final OfInt hierarchy$layout() { - return hierarchy$LAYOUT; - } - - private static final long hierarchy$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * cuvsHnswHierarchy hierarchy - * } - */ - public static final long hierarchy$offset() { - return hierarchy$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * cuvsHnswHierarchy hierarchy - * } - */ - public static int hierarchy(MemorySegment struct) { - return struct.get(hierarchy$LAYOUT, hierarchy$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * cuvsHnswHierarchy hierarchy - * } - */ - public static void hierarchy(MemorySegment struct, int fieldValue) { - struct.set(hierarchy$LAYOUT, hierarchy$OFFSET, fieldValue); - } - - private static final OfInt ef_construction$LAYOUT = (OfInt) $LAYOUT.select(groupElement("ef_construction")); - - /** - * Layout for field: - * {@snippet lang = c : * int ef_construction - * } - */ - public static final OfInt ef_construction$layout() { - return ef_construction$LAYOUT; - } - - private static final long ef_construction$OFFSET = 4; - - /** - * Offset for field: - * {@snippet lang = c : * int ef_construction - * } - */ - public static final long ef_construction$offset() { - return ef_construction$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int ef_construction - * } - */ - public static int ef_construction(MemorySegment struct) { - return struct.get(ef_construction$LAYOUT, ef_construction$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int ef_construction - * } - */ - public static void ef_construction(MemorySegment struct, int fieldValue) { - struct.set(ef_construction$LAYOUT, ef_construction$OFFSET, fieldValue); - } - - private static final OfInt num_threads$LAYOUT = (OfInt) $LAYOUT.select(groupElement("num_threads")); - - /** - * Layout for field: - * {@snippet lang = c : * int num_threads - * } - */ - public static final OfInt num_threads$layout() { - return num_threads$LAYOUT; - } - - private static final long num_threads$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang = c : * int num_threads - * } - */ - public static final long num_threads$offset() { - return num_threads$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int num_threads - * } - */ - public static int num_threads(MemorySegment struct) { - return struct.get(num_threads$LAYOUT, num_threads$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int num_threads - * } - */ - public static void num_threads(MemorySegment struct, int fieldValue) { - struct.set(num_threads$LAYOUT, num_threads$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswSearchParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswSearchParams.java deleted file mode 100644 index ff8329a57..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswSearchParams.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct cuvsHnswSearchParams { - * int32_t ef; - * int32_t num_threads; - * } - * } - */ -public class CuVSHnswSearchParams { - - CuVSHnswSearchParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout - .structLayout(HnswH.C_INT.withName("ef"), HnswH.C_INT.withName("num_threads")).withName("cuvsHnswSearchParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt ef$LAYOUT = (OfInt) $LAYOUT.select(groupElement("ef")); - - /** - * Layout for field: - * {@snippet lang = c : * int32_t ef - * } - */ - public static final OfInt ef$layout() { - return ef$LAYOUT; - } - - private static final long ef$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * int32_t ef - * } - */ - public static final long ef$offset() { - return ef$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int32_t ef - * } - */ - public static int ef(MemorySegment struct) { - return struct.get(ef$LAYOUT, ef$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int32_t ef - * } - */ - public static void ef(MemorySegment struct, int fieldValue) { - struct.set(ef$LAYOUT, ef$OFFSET, fieldValue); - } - - private static final OfInt num_threads$LAYOUT = (OfInt) $LAYOUT.select(groupElement("num_threads")); - - /** - * Layout for field: - * {@snippet lang = c : * int32_t num_threads - * } - */ - public static final OfInt num_threads$layout() { - return num_threads$LAYOUT; - } - - private static final long num_threads$OFFSET = 4; - - /** - * Offset for field: - * {@snippet lang = c : * int32_t num_threads - * } - */ - public static final long num_threads$offset() { - return num_threads$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int32_t num_threads - * } - */ - public static int num_threads(MemorySegment struct) { - return struct.get(num_threads$LAYOUT, num_threads$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int32_t num_threads - * } - */ - public static void num_threads(MemorySegment struct, int fieldValue) { - struct.set(num_threads$LAYOUT, num_threads$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLDataType.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLDataType.java deleted file mode 100644 index aaa2f4d2d..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLDataType.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfByte; -import java.lang.foreign.ValueLayout.OfShort; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct { - * uint8_t code; - * uint8_t bits; - * uint16_t lanes; - * } - * } - */ -public class DLDataType { - - DLDataType() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - DlpackH.C_CHAR.withName("code"), - DlpackH.C_CHAR.withName("bits"), - DlpackH.C_SHORT.withName("lanes") - ).withName("$anon$174:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfByte code$LAYOUT = (OfByte)$LAYOUT.select(groupElement("code")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint8_t code - * } - */ - public static final OfByte code$layout() { - return code$LAYOUT; - } - - private static final long code$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * uint8_t code - * } - */ - public static final long code$offset() { - return code$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint8_t code - * } - */ - public static byte code(MemorySegment struct) { - return struct.get(code$LAYOUT, code$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint8_t code - * } - */ - public static void code(MemorySegment struct, byte fieldValue) { - struct.set(code$LAYOUT, code$OFFSET, fieldValue); - } - - private static final OfByte bits$LAYOUT = (OfByte)$LAYOUT.select(groupElement("bits")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint8_t bits - * } - */ - public static final OfByte bits$layout() { - return bits$LAYOUT; - } - - private static final long bits$OFFSET = 1; - - /** - * Offset for field: - * {@snippet lang=c : - * uint8_t bits - * } - */ - public static final long bits$offset() { - return bits$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint8_t bits - * } - */ - public static byte bits(MemorySegment struct) { - return struct.get(bits$LAYOUT, bits$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint8_t bits - * } - */ - public static void bits(MemorySegment struct, byte fieldValue) { - struct.set(bits$LAYOUT, bits$OFFSET, fieldValue); - } - - private static final OfShort lanes$LAYOUT = (OfShort)$LAYOUT.select(groupElement("lanes")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint16_t lanes - * } - */ - public static final OfShort lanes$layout() { - return lanes$LAYOUT; - } - - private static final long lanes$OFFSET = 2; - - /** - * Offset for field: - * {@snippet lang=c : - * uint16_t lanes - * } - */ - public static final long lanes$offset() { - return lanes$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint16_t lanes - * } - */ - public static short lanes(MemorySegment struct) { - return struct.get(lanes$LAYOUT, lanes$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint16_t lanes - * } - */ - public static void lanes(MemorySegment struct, short fieldValue) { - struct.set(lanes$LAYOUT, lanes$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLDevice.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLDevice.java deleted file mode 100644 index ceadb6a69..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLDevice.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct { - * DLDeviceType device_type; - * int32_t device_id; - * } - * } - */ -public class DLDevice { - - DLDevice() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - DlpackH.C_INT.withName("device_type"), - DlpackH.C_INT.withName("device_id") - ).withName("$anon$126:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt device_type$LAYOUT = (OfInt)$LAYOUT.select(groupElement("device_type")); - - /** - * Layout for field: - * {@snippet lang=c : - * DLDeviceType device_type - * } - */ - public static final OfInt device_type$layout() { - return device_type$LAYOUT; - } - - private static final long device_type$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * DLDeviceType device_type - * } - */ - public static final long device_type$offset() { - return device_type$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * DLDeviceType device_type - * } - */ - public static int device_type(MemorySegment struct) { - return struct.get(device_type$LAYOUT, device_type$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * DLDeviceType device_type - * } - */ - public static void device_type(MemorySegment struct, int fieldValue) { - struct.set(device_type$LAYOUT, device_type$OFFSET, fieldValue); - } - - private static final OfInt device_id$LAYOUT = (OfInt)$LAYOUT.select(groupElement("device_id")); - - /** - * Layout for field: - * {@snippet lang=c : - * int32_t device_id - * } - */ - public static final OfInt device_id$layout() { - return device_id$LAYOUT; - } - - private static final long device_id$OFFSET = 4; - - /** - * Offset for field: - * {@snippet lang=c : - * int32_t device_id - * } - */ - public static final long device_id$offset() { - return device_id$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * int32_t device_id - * } - */ - public static int device_id(MemorySegment struct) { - return struct.get(device_id$LAYOUT, device_id$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * int32_t device_id - * } - */ - public static void device_id(MemorySegment struct, int fieldValue) { - struct.set(device_id$LAYOUT, device_id$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLManagedTensor.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLManagedTensor.java deleted file mode 100644 index c28dd71c3..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLManagedTensor.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.invoke.MethodHandle; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct DLManagedTensor { - * DLTensor dl_tensor; - * void *manager_ctx; - * void (*deleter)(struct DLManagedTensor *); - * } - * } - */ -public class DLManagedTensor { - - DLManagedTensor() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - DLTensor.layout().withName("dl_tensor"), - DlpackH.C_POINTER.withName("manager_ctx"), - DlpackH.C_POINTER.withName("deleter") - ).withName("DLManagedTensor"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final GroupLayout dl_tensor$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dl_tensor")); - - /** - * Layout for field: - * {@snippet lang=c : - * DLTensor dl_tensor - * } - */ - public static final GroupLayout dl_tensor$layout() { - return dl_tensor$LAYOUT; - } - - private static final long dl_tensor$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * DLTensor dl_tensor - * } - */ - public static final long dl_tensor$offset() { - return dl_tensor$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * DLTensor dl_tensor - * } - */ - public static MemorySegment dl_tensor(MemorySegment struct) { - return struct.asSlice(dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang=c : - * DLTensor dl_tensor - * } - */ - public static void dl_tensor(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); - } - - private static final AddressLayout manager_ctx$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("manager_ctx")); - - /** - * Layout for field: - * {@snippet lang=c : - * void *manager_ctx - * } - */ - public static final AddressLayout manager_ctx$layout() { - return manager_ctx$LAYOUT; - } - - private static final long manager_ctx$OFFSET = 48; - - /** - * Offset for field: - * {@snippet lang=c : - * void *manager_ctx - * } - */ - public static final long manager_ctx$offset() { - return manager_ctx$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * void *manager_ctx - * } - */ - public static MemorySegment manager_ctx(MemorySegment struct) { - return struct.get(manager_ctx$LAYOUT, manager_ctx$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * void *manager_ctx - * } - */ - public static void manager_ctx(MemorySegment struct, MemorySegment fieldValue) { - struct.set(manager_ctx$LAYOUT, manager_ctx$OFFSET, fieldValue); - } - - /** - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensor *) - * } - */ - public static class deleter { - - deleter() { - // Should not be called directly - } - - /** - * The function pointer signature, expressed as a functional interface - */ - public interface Function { - void apply(MemorySegment _x0); - } - - private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( - DlpackH.C_POINTER - ); - - /** - * The descriptor of this function pointer - */ - public static FunctionDescriptor descriptor() { - return $DESC; - } - - private static final MethodHandle UP$MH = DlpackH.upcallHandle(deleter.Function.class, "apply", $DESC); - - /** - * Allocates a new upcall stub, whose implementation is defined by {@code fi}. - * The lifetime of the returned segment is managed by {@code arena} - */ - public static MemorySegment allocate(deleter.Function fi, Arena arena) { - return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); - } - - private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); - - /** - * Invoke the upcall stub {@code funcPtr}, with given parameters - */ - public static void invoke(MemorySegment funcPtr,MemorySegment _x0) { - try { - DOWN$MH.invokeExact(funcPtr, _x0); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - } - - private static final AddressLayout deleter$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("deleter")); - - /** - * Layout for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensor *) - * } - */ - public static final AddressLayout deleter$layout() { - return deleter$LAYOUT; - } - - private static final long deleter$OFFSET = 56; - - /** - * Offset for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensor *) - * } - */ - public static final long deleter$offset() { - return deleter$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensor *) - * } - */ - public static MemorySegment deleter(MemorySegment struct) { - return struct.get(deleter$LAYOUT, deleter$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensor *) - * } - */ - public static void deleter(MemorySegment struct, MemorySegment fieldValue) { - struct.set(deleter$LAYOUT, deleter$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLManagedTensorVersioned.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLManagedTensorVersioned.java deleted file mode 100644 index f631140e2..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLManagedTensorVersioned.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfLong; -import java.lang.invoke.MethodHandle; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct DLManagedTensorVersioned { - * DLPackVersion version; - * void *manager_ctx; - * void (*deleter)(struct DLManagedTensorVersioned *); - * uint64_t flags; - * DLTensor dl_tensor; - * } - * } - */ -public class DLManagedTensorVersioned { - - DLManagedTensorVersioned() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - DLPackVersion.layout().withName("version"), - DlpackH.C_POINTER.withName("manager_ctx"), - DlpackH.C_POINTER.withName("deleter"), - DlpackH.C_LONG.withName("flags"), - DLTensor.layout().withName("dl_tensor") - ).withName("DLManagedTensorVersioned"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final GroupLayout version$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("version")); - - /** - * Layout for field: - * {@snippet lang=c : - * DLPackVersion version - * } - */ - public static final GroupLayout version$layout() { - return version$LAYOUT; - } - - private static final long version$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * DLPackVersion version - * } - */ - public static final long version$offset() { - return version$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * DLPackVersion version - * } - */ - public static MemorySegment version(MemorySegment struct) { - return struct.asSlice(version$OFFSET, version$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang=c : - * DLPackVersion version - * } - */ - public static void version(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, version$OFFSET, version$LAYOUT.byteSize()); - } - - private static final AddressLayout manager_ctx$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("manager_ctx")); - - /** - * Layout for field: - * {@snippet lang=c : - * void *manager_ctx - * } - */ - public static final AddressLayout manager_ctx$layout() { - return manager_ctx$LAYOUT; - } - - private static final long manager_ctx$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * void *manager_ctx - * } - */ - public static final long manager_ctx$offset() { - return manager_ctx$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * void *manager_ctx - * } - */ - public static MemorySegment manager_ctx(MemorySegment struct) { - return struct.get(manager_ctx$LAYOUT, manager_ctx$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * void *manager_ctx - * } - */ - public static void manager_ctx(MemorySegment struct, MemorySegment fieldValue) { - struct.set(manager_ctx$LAYOUT, manager_ctx$OFFSET, fieldValue); - } - - /** - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensorVersioned *) - * } - */ - public static class deleter { - - deleter() { - // Should not be called directly - } - - /** - * The function pointer signature, expressed as a functional interface - */ - public interface Function { - void apply(MemorySegment _x0); - } - - private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( - DlpackH.C_POINTER - ); - - /** - * The descriptor of this function pointer - */ - public static FunctionDescriptor descriptor() { - return $DESC; - } - - private static final MethodHandle UP$MH = DlpackH.upcallHandle(deleter.Function.class, "apply", $DESC); - - /** - * Allocates a new upcall stub, whose implementation is defined by {@code fi}. - * The lifetime of the returned segment is managed by {@code arena} - */ - public static MemorySegment allocate(deleter.Function fi, Arena arena) { - return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); - } - - private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); - - /** - * Invoke the upcall stub {@code funcPtr}, with given parameters - */ - public static void invoke(MemorySegment funcPtr,MemorySegment _x0) { - try { - DOWN$MH.invokeExact(funcPtr, _x0); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - } - - private static final AddressLayout deleter$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("deleter")); - - /** - * Layout for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensorVersioned *) - * } - */ - public static final AddressLayout deleter$layout() { - return deleter$LAYOUT; - } - - private static final long deleter$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensorVersioned *) - * } - */ - public static final long deleter$offset() { - return deleter$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensorVersioned *) - * } - */ - public static MemorySegment deleter(MemorySegment struct) { - return struct.get(deleter$LAYOUT, deleter$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensorVersioned *) - * } - */ - public static void deleter(MemorySegment struct, MemorySegment fieldValue) { - struct.set(deleter$LAYOUT, deleter$OFFSET, fieldValue); - } - - private static final OfLong flags$LAYOUT = (OfLong)$LAYOUT.select(groupElement("flags")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint64_t flags - * } - */ - public static final OfLong flags$layout() { - return flags$LAYOUT; - } - - private static final long flags$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang=c : - * uint64_t flags - * } - */ - public static final long flags$offset() { - return flags$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint64_t flags - * } - */ - public static long flags(MemorySegment struct) { - return struct.get(flags$LAYOUT, flags$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint64_t flags - * } - */ - public static void flags(MemorySegment struct, long fieldValue) { - struct.set(flags$LAYOUT, flags$OFFSET, fieldValue); - } - - private static final GroupLayout dl_tensor$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dl_tensor")); - - /** - * Layout for field: - * {@snippet lang=c : - * DLTensor dl_tensor - * } - */ - public static final GroupLayout dl_tensor$layout() { - return dl_tensor$LAYOUT; - } - - private static final long dl_tensor$OFFSET = 32; - - /** - * Offset for field: - * {@snippet lang=c : - * DLTensor dl_tensor - * } - */ - public static final long dl_tensor$offset() { - return dl_tensor$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * DLTensor dl_tensor - * } - */ - public static MemorySegment dl_tensor(MemorySegment struct) { - return struct.asSlice(dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang=c : - * DLTensor dl_tensor - * } - */ - public static void dl_tensor(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLPackVersion.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLPackVersion.java deleted file mode 100644 index c65fdd887..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLPackVersion.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct { - * uint32_t major; - * uint32_t minor; - * } - * } - */ -public class DLPackVersion { - - DLPackVersion() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - DlpackH.C_INT.withName("major"), - DlpackH.C_INT.withName("minor") - ).withName("$anon$61:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt major$LAYOUT = (OfInt)$LAYOUT.select(groupElement("major")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t major - * } - */ - public static final OfInt major$layout() { - return major$LAYOUT; - } - - private static final long major$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t major - * } - */ - public static final long major$offset() { - return major$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t major - * } - */ - public static int major(MemorySegment struct) { - return struct.get(major$LAYOUT, major$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t major - * } - */ - public static void major(MemorySegment struct, int fieldValue) { - struct.set(major$LAYOUT, major$OFFSET, fieldValue); - } - - private static final OfInt minor$LAYOUT = (OfInt)$LAYOUT.select(groupElement("minor")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t minor - * } - */ - public static final OfInt minor$layout() { - return minor$LAYOUT; - } - - private static final long minor$OFFSET = 4; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t minor - * } - */ - public static final long minor$offset() { - return minor$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t minor - * } - */ - public static int minor(MemorySegment struct) { - return struct.get(minor$LAYOUT, minor$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t minor - * } - */ - public static void minor(MemorySegment struct, int fieldValue) { - struct.set(minor$LAYOUT, minor$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLTensor.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLTensor.java deleted file mode 100644 index 21d928905..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DLTensor.java +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct { - * void *data; - * DLDevice device; - * int32_t ndim; - * DLDataType dtype; - * int64_t *shape; - * int64_t *strides; - * uint64_t byte_offset; - * } - * } - */ -public class DLTensor { - - DLTensor() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - DlpackH.C_POINTER.withName("data"), - DLDevice.layout().withName("device"), - DlpackH.C_INT.withName("ndim"), - DLDataType.layout().withName("dtype"), - DlpackH.C_POINTER.withName("shape"), - DlpackH.C_POINTER.withName("strides"), - DlpackH.C_LONG.withName("byte_offset") - ).withName("$anon$192:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final AddressLayout data$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("data")); - - /** - * Layout for field: - * {@snippet lang=c : - * void *data - * } - */ - public static final AddressLayout data$layout() { - return data$LAYOUT; - } - - private static final long data$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * void *data - * } - */ - public static final long data$offset() { - return data$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * void *data - * } - */ - public static MemorySegment data(MemorySegment struct) { - return struct.get(data$LAYOUT, data$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * void *data - * } - */ - public static void data(MemorySegment struct, MemorySegment fieldValue) { - struct.set(data$LAYOUT, data$OFFSET, fieldValue); - } - - private static final GroupLayout device$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("device")); - - /** - * Layout for field: - * {@snippet lang=c : - * DLDevice device - * } - */ - public static final GroupLayout device$layout() { - return device$LAYOUT; - } - - private static final long device$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * DLDevice device - * } - */ - public static final long device$offset() { - return device$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * DLDevice device - * } - */ - public static MemorySegment device(MemorySegment struct) { - return struct.asSlice(device$OFFSET, device$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang=c : - * DLDevice device - * } - */ - public static void device(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, device$OFFSET, device$LAYOUT.byteSize()); - } - - private static final OfInt ndim$LAYOUT = (OfInt)$LAYOUT.select(groupElement("ndim")); - - /** - * Layout for field: - * {@snippet lang=c : - * int32_t ndim - * } - */ - public static final OfInt ndim$layout() { - return ndim$LAYOUT; - } - - private static final long ndim$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang=c : - * int32_t ndim - * } - */ - public static final long ndim$offset() { - return ndim$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * int32_t ndim - * } - */ - public static int ndim(MemorySegment struct) { - return struct.get(ndim$LAYOUT, ndim$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * int32_t ndim - * } - */ - public static void ndim(MemorySegment struct, int fieldValue) { - struct.set(ndim$LAYOUT, ndim$OFFSET, fieldValue); - } - - private static final GroupLayout dtype$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dtype")); - - /** - * Layout for field: - * {@snippet lang=c : - * DLDataType dtype - * } - */ - public static final GroupLayout dtype$layout() { - return dtype$LAYOUT; - } - - private static final long dtype$OFFSET = 20; - - /** - * Offset for field: - * {@snippet lang=c : - * DLDataType dtype - * } - */ - public static final long dtype$offset() { - return dtype$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * DLDataType dtype - * } - */ - public static MemorySegment dtype(MemorySegment struct) { - return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang=c : - * DLDataType dtype - * } - */ - public static void dtype(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - private static final AddressLayout shape$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("shape")); - - /** - * Layout for field: - * {@snippet lang=c : - * int64_t *shape - * } - */ - public static final AddressLayout shape$layout() { - return shape$LAYOUT; - } - - private static final long shape$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang=c : - * int64_t *shape - * } - */ - public static final long shape$offset() { - return shape$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * int64_t *shape - * } - */ - public static MemorySegment shape(MemorySegment struct) { - return struct.get(shape$LAYOUT, shape$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * int64_t *shape - * } - */ - public static void shape(MemorySegment struct, MemorySegment fieldValue) { - struct.set(shape$LAYOUT, shape$OFFSET, fieldValue); - } - - private static final AddressLayout strides$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("strides")); - - /** - * Layout for field: - * {@snippet lang=c : - * int64_t *strides - * } - */ - public static final AddressLayout strides$layout() { - return strides$LAYOUT; - } - - private static final long strides$OFFSET = 32; - - /** - * Offset for field: - * {@snippet lang=c : - * int64_t *strides - * } - */ - public static final long strides$offset() { - return strides$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * int64_t *strides - * } - */ - public static MemorySegment strides(MemorySegment struct) { - return struct.get(strides$LAYOUT, strides$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * int64_t *strides - * } - */ - public static void strides(MemorySegment struct, MemorySegment fieldValue) { - struct.set(strides$LAYOUT, strides$OFFSET, fieldValue); - } - - private static final OfLong byte_offset$LAYOUT = (OfLong)$LAYOUT.select(groupElement("byte_offset")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint64_t byte_offset - * } - */ - public static final OfLong byte_offset$layout() { - return byte_offset$LAYOUT; - } - - private static final long byte_offset$OFFSET = 40; - - /** - * Offset for field: - * {@snippet lang=c : - * uint64_t byte_offset - * } - */ - public static final long byte_offset$offset() { - return byte_offset$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint64_t byte_offset - * } - */ - public static long byte_offset(MemorySegment struct) { - return struct.get(byte_offset$LAYOUT, byte_offset$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint64_t byte_offset - * } - */ - public static void byte_offset(MemorySegment struct, long fieldValue) { - struct.set(byte_offset$LAYOUT, byte_offset$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DistanceH.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DistanceH.java deleted file mode 100644 index b98f95ae2..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DistanceH.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import java.lang.invoke.*; -import java.lang.foreign.*; -import java.nio.ByteOrder; -import java.util.*; -import java.util.function.*; -import java.util.stream.*; - -import static java.lang.foreign.ValueLayout.*; -import static java.lang.foreign.MemoryLayout.PathElement.*; - -public class DistanceH { - - DistanceH() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args) - .map(Object::toString) - .collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol) - .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream() - .map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? - MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() - .or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int L2Expanded = (int)0L; - /** - * {@snippet lang=c : - * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - private static final int L2SqrtExpanded = (int)1L; - /** - * {@snippet lang=c : - * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - private static final int CosineExpanded = (int)2L; - /** - * {@snippet lang=c : - * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - private static final int L1 = (int)3L; - /** - * {@snippet lang=c : - * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - private static final int L2Unexpanded = (int)4L; - /** - * {@snippet lang=c : - * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - private static final int L2SqrtUnexpanded = (int)5L; - /** - * {@snippet lang=c : - * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - private static final int InnerProduct = (int)6L; - /** - * {@snippet lang=c : - * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - private static final int Linf = (int)7L; - /** - * {@snippet lang=c : - * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - private static final int Canberra = (int)8L; - /** - * {@snippet lang=c : - * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - private static final int LpUnexpanded = (int)9L; - /** - * {@snippet lang=c : - * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - private static final int CorrelationExpanded = (int)10L; - /** - * {@snippet lang=c : - * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - private static final int JaccardExpanded = (int)11L; - /** - * {@snippet lang=c : - * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - private static final int HellingerExpanded = (int)12L; - /** - * {@snippet lang=c : - * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - private static final int Haversine = (int)13L; - /** - * {@snippet lang=c : - * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - private static final int BrayCurtis = (int)14L; - /** - * {@snippet lang=c : - * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - private static final int JensenShannon = (int)15L; - /** - * {@snippet lang=c : - * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - private static final int HammingUnexpanded = (int)16L; - /** - * {@snippet lang=c : - * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - private static final int KLDivergence = (int)17L; - /** - * {@snippet lang=c : - * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - private static final int RusselRaoExpanded = (int)18L; - /** - * {@snippet lang=c : - * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - private static final int DiceExpanded = (int)19L; - /** - * {@snippet lang=c : - * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - private static final int Precomputed = (int)100L; - /** - * {@snippet lang=c : - * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DlpackH.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DlpackH.java deleted file mode 100644 index 6ef78336f..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/DlpackH.java +++ /dev/null @@ -1,1898 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.ValueLayout.JAVA_BYTE; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.PaddingLayout; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.StructLayout; -import java.lang.foreign.SymbolLookup; -import java.lang.foreign.ValueLayout; -import java.lang.foreign.ValueLayout.OfByte; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.lang.foreign.ValueLayout.OfShort; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class DlpackH { - - DlpackH() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args) - .map(Object::toString) - .collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol) - .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream() - .map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? - MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() - .or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int DLPACK_MAJOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - private static final int DLPACK_MINOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - private static final int _STDINT_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - private static final int _FEATURES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - private static final int _DEFAULT_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - private static final int __GLIBC_USE_ISOC2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - private static final int __USE_ISOC11 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - private static final int __USE_ISOC99 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - private static final int __USE_ISOC95 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - private static final int __USE_POSIX_IMPLICITLY = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - private static final int _POSIX_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - private static final int __USE_POSIX = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - private static final int __USE_POSIX2 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - private static final int __USE_POSIX199309 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - private static final int __USE_POSIX199506 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - private static final int __USE_XOPEN2K = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - private static final int __USE_XOPEN2K8 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - private static final int _ATFILE_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - private static final int __WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; - /** - * {@snippet lang=c : - * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - private static final int __SYSCALL_WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - private static final int __USE_MISC = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - private static final int __USE_ATFILE = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - private static final int __USE_FORTIFY_LEVEL = (int)0L; - /** - * {@snippet lang=c : - * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - private static final int _STDC_PREDEF_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - private static final int __STDC_IEC_559__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - private static final int __GNU_LIBRARY__ = (int)6L; - /** - * {@snippet lang=c : - * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - private static final int __GLIBC__ = (int)2L; - /** - * {@snippet lang=c : - * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - private static final int __GLIBC_MINOR__ = (int)35L; - /** - * {@snippet lang=c : - * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - private static final int _SYS_CDEFS_H = (int)1L; - /** - * {@snippet lang=c : - * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - private static final int __glibc_c99_flexarr_available = (int)1L; - /** - * {@snippet lang=c : - * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; - /** - * {@snippet lang=c : - * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - private static final int __HAVE_GENERIC_SELECTION = (int)1L; - /** - * {@snippet lang=c : - * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - private static final int _BITS_TYPES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - private static final int _BITS_TYPESIZES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - private static final int __INO_T_MATCHES_INO64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - private static final int __STATFS_MATCHES_STATFS64 = (int)1L; - /** - * {@snippet lang=c : - * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; - /** - * {@snippet lang=c : - * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - private static final int __FD_SETSIZE = (int)1024L; - /** - * {@snippet lang=c : - * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - private static final int _BITS_TIME64_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - private static final int _BITS_WCHAR_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - private static final int _BITS_STDINT_INTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - private static final int _BITS_STDINT_UINTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = DlpackH.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = DlpackH.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = DlpackH.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = DlpackH.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = DlpackH.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = DlpackH.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = DlpackH.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = DlpackH.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = DlpackH.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = DlpackH.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = DlpackH.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = DlpackH.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = DlpackH.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = DlpackH.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = DlpackH.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/Fsidt.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/Fsidt.java deleted file mode 100644 index fb5f82ed1..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/Fsidt.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; -import static java.lang.foreign.MemoryLayout.PathElement.sequenceElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.SequenceLayout; -import java.lang.invoke.VarHandle; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct { - * int __val[2]; - * } - * } - */ -public class Fsidt { - - Fsidt() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout - .structLayout(MemoryLayout.sequenceLayout(2, CagraH.C_INT).withName("__val")).withName("$anon$155:12"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final SequenceLayout __val$LAYOUT = (SequenceLayout) $LAYOUT.select(groupElement("__val")); - - /** - * Layout for field: - * {@snippet lang = c : * int __val[2] - * } - */ - public static final SequenceLayout __val$layout() { - return __val$LAYOUT; - } - - private static final long __val$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * int __val[2] - * } - */ - public static final long __val$offset() { - return __val$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int __val[2] - * } - */ - public static MemorySegment __val(MemorySegment struct) { - return struct.asSlice(__val$OFFSET, __val$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang = c : * int __val[2] - * } - */ - public static void __val(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, __val$OFFSET, __val$LAYOUT.byteSize()); - } - - private static long[] __val$DIMS = { 2 }; - - /** - * Dimensions for array field: - * {@snippet lang = c : * int __val[2] - * } - */ - public static long[] __val$dimensions() { - return __val$DIMS; - } - - private static final VarHandle __val$ELEM_HANDLE = __val$LAYOUT.varHandle(sequenceElement()); - - /** - * Indexed getter for field: - * {@snippet lang = c : * int __val[2] - * } - */ - public static int __val(MemorySegment struct, long index0) { - return (int) __val$ELEM_HANDLE.get(struct, 0L, index0); - } - - /** - * Indexed setter for field: - * {@snippet lang = c : * int __val[2] - * } - */ - public static void __val(MemorySegment struct, long index0, int fieldValue) { - __val$ELEM_HANDLE.set(struct, 0L, index0, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/GpuInfo.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/GpuInfo.java deleted file mode 100644 index eb8aba223..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/GpuInfo.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; -import static java.lang.foreign.MemoryLayout.PathElement.sequenceElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.ValueLayout.OfFloat; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.lang.invoke.VarHandle; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct gpuInfo { - * int gpu_id; - * char name[256]; - * long free_memory; - * long total_memory; - * float compute_capability; - * } - * } - */ -public class GpuInfo { - GpuInfo() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(GpuInfoH.C_INT.withName("gpu_id"), - MemoryLayout.sequenceLayout(256, GpuInfoH.C_CHAR).withName("name"), MemoryLayout.paddingLayout(4), - GpuInfoH.C_LONG.withName("free_memory"), GpuInfoH.C_LONG.withName("total_memory"), - GpuInfoH.C_FLOAT.withName("compute_capability"), MemoryLayout.paddingLayout(4)).withName("gpuInfo"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt gpu_id$LAYOUT = (OfInt) $LAYOUT.select(groupElement("gpu_id")); - - /** - * Layout for field: - * {@snippet lang = c : * int gpu_id - * } - */ - public static final OfInt gpu_id$layout() { - return gpu_id$LAYOUT; - } - - private static final long gpu_id$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * int gpu_id - * } - */ - public static final long gpu_id$offset() { - return gpu_id$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int gpu_id - * } - */ - public static int gpu_id(MemorySegment struct) { - return struct.get(gpu_id$LAYOUT, gpu_id$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int gpu_id - * } - */ - public static void gpu_id(MemorySegment struct, int fieldValue) { - struct.set(gpu_id$LAYOUT, gpu_id$OFFSET, fieldValue); - } - - private static final SequenceLayout name$LAYOUT = (SequenceLayout) $LAYOUT.select(groupElement("name")); - - /** - * Layout for field: - * {@snippet lang = c : * char name[256] - * } - */ - public static final SequenceLayout name$layout() { - return name$LAYOUT; - } - - private static final long name$OFFSET = 4; - - /** - * Offset for field: - * {@snippet lang = c : * char name[256] - * } - */ - public static final long name$offset() { - return name$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * char name[256] - * } - */ - public static MemorySegment name(MemorySegment struct) { - return struct.asSlice(name$OFFSET, name$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang = c : * char name[256] - * } - */ - public static void name(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, name$OFFSET, name$LAYOUT.byteSize()); - } - - private static long[] name$DIMS = { 256 }; - - /** - * Dimensions for array field: - * {@snippet lang = c : * char name[256] - * } - */ - public static long[] name$dimensions() { - return name$DIMS; - } - - private static final VarHandle name$ELEM_HANDLE = name$LAYOUT.varHandle(sequenceElement()); - - /** - * Indexed getter for field: - * {@snippet lang = c : * char name[256] - * } - */ - public static byte name(MemorySegment struct, long index0) { - return (byte) name$ELEM_HANDLE.get(struct, 0L, index0); - } - - /** - * Indexed setter for field: - * {@snippet lang = c : * char name[256] - * } - */ - public static void name(MemorySegment struct, long index0, byte fieldValue) { - name$ELEM_HANDLE.set(struct, 0L, index0, fieldValue); - } - - private static final OfLong free_memory$LAYOUT = (OfLong) $LAYOUT.select(groupElement("free_memory")); - - /** - * Layout for field: - * {@snippet lang = c : * long free_memory - * } - */ - public static final OfLong free_memory$layout() { - return free_memory$LAYOUT; - } - - private static final long free_memory$OFFSET = 264; - - /** - * Offset for field: - * {@snippet lang = c : * long free_memory - * } - */ - public static final long free_memory$offset() { - return free_memory$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long free_memory - * } - */ - public static long free_memory(MemorySegment struct) { - return struct.get(free_memory$LAYOUT, free_memory$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long free_memory - * } - */ - public static void free_memory(MemorySegment struct, long fieldValue) { - struct.set(free_memory$LAYOUT, free_memory$OFFSET, fieldValue); - } - - private static final OfLong total_memory$LAYOUT = (OfLong) $LAYOUT.select(groupElement("total_memory")); - - /** - * Layout for field: - * {@snippet lang = c : * long total_memory - * } - */ - public static final OfLong total_memory$layout() { - return total_memory$LAYOUT; - } - - private static final long total_memory$OFFSET = 272; - - /** - * Offset for field: - * {@snippet lang = c : * long total_memory - * } - */ - public static final long total_memory$offset() { - return total_memory$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * long total_memory - * } - */ - public static long total_memory(MemorySegment struct) { - return struct.get(total_memory$LAYOUT, total_memory$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * long total_memory - * } - */ - public static void total_memory(MemorySegment struct, long fieldValue) { - struct.set(total_memory$LAYOUT, total_memory$OFFSET, fieldValue); - } - - private static final OfFloat compute_capability$LAYOUT = (OfFloat) $LAYOUT.select(groupElement("compute_capability")); - - /** - * Layout for field: - * {@snippet lang = c : * float compute_capability - * } - */ - public static final OfFloat compute_capability$layout() { - return compute_capability$LAYOUT; - } - - private static final long compute_capability$OFFSET = 280; - - /** - * Offset for field: - * {@snippet lang = c : * float compute_capability - * } - */ - public static final long compute_capability$offset() { - return compute_capability$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * float compute_capability - * } - */ - public static float compute_capability(MemorySegment struct) { - return struct.get(compute_capability$LAYOUT, compute_capability$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * float compute_capability - * } - */ - public static void compute_capability(MemorySegment struct, float fieldValue) { - struct.set(compute_capability$LAYOUT, compute_capability$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at - * {@code index}. The returned segment has address - * {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { - return layout().byteSize(); - } - - /** - * Allocate a segment of size {@code layout().byteSize()} using - * {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. The - * returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and - * {@code cleanupAction} (if any). The returned segment has size - * {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, - Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/GpuInfoH.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/GpuInfoH.java deleted file mode 100644 index 0457d50be..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/GpuInfoH.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.ValueLayout.JAVA_BYTE; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.PaddingLayout; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.StructLayout; -import java.lang.foreign.SymbolLookup; -import java.lang.foreign.ValueLayout; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class GpuInfoH { - GpuInfoH() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) - : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/HnswH.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/HnswH.java deleted file mode 100644 index b6945030b..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/HnswH.java +++ /dev/null @@ -1,2350 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.ValueLayout.JAVA_BYTE; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.PaddingLayout; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.StructLayout; -import java.lang.foreign.SymbolLookup; -import java.lang.foreign.ValueLayout; -import java.lang.foreign.ValueLayout.OfByte; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.lang.foreign.ValueLayout.OfShort; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class HnswH { - - HnswH() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) - : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int DLPACK_VERSION = (int) 80L; - - /** - * {@snippet lang = c : * #define DLPACK_VERSION 80 - * } - */ - public static int DLPACK_VERSION() { - return DLPACK_VERSION; - } - - private static final int DLPACK_ABI_VERSION = (int) 1L; - - /** - * {@snippet lang = c : * #define DLPACK_ABI_VERSION 1 - * } - */ - public static int DLPACK_ABI_VERSION() { - return DLPACK_ABI_VERSION; - } - - private static final int _STDINT_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - - private static final int _FEATURES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - - private static final int _DEFAULT_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - - private static final int __GLIBC_USE_ISOC2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - - private static final int __USE_ISOC11 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - - private static final int __USE_ISOC99 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - - private static final int __USE_ISOC95 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - - private static final int __USE_POSIX_IMPLICITLY = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - - private static final int _POSIX_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - - private static final int __USE_POSIX = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - - private static final int __USE_POSIX2 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - - private static final int __USE_POSIX199309 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - - private static final int __USE_POSIX199506 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - - private static final int __USE_XOPEN2K = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - - private static final int __USE_XOPEN2K8 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - - private static final int _ATFILE_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - - private static final int __WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - - private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; - - /** - * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - - private static final int __SYSCALL_WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - - private static final int __USE_MISC = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - - private static final int __USE_ATFILE = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - - private static final int __USE_FORTIFY_LEVEL = (int) 0L; - - /** - * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - - private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - - private static final int _STDC_PREDEF_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - - private static final int __STDC_IEC_559__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - - private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - - private static final int __GNU_LIBRARY__ = (int) 6L; - - /** - * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - - private static final int __GLIBC__ = (int) 2L; - - /** - * {@snippet lang = c : * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - - private static final int __GLIBC_MINOR__ = (int) 35L; - - /** - * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - - private static final int _SYS_CDEFS_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - - private static final int __glibc_c99_flexarr_available = (int) 1L; - - /** - * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; - - /** - * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - - private static final int __HAVE_GENERIC_SELECTION = (int) 1L; - - /** - * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - - private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - - private static final int _BITS_TYPES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - - private static final int _BITS_TYPESIZES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - - private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - - private static final int __INO_T_MATCHES_INO64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - - private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - - private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - - private static final int __FD_SETSIZE = (int) 1024L; - - /** - * {@snippet lang = c : * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - - private static final int _BITS_TIME64_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - - private static final int _BITS_WCHAR_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - - private static final int _BITS_STDINT_INTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - - private static final int _BITS_STDINT_UINTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - - private static final int true_ = (int) 1L; - - /** - * {@snippet lang = c : * #define true 1 - * } - */ - public static int true_() { - return true_; - } - - private static final int false_ = (int) 0L; - - /** - * {@snippet lang = c : * #define false 0 - * } - */ - public static int false_() { - return false_; - } - - private static final int __bool_true_false_are_defined = (int) 1L; - - /** - * {@snippet lang = c : * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - - private static final int L2Expanded = (int) 0L; - - /** - * {@snippet lang = c : * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - - private static final int L2SqrtExpanded = (int) 1L; - - /** - * {@snippet lang = c : * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - - private static final int CosineExpanded = (int) 2L; - - /** - * {@snippet lang = c : * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - - private static final int L1 = (int) 3L; - - /** - * {@snippet lang = c : * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - - private static final int L2Unexpanded = (int) 4L; - - /** - * {@snippet lang = c : * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - - private static final int L2SqrtUnexpanded = (int) 5L; - - /** - * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - - private static final int InnerProduct = (int) 6L; - - /** - * {@snippet lang = c : * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - - private static final int Linf = (int) 7L; - - /** - * {@snippet lang = c : * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - - private static final int Canberra = (int) 8L; - - /** - * {@snippet lang = c : * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - - private static final int LpUnexpanded = (int) 9L; - - /** - * {@snippet lang = c : * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - - private static final int CorrelationExpanded = (int) 10L; - - /** - * {@snippet lang = c : * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - - private static final int JaccardExpanded = (int) 11L; - - /** - * {@snippet lang = c : * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - - private static final int HellingerExpanded = (int) 12L; - - /** - * {@snippet lang = c : * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - - private static final int Haversine = (int) 13L; - - /** - * {@snippet lang = c : * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - - private static final int BrayCurtis = (int) 14L; - - /** - * {@snippet lang = c : * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - - private static final int JensenShannon = (int) 15L; - - /** - * {@snippet lang = c : * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - - private static final int HammingUnexpanded = (int) 16L; - - /** - * {@snippet lang = c : * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - - private static final int KLDivergence = (int) 17L; - - /** - * {@snippet lang = c : * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - - private static final int RusselRaoExpanded = (int) 18L; - - /** - * {@snippet lang = c : * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - - private static final int DiceExpanded = (int) 19L; - - /** - * {@snippet lang = c : * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - - private static final int Precomputed = (int) 100L; - - /** - * {@snippet lang = c : * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - - /** - * {@snippet lang = c : * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = HnswH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = HnswH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = HnswH.C_SHORT; - /** - * {@snippet lang = c : * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = HnswH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = HnswH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off_t - * } - */ - public static final OfLong __off_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef long __time_t - * } - */ - public static final OfLong __time_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef int __key_t - * } - */ - public static final OfInt __key_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = HnswH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = HnswH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = HnswH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = HnswH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = HnswH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = HnswH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = HnswH.C_INT; - /** - * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = HnswH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = HnswH.C_LONG; - /** - * {@snippet lang = c : * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = HnswH.C_INT; - private static final int kDLCPU = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - - private static final int kDLCUDA = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - - private static final int kDLCUDAHost = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - - private static final int kDLOpenCL = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - - private static final int kDLVulkan = (int) 7L; - - /** - * {@snippet lang = c : * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - - private static final int kDLMetal = (int) 8L; - - /** - * {@snippet lang = c : * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - - private static final int kDLVPI = (int) 9L; - - /** - * {@snippet lang = c : * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - - private static final int kDLROCM = (int) 10L; - - /** - * {@snippet lang = c : * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - - private static final int kDLROCMHost = (int) 11L; - - /** - * {@snippet lang = c : * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - - private static final int kDLExtDev = (int) 12L; - - /** - * {@snippet lang = c : * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - - private static final int kDLCUDAManaged = (int) 13L; - - /** - * {@snippet lang = c : * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - - private static final int kDLOneAPI = (int) 14L; - - /** - * {@snippet lang = c : * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - - private static final int kDLWebGPU = (int) 15L; - - /** - * {@snippet lang = c : * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - - private static final int kDLHexagon = (int) 16L; - - /** - * {@snippet lang = c : * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - - private static final int kDLInt = (int) 0L; - - /** - * {@snippet lang = c : * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - - private static final int kDLUInt = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - - private static final int kDLFloat = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - - private static final int kDLOpaqueHandle = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - - private static final int kDLBfloat = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - - private static final int kDLComplex = (int) 5L; - - /** - * {@snippet lang = c : * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - - private static final int kDLBool = (int) 6L; - - /** - * {@snippet lang = c : * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - - private static final int AUTO_SELECT = (int) 0L; - - /** - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 - * } - */ - public static int AUTO_SELECT() { - return AUTO_SELECT; - } - - private static final int IVF_PQ = (int) 1L; - - /** - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 - * } - */ - public static int IVF_PQ() { - return IVF_PQ; - } - - private static final int NN_DESCENT = (int) 2L; - - /** - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 - * } - */ - public static int NN_DESCENT() { - return NN_DESCENT; - } - - /** - * {@snippet lang = c : - * typedef struct cuvsCagraCompressionParams { - * uint32_t pq_bits; - * uint32_t pq_dim; - * uint32_t vq_n_centers; - * uint32_t kmeans_n_iters; - * double vq_kmeans_trainset_fraction; - * double pq_kmeans_trainset_fraction; - * } *cuvsCagraCompressionParams_t - * } - */ - public static final AddressLayout cuvsCagraCompressionParams_t = HnswH.C_POINTER; - /** - * {@snippet lang = c : - * typedef struct cuvsCagraIndexParams { - * cuvsDistanceType metric; - * long intermediate_graph_degree; - * long graph_degree; - * enum cuvsCagraGraphBuildAlgo build_algo; - * long nn_descent_niter; - * cuvsCagraCompressionParams_t compression; - * } *cuvsCagraIndexParams_t - * } - */ - public static final AddressLayout cuvsCagraIndexParams_t = HnswH.C_POINTER; - private static final int SINGLE_CTA = (int) 0L; - - /** - * {@snippet lang = c : * enum cuvsCagraSearchAlgo.SINGLE_CTA = 0 - * } - */ - public static int SINGLE_CTA() { - return SINGLE_CTA; - } - - private static final int MULTI_CTA = (int) 1L; - - /** - * {@snippet lang = c : * enum cuvsCagraSearchAlgo.MULTI_CTA = 1 - * } - */ - public static int MULTI_CTA() { - return MULTI_CTA; - } - - private static final int MULTI_KERNEL = (int) 2L; - - /** - * {@snippet lang = c : * enum cuvsCagraSearchAlgo.MULTI_KERNEL = 2 - * } - */ - public static int MULTI_KERNEL() { - return MULTI_KERNEL; - } - - private static final int AUTO = (int) 3L; - - /** - * {@snippet lang = c : * enum cuvsCagraSearchAlgo.AUTO = 3 - * } - */ - public static int AUTO() { - return AUTO; - } - - private static final int HASH = (int) 0L; - - /** - * {@snippet lang = c : * enum cuvsCagraHashMode.HASH = 0 - * } - */ - public static int HASH() { - return HASH; - } - - private static final int SMALL = (int) 1L; - - /** - * {@snippet lang = c : * enum cuvsCagraHashMode.SMALL = 1 - * } - */ - public static int SMALL() { - return SMALL; - } - - private static final int AUTO_HASH = (int) 2L; - - /** - * {@snippet lang = c : * enum cuvsCagraHashMode.AUTO_HASH = 2 - * } - */ - public static int AUTO_HASH() { - return AUTO_HASH; - } - - /** - * {@snippet lang = c : - * typedef struct cuvsCagraSearchParams { - * long max_queries; - * long itopk_size; - * long max_iterations; - * enum cuvsCagraSearchAlgo algo; - * long team_size; - * long search_width; - * long min_iterations; - * long thread_block_size; - * enum cuvsCagraHashMode hashmap_mode; - * long hashmap_min_bitlen; - * float hashmap_max_fill_rate; - * uint32_t num_random_samplings; - * uint64_t rand_xor_mask; - * } *cuvsCagraSearchParams_t - * } - */ - public static final AddressLayout cuvsCagraSearchParams_t = HnswH.C_POINTER; - /** - * {@snippet lang = c : * typedef cuvsCagraIndex *cuvsCagraIndex_t - * } - */ - public static final AddressLayout cuvsCagraIndex_t = HnswH.C_POINTER; - private static final int NONE = (int) 0L; - - /** - * {@snippet lang = c : * enum cuvsHnswHierarchy.NONE = 0 - * } - */ - public static int NONE() { - return NONE; - } - - private static final int CPU = (int) 1L; - - /** - * {@snippet lang = c : * enum cuvsHnswHierarchy.CPU = 1 - * } - */ - public static int CPU() { - return CPU; - } - - /** - * {@snippet lang = c : - * typedef struct cuvsHnswIndexParams { - * cuvsHnswHierarchy hierarchy; - * int ef_construction; - * int num_threads; - * } *cuvsHnswIndexParams_t - * } - */ - public static final AddressLayout cuvsHnswIndexParams_t = HnswH.C_POINTER; - /** - * {@snippet lang = c : * typedef cuvsHnswIndex *cuvsHnswIndex_t - * } - */ - public static final AddressLayout cuvsHnswIndex_t = HnswH.C_POINTER; - /** - * {@snippet lang = c : - * typedef struct cuvsHnswExtendParams { - * int num_threads; - * } *cuvsHnswExtendParams_t - * } - */ - public static final AddressLayout cuvsHnswExtendParams_t = HnswH.C_POINTER; - /** - * {@snippet lang = c : - * typedef struct cuvsHnswSearchParams { - * int32_t ef; - * int32_t num_threads; - * } *cuvsHnswSearchParams_t - * } - */ - public static final AddressLayout cuvsHnswSearchParams_t = HnswH.C_POINTER; - private static final long _POSIX_C_SOURCE = 200809L; - - /** - * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - - private static final int __TIMESIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - - private static final long __STDC_IEC_60559_BFP__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - - private static final long __STDC_ISO_10646__ = 201706L; - - /** - * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - - private static final int __WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - - private static final int __WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - - private static final int INT8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - - private static final int INT16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - - private static final int INT32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - - private static final long INT64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - - private static final int INT8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - - private static final int INT16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - - private static final int INT32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - - private static final long INT64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - - private static final int UINT8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - - private static final int UINT16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - - private static final int UINT32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - - private static final long UINT64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - - private static final int INT_LEAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - - private static final int INT_LEAST16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - - private static final int INT_LEAST32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - - private static final long INT_LEAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - - private static final int INT_LEAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - - private static final int INT_LEAST16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - - private static final int INT_LEAST32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - - private static final long INT_LEAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - - private static final int UINT_LEAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - - private static final int UINT_LEAST16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - - private static final int UINT_LEAST32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - - private static final long UINT_LEAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - - private static final int INT_FAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - - private static final long INT_FAST16_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - - private static final long INT_FAST32_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - - private static final long INT_FAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - - private static final int INT_FAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - - private static final long INT_FAST16_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - - private static final long INT_FAST32_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - - private static final long INT_FAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - - private static final int UINT_FAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - - private static final long UINT_FAST16_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - - private static final long UINT_FAST32_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - - private static final long UINT_FAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - - private static final long INTPTR_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - - private static final long INTPTR_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - - private static final long UINTPTR_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - - private static final long INTMAX_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - - private static final long INTMAX_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - - private static final long UINTMAX_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - - private static final long PTRDIFF_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - - private static final long PTRDIFF_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - - private static final int SIG_ATOMIC_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - - private static final int SIG_ATOMIC_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - - private static final long SIZE_MAX = -1L; - - /** - * {@snippet lang = c : * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - - private static final int WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - - private static final int WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - - private static final int WINT_MIN = (int) 0L; - - /** - * {@snippet lang = c : * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - - private static final int WINT_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - - /** - * {@snippet lang = c : * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/IvfFlatH.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/IvfFlatH.java deleted file mode 100644 index 32cdeb813..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/IvfFlatH.java +++ /dev/null @@ -1,2845 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.ValueLayout.JAVA_BYTE; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.PaddingLayout; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.StructLayout; -import java.lang.foreign.SymbolLookup; -import java.lang.foreign.ValueLayout; -import java.lang.foreign.ValueLayout.OfByte; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.lang.foreign.ValueLayout.OfShort; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class IvfFlatH { - - IvfFlatH() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) - : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int _STDINT_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - - private static final int _FEATURES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - - private static final int _DEFAULT_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - - private static final int __GLIBC_USE_ISOC2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - - private static final int __USE_ISOC11 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - - private static final int __USE_ISOC99 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - - private static final int __USE_ISOC95 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - - private static final int __USE_POSIX_IMPLICITLY = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - - private static final int _POSIX_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - - private static final int __USE_POSIX = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - - private static final int __USE_POSIX2 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - - private static final int __USE_POSIX199309 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - - private static final int __USE_POSIX199506 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - - private static final int __USE_XOPEN2K = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - - private static final int __USE_XOPEN2K8 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - - private static final int _ATFILE_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - - private static final int __WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - - private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; - - /** - * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - - private static final int __SYSCALL_WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - - private static final int __USE_MISC = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - - private static final int __USE_ATFILE = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - - private static final int __USE_FORTIFY_LEVEL = (int) 0L; - - /** - * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - - private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - - private static final int _STDC_PREDEF_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - - private static final int __STDC_IEC_559__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - - private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - - private static final int __GNU_LIBRARY__ = (int) 6L; - - /** - * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - - private static final int __GLIBC__ = (int) 2L; - - /** - * {@snippet lang = c : * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - - private static final int __GLIBC_MINOR__ = (int) 35L; - - /** - * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - - private static final int _SYS_CDEFS_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - - private static final int __glibc_c99_flexarr_available = (int) 1L; - - /** - * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; - - /** - * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - - private static final int __HAVE_GENERIC_SELECTION = (int) 1L; - - /** - * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - - private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - - private static final int _BITS_TYPES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - - private static final int _BITS_TYPESIZES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - - private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - - private static final int __INO_T_MATCHES_INO64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - - private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - - private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - - private static final int __FD_SETSIZE = (int) 1024L; - - /** - * {@snippet lang = c : * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - - private static final int _BITS_TIME64_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - - private static final int _BITS_WCHAR_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - - private static final int _BITS_STDINT_INTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - - private static final int _BITS_STDINT_UINTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - - private static final int DLPACK_MAJOR_VERSION = (int) 1L; - - /** - * {@snippet lang = c : * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - - private static final int DLPACK_MINOR_VERSION = (int) 0L; - - /** - * {@snippet lang = c : * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - - private static final int true_ = (int) 1L; - - /** - * {@snippet lang = c : * #define true 1 - * } - */ - public static int true_() { - return true_; - } - - private static final int false_ = (int) 0L; - - /** - * {@snippet lang = c : * #define false 0 - * } - */ - public static int false_() { - return false_; - } - - private static final int __bool_true_false_are_defined = (int) 1L; - - /** - * {@snippet lang = c : * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - - /** - * {@snippet lang = c : * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = IvfFlatH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = IvfFlatH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = IvfFlatH.C_SHORT; - /** - * {@snippet lang = c : * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = IvfFlatH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = IvfFlatH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off_t - * } - */ - public static final OfLong __off_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef long __time_t - * } - */ - public static final OfLong __time_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef int __key_t - * } - */ - public static final OfInt __key_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = IvfFlatH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = IvfFlatH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = IvfFlatH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = IvfFlatH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = IvfFlatH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = IvfFlatH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = IvfFlatH.C_INT; - /** - * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = IvfFlatH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = IvfFlatH.C_LONG; - private static final int CUVS_ERROR = (int) 0L; - - /** - * {@snippet lang = c : * enum .CUVS_ERROR = 0 - * } - */ - public static int CUVS_ERROR() { - return CUVS_ERROR; - } - - private static final int CUVS_SUCCESS = (int) 1L; - - /** - * {@snippet lang = c : * enum .CUVS_SUCCESS = 1 - * } - */ - public static int CUVS_SUCCESS() { - return CUVS_SUCCESS; - } - - /** - * {@snippet lang = c : * typedef uintptr_t cuvsResources_t - * } - */ - public static final OfLong cuvsResources_t = IvfFlatH.C_LONG; - private static final int L2Expanded = (int) 0L; - - /** - * {@snippet lang = c : * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - - private static final int L2SqrtExpanded = (int) 1L; - - /** - * {@snippet lang = c : * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - - private static final int CosineExpanded = (int) 2L; - - /** - * {@snippet lang = c : * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - - private static final int L1 = (int) 3L; - - /** - * {@snippet lang = c : * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - - private static final int L2Unexpanded = (int) 4L; - - /** - * {@snippet lang = c : * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - - private static final int L2SqrtUnexpanded = (int) 5L; - - /** - * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - - private static final int InnerProduct = (int) 6L; - - /** - * {@snippet lang = c : * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - - private static final int Linf = (int) 7L; - - /** - * {@snippet lang = c : * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - - private static final int Canberra = (int) 8L; - - /** - * {@snippet lang = c : * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - - private static final int LpUnexpanded = (int) 9L; - - /** - * {@snippet lang = c : * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - - private static final int CorrelationExpanded = (int) 10L; - - /** - * {@snippet lang = c : * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - - private static final int JaccardExpanded = (int) 11L; - - /** - * {@snippet lang = c : * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - - private static final int HellingerExpanded = (int) 12L; - - /** - * {@snippet lang = c : * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - - private static final int Haversine = (int) 13L; - - /** - * {@snippet lang = c : * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - - private static final int BrayCurtis = (int) 14L; - - /** - * {@snippet lang = c : * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - - private static final int JensenShannon = (int) 15L; - - /** - * {@snippet lang = c : * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - - private static final int HammingUnexpanded = (int) 16L; - - /** - * {@snippet lang = c : * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - - private static final int KLDivergence = (int) 17L; - - /** - * {@snippet lang = c : * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - - private static final int RusselRaoExpanded = (int) 18L; - - /** - * {@snippet lang = c : * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - - private static final int DiceExpanded = (int) 19L; - - /** - * {@snippet lang = c : * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - - private static final int Precomputed = (int) 100L; - - /** - * {@snippet lang = c : * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - - /** - * {@snippet lang = c : * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = IvfFlatH.C_LONG; - /** - * {@snippet lang = c : * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = IvfFlatH.C_INT; - private static final int kDLCPU = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - - private static final int kDLCUDA = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - - private static final int kDLCUDAHost = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - - private static final int kDLOpenCL = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - - private static final int kDLVulkan = (int) 7L; - - /** - * {@snippet lang = c : * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - - private static final int kDLMetal = (int) 8L; - - /** - * {@snippet lang = c : * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - - private static final int kDLVPI = (int) 9L; - - /** - * {@snippet lang = c : * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - - private static final int kDLROCM = (int) 10L; - - /** - * {@snippet lang = c : * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - - private static final int kDLROCMHost = (int) 11L; - - /** - * {@snippet lang = c : * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - - private static final int kDLExtDev = (int) 12L; - - /** - * {@snippet lang = c : * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - - private static final int kDLCUDAManaged = (int) 13L; - - /** - * {@snippet lang = c : * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - - private static final int kDLOneAPI = (int) 14L; - - /** - * {@snippet lang = c : * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - - private static final int kDLWebGPU = (int) 15L; - - /** - * {@snippet lang = c : * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - - private static final int kDLHexagon = (int) 16L; - - /** - * {@snippet lang = c : * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - - private static final int kDLMAIA = (int) 17L; - - /** - * {@snippet lang = c : * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - - private static final int kDLInt = (int) 0L; - - /** - * {@snippet lang = c : * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - - private static final int kDLUInt = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - - private static final int kDLFloat = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - - private static final int kDLOpaqueHandle = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - - private static final int kDLBfloat = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - - private static final int kDLComplex = (int) 5L; - - /** - * {@snippet lang = c : * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - - private static final int kDLBool = (int) 6L; - - /** - * {@snippet lang = c : * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - - /** - * {@snippet lang = c : - * typedef struct cuvsIvfFlatIndexParams { - * cuvsDistanceType metric; - * float metric_arg; - * _Bool add_data_on_build; - * uint32_t n_lists; - * uint32_t kmeans_n_iters; - * double kmeans_trainset_fraction; - * _Bool adaptive_centers; - * _Bool conservative_memory_allocation; - * } *cuvsIvfFlatIndexParams_t - * } - */ - public static final AddressLayout cuvsIvfFlatIndexParams_t = IvfFlatH.C_POINTER; - - private static class cuvsIvfFlatIndexParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatIndexParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexParamsCreate$descriptor() { - return cuvsIvfFlatIndexParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static MethodHandle cuvsIvfFlatIndexParamsCreate$handle() { - return cuvsIvfFlatIndexParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static MemorySegment cuvsIvfFlatIndexParamsCreate$address() { - return cuvsIvfFlatIndexParamsCreate.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static int cuvsIvfFlatIndexParamsCreate(MemorySegment index_params) { - var mh$ = cuvsIvfFlatIndexParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexParamsCreate", index_params); - } - return (int) mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatIndexParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatIndexParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexParamsDestroy$descriptor() { - return cuvsIvfFlatIndexParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static MethodHandle cuvsIvfFlatIndexParamsDestroy$handle() { - return cuvsIvfFlatIndexParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static MemorySegment cuvsIvfFlatIndexParamsDestroy$address() { - return cuvsIvfFlatIndexParamsDestroy.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static int cuvsIvfFlatIndexParamsDestroy(MemorySegment index_params) { - var mh$ = cuvsIvfFlatIndexParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexParamsDestroy", index_params); - } - return (int) mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - /** - * {@snippet lang = c : - * typedef struct cuvsIvfFlatSearchParams { - * uint32_t n_probes; - * } *cuvsIvfFlatSearchParams_t - * } - */ - public static final AddressLayout cuvsIvfFlatSearchParams_t = IvfFlatH.C_POINTER; - - private static class cuvsIvfFlatSearchParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatSearchParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSearchParamsCreate$descriptor() { - return cuvsIvfFlatSearchParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static MethodHandle cuvsIvfFlatSearchParamsCreate$handle() { - return cuvsIvfFlatSearchParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static MemorySegment cuvsIvfFlatSearchParamsCreate$address() { - return cuvsIvfFlatSearchParamsCreate.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static int cuvsIvfFlatSearchParamsCreate(MemorySegment params) { - var mh$ = cuvsIvfFlatSearchParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSearchParamsCreate", params); - } - return (int) mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatSearchParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatSearchParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSearchParamsDestroy$descriptor() { - return cuvsIvfFlatSearchParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static MethodHandle cuvsIvfFlatSearchParamsDestroy$handle() { - return cuvsIvfFlatSearchParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static MemorySegment cuvsIvfFlatSearchParamsDestroy$address() { - return cuvsIvfFlatSearchParamsDestroy.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static int cuvsIvfFlatSearchParamsDestroy(MemorySegment params) { - var mh$ = cuvsIvfFlatSearchParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSearchParamsDestroy", params); - } - return (int) mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - /** - * {@snippet lang = c : * typedef cuvsIvfFlatIndex *cuvsIvfFlatIndex_t - * } - */ - public static final AddressLayout cuvsIvfFlatIndex_t = IvfFlatH.C_POINTER; - - private static class cuvsIvfFlatIndexCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatIndexCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexCreate$descriptor() { - return cuvsIvfFlatIndexCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static MethodHandle cuvsIvfFlatIndexCreate$handle() { - return cuvsIvfFlatIndexCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static MemorySegment cuvsIvfFlatIndexCreate$address() { - return cuvsIvfFlatIndexCreate.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static int cuvsIvfFlatIndexCreate(MemorySegment index) { - var mh$ = cuvsIvfFlatIndexCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexCreate", index); - } - return (int) mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatIndexDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatIndexDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexDestroy$descriptor() { - return cuvsIvfFlatIndexDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatIndexDestroy$handle() { - return cuvsIvfFlatIndexDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatIndexDestroy$address() { - return cuvsIvfFlatIndexDestroy.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatIndexDestroy(MemorySegment index) { - var mh$ = cuvsIvfFlatIndexDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexDestroy", index); - } - return (int) mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatBuild { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_LONG, - IvfFlatH.C_POINTER, IvfFlatH.C_POINTER, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatBuild"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatBuild$descriptor() { - return cuvsIvfFlatBuild.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatBuild$handle() { - return cuvsIvfFlatBuild.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatBuild$address() { - return cuvsIvfFlatBuild.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatBuild(long res, MemorySegment index_params, MemorySegment dataset, MemorySegment index) { - var mh$ = cuvsIvfFlatBuild.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatBuild", res, index_params, dataset, index); - } - return (int) mh$.invokeExact(res, index_params, dataset, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatSearch { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_LONG, - IvfFlatH.C_POINTER, IvfFlatH.C_POINTER, IvfFlatH.C_POINTER, IvfFlatH.C_POINTER, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatSearch"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSearch$descriptor() { - return cuvsIvfFlatSearch.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MethodHandle cuvsIvfFlatSearch$handle() { - return cuvsIvfFlatSearch.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MemorySegment cuvsIvfFlatSearch$address() { - return cuvsIvfFlatSearch.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static int cuvsIvfFlatSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, - MemorySegment neighbors, MemorySegment distances) { - var mh$ = cuvsIvfFlatSearch.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSearch", res, search_params, index, queries, neighbors, distances); - } - return (int) mh$.invokeExact(res, search_params, index, queries, neighbors, distances); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatSerialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_LONG, - IvfFlatH.C_POINTER, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatSerialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSerialize$descriptor() { - return cuvsIvfFlatSerialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatSerialize$handle() { - return cuvsIvfFlatSerialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatSerialize$address() { - return cuvsIvfFlatSerialize.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatSerialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfFlatSerialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSerialize", res, filename, index); - } - return (int) mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatDeserialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_LONG, - IvfFlatH.C_POINTER, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatDeserialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatDeserialize$descriptor() { - return cuvsIvfFlatDeserialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatDeserialize$handle() { - return cuvsIvfFlatDeserialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatDeserialize$address() { - return cuvsIvfFlatDeserialize.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatDeserialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfFlatDeserialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatDeserialize", res, filename, index); - } - return (int) mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatExtend { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfFlatH.C_INT, IvfFlatH.C_LONG, - IvfFlatH.C_POINTER, IvfFlatH.C_POINTER, IvfFlatH.C_POINTER); - - public static final MemorySegment ADDR = IvfFlatH.findOrThrow("cuvsIvfFlatExtend"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatExtend$descriptor() { - return cuvsIvfFlatExtend.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatExtend$handle() { - return cuvsIvfFlatExtend.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatExtend$address() { - return cuvsIvfFlatExtend.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, - MemorySegment index) { - var mh$ = cuvsIvfFlatExtend.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatExtend", res, new_vectors, new_indices, index); - } - return (int) mh$.invokeExact(res, new_vectors, new_indices, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static final long _POSIX_C_SOURCE = 200809L; - - /** - * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - - private static final int __TIMESIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - - private static final long __STDC_IEC_60559_BFP__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - - private static final long __STDC_ISO_10646__ = 201706L; - - /** - * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - - private static final int __WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - - private static final int __WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - - private static final int INT8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - - private static final int INT16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - - private static final int INT32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - - private static final long INT64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - - private static final int INT8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - - private static final int INT16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - - private static final int INT32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - - private static final long INT64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - - private static final int UINT8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - - private static final int UINT16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - - private static final int UINT32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - - private static final long UINT64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - - private static final int INT_LEAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - - private static final int INT_LEAST16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - - private static final int INT_LEAST32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - - private static final long INT_LEAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - - private static final int INT_LEAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - - private static final int INT_LEAST16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - - private static final int INT_LEAST32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - - private static final long INT_LEAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - - private static final int UINT_LEAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - - private static final int UINT_LEAST16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - - private static final int UINT_LEAST32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - - private static final long UINT_LEAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - - private static final int INT_FAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - - private static final long INT_FAST16_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - - private static final long INT_FAST32_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - - private static final long INT_FAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - - private static final int INT_FAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - - private static final long INT_FAST16_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - - private static final long INT_FAST32_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - - private static final long INT_FAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - - private static final int UINT_FAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - - private static final long UINT_FAST16_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - - private static final long UINT_FAST32_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - - private static final long UINT_FAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - - private static final long INTPTR_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - - private static final long INTPTR_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - - private static final long UINTPTR_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - - private static final long INTMAX_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - - private static final long INTMAX_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - - private static final long UINTMAX_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - - private static final long PTRDIFF_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - - private static final long PTRDIFF_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - - private static final int SIG_ATOMIC_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - - private static final int SIG_ATOMIC_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - - private static final long SIZE_MAX = -1L; - - /** - * {@snippet lang = c : * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - - private static final int WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - - private static final int WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - - private static final int WINT_MIN = (int) 0L; - - /** - * {@snippet lang = c : * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - - private static final int WINT_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - - /** - * {@snippet lang = c : * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - - /** - * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - - /** - * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/IvfPqH.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/IvfPqH.java deleted file mode 100644 index 66d0ba5ac..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/IvfPqH.java +++ /dev/null @@ -1,3182 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.ValueLayout.JAVA_BYTE; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.PaddingLayout; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.StructLayout; -import java.lang.foreign.SymbolLookup; -import java.lang.foreign.ValueLayout; -import java.lang.foreign.ValueLayout.OfByte; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.lang.foreign.ValueLayout.OfShort; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class IvfPqH { - - IvfPqH() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) - : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int _STDINT_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - - private static final int _FEATURES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - - private static final int _DEFAULT_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - - private static final int __GLIBC_USE_ISOC2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - - private static final int __USE_ISOC11 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - - private static final int __USE_ISOC99 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - - private static final int __USE_ISOC95 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - - private static final int __USE_POSIX_IMPLICITLY = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - - private static final int _POSIX_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - - private static final int __USE_POSIX = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - - private static final int __USE_POSIX2 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - - private static final int __USE_POSIX199309 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - - private static final int __USE_POSIX199506 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - - private static final int __USE_XOPEN2K = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - - private static final int __USE_XOPEN2K8 = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - - private static final int _ATFILE_SOURCE = (int) 1L; - - /** - * {@snippet lang = c : * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - - private static final int __WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - - private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; - - /** - * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - - private static final int __SYSCALL_WORDSIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - - private static final int __USE_MISC = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - - private static final int __USE_ATFILE = (int) 1L; - - /** - * {@snippet lang = c : * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - - private static final int __USE_FORTIFY_LEVEL = (int) 0L; - - /** - * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - - private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - - private static final int _STDC_PREDEF_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - - private static final int __STDC_IEC_559__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - - private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - - private static final int __GNU_LIBRARY__ = (int) 6L; - - /** - * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - - private static final int __GLIBC__ = (int) 2L; - - /** - * {@snippet lang = c : * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - - private static final int __GLIBC_MINOR__ = (int) 35L; - - /** - * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - - private static final int _SYS_CDEFS_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - - private static final int __glibc_c99_flexarr_available = (int) 1L; - - /** - * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; - - /** - * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - - private static final int __HAVE_GENERIC_SELECTION = (int) 1L; - - /** - * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - - private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; - - /** - * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - - private static final int _BITS_TYPES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - - private static final int _BITS_TYPESIZES_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - - private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - - private static final int __INO_T_MATCHES_INO64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - - private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; - - /** - * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - - private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; - - /** - * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - - private static final int __FD_SETSIZE = (int) 1024L; - - /** - * {@snippet lang = c : * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - - private static final int _BITS_TIME64_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - - private static final int _BITS_WCHAR_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - - private static final int _BITS_STDINT_INTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - - private static final int _BITS_STDINT_UINTN_H = (int) 1L; - - /** - * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - - private static final int DLPACK_MAJOR_VERSION = (int) 1L; - - /** - * {@snippet lang = c : * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - - private static final int DLPACK_MINOR_VERSION = (int) 0L; - - /** - * {@snippet lang = c : * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - - private static final int true_ = (int) 1L; - - /** - * {@snippet lang = c : * #define true 1 - * } - */ - public static int true_() { - return true_; - } - - private static final int false_ = (int) 0L; - - /** - * {@snippet lang = c : * #define false 0 - * } - */ - public static int false_() { - return false_; - } - - private static final int __bool_true_false_are_defined = (int) 1L; - - /** - * {@snippet lang = c : * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - - /** - * {@snippet lang = c : * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = IvfPqH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = IvfPqH.C_SHORT; - /** - * {@snippet lang = c : * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = IvfPqH.C_SHORT; - /** - * {@snippet lang = c : * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = IvfPqH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = IvfPqH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off_t - * } - */ - public static final OfLong __off_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef long __time_t - * } - */ - public static final OfLong __time_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef int __key_t - * } - */ - public static final OfInt __key_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = IvfPqH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = IvfPqH.C_POINTER; - /** - * {@snippet lang = c : * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = IvfPqH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = IvfPqH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = IvfPqH.C_SHORT; - /** - * {@snippet lang = c : * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = IvfPqH.C_SHORT; - /** - * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = IvfPqH.C_INT; - /** - * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = IvfPqH.C_CHAR; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = IvfPqH.C_LONG; - private static final int CUVS_ERROR = (int) 0L; - - /** - * {@snippet lang = c : * enum .CUVS_ERROR = 0 - * } - */ - public static int CUVS_ERROR() { - return CUVS_ERROR; - } - - private static final int CUVS_SUCCESS = (int) 1L; - - /** - * {@snippet lang = c : * enum .CUVS_SUCCESS = 1 - * } - */ - public static int CUVS_SUCCESS() { - return CUVS_SUCCESS; - } - - /** - * {@snippet lang = c : * typedef uintptr_t cuvsResources_t - * } - */ - public static final OfLong cuvsResources_t = IvfPqH.C_LONG; - private static final int L2Expanded = (int) 0L; - - /** - * {@snippet lang = c : * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - - private static final int L2SqrtExpanded = (int) 1L; - - /** - * {@snippet lang = c : * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - - private static final int CosineExpanded = (int) 2L; - - /** - * {@snippet lang = c : * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - - private static final int L1 = (int) 3L; - - /** - * {@snippet lang = c : * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - - private static final int L2Unexpanded = (int) 4L; - - /** - * {@snippet lang = c : * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - - private static final int L2SqrtUnexpanded = (int) 5L; - - /** - * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - - private static final int InnerProduct = (int) 6L; - - /** - * {@snippet lang = c : * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - - private static final int Linf = (int) 7L; - - /** - * {@snippet lang = c : * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - - private static final int Canberra = (int) 8L; - - /** - * {@snippet lang = c : * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - - private static final int LpUnexpanded = (int) 9L; - - /** - * {@snippet lang = c : * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - - private static final int CorrelationExpanded = (int) 10L; - - /** - * {@snippet lang = c : * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - - private static final int JaccardExpanded = (int) 11L; - - /** - * {@snippet lang = c : * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - - private static final int HellingerExpanded = (int) 12L; - - /** - * {@snippet lang = c : * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - - private static final int Haversine = (int) 13L; - - /** - * {@snippet lang = c : * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - - private static final int BrayCurtis = (int) 14L; - - /** - * {@snippet lang = c : * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - - private static final int JensenShannon = (int) 15L; - - /** - * {@snippet lang = c : * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - - private static final int HammingUnexpanded = (int) 16L; - - /** - * {@snippet lang = c : * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - - private static final int KLDivergence = (int) 17L; - - /** - * {@snippet lang = c : * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - - private static final int RusselRaoExpanded = (int) 18L; - - /** - * {@snippet lang = c : * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - - private static final int DiceExpanded = (int) 19L; - - /** - * {@snippet lang = c : * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - - private static final int Precomputed = (int) 100L; - - /** - * {@snippet lang = c : * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - - /** - * {@snippet lang = c : * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = IvfPqH.C_LONG; - /** - * {@snippet lang = c : * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = IvfPqH.C_INT; - private static final int kDLCPU = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - - private static final int kDLCUDA = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - - private static final int kDLCUDAHost = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - - private static final int kDLOpenCL = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - - private static final int kDLVulkan = (int) 7L; - - /** - * {@snippet lang = c : * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - - private static final int kDLMetal = (int) 8L; - - /** - * {@snippet lang = c : * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - - private static final int kDLVPI = (int) 9L; - - /** - * {@snippet lang = c : * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - - private static final int kDLROCM = (int) 10L; - - /** - * {@snippet lang = c : * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - - private static final int kDLROCMHost = (int) 11L; - - /** - * {@snippet lang = c : * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - - private static final int kDLExtDev = (int) 12L; - - /** - * {@snippet lang = c : * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - - private static final int kDLCUDAManaged = (int) 13L; - - /** - * {@snippet lang = c : * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - - private static final int kDLOneAPI = (int) 14L; - - /** - * {@snippet lang = c : * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - - private static final int kDLWebGPU = (int) 15L; - - /** - * {@snippet lang = c : * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - - private static final int kDLHexagon = (int) 16L; - - /** - * {@snippet lang = c : * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - - private static final int kDLMAIA = (int) 17L; - - /** - * {@snippet lang = c : * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - - private static final int kDLInt = (int) 0L; - - /** - * {@snippet lang = c : * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - - private static final int kDLUInt = (int) 1L; - - /** - * {@snippet lang = c : * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - - private static final int kDLFloat = (int) 2L; - - /** - * {@snippet lang = c : * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - - private static final int kDLOpaqueHandle = (int) 3L; - - /** - * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - - private static final int kDLBfloat = (int) 4L; - - /** - * {@snippet lang = c : * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - - private static final int kDLComplex = (int) 5L; - - /** - * {@snippet lang = c : * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - - private static final int kDLBool = (int) 6L; - - /** - * {@snippet lang = c : * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - - private static final int CUDA_R_16F = (int) 2L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16F = 2 - * } - */ - public static int CUDA_R_16F() { - return CUDA_R_16F; - } - - private static final int CUDA_C_16F = (int) 6L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16F = 6 - * } - */ - public static int CUDA_C_16F() { - return CUDA_C_16F; - } - - private static final int CUDA_R_16BF = (int) 14L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16BF = 14 - * } - */ - public static int CUDA_R_16BF() { - return CUDA_R_16BF; - } - - private static final int CUDA_C_16BF = (int) 15L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16BF = 15 - * } - */ - public static int CUDA_C_16BF() { - return CUDA_C_16BF; - } - - private static final int CUDA_R_32F = (int) 0L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_32F = 0 - * } - */ - public static int CUDA_R_32F() { - return CUDA_R_32F; - } - - private static final int CUDA_C_32F = (int) 4L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_32F = 4 - * } - */ - public static int CUDA_C_32F() { - return CUDA_C_32F; - } - - private static final int CUDA_R_64F = (int) 1L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_64F = 1 - * } - */ - public static int CUDA_R_64F() { - return CUDA_R_64F; - } - - private static final int CUDA_C_64F = (int) 5L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_64F = 5 - * } - */ - public static int CUDA_C_64F() { - return CUDA_C_64F; - } - - private static final int CUDA_R_4I = (int) 16L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_4I = 16 - * } - */ - public static int CUDA_R_4I() { - return CUDA_R_4I; - } - - private static final int CUDA_C_4I = (int) 17L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_4I = 17 - * } - */ - public static int CUDA_C_4I() { - return CUDA_C_4I; - } - - private static final int CUDA_R_4U = (int) 18L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_4U = 18 - * } - */ - public static int CUDA_R_4U() { - return CUDA_R_4U; - } - - private static final int CUDA_C_4U = (int) 19L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_4U = 19 - * } - */ - public static int CUDA_C_4U() { - return CUDA_C_4U; - } - - private static final int CUDA_R_8I = (int) 3L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_8I = 3 - * } - */ - public static int CUDA_R_8I() { - return CUDA_R_8I; - } - - private static final int CUDA_C_8I = (int) 7L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_8I = 7 - * } - */ - public static int CUDA_C_8I() { - return CUDA_C_8I; - } - - private static final int CUDA_R_8U = (int) 8L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_8U = 8 - * } - */ - public static int CUDA_R_8U() { - return CUDA_R_8U; - } - - private static final int CUDA_C_8U = (int) 9L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_8U = 9 - * } - */ - public static int CUDA_C_8U() { - return CUDA_C_8U; - } - - private static final int CUDA_R_16I = (int) 20L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16I = 20 - * } - */ - public static int CUDA_R_16I() { - return CUDA_R_16I; - } - - private static final int CUDA_C_16I = (int) 21L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16I = 21 - * } - */ - public static int CUDA_C_16I() { - return CUDA_C_16I; - } - - private static final int CUDA_R_16U = (int) 22L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16U = 22 - * } - */ - public static int CUDA_R_16U() { - return CUDA_R_16U; - } - - private static final int CUDA_C_16U = (int) 23L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16U = 23 - * } - */ - public static int CUDA_C_16U() { - return CUDA_C_16U; - } - - private static final int CUDA_R_32I = (int) 10L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_32I = 10 - * } - */ - public static int CUDA_R_32I() { - return CUDA_R_32I; - } - - private static final int CUDA_C_32I = (int) 11L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_32I = 11 - * } - */ - public static int CUDA_C_32I() { - return CUDA_C_32I; - } - - private static final int CUDA_R_32U = (int) 12L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_32U = 12 - * } - */ - public static int CUDA_R_32U() { - return CUDA_R_32U; - } - - private static final int CUDA_C_32U = (int) 13L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_32U = 13 - * } - */ - public static int CUDA_C_32U() { - return CUDA_C_32U; - } - - private static final int CUDA_R_64I = (int) 24L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_64I = 24 - * } - */ - public static int CUDA_R_64I() { - return CUDA_R_64I; - } - - private static final int CUDA_C_64I = (int) 25L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_64I = 25 - * } - */ - public static int CUDA_C_64I() { - return CUDA_C_64I; - } - - private static final int CUDA_R_64U = (int) 26L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_64U = 26 - * } - */ - public static int CUDA_R_64U() { - return CUDA_R_64U; - } - - private static final int CUDA_C_64U = (int) 27L; - - /** - * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_64U = 27 - * } - */ - public static int CUDA_C_64U() { - return CUDA_C_64U; - } - - private static final int MAJOR_VERSION = (int) 0L; - - /** - * {@snippet lang = c : * enum libraryPropertyType_t.MAJOR_VERSION = 0 - * } - */ - public static int MAJOR_VERSION() { - return MAJOR_VERSION; - } - - private static final int MINOR_VERSION = (int) 1L; - - /** - * {@snippet lang = c : * enum libraryPropertyType_t.MINOR_VERSION = 1 - * } - */ - public static int MINOR_VERSION() { - return MINOR_VERSION; - } - - private static final int PATCH_LEVEL = (int) 2L; - - /** - * {@snippet lang = c : * enum libraryPropertyType_t.PATCH_LEVEL = 2 - * } - */ - public static int PATCH_LEVEL() { - return PATCH_LEVEL; - } - - private static final int PER_SUBSPACE = (int) 0L; - - /** - * {@snippet lang = c : * enum codebook_gen.PER_SUBSPACE = 0 - * } - */ - public static int PER_SUBSPACE() { - return PER_SUBSPACE; - } - - private static final int PER_CLUSTER = (int) 1L; - - /** - * {@snippet lang = c : * enum codebook_gen.PER_CLUSTER = 1 - * } - */ - public static int PER_CLUSTER() { - return PER_CLUSTER; - } - - /** - * {@snippet lang = c : - * typedef struct cuvsIvfPqIndexParams { - * cuvsDistanceType metric; - * float metric_arg; - * _Bool add_data_on_build; - * uint32_t n_lists; - * uint32_t kmeans_n_iters; - * double kmeans_trainset_fraction; - * uint32_t pq_bits; - * uint32_t pq_dim; - * enum codebook_gen codebook_kind; - * _Bool force_random_rotation; - * _Bool conservative_memory_allocation; - * uint32_t max_train_points_per_pq_code; - * } *cuvsIvfPqIndexParams_t - * } - */ - public static final AddressLayout cuvsIvfPqIndexParams_t = IvfPqH.C_POINTER; - - private static class cuvsIvfPqIndexParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqIndexParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexParamsCreate$descriptor() { - return cuvsIvfPqIndexParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static MethodHandle cuvsIvfPqIndexParamsCreate$handle() { - return cuvsIvfPqIndexParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static MemorySegment cuvsIvfPqIndexParamsCreate$address() { - return cuvsIvfPqIndexParamsCreate.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static int cuvsIvfPqIndexParamsCreate(MemorySegment index_params) { - var mh$ = cuvsIvfPqIndexParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexParamsCreate", index_params); - } - return (int) mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqIndexParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqIndexParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexParamsDestroy$descriptor() { - return cuvsIvfPqIndexParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static MethodHandle cuvsIvfPqIndexParamsDestroy$handle() { - return cuvsIvfPqIndexParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static MemorySegment cuvsIvfPqIndexParamsDestroy$address() { - return cuvsIvfPqIndexParamsDestroy.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static int cuvsIvfPqIndexParamsDestroy(MemorySegment index_params) { - var mh$ = cuvsIvfPqIndexParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexParamsDestroy", index_params); - } - return (int) mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - /** - * {@snippet lang = c : - * typedef struct cuvsIvfPqSearchParams { - * uint32_t n_probes; - * cudaDataType_t lut_dtype; - * cudaDataType_t internal_distance_dtype; - * double preferred_shmem_carveout; - * } *cuvsIvfPqSearchParams_t - * } - */ - public static final AddressLayout cuvsIvfPqSearchParams_t = IvfPqH.C_POINTER; - - private static class cuvsIvfPqSearchParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqSearchParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static FunctionDescriptor cuvsIvfPqSearchParamsCreate$descriptor() { - return cuvsIvfPqSearchParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static MethodHandle cuvsIvfPqSearchParamsCreate$handle() { - return cuvsIvfPqSearchParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static MemorySegment cuvsIvfPqSearchParamsCreate$address() { - return cuvsIvfPqSearchParamsCreate.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static int cuvsIvfPqSearchParamsCreate(MemorySegment params) { - var mh$ = cuvsIvfPqSearchParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSearchParamsCreate", params); - } - return (int) mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqSearchParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqSearchParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static FunctionDescriptor cuvsIvfPqSearchParamsDestroy$descriptor() { - return cuvsIvfPqSearchParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static MethodHandle cuvsIvfPqSearchParamsDestroy$handle() { - return cuvsIvfPqSearchParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static MemorySegment cuvsIvfPqSearchParamsDestroy$address() { - return cuvsIvfPqSearchParamsDestroy.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static int cuvsIvfPqSearchParamsDestroy(MemorySegment params) { - var mh$ = cuvsIvfPqSearchParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSearchParamsDestroy", params); - } - return (int) mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - /** - * {@snippet lang = c : * typedef cuvsIvfPq *cuvsIvfPqIndex_t - * } - */ - public static final AddressLayout cuvsIvfPqIndex_t = IvfPqH.C_POINTER; - - private static class cuvsIvfPqIndexCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqIndexCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexCreate$descriptor() { - return cuvsIvfPqIndexCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static MethodHandle cuvsIvfPqIndexCreate$handle() { - return cuvsIvfPqIndexCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static MemorySegment cuvsIvfPqIndexCreate$address() { - return cuvsIvfPqIndexCreate.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static int cuvsIvfPqIndexCreate(MemorySegment index) { - var mh$ = cuvsIvfPqIndexCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexCreate", index); - } - return (int) mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqIndexDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqIndexDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexDestroy$descriptor() { - return cuvsIvfPqIndexDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqIndexDestroy$handle() { - return cuvsIvfPqIndexDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqIndexDestroy$address() { - return cuvsIvfPqIndexDestroy.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqIndexDestroy(MemorySegment index) { - var mh$ = cuvsIvfPqIndexDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexDestroy", index); - } - return (int) mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqBuild { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_LONG, - IvfPqH.C_POINTER, IvfPqH.C_POINTER, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqBuild"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqBuild$descriptor() { - return cuvsIvfPqBuild.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqBuild$handle() { - return cuvsIvfPqBuild.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqBuild$address() { - return cuvsIvfPqBuild.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqBuild(long res, MemorySegment params, MemorySegment dataset, MemorySegment index) { - var mh$ = cuvsIvfPqBuild.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqBuild", res, params, dataset, index); - } - return (int) mh$.invokeExact(res, params, dataset, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqSearch { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_LONG, - IvfPqH.C_POINTER, IvfPqH.C_POINTER, IvfPqH.C_POINTER, IvfPqH.C_POINTER, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqSearch"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static FunctionDescriptor cuvsIvfPqSearch$descriptor() { - return cuvsIvfPqSearch.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MethodHandle cuvsIvfPqSearch$handle() { - return cuvsIvfPqSearch.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MemorySegment cuvsIvfPqSearch$address() { - return cuvsIvfPqSearch.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static int cuvsIvfPqSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, - MemorySegment neighbors, MemorySegment distances) { - var mh$ = cuvsIvfPqSearch.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSearch", res, search_params, index, queries, neighbors, distances); - } - return (int) mh$.invokeExact(res, search_params, index, queries, neighbors, distances); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqSerialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_LONG, - IvfPqH.C_POINTER, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqSerialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqSerialize$descriptor() { - return cuvsIvfPqSerialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqSerialize$handle() { - return cuvsIvfPqSerialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqSerialize$address() { - return cuvsIvfPqSerialize.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqSerialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfPqSerialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSerialize", res, filename, index); - } - return (int) mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqDeserialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_LONG, - IvfPqH.C_POINTER, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqDeserialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqDeserialize$descriptor() { - return cuvsIvfPqDeserialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqDeserialize$handle() { - return cuvsIvfPqDeserialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqDeserialize$address() { - return cuvsIvfPqDeserialize.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqDeserialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfPqDeserialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqDeserialize", res, filename, index); - } - return (int) mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqExtend { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_LONG, - IvfPqH.C_POINTER, IvfPqH.C_POINTER, IvfPqH.C_POINTER); - - public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqExtend"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqExtend$descriptor() { - return cuvsIvfPqExtend.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqExtend$handle() { - return cuvsIvfPqExtend.HANDLE; - } - - /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqExtend$address() { - return cuvsIvfPqExtend.ADDR; - } - - /** - * {@snippet lang = c - * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, - MemorySegment index) { - var mh$ = cuvsIvfPqExtend.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqExtend", res, new_vectors, new_indices, index); - } - return (int) mh$.invokeExact(res, new_vectors, new_indices, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static final long _POSIX_C_SOURCE = 200809L; - - /** - * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - - private static final int __TIMESIZE = (int) 64L; - - /** - * {@snippet lang = c : * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - - private static final long __STDC_IEC_60559_BFP__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - - /** - * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - - private static final long __STDC_ISO_10646__ = 201706L; - - /** - * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - - private static final int __WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - - private static final int __WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - - private static final int INT8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - - private static final int INT16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - - private static final int INT32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - - private static final long INT64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - - private static final int INT8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - - private static final int INT16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - - private static final int INT32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - - private static final long INT64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - - private static final int UINT8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - - private static final int UINT16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - - private static final int UINT32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - - private static final long UINT64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - - private static final int INT_LEAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - - private static final int INT_LEAST16_MIN = (int) -32768L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - - private static final int INT_LEAST32_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - - private static final long INT_LEAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - - private static final int INT_LEAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - - private static final int INT_LEAST16_MAX = (int) 32767L; - - /** - * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - - private static final int INT_LEAST32_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - - private static final long INT_LEAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - - private static final int UINT_LEAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - - private static final int UINT_LEAST16_MAX = (int) 65535L; - - /** - * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - - private static final int UINT_LEAST32_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - - private static final long UINT_LEAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - - private static final int INT_FAST8_MIN = (int) -128L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - - private static final long INT_FAST16_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - - private static final long INT_FAST32_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - - private static final long INT_FAST64_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - - private static final int INT_FAST8_MAX = (int) 127L; - - /** - * {@snippet lang = c : * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - - private static final long INT_FAST16_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - - private static final long INT_FAST32_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - - private static final long INT_FAST64_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - - private static final int UINT_FAST8_MAX = (int) 255L; - - /** - * {@snippet lang = c : * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - - private static final long UINT_FAST16_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - - private static final long UINT_FAST32_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - - private static final long UINT_FAST64_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - - private static final long INTPTR_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - - private static final long INTPTR_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - - private static final long UINTPTR_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - - private static final long INTMAX_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - - private static final long INTMAX_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - - private static final long UINTMAX_MAX = -1L; - - /** - * {@snippet lang = c : * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - - private static final long PTRDIFF_MIN = -9223372036854775808L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - - private static final long PTRDIFF_MAX = 9223372036854775807L; - - /** - * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - - private static final int SIG_ATOMIC_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - - private static final int SIG_ATOMIC_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - - private static final long SIZE_MAX = -1L; - - /** - * {@snippet lang = c : * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - - private static final int WCHAR_MIN = (int) -2147483648L; - - /** - * {@snippet lang = c : * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - - private static final int WCHAR_MAX = (int) 2147483647L; - - /** - * {@snippet lang = c : * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - - private static final int WINT_MIN = (int) 0L; - - /** - * {@snippet lang = c : * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - - private static final int WINT_MAX = (int) 4294967295L; - - /** - * {@snippet lang = c : * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - - /** - * {@snippet lang = c : * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - - /** - * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - - /** - * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } -} diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/MaxAlignT.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/MaxAlignT.java deleted file mode 100644 index d07c524db..000000000 --- a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/MaxAlignT.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2025, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nvidia.cuvs.internal.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct { - * long long __clang_max_align_nonce1; - * long double __clang_max_align_nonce2; - * } - * } - */ -public class MaxAlignT { - - MaxAlignT() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - DlpackH.C_LONG_LONG.withName("__clang_max_align_nonce1"), - MemoryLayout.paddingLayout(24) - ).withName("$anon$19:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong __clang_max_align_nonce1$LAYOUT = (OfLong)$LAYOUT.select(groupElement("__clang_max_align_nonce1")); - - /** - * Layout for field: - * {@snippet lang=c : - * long long __clang_max_align_nonce1 - * } - */ - public static final OfLong __clang_max_align_nonce1$layout() { - return __clang_max_align_nonce1$LAYOUT; - } - - private static final long __clang_max_align_nonce1$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * long long __clang_max_align_nonce1 - * } - */ - public static final long __clang_max_align_nonce1$offset() { - return __clang_max_align_nonce1$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * long long __clang_max_align_nonce1 - * } - */ - public static long __clang_max_align_nonce1(MemorySegment struct) { - return struct.get(__clang_max_align_nonce1$LAYOUT, __clang_max_align_nonce1$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * long long __clang_max_align_nonce1 - * } - */ - public static void __clang_max_align_nonce1(MemorySegment struct, long fieldValue) { - struct.set(__clang_max_align_nonce1$LAYOUT, __clang_max_align_nonce1$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/HnswBuildAndSearchIT.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/HnswBuildAndSearchIT.java index eb4933cf9..e2fad43c8 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/HnswBuildAndSearchIT.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/HnswBuildAndSearchIT.java @@ -83,7 +83,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { // Configure index parameters CagraIndexParams indexParams = new CagraIndexParams.Builder() - .withCagraGraphBuildAlgo(CagraGraphBuildAlgo.IVF_PQ) + .withCagraGraphBuildAlgo(CagraGraphBuildAlgo.NN_DESCENT) .withGraphDegree(64) .withIntermediateGraphDegree(128) .withNumWriterThreads(32) diff --git a/java/examples/.gitignore b/java/examples/.gitignore deleted file mode 100644 index b83d22266..000000000 --- a/java/examples/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/java/examples/README.md b/java/examples/README.md index d05d7b911..b8e03608e 100644 --- a/java/examples/README.md +++ b/java/examples/README.md @@ -1,8 +1,27 @@ -Building and Running --------------------- +# CuVS Java API Examples -Make sure to have JDK 22 and Maven 3.9.6+. +This maven project contains examples for CAGRA, HNSW, and Bruteforce algorithms. - mvn clean compile assembly:single +## Prerequisites +- [CuVS libraries](https://docs.rapids.ai/api/cuvs/stable/build/#build-from-source) +- Build the CuVS-Java API - java --enable-native-access=ALL-UNNAMED -jar ./target/cagra-sample-1.0-SNAPSHOT-jar-with-dependencies.jar +## Run Examples + +### CAGRA Example +In the current directory do: +``` +mvn package && java --enable-native-access=ALL-UNNAMED -cp target/cuvs-java-examples-25.06.0.jar:$HOME/.m2/repository/com/nvidia/cuvs/cuvs-java/25.06.0/cuvs-java-25.06.0.jar com.nvidia.cuvs.examples.CagraExample +``` + +### HNSW Example +In the current directory do: +``` +mvn package && java --enable-native-access=ALL-UNNAMED -cp target/cuvs-java-examples-25.06.0.jar:$HOME/.m2/repository/com/nvidia/cuvs/cuvs-java/25.06.0/cuvs-java-25.06.0.jar com.nvidia.cuvs.examples.HnswExample +``` + +### Bruteforce Example +In the current directory do: +``` +mvn package && java --enable-native-access=ALL-UNNAMED -cp target/cuvs-java-examples-25.06.0.jar:$HOME/.m2/repository/com/nvidia/cuvs/cuvs-java/25.06.0/cuvs-java-25.06.0.jar com.nvidia.cuvs.examples.BruteForceExample +``` diff --git a/java/examples/pom.xml b/java/examples/pom.xml index c5798864c..9a86a99b3 100644 --- a/java/examples/pom.xml +++ b/java/examples/pom.xml @@ -20,17 +20,6 @@ 25.06.0 - - org.slf4j - slf4j-api - 2.0.13 - - - org.slf4j - slf4j-simple - 2.0.13 - runtime - diff --git a/java/examples/src/main/java/com/nvidia/cuvs/examples/BruteForceExample.java b/java/examples/src/main/java/com/nvidia/cuvs/examples/BruteForceExample.java index c85912941..72924779e 100644 --- a/java/examples/src/main/java/com/nvidia/cuvs/examples/BruteForceExample.java +++ b/java/examples/src/main/java/com/nvidia/cuvs/examples/BruteForceExample.java @@ -4,21 +4,18 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; -import java.lang.invoke.MethodHandles; import java.util.UUID; - -import com.nvidia.cuvs.SearchResults; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.logging.Logger; import com.nvidia.cuvs.BruteForceIndex; import com.nvidia.cuvs.BruteForceIndexParams; import com.nvidia.cuvs.BruteForceQuery; import com.nvidia.cuvs.CuVSResources; +import com.nvidia.cuvs.SearchResults; public class BruteForceExample { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private static final Logger log = Logger.getLogger(BruteForceExample.class.getName()); public static void main(String[] args) throws Throwable { diff --git a/java/examples/src/main/java/com/nvidia/cuvs/examples/CagraExample.java b/java/examples/src/main/java/com/nvidia/cuvs/examples/CagraExample.java index 9dabcc6bc..76767fc4c 100644 --- a/java/examples/src/main/java/com/nvidia/cuvs/examples/CagraExample.java +++ b/java/examples/src/main/java/com/nvidia/cuvs/examples/CagraExample.java @@ -4,12 +4,8 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; -import java.lang.invoke.MethodHandles; import java.util.UUID; - -import com.nvidia.cuvs.SearchResults; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.logging.Logger; import com.nvidia.cuvs.CagraIndex; import com.nvidia.cuvs.CagraIndexParams; @@ -18,10 +14,11 @@ import com.nvidia.cuvs.CagraQuery; import com.nvidia.cuvs.CagraSearchParams; import com.nvidia.cuvs.CuVSResources; +import com.nvidia.cuvs.SearchResults; public class CagraExample { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private static final Logger log = Logger.getLogger(CagraExample.class.getName()); public static void main(String[] args) throws Throwable { diff --git a/java/examples/src/main/java/com/nvidia/cuvs/examples/HnswExample.java b/java/examples/src/main/java/com/nvidia/cuvs/examples/HnswExample.java index 7fbbccf64..0268ff62e 100644 --- a/java/examples/src/main/java/com/nvidia/cuvs/examples/HnswExample.java +++ b/java/examples/src/main/java/com/nvidia/cuvs/examples/HnswExample.java @@ -4,26 +4,26 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; -import java.lang.invoke.MethodHandles; import java.util.UUID; - -import com.nvidia.cuvs.SearchResults; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.logging.Logger; import com.nvidia.cuvs.CagraIndex; import com.nvidia.cuvs.CagraIndexParams; import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; import com.nvidia.cuvs.CagraIndexParams.CuvsDistanceType; +import com.nvidia.cuvs.CuVSIvfPqIndexParams; +import com.nvidia.cuvs.CuVSIvfPqParams; +import com.nvidia.cuvs.CuVSIvfPqSearchParams; import com.nvidia.cuvs.CuVSResources; import com.nvidia.cuvs.HnswIndex; import com.nvidia.cuvs.HnswIndexParams; import com.nvidia.cuvs.HnswQuery; import com.nvidia.cuvs.HnswSearchParams; +import com.nvidia.cuvs.SearchResults; public class HnswExample { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private static final Logger log = Logger.getLogger(HnswExample.class.getName()); public static void main(String[] args) throws Throwable { @@ -44,6 +44,20 @@ public static void main(String[] args) throws Throwable { try (CuVSResources resources = CuVSResources.create()) { + // Configure IVF_PQ index parameters (optional - default values set when not defined) + CuVSIvfPqIndexParams cuVSIvfPqIndexParams = new CuVSIvfPqIndexParams.Builder() + .build(); + + // Configure IVF_PQ search parameters (optional - default values set when not defined) + CuVSIvfPqSearchParams cuVSIvfPqSearchParams = new CuVSIvfPqSearchParams.Builder() + .build(); + + // Configure IVF_PQ search parameters (used when build algo is IVF_PQ, optional otherwise) + CuVSIvfPqParams cuVSIvfPqParams = new CuVSIvfPqParams.Builder() + .withCuVSIvfPqIndexParams(cuVSIvfPqIndexParams) + .withCuVSIvfPqSearchParams(cuVSIvfPqSearchParams) + .build(); + // Configure index parameters CagraIndexParams indexParams = new CagraIndexParams.Builder() .withCagraGraphBuildAlgo(CagraGraphBuildAlgo.IVF_PQ) @@ -51,6 +65,7 @@ public static void main(String[] args) throws Throwable { .withIntermediateGraphDegree(128) .withNumWriterThreads(32) .withMetric(CuvsDistanceType.L2Expanded) + .withCuVSIvfPqParams(cuVSIvfPqParams) .build(); // Create the index with the dataset diff --git a/java/examples/src/main/resources/.gitkeep b/java/examples/src/main/resources/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/java/examples/src/main/resources/log4j2.xml b/java/examples/src/main/resources/log4j2.xml deleted file mode 100644 index bf0eb598c..000000000 --- a/java/examples/src/main/resources/log4j2.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index 025b0f6e9..0b9c2f794 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -103,6 +103,12 @@ cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, c cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); + if (index_params->build_algo == 1) { // when build algo is IVF_PQ + uint32_t n_lists = index_params->graph_build_params->ivf_pq_build_params->n_lists; + // As rows cannot be less than n_lists value so trim down. + index_params->graph_build_params->ivf_pq_build_params->n_lists = rows < n_lists ? rows : n_lists; + } + index_params->compression = compression_params; cuvsStreamSync(cuvs_resources); *return_value = cuvsCagraBuild(cuvs_resources, index_params, &dataset_tensor, index); diff --git a/java/panama-bindings/generate-bindings.sh b/java/panama-bindings/generate-bindings.sh new file mode 100755 index 000000000..db4dacd61 --- /dev/null +++ b/java/panama-bindings/generate-bindings.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +echo "Starting Panama FFM API bindings generation ..." +REPODIR=$(cd $(dirname $0); cd ../../ ; pwd) +CURDIR=$(cd $(dirname $0); pwd) +CUDA_HOME=$(which nvcc | cut -d/ -f-5) +TARGET_PACKAGE="com.nvidia.cuvs.internal.panama" + +JEXTRACT_COMMAND="jextract" + +if [[ `command -v jextract` == "" ]]; +then + JEXTRACT_DOWNLOAD_URL="https://download.java.net/java/early_access/jextract/22/6/openjdk-22-jextract+6-47_linux-x64_bin.tar.gz" + echo "jextract doesn't exist. Downloading it from $JEXTRACT_DOWNLOAD_URL."; + wget -c $JEXTRACT_DOWNLOAD_URL + tar -xvf openjdk-22-jextract+6-47_linux-x64_bin.tar.gz + JEXTRACT_COMMAND="jextract-22/bin/jextract" + echo "jextract downloaded to `pwd`/jextract-22" +fi + +# Use Jextract utility to generate panama bindings +$JEXTRACT_COMMAND \ + --include-dir ${REPODIR}/cpp/build/_deps/dlpack-src/include/ \ + --include-dir ${CUDA_HOME}/targets/x86_64-linux/include \ + --include-dir ${REPODIR}/cpp/include \ + --output "${REPODIR}/java/cuvs-java/src/main/java22/" \ + --target-package ${TARGET_PACKAGE} \ + --header-class-name PanamaFFMAPI \ + ${CURDIR}/headers.h + +# Did Jextract complete normally? If not, stop and return +JEXTRACT_RETURN_VALUE=$? +if [ $JEXTRACT_RETURN_VALUE == 0 ] +then + echo "Jextract SUCCESS" +else + echo "Jextract encountered issues (returned value ${JEXTRACT_RETURN_VALUE})" + exit $JEXTRACT_RETURN_VALUE +fi + +echo "Panama FFM API bindings generation done" diff --git a/java/panama-bindings/gpuinfo.h b/java/panama-bindings/gpuinfo.h new file mode 100644 index 000000000..dfd7e7444 --- /dev/null +++ b/java/panama-bindings/gpuinfo.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @brief struct for containing gpu information + */ +typedef struct gpuInfo { + int gpu_id; + char name[256]; + long free_memory; + long total_memory; + float compute_capability; +} gpuInfo; diff --git a/java/panama-bindings/headers.h b/java/panama-bindings/headers.h new file mode 100644 index 000000000..2b035f23d --- /dev/null +++ b/java/panama-bindings/headers.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Please add the required header files below for which panama FFM API bindings are needed + +#include +#include +#include +#include +#include "gpuinfo.h"