diff --git a/java/README.md b/java/README.md index e5676146a..0b62222e6 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 --------- -`./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. +## Prerequisites + +- [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/) + + +## 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/cuvs-java/.gitignore b/java/cuvs-java/.gitignore index b83d22266..0f630157f 100644 --- a/java/cuvs-java/.gitignore +++ b/java/cuvs-java/.gitignore @@ -1 +1,2 @@ /target/ +/bin/ diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 835fb6eaf..c0bbe2e06 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -258,7 +258,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.11.2 attach-javadocs 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..70fa66221 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..623f97cd5 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,119 @@ 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 { + + /** + * real as a half + */ + CUDA_R_16F(2), + + /** + * complex as a pair of half numbers + */ + CUDA_C_16F(6), + + /** + * real as a float + */ + CUDA_R_32F(0), + + /** + * complex as a pair of float numbers + */ + CUDA_C_32F(4), + + /** + * real as a double + */ + CUDA_R_64F(1), + + /** + * complex as a pair of double numbers + */ + CUDA_C_64F(5), + + /** + * real as a signed char + */ + CUDA_R_8I(3), + + /** + * complex as a pair of signed char numbers + */ + CUDA_C_8I(7), + + /** + * real as a unsigned char + */ + CUDA_R_8U(8), + + /** + * complex as a pair of unsigned char numbers + */ + CUDA_C_8U(9), + + /** + * real as a signed int + */ + CUDA_R_32I(10), + + /** + * complex as a pair of signed int numbers + */ + CUDA_C_32I(11), + + /** + * real as a unsigned int + */ + CUDA_R_32U(12), + + /** + * complex as a pair of unsigned int numbers + */ + CUDA_C_32U(13); + + /** + * The value for the enum choice. + */ + 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 +321,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 +347,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 +420,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..5e83532cf 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; @@ -43,13 +47,6 @@ 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; - /** * * {@link BruteForceIndex} encapsulates a BRUTEFORCE index, along with methods @@ -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); 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..8720140a0 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,6 +41,7 @@ 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; @@ -43,13 +51,9 @@ 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.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 @@ -394,6 +398,37 @@ private MemorySegment segmentFromIndexParams(CagraIndexParams params) { 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; } 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..9147e9195 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,20 +32,12 @@ 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; - public class Util { public static final int CUVS_SUCCESS = 1; 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 index 82ecbdc34..47e406c39 100644 --- 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 @@ -90,24 +90,34 @@ static MemoryLayout align(MemoryLayout layout, long align) { 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; + private static final int true_ = (int) 1L; /** - * {@snippet lang = c : * #define DLPACK_VERSION 80 + * {@snippet lang = c : * #define true 1 * } */ - public static int DLPACK_VERSION() { - return DLPACK_VERSION; + public static int true_() { + return true_; } - private static final int DLPACK_ABI_VERSION = (int) 1L; + private static final int false_ = (int) 0L; /** - * {@snippet lang = c : * #define DLPACK_ABI_VERSION 1 + * {@snippet lang = c : * #define false 0 * } */ - public static int DLPACK_ABI_VERSION() { - return DLPACK_ABI_VERSION; + 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 _STDINT_H = (int) 1L; @@ -640,376 +650,156 @@ public static int _BITS_STDINT_UINTN_H() { return _BITS_STDINT_UINTN_H; } - private static final int true_ = (int) 1L; + private static final int DLPACK_VERSION = (int) 80L; /** - * {@snippet lang = c : * #define true 1 + * {@snippet lang = c : * #define DLPACK_VERSION 80 * } */ - public static int true_() { - return true_; + public static int DLPACK_VERSION() { + return DLPACK_VERSION; } - private static final int false_ = (int) 0L; + private static final int DLPACK_ABI_VERSION = (int) 1L; /** - * {@snippet lang = c : * #define false 0 + * {@snippet lang = c : * #define DLPACK_ABI_VERSION 1 * } */ - public static int false_() { - return false_; + public static int DLPACK_ABI_VERSION() { + return DLPACK_ABI_VERSION; } - private static final int __bool_true_false_are_defined = (int) 1L; - /** - * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * {@snippet lang = c : * typedef unsigned char __u_char * } */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - - private static final int L2Expanded = (int) 0L; - + public static final OfByte __u_char = CagraH.C_CHAR; /** - * {@snippet lang = c : * enum .L2Expanded = 0 + * {@snippet lang = c : * typedef unsigned short __u_short * } */ - public static int L2Expanded() { - return L2Expanded; - } - - private static final int L2SqrtExpanded = (int) 1L; - + public static final OfShort __u_short = CagraH.C_SHORT; /** - * {@snippet lang = c : * enum .L2SqrtExpanded = 1 + * {@snippet lang = c : * typedef unsigned int __u_int * } */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - - private static final int CosineExpanded = (int) 2L; - + public static final OfInt __u_int = CagraH.C_INT; /** - * {@snippet lang = c : * enum .CosineExpanded = 2 + * {@snippet lang = c : * typedef unsigned long __u_long * } */ - public static int CosineExpanded() { - return CosineExpanded; - } - - private static final int L1 = (int) 3L; - + public static final OfLong __u_long = CagraH.C_LONG; /** - * {@snippet lang = c : * enum .L1 = 3 + * {@snippet lang = c : * typedef signed char __int8_t * } */ - public static int L1() { - return L1; - } - - private static final int L2Unexpanded = (int) 4L; - + public static final OfByte __int8_t = CagraH.C_CHAR; /** - * {@snippet lang = c : * enum .L2Unexpanded = 4 + * {@snippet lang = c : * typedef unsigned char __uint8_t * } */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - - private static final int L2SqrtUnexpanded = (int) 5L; - + public static final OfByte __uint8_t = CagraH.C_CHAR; /** - * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 + * {@snippet lang = c : * typedef short __int16_t * } */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - - private static final int InnerProduct = (int) 6L; - + public static final OfShort __int16_t = CagraH.C_SHORT; /** - * {@snippet lang = c : * enum .InnerProduct = 6 + * {@snippet lang = c : * typedef unsigned short __uint16_t * } */ - public static int InnerProduct() { - return InnerProduct; - } - - private static final int Linf = (int) 7L; - + public static final OfShort __uint16_t = CagraH.C_SHORT; /** - * {@snippet lang = c : * enum .Linf = 7 + * {@snippet lang = c : * typedef int __int32_t * } */ - public static int Linf() { - return Linf; - } - - private static final int Canberra = (int) 8L; - + public static final OfInt __int32_t = CagraH.C_INT; /** - * {@snippet lang = c : * enum .Canberra = 8 + * {@snippet lang = c : * typedef unsigned int __uint32_t * } */ - public static int Canberra() { - return Canberra; - } - - private static final int LpUnexpanded = (int) 9L; - + public static final OfInt __uint32_t = CagraH.C_INT; /** - * {@snippet lang = c : * enum .LpUnexpanded = 9 + * {@snippet lang = c : * typedef long __int64_t * } */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - - private static final int CorrelationExpanded = (int) 10L; - + public static final OfLong __int64_t = CagraH.C_LONG; /** - * {@snippet lang = c : * enum .CorrelationExpanded = 10 + * {@snippet lang = c : * typedef unsigned long __uint64_t * } */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - - private static final int JaccardExpanded = (int) 11L; - + public static final OfLong __uint64_t = CagraH.C_LONG; /** - * {@snippet lang = c : * enum .JaccardExpanded = 11 + * {@snippet lang = c : * typedef __int8_t __int_least8_t * } */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - - private static final int HellingerExpanded = (int) 12L; - + public static final OfByte __int_least8_t = CagraH.C_CHAR; /** - * {@snippet lang = c : * enum .HellingerExpanded = 12 + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t * } */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - - private static final int Haversine = (int) 13L; - + public static final OfByte __uint_least8_t = CagraH.C_CHAR; /** - * {@snippet lang = c : * enum .Haversine = 13 + * {@snippet lang = c : * typedef __int16_t __int_least16_t * } */ - public static int Haversine() { - return Haversine; - } - - private static final int BrayCurtis = (int) 14L; - + public static final OfShort __int_least16_t = CagraH.C_SHORT; /** - * {@snippet lang = c : * enum .BrayCurtis = 14 + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t * } */ - public static int BrayCurtis() { - return BrayCurtis; - } - - private static final int JensenShannon = (int) 15L; - + public static final OfShort __uint_least16_t = CagraH.C_SHORT; /** - * {@snippet lang = c : * enum .JensenShannon = 15 + * {@snippet lang = c : * typedef __int32_t __int_least32_t * } */ - public static int JensenShannon() { - return JensenShannon; - } - - private static final int HammingUnexpanded = (int) 16L; - + public static final OfInt __int_least32_t = CagraH.C_INT; /** - * {@snippet lang = c : * enum .HammingUnexpanded = 16 + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t * } */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - - private static final int KLDivergence = (int) 17L; - + public static final OfInt __uint_least32_t = CagraH.C_INT; /** - * {@snippet lang = c : * enum .KLDivergence = 17 + * {@snippet lang = c : * typedef __int64_t __int_least64_t * } */ - public static int KLDivergence() { - return KLDivergence; - } - - private static final int RusselRaoExpanded = (int) 18L; - + public static final OfLong __int_least64_t = CagraH.C_LONG; /** - * {@snippet lang = c : * enum .RusselRaoExpanded = 18 + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t * } */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - - private static final int DiceExpanded = (int) 19L; - + public static final OfLong __uint_least64_t = CagraH.C_LONG; /** - * {@snippet lang = c : * enum .DiceExpanded = 19 + * {@snippet lang = c : * typedef long __quad_t * } */ - public static int DiceExpanded() { - return DiceExpanded; - } - - private static final int Precomputed = (int) 100L; - + public static final OfLong __quad_t = CagraH.C_LONG; /** - * {@snippet lang = c : * enum .Precomputed = 100 + * {@snippet lang = c : * typedef unsigned long __u_quad_t * } */ - public static int Precomputed() { - return Precomputed; - } - + public static final OfLong __u_quad_t = CagraH.C_LONG; /** - * {@snippet lang = c : * typedef unsigned char __u_char + * {@snippet lang = c : * typedef long __intmax_t * } */ - public static final OfByte __u_char = CagraH.C_CHAR; + public static final OfLong __intmax_t = CagraH.C_LONG; /** - * {@snippet lang = c : * typedef unsigned short __u_short + * {@snippet lang = c : * typedef unsigned long __uintmax_t * } */ - public static final OfShort __u_short = CagraH.C_SHORT; + public static final OfLong __uintmax_t = CagraH.C_LONG; /** - * {@snippet lang = c : * typedef unsigned int __u_int + * {@snippet lang = c : * typedef unsigned long __dev_t * } */ - public static final OfInt __u_int = CagraH.C_INT; + public static final OfLong __dev_t = CagraH.C_LONG; /** - * {@snippet lang = c : * typedef unsigned long __u_long + * {@snippet lang = c : * typedef unsigned int __uid_t * } */ - 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; + public static final OfInt __uid_t = CagraH.C_INT; /** * {@snippet lang = c : * typedef unsigned int __gid_t * } @@ -1330,6 +1120,241 @@ public static int Precomputed() { * } */ public static final OfLong uintmax_t = CagraH.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 = CagraH.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 * } @@ -1555,6 +1580,201 @@ public static int kDLBool() { return kDLBool; } + 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; + } + + 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_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_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_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; + } + + /** + * {@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 = CagraH.C_POINTER; + /** + * {@snippet lang = c : + * typedef struct cuvsIvfPqSearchParams { + * uint32_t n_probes; + * enum cudaDataType_t lut_dtype; + * enum cudaDataType_t internal_distance_dtype; + * double preferred_shmem_carveout; + * } *cuvsIvfPqSearchParams_t + * } + */ + public static final AddressLayout cuvsIvfPqSearchParams_t = CagraH.C_POINTER; + /** + * {@snippet lang = c : * typedef cuvsIvfPqIndex *cuvsIvfPqIndex_t + * } + */ + public static final AddressLayout cuvsIvfPqIndex_t = CagraH.C_POINTER; private static final int AUTO_SELECT = (int) 0L; /** @@ -1585,6 +1805,17 @@ public static int NN_DESCENT() { return NN_DESCENT; } + private static final int ITERATIVE_CAGRA_SEARCH = (int) 3L; + + /** + * {@snippet lang = c + * : * enum cuvsCagraGraphBuildAlgo.ITERATIVE_CAGRA_SEARCH = 3 + * } + */ + public static int ITERATIVE_CAGRA_SEARCH() { + return ITERATIVE_CAGRA_SEARCH; + } + /** * {@snippet lang = c : * typedef struct cuvsCagraCompressionParams { @@ -1598,19 +1829,38 @@ public static int NN_DESCENT() { * } */ public static final AddressLayout cuvsCagraCompressionParams_t = CagraH.C_POINTER; + /** + * {@snippet lang = c : + * typedef struct cuvsIvfPqParams { + * cuvsIvfPqIndexParams_t ivf_pq_build_params; + * cuvsIvfPqSearchParams_t ivf_pq_search_params; + * float refinement_rate; + * } *cuvsIvfPqParams_t + * } + */ + public static final AddressLayout cuvsIvfPqParams_t = CagraH.C_POINTER; /** * {@snippet lang = c : * typedef struct cuvsCagraIndexParams { * cuvsDistanceType metric; - * long intermediate_graph_degree; - * long graph_degree; + * size_t intermediate_graph_degree; + * size_t graph_degree; * enum cuvsCagraGraphBuildAlgo build_algo; - * long nn_descent_niter; + * size_t nn_descent_niter; * cuvsCagraCompressionParams_t compression; + * cuvsIvfPqParams_t graph_build_params; * } *cuvsCagraIndexParams_t * } */ public static final AddressLayout cuvsCagraIndexParams_t = CagraH.C_POINTER; + /** + * {@snippet lang = c : + * typedef struct cuvsCagraExtendParams { + * uint32_t max_chunk_size; + * } *cuvsCagraExtendParams_t + * } + */ + public static final AddressLayout cuvsCagraExtendParams_t = CagraH.C_POINTER; private static final int SINGLE_CTA = (int) 0L; /** @@ -1684,16 +1934,16 @@ public static int AUTO_HASH() { /** * {@snippet lang = c : * typedef struct cuvsCagraSearchParams { - * long max_queries; - * long itopk_size; - * long max_iterations; + * size_t max_queries; + * size_t itopk_size; + * size_t max_iterations; * enum cuvsCagraSearchAlgo algo; - * long team_size; - * long search_width; - * long min_iterations; - * long thread_block_size; + * size_t team_size; + * size_t search_width; + * size_t min_iterations; + * size_t thread_block_size; * enum cuvsCagraHashMode hashmap_mode; - * long hashmap_min_bitlen; + * size_t hashmap_min_bitlen; * float hashmap_max_fill_rate; * uint32_t num_random_samplings; * uint64_t rand_xor_mask; 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 index 923287fe4..74d6339e0 100644 --- 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 @@ -46,9 +46,9 @@ public class CuVSCagraCompressionParams { } 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"); + 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 diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraExtendParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraExtendParams.java new file mode 100644 index 000000000..151102ccf --- /dev/null +++ b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSCagraExtendParams.java @@ -0,0 +1,142 @@ +/* + * 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 cuvsCagraExtendParams { + * uint32_t max_chunk_size; + * } + * } + */ +public class CuVSCagraExtendParams { + + CuVSCagraExtendParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(CagraH.C_INT.withName("max_chunk_size")) + .withName("cuvsCagraExtendParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt max_chunk_size$LAYOUT = (OfInt) $LAYOUT.select(groupElement("max_chunk_size")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t max_chunk_size + * } + */ + public static final OfInt max_chunk_size$layout() { + return max_chunk_size$LAYOUT; + } + + private static final long max_chunk_size$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t max_chunk_size + * } + */ + public static final long max_chunk_size$offset() { + return max_chunk_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t max_chunk_size + * } + */ + public static int max_chunk_size(MemorySegment struct) { + return struct.get(max_chunk_size$LAYOUT, max_chunk_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t max_chunk_size + * } + */ + public static void max_chunk_size(MemorySegment struct, int fieldValue) { + struct.set(max_chunk_size$LAYOUT, max_chunk_size$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 index 7ea435ba0..f24f654e0 100644 --- 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 @@ -41,7 +41,7 @@ public class CuVSCagraIndex { } private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(CagraH.C_LONG.withName("addr"), - DLDataType.layout().withName("dtype"), MemoryLayout.paddingLayout(4)).withName("$anon$175:9"); + DLDataType.layout().withName("dtype"), MemoryLayout.paddingLayout(4)).withName("$anon$231:9"); /** * The layout of this struct 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 index ffe88effa..0fc1c5e1f 100644 --- 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 @@ -32,11 +32,12 @@ * {@snippet lang = c : * struct cuvsCagraIndexParams { * cuvsDistanceType metric; - * long intermediate_graph_degree; - * long graph_degree; + * size_t intermediate_graph_degree; + * size_t graph_degree; * enum cuvsCagraGraphBuildAlgo build_algo; - * long nn_descent_niter; + * size_t nn_descent_niter; * cuvsCagraCompressionParams_t compression; + * cuvsIvfPqParams_t graph_build_params; * } * } */ @@ -46,12 +47,11 @@ public class 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"); + 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"), + CagraH.C_POINTER.withName("graph_build_params")).withName("cuvsCagraIndexParams"); /** * The layout of this struct @@ -105,7 +105,7 @@ public static void metric(MemorySegment struct, int fieldValue) { /** * Layout for field: - * {@snippet lang = c : * long intermediate_graph_degree + * {@snippet lang = c : * size_t intermediate_graph_degree * } */ public static final OfLong intermediate_graph_degree$layout() { @@ -116,7 +116,7 @@ public static void metric(MemorySegment struct, int fieldValue) { /** * Offset for field: - * {@snippet lang = c : * long intermediate_graph_degree + * {@snippet lang = c : * size_t intermediate_graph_degree * } */ public static final long intermediate_graph_degree$offset() { @@ -125,7 +125,7 @@ public static void metric(MemorySegment struct, int fieldValue) { /** * Getter for field: - * {@snippet lang = c : * long intermediate_graph_degree + * {@snippet lang = c : * size_t intermediate_graph_degree * } */ public static long intermediate_graph_degree(MemorySegment struct) { @@ -134,7 +134,7 @@ public static long intermediate_graph_degree(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long intermediate_graph_degree + * {@snippet lang = c : * size_t intermediate_graph_degree * } */ public static void intermediate_graph_degree(MemorySegment struct, long fieldValue) { @@ -145,7 +145,7 @@ public static void intermediate_graph_degree(MemorySegment struct, long fieldVal /** * Layout for field: - * {@snippet lang = c : * long graph_degree + * {@snippet lang = c : * size_t graph_degree * } */ public static final OfLong graph_degree$layout() { @@ -156,7 +156,7 @@ public static void intermediate_graph_degree(MemorySegment struct, long fieldVal /** * Offset for field: - * {@snippet lang = c : * long graph_degree + * {@snippet lang = c : * size_t graph_degree * } */ public static final long graph_degree$offset() { @@ -165,7 +165,7 @@ public static void intermediate_graph_degree(MemorySegment struct, long fieldVal /** * Getter for field: - * {@snippet lang = c : * long graph_degree + * {@snippet lang = c : * size_t graph_degree * } */ public static long graph_degree(MemorySegment struct) { @@ -174,7 +174,7 @@ public static long graph_degree(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long graph_degree + * {@snippet lang = c : * size_t graph_degree * } */ public static void graph_degree(MemorySegment struct, long fieldValue) { @@ -225,7 +225,7 @@ public static void build_algo(MemorySegment struct, int fieldValue) { /** * Layout for field: - * {@snippet lang = c : * long nn_descent_niter + * {@snippet lang = c : * size_t nn_descent_niter * } */ public static final OfLong nn_descent_niter$layout() { @@ -236,7 +236,7 @@ public static void build_algo(MemorySegment struct, int fieldValue) { /** * Offset for field: - * {@snippet lang = c : * long nn_descent_niter + * {@snippet lang = c : * size_t nn_descent_niter * } */ public static final long nn_descent_niter$offset() { @@ -245,7 +245,7 @@ public static void build_algo(MemorySegment struct, int fieldValue) { /** * Getter for field: - * {@snippet lang = c : * long nn_descent_niter + * {@snippet lang = c : * size_t nn_descent_niter * } */ public static long nn_descent_niter(MemorySegment struct) { @@ -254,7 +254,7 @@ public static long nn_descent_niter(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long nn_descent_niter + * {@snippet lang = c : * size_t nn_descent_niter * } */ public static void nn_descent_niter(MemorySegment struct, long fieldValue) { @@ -301,6 +301,47 @@ public static void compression(MemorySegment struct, MemorySegment fieldValue) { struct.set(compression$LAYOUT, compression$OFFSET, fieldValue); } + private static final AddressLayout graph_build_params$LAYOUT = (AddressLayout) $LAYOUT + .select(groupElement("graph_build_params")); + + /** + * Layout for field: + * {@snippet lang = c : * cuvsIvfPqParams_t graph_build_params + * } + */ + public static final AddressLayout graph_build_params$layout() { + return graph_build_params$LAYOUT; + } + + private static final long graph_build_params$OFFSET = 48; + + /** + * Offset for field: + * {@snippet lang = c : * cuvsIvfPqParams_t graph_build_params + * } + */ + public static final long graph_build_params$offset() { + return graph_build_params$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * cuvsIvfPqParams_t graph_build_params + * } + */ + public static MemorySegment graph_build_params(MemorySegment struct) { + return struct.get(graph_build_params$LAYOUT, graph_build_params$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * cuvsIvfPqParams_t graph_build_params + * } + */ + public static void graph_build_params(MemorySegment struct, MemorySegment fieldValue) { + struct.set(graph_build_params$LAYOUT, graph_build_params$OFFSET, fieldValue); + } + /** * Obtains a slice of {@code arrayParam} which selects the array element at * {@code index}. The returned segment has address 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 index 2a1efbfd7..291a295b1 100644 --- 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 @@ -31,16 +31,16 @@ /** * {@snippet lang = c : * struct cuvsCagraSearchParams { - * long max_queries; - * long itopk_size; - * long max_iterations; + * size_t max_queries; + * size_t itopk_size; + * size_t max_iterations; * enum cuvsCagraSearchAlgo algo; - * long team_size; - * long search_width; - * long min_iterations; - * long thread_block_size; + * size_t team_size; + * size_t search_width; + * size_t min_iterations; + * size_t thread_block_size; * enum cuvsCagraHashMode hashmap_mode; - * long hashmap_min_bitlen; + * size_t hashmap_min_bitlen; * float hashmap_max_fill_rate; * uint32_t num_random_samplings; * uint64_t rand_xor_mask; @@ -74,7 +74,7 @@ public static final GroupLayout layout() { /** * Layout for field: - * {@snippet lang = c : * long max_queries + * {@snippet lang = c : * size_t max_queries * } */ public static final OfLong max_queries$layout() { @@ -85,7 +85,7 @@ public static final GroupLayout layout() { /** * Offset for field: - * {@snippet lang = c : * long max_queries + * {@snippet lang = c : * size_t max_queries * } */ public static final long max_queries$offset() { @@ -94,7 +94,7 @@ public static final GroupLayout layout() { /** * Getter for field: - * {@snippet lang = c : * long max_queries + * {@snippet lang = c : * size_t max_queries * } */ public static long max_queries(MemorySegment struct) { @@ -103,7 +103,7 @@ public static long max_queries(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long max_queries + * {@snippet lang = c : * size_t max_queries * } */ public static void max_queries(MemorySegment struct, long fieldValue) { @@ -114,7 +114,7 @@ public static void max_queries(MemorySegment struct, long fieldValue) { /** * Layout for field: - * {@snippet lang = c : * long itopk_size + * {@snippet lang = c : * size_t itopk_size * } */ public static final OfLong itopk_size$layout() { @@ -125,7 +125,7 @@ public static void max_queries(MemorySegment struct, long fieldValue) { /** * Offset for field: - * {@snippet lang = c : * long itopk_size + * {@snippet lang = c : * size_t itopk_size * } */ public static final long itopk_size$offset() { @@ -134,7 +134,7 @@ public static void max_queries(MemorySegment struct, long fieldValue) { /** * Getter for field: - * {@snippet lang = c : * long itopk_size + * {@snippet lang = c : * size_t itopk_size * } */ public static long itopk_size(MemorySegment struct) { @@ -143,7 +143,7 @@ public static long itopk_size(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long itopk_size + * {@snippet lang = c : * size_t itopk_size * } */ public static void itopk_size(MemorySegment struct, long fieldValue) { @@ -154,7 +154,7 @@ public static void itopk_size(MemorySegment struct, long fieldValue) { /** * Layout for field: - * {@snippet lang = c : * long max_iterations + * {@snippet lang = c : * size_t max_iterations * } */ public static final OfLong max_iterations$layout() { @@ -165,7 +165,7 @@ public static void itopk_size(MemorySegment struct, long fieldValue) { /** * Offset for field: - * {@snippet lang = c : * long max_iterations + * {@snippet lang = c : * size_t max_iterations * } */ public static final long max_iterations$offset() { @@ -174,7 +174,7 @@ public static void itopk_size(MemorySegment struct, long fieldValue) { /** * Getter for field: - * {@snippet lang = c : * long max_iterations + * {@snippet lang = c : * size_t max_iterations * } */ public static long max_iterations(MemorySegment struct) { @@ -183,7 +183,7 @@ public static long max_iterations(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long max_iterations + * {@snippet lang = c : * size_t max_iterations * } */ public static void max_iterations(MemorySegment struct, long fieldValue) { @@ -234,7 +234,7 @@ public static void algo(MemorySegment struct, int fieldValue) { /** * Layout for field: - * {@snippet lang = c : * long team_size + * {@snippet lang = c : * size_t team_size * } */ public static final OfLong team_size$layout() { @@ -245,7 +245,7 @@ public static void algo(MemorySegment struct, int fieldValue) { /** * Offset for field: - * {@snippet lang = c : * long team_size + * {@snippet lang = c : * size_t team_size * } */ public static final long team_size$offset() { @@ -254,7 +254,7 @@ public static void algo(MemorySegment struct, int fieldValue) { /** * Getter for field: - * {@snippet lang = c : * long team_size + * {@snippet lang = c : * size_t team_size * } */ public static long team_size(MemorySegment struct) { @@ -263,7 +263,7 @@ public static long team_size(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long team_size + * {@snippet lang = c : * size_t team_size * } */ public static void team_size(MemorySegment struct, long fieldValue) { @@ -274,7 +274,7 @@ public static void team_size(MemorySegment struct, long fieldValue) { /** * Layout for field: - * {@snippet lang = c : * long search_width + * {@snippet lang = c : * size_t search_width * } */ public static final OfLong search_width$layout() { @@ -285,7 +285,7 @@ public static void team_size(MemorySegment struct, long fieldValue) { /** * Offset for field: - * {@snippet lang = c : * long search_width + * {@snippet lang = c : * size_t search_width * } */ public static final long search_width$offset() { @@ -294,7 +294,7 @@ public static void team_size(MemorySegment struct, long fieldValue) { /** * Getter for field: - * {@snippet lang = c : * long search_width + * {@snippet lang = c : * size_t search_width * } */ public static long search_width(MemorySegment struct) { @@ -303,7 +303,7 @@ public static long search_width(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long search_width + * {@snippet lang = c : * size_t search_width * } */ public static void search_width(MemorySegment struct, long fieldValue) { @@ -314,7 +314,7 @@ public static void search_width(MemorySegment struct, long fieldValue) { /** * Layout for field: - * {@snippet lang = c : * long min_iterations + * {@snippet lang = c : * size_t min_iterations * } */ public static final OfLong min_iterations$layout() { @@ -325,7 +325,7 @@ public static void search_width(MemorySegment struct, long fieldValue) { /** * Offset for field: - * {@snippet lang = c : * long min_iterations + * {@snippet lang = c : * size_t min_iterations * } */ public static final long min_iterations$offset() { @@ -334,7 +334,7 @@ public static void search_width(MemorySegment struct, long fieldValue) { /** * Getter for field: - * {@snippet lang = c : * long min_iterations + * {@snippet lang = c : * size_t min_iterations * } */ public static long min_iterations(MemorySegment struct) { @@ -343,7 +343,7 @@ public static long min_iterations(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long min_iterations + * {@snippet lang = c : * size_t min_iterations * } */ public static void min_iterations(MemorySegment struct, long fieldValue) { @@ -354,7 +354,7 @@ public static void min_iterations(MemorySegment struct, long fieldValue) { /** * Layout for field: - * {@snippet lang = c : * long thread_block_size + * {@snippet lang = c : * size_t thread_block_size * } */ public static final OfLong thread_block_size$layout() { @@ -365,7 +365,7 @@ public static void min_iterations(MemorySegment struct, long fieldValue) { /** * Offset for field: - * {@snippet lang = c : * long thread_block_size + * {@snippet lang = c : * size_t thread_block_size * } */ public static final long thread_block_size$offset() { @@ -374,7 +374,7 @@ public static void min_iterations(MemorySegment struct, long fieldValue) { /** * Getter for field: - * {@snippet lang = c : * long thread_block_size + * {@snippet lang = c : * size_t thread_block_size * } */ public static long thread_block_size(MemorySegment struct) { @@ -383,7 +383,7 @@ public static long thread_block_size(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long thread_block_size + * {@snippet lang = c : * size_t thread_block_size * } */ public static void thread_block_size(MemorySegment struct, long fieldValue) { @@ -434,7 +434,7 @@ public static void hashmap_mode(MemorySegment struct, int fieldValue) { /** * Layout for field: - * {@snippet lang = c : * long hashmap_min_bitlen + * {@snippet lang = c : * size_t hashmap_min_bitlen * } */ public static final OfLong hashmap_min_bitlen$layout() { @@ -445,7 +445,7 @@ public static void hashmap_mode(MemorySegment struct, int fieldValue) { /** * Offset for field: - * {@snippet lang = c : * long hashmap_min_bitlen + * {@snippet lang = c : * size_t hashmap_min_bitlen * } */ public static final long hashmap_min_bitlen$offset() { @@ -454,7 +454,7 @@ public static void hashmap_mode(MemorySegment struct, int fieldValue) { /** * Getter for field: - * {@snippet lang = c : * long hashmap_min_bitlen + * {@snippet lang = c : * size_t hashmap_min_bitlen * } */ public static long hashmap_min_bitlen(MemorySegment struct) { @@ -463,7 +463,7 @@ public static long hashmap_min_bitlen(MemorySegment struct) { /** * Setter for field: - * {@snippet lang = c : * long hashmap_min_bitlen + * {@snippet lang = c : * size_t hashmap_min_bitlen * } */ public static void hashmap_min_bitlen(MemorySegment struct, long fieldValue) { 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 index dceaca994..fd9cafb1b 100644 --- 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 @@ -28,7 +28,7 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct { * uintptr_t addr; * enum cuvsFilterType type; @@ -37,152 +37,148 @@ */ 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); - } + 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/CuVSHnswIndex.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSHnswIndex.java index aa12e4400..2cb34066d 100644 --- 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 @@ -40,8 +40,9 @@ public class 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"); + 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 diff --git a/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSIvfPqIndex.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSIvfPqIndex.java new file mode 100644 index 000000000..316ab9d43 --- /dev/null +++ b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSIvfPqIndex.java @@ -0,0 +1,183 @@ +/* + * 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 CuVSIvfPqIndex { + + CuVSIvfPqIndex() { + // 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$207: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/CuVSIvfPqIndexParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSIvfPqIndexParams.java new file mode 100644 index 000000000..9e87ffdff --- /dev/null +++ b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSIvfPqIndexParams.java @@ -0,0 +1,607 @@ +/* + * 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.OfBoolean; +import java.lang.foreign.ValueLayout.OfDouble; +import java.lang.foreign.ValueLayout.OfFloat; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * 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; + * } + * } + */ +public class CuVSIvfPqIndexParams { + + CuVSIvfPqIndexParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(CagraH.C_INT.withName("metric"), + CagraH.C_FLOAT.withName("metric_arg"), CagraH.C_BOOL.withName("add_data_on_build"), MemoryLayout.paddingLayout(3), + CagraH.C_INT.withName("n_lists"), CagraH.C_INT.withName("kmeans_n_iters"), MemoryLayout.paddingLayout(4), + CagraH.C_DOUBLE.withName("kmeans_trainset_fraction"), CagraH.C_INT.withName("pq_bits"), + CagraH.C_INT.withName("pq_dim"), CagraH.C_INT.withName("codebook_kind"), + CagraH.C_BOOL.withName("force_random_rotation"), CagraH.C_BOOL.withName("conservative_memory_allocation"), + MemoryLayout.paddingLayout(2), CagraH.C_INT.withName("max_train_points_per_pq_code"), + MemoryLayout.paddingLayout(4)).withName("cuvsIvfPqIndexParams"); + + /** + * 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 OfFloat metric_arg$LAYOUT = (OfFloat) $LAYOUT.select(groupElement("metric_arg")); + + /** + * Layout for field: + * {@snippet lang = c : * float metric_arg + * } + */ + public static final OfFloat metric_arg$layout() { + return metric_arg$LAYOUT; + } + + private static final long metric_arg$OFFSET = 4; + + /** + * Offset for field: + * {@snippet lang = c : * float metric_arg + * } + */ + public static final long metric_arg$offset() { + return metric_arg$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * float metric_arg + * } + */ + public static float metric_arg(MemorySegment struct) { + return struct.get(metric_arg$LAYOUT, metric_arg$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * float metric_arg + * } + */ + public static void metric_arg(MemorySegment struct, float fieldValue) { + struct.set(metric_arg$LAYOUT, metric_arg$OFFSET, fieldValue); + } + + private static final OfBoolean add_data_on_build$LAYOUT = (OfBoolean) $LAYOUT + .select(groupElement("add_data_on_build")); + + /** + * Layout for field: + * {@snippet lang = c : * bool add_data_on_build + * } + */ + public static final OfBoolean add_data_on_build$layout() { + return add_data_on_build$LAYOUT; + } + + private static final long add_data_on_build$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * bool add_data_on_build + * } + */ + public static final long add_data_on_build$offset() { + return add_data_on_build$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * bool add_data_on_build + * } + */ + public static boolean add_data_on_build(MemorySegment struct) { + return struct.get(add_data_on_build$LAYOUT, add_data_on_build$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * bool add_data_on_build + * } + */ + public static void add_data_on_build(MemorySegment struct, boolean fieldValue) { + struct.set(add_data_on_build$LAYOUT, add_data_on_build$OFFSET, fieldValue); + } + + private static final OfInt n_lists$LAYOUT = (OfInt) $LAYOUT.select(groupElement("n_lists")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t n_lists + * } + */ + public static final OfInt n_lists$layout() { + return n_lists$LAYOUT; + } + + private static final long n_lists$OFFSET = 12; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t n_lists + * } + */ + public static final long n_lists$offset() { + return n_lists$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t n_lists + * } + */ + public static int n_lists(MemorySegment struct) { + return struct.get(n_lists$LAYOUT, n_lists$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t n_lists + * } + */ + public static void n_lists(MemorySegment struct, int fieldValue) { + struct.set(n_lists$LAYOUT, n_lists$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 = 16; + + /** + * 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 kmeans_trainset_fraction$LAYOUT = (OfDouble) $LAYOUT + .select(groupElement("kmeans_trainset_fraction")); + + /** + * Layout for field: + * {@snippet lang = c : * double kmeans_trainset_fraction + * } + */ + public static final OfDouble kmeans_trainset_fraction$layout() { + return kmeans_trainset_fraction$LAYOUT; + } + + private static final long kmeans_trainset_fraction$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang = c : * double kmeans_trainset_fraction + * } + */ + public static final long kmeans_trainset_fraction$offset() { + return kmeans_trainset_fraction$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * double kmeans_trainset_fraction + * } + */ + public static double kmeans_trainset_fraction(MemorySegment struct) { + return struct.get(kmeans_trainset_fraction$LAYOUT, kmeans_trainset_fraction$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * double kmeans_trainset_fraction + * } + */ + public static void kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { + struct.set(kmeans_trainset_fraction$LAYOUT, kmeans_trainset_fraction$OFFSET, fieldValue); + } + + 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 = 32; + + /** + * 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 = 36; + + /** + * 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 codebook_kind$LAYOUT = (OfInt) $LAYOUT.select(groupElement("codebook_kind")); + + /** + * Layout for field: + * {@snippet lang = c : * enum codebook_gen codebook_kind + * } + */ + public static final OfInt codebook_kind$layout() { + return codebook_kind$LAYOUT; + } + + private static final long codebook_kind$OFFSET = 40; + + /** + * Offset for field: + * {@snippet lang = c : * enum codebook_gen codebook_kind + * } + */ + public static final long codebook_kind$offset() { + return codebook_kind$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * enum codebook_gen codebook_kind + * } + */ + public static int codebook_kind(MemorySegment struct) { + return struct.get(codebook_kind$LAYOUT, codebook_kind$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * enum codebook_gen codebook_kind + * } + */ + public static void codebook_kind(MemorySegment struct, int fieldValue) { + struct.set(codebook_kind$LAYOUT, codebook_kind$OFFSET, fieldValue); + } + + private static final OfBoolean force_random_rotation$LAYOUT = (OfBoolean) $LAYOUT + .select(groupElement("force_random_rotation")); + + /** + * Layout for field: + * {@snippet lang = c : * bool force_random_rotation + * } + */ + public static final OfBoolean force_random_rotation$layout() { + return force_random_rotation$LAYOUT; + } + + private static final long force_random_rotation$OFFSET = 44; + + /** + * Offset for field: + * {@snippet lang = c : * bool force_random_rotation + * } + */ + public static final long force_random_rotation$offset() { + return force_random_rotation$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * bool force_random_rotation + * } + */ + public static boolean force_random_rotation(MemorySegment struct) { + return struct.get(force_random_rotation$LAYOUT, force_random_rotation$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * bool force_random_rotation + * } + */ + public static void force_random_rotation(MemorySegment struct, boolean fieldValue) { + struct.set(force_random_rotation$LAYOUT, force_random_rotation$OFFSET, fieldValue); + } + + private static final OfBoolean conservative_memory_allocation$LAYOUT = (OfBoolean) $LAYOUT + .select(groupElement("conservative_memory_allocation")); + + /** + * Layout for field: + * {@snippet lang = c : * bool conservative_memory_allocation + * } + */ + public static final OfBoolean conservative_memory_allocation$layout() { + return conservative_memory_allocation$LAYOUT; + } + + private static final long conservative_memory_allocation$OFFSET = 45; + + /** + * Offset for field: + * {@snippet lang = c : * bool conservative_memory_allocation + * } + */ + public static final long conservative_memory_allocation$offset() { + return conservative_memory_allocation$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * bool conservative_memory_allocation + * } + */ + public static boolean conservative_memory_allocation(MemorySegment struct) { + return struct.get(conservative_memory_allocation$LAYOUT, conservative_memory_allocation$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * bool conservative_memory_allocation + * } + */ + public static void conservative_memory_allocation(MemorySegment struct, boolean fieldValue) { + struct.set(conservative_memory_allocation$LAYOUT, conservative_memory_allocation$OFFSET, fieldValue); + } + + private static final OfInt max_train_points_per_pq_code$LAYOUT = (OfInt) $LAYOUT + .select(groupElement("max_train_points_per_pq_code")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t max_train_points_per_pq_code + * } + */ + public static final OfInt max_train_points_per_pq_code$layout() { + return max_train_points_per_pq_code$LAYOUT; + } + + private static final long max_train_points_per_pq_code$OFFSET = 48; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t max_train_points_per_pq_code + * } + */ + public static final long max_train_points_per_pq_code$offset() { + return max_train_points_per_pq_code$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t max_train_points_per_pq_code + * } + */ + public static int max_train_points_per_pq_code(MemorySegment struct) { + return struct.get(max_train_points_per_pq_code$LAYOUT, max_train_points_per_pq_code$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t max_train_points_per_pq_code + * } + */ + public static void max_train_points_per_pq_code(MemorySegment struct, int fieldValue) { + struct.set(max_train_points_per_pq_code$LAYOUT, max_train_points_per_pq_code$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/CuVSIvfPqParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSIvfPqParams.java new file mode 100644 index 000000000..92317fed5 --- /dev/null +++ b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSIvfPqParams.java @@ -0,0 +1,229 @@ +/* + * 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.OfFloat; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct cuvsIvfPqParams { + * cuvsIvfPqIndexParams_t ivf_pq_build_params; + * cuvsIvfPqSearchParams_t ivf_pq_search_params; + * float refinement_rate; + * } + * } + */ +public class CuVSIvfPqParams { + + CuVSIvfPqParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(CagraH.C_POINTER.withName("ivf_pq_build_params"), CagraH.C_POINTER.withName("ivf_pq_search_params"), + CagraH.C_FLOAT.withName("refinement_rate"), MemoryLayout.paddingLayout(4)) + .withName("cuvsIvfPqParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final AddressLayout ivf_pq_build_params$LAYOUT = (AddressLayout) $LAYOUT + .select(groupElement("ivf_pq_build_params")); + + /** + * Layout for field: + * {@snippet lang = c : * cuvsIvfPqIndexParams_t ivf_pq_build_params + * } + */ + public static final AddressLayout ivf_pq_build_params$layout() { + return ivf_pq_build_params$LAYOUT; + } + + private static final long ivf_pq_build_params$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * cuvsIvfPqIndexParams_t ivf_pq_build_params + * } + */ + public static final long ivf_pq_build_params$offset() { + return ivf_pq_build_params$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * cuvsIvfPqIndexParams_t ivf_pq_build_params + * } + */ + public static MemorySegment ivf_pq_build_params(MemorySegment struct) { + return struct.get(ivf_pq_build_params$LAYOUT, ivf_pq_build_params$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * cuvsIvfPqIndexParams_t ivf_pq_build_params + * } + */ + public static void ivf_pq_build_params(MemorySegment struct, MemorySegment fieldValue) { + struct.set(ivf_pq_build_params$LAYOUT, ivf_pq_build_params$OFFSET, fieldValue); + } + + private static final AddressLayout ivf_pq_search_params$LAYOUT = (AddressLayout) $LAYOUT + .select(groupElement("ivf_pq_search_params")); + + /** + * Layout for field: + * {@snippet lang = c : * cuvsIvfPqSearchParams_t ivf_pq_search_params + * } + */ + public static final AddressLayout ivf_pq_search_params$layout() { + return ivf_pq_search_params$LAYOUT; + } + + private static final long ivf_pq_search_params$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * cuvsIvfPqSearchParams_t ivf_pq_search_params + * } + */ + public static final long ivf_pq_search_params$offset() { + return ivf_pq_search_params$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * cuvsIvfPqSearchParams_t ivf_pq_search_params + * } + */ + public static MemorySegment ivf_pq_search_params(MemorySegment struct) { + return struct.get(ivf_pq_search_params$LAYOUT, ivf_pq_search_params$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * cuvsIvfPqSearchParams_t ivf_pq_search_params + * } + */ + public static void ivf_pq_search_params(MemorySegment struct, MemorySegment fieldValue) { + struct.set(ivf_pq_search_params$LAYOUT, ivf_pq_search_params$OFFSET, fieldValue); + } + + private static final OfFloat refinement_rate$LAYOUT = (OfFloat) $LAYOUT.select(groupElement("refinement_rate")); + + /** + * Layout for field: + * {@snippet lang = c : * float refinement_rate + * } + */ + public static final OfFloat refinement_rate$layout() { + return refinement_rate$LAYOUT; + } + + private static final long refinement_rate$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * float refinement_rate + * } + */ + public static final long refinement_rate$offset() { + return refinement_rate$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * float refinement_rate + * } + */ + public static float refinement_rate(MemorySegment struct) { + return struct.get(refinement_rate$LAYOUT, refinement_rate$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * float refinement_rate + * } + */ + public static void refinement_rate(MemorySegment struct, float fieldValue) { + struct.set(refinement_rate$LAYOUT, refinement_rate$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/CuVSIvfPqSearchParams.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSIvfPqSearchParams.java new file mode 100644 index 000000000..c9b6ae137 --- /dev/null +++ b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/CuVSIvfPqSearchParams.java @@ -0,0 +1,270 @@ +/* + * 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 cuvsIvfPqSearchParams { + * uint32_t n_probes; + * enum cudaDataType_t lut_dtype; + * enum cudaDataType_t internal_distance_dtype; + * double preferred_shmem_carveout; + * } + * } + */ +public class CuVSIvfPqSearchParams { + + CuVSIvfPqSearchParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(CagraH.C_INT.withName("n_probes"), + CagraH.C_INT.withName("lut_dtype"), CagraH.C_INT.withName("internal_distance_dtype"), + MemoryLayout.paddingLayout(4), CagraH.C_DOUBLE.withName("preferred_shmem_carveout")) + .withName("cuvsIvfPqSearchParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt n_probes$LAYOUT = (OfInt) $LAYOUT.select(groupElement("n_probes")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t n_probes + * } + */ + public static final OfInt n_probes$layout() { + return n_probes$LAYOUT; + } + + private static final long n_probes$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t n_probes + * } + */ + public static final long n_probes$offset() { + return n_probes$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t n_probes + * } + */ + public static int n_probes(MemorySegment struct) { + return struct.get(n_probes$LAYOUT, n_probes$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t n_probes + * } + */ + public static void n_probes(MemorySegment struct, int fieldValue) { + struct.set(n_probes$LAYOUT, n_probes$OFFSET, fieldValue); + } + + private static final OfInt lut_dtype$LAYOUT = (OfInt) $LAYOUT.select(groupElement("lut_dtype")); + + /** + * Layout for field: + * {@snippet lang = c : * enum cudaDataType_t lut_dtype + * } + */ + public static final OfInt lut_dtype$layout() { + return lut_dtype$LAYOUT; + } + + private static final long lut_dtype$OFFSET = 4; + + /** + * Offset for field: + * {@snippet lang = c : * enum cudaDataType_t lut_dtype + * } + */ + public static final long lut_dtype$offset() { + return lut_dtype$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * enum cudaDataType_t lut_dtype + * } + */ + public static int lut_dtype(MemorySegment struct) { + return struct.get(lut_dtype$LAYOUT, lut_dtype$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * enum cudaDataType_t lut_dtype + * } + */ + public static void lut_dtype(MemorySegment struct, int fieldValue) { + struct.set(lut_dtype$LAYOUT, lut_dtype$OFFSET, fieldValue); + } + + private static final OfInt internal_distance_dtype$LAYOUT = (OfInt) $LAYOUT + .select(groupElement("internal_distance_dtype")); + + /** + * Layout for field: + * {@snippet lang = c : * enum cudaDataType_t internal_distance_dtype + * } + */ + public static final OfInt internal_distance_dtype$layout() { + return internal_distance_dtype$LAYOUT; + } + + private static final long internal_distance_dtype$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * enum cudaDataType_t internal_distance_dtype + * } + */ + public static final long internal_distance_dtype$offset() { + return internal_distance_dtype$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * enum cudaDataType_t internal_distance_dtype + * } + */ + public static int internal_distance_dtype(MemorySegment struct) { + return struct.get(internal_distance_dtype$LAYOUT, internal_distance_dtype$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * enum cudaDataType_t internal_distance_dtype + * } + */ + public static void internal_distance_dtype(MemorySegment struct, int fieldValue) { + struct.set(internal_distance_dtype$LAYOUT, internal_distance_dtype$OFFSET, fieldValue); + } + + private static final OfDouble preferred_shmem_carveout$LAYOUT = (OfDouble) $LAYOUT + .select(groupElement("preferred_shmem_carveout")); + + /** + * Layout for field: + * {@snippet lang = c : * double preferred_shmem_carveout + * } + */ + public static final OfDouble preferred_shmem_carveout$layout() { + return preferred_shmem_carveout$LAYOUT; + } + + private static final long preferred_shmem_carveout$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * double preferred_shmem_carveout + * } + */ + public static final long preferred_shmem_carveout$offset() { + return preferred_shmem_carveout$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * double preferred_shmem_carveout + * } + */ + public static double preferred_shmem_carveout(MemorySegment struct) { + return struct.get(preferred_shmem_carveout$LAYOUT, preferred_shmem_carveout$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * double preferred_shmem_carveout + * } + */ + public static void preferred_shmem_carveout(MemorySegment struct, double fieldValue) { + struct.set(preferred_shmem_carveout$LAYOUT, preferred_shmem_carveout$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 index aaa2f4d2d..97d4e8e53 100644 --- 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 @@ -28,7 +28,7 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct { * uint8_t code; * uint8_t bits; @@ -38,196 +38,189 @@ */ 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); - } + DLDataType() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(CagraH.C_CHAR.withName("code"), CagraH.C_CHAR.withName("bits"), CagraH.C_SHORT.withName("lanes")) + .withName("$anon$145: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 index ceadb6a69..d29ff77d1 100644 --- 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 @@ -27,7 +27,7 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct { * DLDeviceType device_type; * int32_t device_id; @@ -36,151 +36,148 @@ */ 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); - } + DLDevice() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(CagraH.C_INT.withName("device_type"), CagraH.C_INT.withName("device_id")).withName("$anon$97: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 index c28dd71c3..d63969fd7 100644 --- 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 @@ -30,7 +30,7 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct DLManagedTensor { * DLTensor dl_tensor; * void *manager_ctx; @@ -40,249 +40,238 @@ */ 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()); + DLManagedTensor() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(DLTensor.layout().withName("dl_tensor"), + CagraH.C_POINTER.withName("manager_ctx"), CagraH.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 } /** - * Setter for field: - * {@snippet lang=c : - * DLTensor dl_tensor - * } + * The function pointer signature, expressed as a functional interface */ - public static void dl_tensor(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); + public interface Function { + void apply(MemorySegment _x0); } - private static final AddressLayout manager_ctx$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("manager_ctx")); + private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid(CagraH.C_POINTER); /** - * Layout for field: - * {@snippet lang=c : - * void *manager_ctx - * } + * The descriptor of this function pointer */ - public static final AddressLayout manager_ctx$layout() { - return manager_ctx$LAYOUT; + public static FunctionDescriptor descriptor() { + return $DESC; } - private static final long manager_ctx$OFFSET = 48; + private static final MethodHandle UP$MH = CagraH.upcallHandle(deleter.Function.class, "apply", $DESC); /** - * Offset for field: - * {@snippet lang=c : - * void *manager_ctx - * } + * 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 final long manager_ctx$offset() { - return manager_ctx$OFFSET; + public static MemorySegment allocate(deleter.Function fi, Arena arena) { + return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } - /** - * 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); - } + private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} + * Invoke the upcall stub {@code funcPtr}, with given parameters */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + 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 index f631140e2..939f4cb7e 100644 --- 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 @@ -31,7 +31,7 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct DLManagedTensorVersioned { * DLPackVersion version; * void *manager_ctx; @@ -43,339 +43,319 @@ */ 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); + 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 } /** - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensorVersioned *) - * } + * The function pointer signature, expressed as a functional interface */ - 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$); - } - } + public interface Function { + void apply(MemorySegment _x0); } - private static final AddressLayout deleter$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("deleter")); + private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid(DlpackH.C_POINTER); /** - * Layout for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensorVersioned *) - * } + * The descriptor of this function pointer */ - public static final AddressLayout deleter$layout() { - return deleter$LAYOUT; + public static FunctionDescriptor descriptor() { + return $DESC; } - private static final long deleter$OFFSET = 16; + private static final MethodHandle UP$MH = DlpackH.upcallHandle(deleter.Function.class, "apply", $DESC); /** - * Offset for field: - * {@snippet lang=c : - * void (*deleter)(struct DLManagedTensorVersioned *) - * } + * 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 final long deleter$offset() { - return deleter$OFFSET; + public static MemorySegment allocate(deleter.Function fi, Arena arena) { + return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } - /** - * 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); - } + private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} + * Invoke the upcall stub {@code funcPtr}, with given parameters */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + 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 index c65fdd887..13d31b87f 100644 --- 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 @@ -27,7 +27,7 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct { * uint32_t major; * uint32_t minor; @@ -36,151 +36,148 @@ */ 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); - } + 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 index 21d928905..7dacf0c2f 100644 --- 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 @@ -29,7 +29,7 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct { * void *data; * DLDevice device; @@ -43,376 +43,350 @@ */ 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); - } + DLTensor() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(CagraH.C_POINTER.withName("data"), + DLDevice.layout().withName("device"), CagraH.C_INT.withName("ndim"), DLDataType.layout().withName("dtype"), + CagraH.C_POINTER.withName("shape"), CagraH.C_POINTER.withName("strides"), CagraH.C_LONG.withName("byte_offset")) + .withName("$anon$163: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 index b98f95ae2..3a33787cf 100644 --- 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 @@ -16,259 +16,283 @@ 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.JAVA_BYTE; -import static java.lang.foreign.ValueLayout.*; -import static java.lang.foreign.MemoryLayout.PathElement.*; +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 DistanceH { - DistanceH() { - // Should not be called directly - } + DistanceH() { + // Should not be called directly + } - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + 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 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 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 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 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; - } + 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 index 6ef78336f..b4b3cf410 100644 --- 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 @@ -41,1858 +41,1897 @@ public class DlpackH { - DlpackH() { - // Should not be called directly - } + DlpackH() { + // Should not be called directly + } - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + 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 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 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 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 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; - } + 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/IvfPqH.java b/java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/panama/IvfPqH.java index 66d0ba5ac..c523b4afd 100644 --- 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 @@ -2289,8 +2289,8 @@ public static int cuvsIvfPqIndexDestroy(MemorySegment index) { } 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 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"); @@ -2345,8 +2345,8 @@ public static int cuvsIvfPqBuild(long res, MemorySegment params, MemorySegment d } 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 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"); @@ -2402,8 +2402,8 @@ public static int cuvsIvfPqSearch(long res, MemorySegment search_params, MemoryS } 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 FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_LONG, IvfPqH.C_POINTER, + IvfPqH.C_POINTER); public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqSerialize"); @@ -2458,8 +2458,8 @@ public static int cuvsIvfPqSerialize(long res, MemorySegment filename, MemorySeg } 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 FunctionDescriptor DESC = FunctionDescriptor.of(IvfPqH.C_INT, IvfPqH.C_LONG, IvfPqH.C_POINTER, + IvfPqH.C_POINTER); public static final MemorySegment ADDR = IvfPqH.findOrThrow("cuvsIvfPqDeserialize"); @@ -2514,8 +2514,8 @@ public static int cuvsIvfPqDeserialize(long res, MemorySegment filename, MemoryS } 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 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"); 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 index d07c524db..ece87a54f 100644 --- 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 @@ -27,7 +27,7 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct { * long long __clang_max_align_nonce1; * long double __clang_max_align_nonce2; @@ -36,107 +36,110 @@ */ 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); - } + MaxAlignT() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(CagraH.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/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);