From c777924ade77a49de4223e75795462fa6f62c360 Mon Sep 17 00:00:00 2001 From: Ishan Chattopadhyaya Date: Fri, 8 Nov 2024 19:20:12 +0530 Subject: [PATCH 01/53] Initial cut for a cuVS Java API Co-authored-by: Vivek Narang --- .gitignore | 6 + build.sh | 12 +- java/README.md | 12 + java/build.sh | 9 + java/cuvs-java/pom.xml | 135 + .../main/java/com/nvidia/cuvs/ExampleApp.java | 74 + .../nvidia/cuvs/cagra/CagraIndexParams.java | 118 + .../cuvs/cagra/CagraIndexReference.java | 28 + .../nvidia/cuvs/cagra/CagraSearchParams.java | 256 ++ .../java/com/nvidia/cuvs/cagra/CuVSIndex.java | 335 ++ .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 118 + .../com/nvidia/cuvs/cagra/CuVSResources.java | 43 + .../com/nvidia/cuvs/cagra/IndexParams.java | 9 + .../nvidia/cuvs/cagra/PointerToDataset.java | 5 + .../java/com/nvidia/cuvs/cagra/PreFilter.java | 5 + .../com/nvidia/cuvs/cagra/SearchParams.java | 9 + .../com/nvidia/cuvs/cagra/SearchResult.java | 49 + .../com/nvidia/cuvs/panama/DLDataType.java | 218 ++ .../java/com/nvidia/cuvs/panama/DLDevice.java | 171 + .../nvidia/cuvs/panama/DLManagedTensor.java | 273 ++ .../cuvs/panama/DLManagedTensorVersioned.java | 366 ++ .../com/nvidia/cuvs/panama/DLPackVersion.java | 171 + .../java/com/nvidia/cuvs/panama/DLTensor.java | 402 +++ .../java/com/nvidia/cuvs/panama/__fsid_t.java | 159 + .../com/nvidia/cuvs/panama/brute_force_h.java | 2357 +++++++++++++ .../java/com/nvidia/cuvs/panama/cagra_h.java | 2051 +++++++++++ .../panama/cuvsCagraCompressionParams.java | 356 ++ .../nvidia/cuvs/panama/cuvsCagraIndex.java | 172 + .../cuvs/panama/cuvsCagraIndexParams.java | 265 ++ .../cuvs/panama/cuvsCagraSearchParams.java | 681 ++++ .../com/nvidia/cuvs/panama/cuvsFilter.java | 172 + .../java/com/nvidia/cuvs/panama/dlpack_h.java | 1883 ++++++++++ .../java/com/nvidia/cuvs/panama/hnsw_h.java | 2482 +++++++++++++ .../com/nvidia/cuvs/panama/ivf_flat_h.java | 2792 +++++++++++++++ .../java/com/nvidia/cuvs/panama/ivf_pq_h.java | 3096 +++++++++++++++++ .../com/nvidia/cuvs/panama/max_align_t.java | 127 + .../java/com/nvidia/cuvs/panama/results.java | 211 ++ .../com/nvidia/cuvs/panama/results_h.java | 83 + .../src/test/java/ai/rapids/cuvs/AppTest.java | 19 + java/internal/CMakeLists.txt | 56 + java/internal/VERSION | 1 + java/internal/get_dlpack.cmake | 1 + java/internal/rapids_config.cmake | 1 + java/internal/src/cuvs_java.c | 78 + 44 files changed, 19865 insertions(+), 2 deletions(-) create mode 100644 java/README.md create mode 100755 java/build.sh create mode 100644 java/cuvs-java/pom.xml create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java create mode 100644 java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java create mode 100644 java/internal/CMakeLists.txt create mode 120000 java/internal/VERSION create mode 120000 java/internal/get_dlpack.cmake create mode 120000 java/internal/rapids_config.cmake create mode 100644 java/internal/src/cuvs_java.c diff --git a/.gitignore b/.gitignore index 97eab287d..8fd6a50fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ ## common __pycache__ +.gitignore *.pyc *~ \#* @@ -82,3 +83,8 @@ ivf_pq_index # cuvs_bench datasets/ /*.json + +# java +.classpath + + diff --git a/build.sh b/build.sh index b787d3a41..d7f39c683 100755 --- a/build.sh +++ b/build.sh @@ -18,7 +18,7 @@ ARGS=$* # scripts, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean libcuvs python rust docs tests bench-ann examples --uninstall -v -g -n --compile-static-lib --allgpuarch --no-mg --no-cpu --cpu-only --no-shared-libs --no-nvtx --show_depr_warn --incl-cache-stats --time -h" +VALIDARGS="clean libcuvs python rust java docs tests bench-ann examples --uninstall -v -g -n --compile-static-lib --allgpuarch --no-mg --no-cpu --cpu-only --no-shared-libs --no-nvtx --show_depr_warn --incl-cache-stats --time -h" HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool=] [--limit-tests=] [--limit-bench-ann=] [--build-metrics=] where is: clean - remove all existing build artifacts and configuration (start over) @@ -26,6 +26,7 @@ HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool= + 4.0.0 + com.nvidia.cuvs + cuvs-java + 0.1 + cuvs-java + jar + + + 21 + 21 + + + + + commons-io + commons-io + 2.15.1 + + + + com.github.fommil + jniloader + 1.1 + + + + org.slf4j + slf4j-api + 2.0.13 + + + + org.slf4j + slf4j-simple + 2.0.13 + runtime + + + + org.junit.jupiter + junit-jupiter-api + 5.10.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.7 + + + ${project.build.directory}/classes + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + + copy + compile + + copy + + + + + com.nvidia.cuvs + cuvs-java-internal + 0.1 + so + false + + ${project.build.directory}/classes + libcuvs_java.so + + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + + + jar-with-dependencies + + + add + + + + + com.nvidia.cuvs.ExampleApp + + + + + + assemble-all + package + + single + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + true + + com.nvidia.cuvs.ExampleApp + + + + + + + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java new file mode 100644 index 000000000..3497810bf --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -0,0 +1,74 @@ +package com.nvidia.cuvs; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.Map; + +import com.nvidia.cuvs.cagra.CuVSIndex; +import com.nvidia.cuvs.cagra.CuVSIndex.ANNAlgorithms; +import com.nvidia.cuvs.cagra.CagraIndexParams; +import com.nvidia.cuvs.cagra.CagraIndexParams.CuvsCagraGraphBuildAlgo; +import com.nvidia.cuvs.cagra.CagraSearchParams; +import com.nvidia.cuvs.cagra.CuVSQuery; +import com.nvidia.cuvs.cagra.CuVSResources; +import com.nvidia.cuvs.cagra.SearchResult; + +public class ExampleApp { + public static void main(String[] args) throws Throwable { + + // Sample data and query + float[][] dataset = { { 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, + { 0.6673192f, 0.10993068f } }; + Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); + float[][] queries = { { 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, + { 0.05198065f, 0.5789965f } }; + + CuVSResources res = new CuVSResources(); + + CagraIndexParams cagraIndexParams = new CagraIndexParams.Builder() + .withIntermediateGraphDegree(10) + .withBuildAlgo(CuvsCagraGraphBuildAlgo.IVF_PQ) + .withWriterThreads(1) + .build(); + + CagraSearchParams cagraSearchParams = new CagraSearchParams + .Builder() + .withMaxQueries(15) + .build(); + + // Creating a new index + CuVSIndex index = new CuVSIndex.Builder(res) + .withDataset(dataset) + .withANNAlgorithm(ANNAlgorithms.CAGRA) + .withIndexParams(cagraIndexParams) + .build(); + + // Saving the index on to the disk. + index.serialize(new FileOutputStream("abc.cag"), "/tmp/index.cag"); + + // Loading a cagra index from disk. + InputStream fin = new FileInputStream(new File("abc.cag")); + CuVSIndex index2 = new CuVSIndex.Builder(res) + .from(fin) + .build(); + + // Query + CuVSQuery query = new CuVSQuery.Builder() + .withANNAlgorithm(ANNAlgorithms.CAGRA) + .withSearchParams(cagraSearchParams) + .withQueryVectors(queries) + .withMapping(map) + .build(); + + // Search + SearchResult rslt = index.search(query); + System.out.println(rslt.results); + + // Search from de-serialized index + SearchResult rslt2 = index2.search(query); + System.out.println(rslt2.results); + + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java new file mode 100644 index 000000000..1c99bdfdf --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -0,0 +1,118 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; + +import com.nvidia.cuvs.panama.cuvsCagraIndexParams; + +/* +* struct cuvsCagraIndexParams { +* size_t intermediate_graph_degree; +* size_t graph_degree; +* enum cuvsCagraGraphBuildAlgo build_algo; +* size_t nn_descent_niter; +* } +*/ +public class CagraIndexParams extends IndexParams { + + Arena arena; + int intermediateGraphDegree; + int graphDegree; + CuvsCagraGraphBuildAlgo buildAlgo; + int nnDescentNiter; + + public enum CuvsCagraGraphBuildAlgo { + AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); + + public final int label; + + private CuvsCagraGraphBuildAlgo(int label) { + this.label = label; + } + } + + public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, + CuvsCagraGraphBuildAlgo buildAlgo, int nnDescentNiter) { + this.arena = arena; + this.intermediateGraphDegree = intermediateGraphDegree; + this.graphDegree = graphDegree; + this.buildAlgo = buildAlgo; + this.nnDescentNiter = nnDescentNiter; + this.set(); + } + + private void set() { + indexParamsMS = cuvsCagraIndexParams.allocate(arena); + cuvsCagraIndexParams.intermediate_graph_degree(indexParamsMS, intermediateGraphDegree); + cuvsCagraIndexParams.graph_degree(indexParamsMS, graphDegree); + cuvsCagraIndexParams.build_algo(indexParamsMS, buildAlgo.label); + cuvsCagraIndexParams.nn_descent_niter(indexParamsMS, nnDescentNiter); + } + + public int getIntermediate_graph_degree() { + return intermediateGraphDegree; + } + + public int getGraph_degree() { + return graphDegree; + } + + public CuvsCagraGraphBuildAlgo getBuild_algo() { + return buildAlgo; + } + + public int getNn_descent_niter() { + return nnDescentNiter; + } + + @Override + public String toString() { + return "CagraIndexParams [intermediate_graph_degree=" + intermediateGraphDegree + ", graph_degree=" + graphDegree + + ", build_algo=" + buildAlgo + ", nn_descent_niter=" + nnDescentNiter + "]"; + } + + public static class Builder { + + Arena arena; + int intermediateGraphDegree = 128; + int graphDegree = 64; + CuvsCagraGraphBuildAlgo buildAlgo = CuvsCagraGraphBuildAlgo.IVF_PQ; + int nnDescentNiter = 20; + int writerThreads = 1; + + public Builder() { + this.arena = Arena.ofConfined(); + } + + public Builder withIntermediateGraphDegree(int intermediateGraphDegree) { + this.intermediateGraphDegree = intermediateGraphDegree; + return this; + } + + public Builder withGraphDegree(int graphDegree) { + this.graphDegree = graphDegree; + return this; + } + + public Builder withBuildAlgo(CuvsCagraGraphBuildAlgo buildAlgo) { + this.buildAlgo = buildAlgo; + return this; + } + + public Builder withNNDescentNiter(int nnDescentNiter) { + this.nnDescentNiter = nnDescentNiter; + return this; + } + + public Builder withWriterThreads(int writerThreads) { + this.writerThreads = writerThreads; + return this; + } + + public CagraIndexParams build() throws Throwable { + return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, buildAlgo, nnDescentNiter); + } + + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java new file mode 100644 index 000000000..bbcca2407 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -0,0 +1,28 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; + +import com.nvidia.cuvs.panama.cuvsCagraIndex; + +public class CagraIndexReference { + + public MemorySegment indexMemorySegment; + + /** + * + */ + public CagraIndexReference() { + Arena arena = Arena.ofConfined(); + indexMemorySegment = cuvsCagraIndex.allocate(arena); + } + + /** + * + * @param indexMemorySegment + */ + public CagraIndexReference(MemorySegment indexMemorySegment) { + this.indexMemorySegment = indexMemorySegment; + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java new file mode 100644 index 000000000..3dd5aebd2 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -0,0 +1,256 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; + +import com.nvidia.cuvs.panama.cuvsCagraSearchParams; + +/* +* struct cuvsCagraSearchParams { +* size_t max_queries; +* size_t itopk_size; +* size_t max_iterations; +* enum cuvsCagraSearchAlgo algo; +* size_t team_size; +* size_t search_width; +* size_t min_iterations; +* size_t thread_block_size; +* enum cuvsCagraHashMode hashmap_mode; +* size_t hashmap_min_bitlen; +* float hashmap_max_fill_rate; +* uint32_t num_random_samplings; +* uint64_t rand_xor_mask; +* } +*/ +public class CagraSearchParams extends SearchParams { + + Arena arena; + int maxQueries; + int itopkSize; + int maxIterations; + CuvsCagraSearchAlgo algo; + int teamSize; + int searchWidth; + int minIterations; + int threadBlockSize; + CuvsCagraHashMode hashmapMode; + int hashmapMinBitlen; + float hashmapMaxFillRate; + int numRandomSamplings; + long randXorMask; + + enum CuvsCagraSearchAlgo { + SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); + + public final int label; + + private CuvsCagraSearchAlgo(int label) { + this.label = label; + } + + } + + enum CuvsCagraHashMode { + HASH(0), SMALL(1), AUTO_HASH(2); + + public final int label; + + private CuvsCagraHashMode(int label) { + this.label = label; + } + } + + public CagraSearchParams(Arena arena, int max_queries, int itopk_size, int max_iterations, CuvsCagraSearchAlgo algo, + int team_size, int search_width, int min_iterations, int thread_block_size, CuvsCagraHashMode hashmap_mode, + int hashmap_min_bitlen, float hashmap_max_fill_rate, int num_random_samplings, long rand_xor_mask) { + super(); + this.arena = arena; + this.maxQueries = max_queries; + this.itopkSize = itopk_size; + this.maxIterations = max_iterations; + this.algo = algo; + this.teamSize = team_size; + this.searchWidth = search_width; + this.minIterations = min_iterations; + this.threadBlockSize = thread_block_size; + this.hashmapMode = hashmap_mode; + this.hashmapMinBitlen = hashmap_min_bitlen; + this.hashmapMaxFillRate = hashmap_max_fill_rate; + this.numRandomSamplings = num_random_samplings; + this.randXorMask = rand_xor_mask; + this.set(); + } + + public void set() { + searchParamsMS = cuvsCagraSearchParams.allocate(arena); + cuvsCagraSearchParams.max_queries(searchParamsMS, maxQueries); + cuvsCagraSearchParams.itopk_size(searchParamsMS, itopkSize); + cuvsCagraSearchParams.max_iterations(searchParamsMS, maxIterations); + cuvsCagraSearchParams.algo(searchParamsMS, algo.label); + cuvsCagraSearchParams.team_size(searchParamsMS, teamSize); + cuvsCagraSearchParams.search_width(searchParamsMS, searchWidth); + cuvsCagraSearchParams.min_iterations(searchParamsMS, minIterations); + cuvsCagraSearchParams.thread_block_size(searchParamsMS, threadBlockSize); + cuvsCagraSearchParams.hashmap_mode(searchParamsMS, hashmapMode.label); + cuvsCagraSearchParams.hashmap_min_bitlen(searchParamsMS, hashmapMinBitlen); + cuvsCagraSearchParams.hashmap_max_fill_rate(searchParamsMS, hashmapMaxFillRate); + cuvsCagraSearchParams.num_random_samplings(searchParamsMS, numRandomSamplings); + cuvsCagraSearchParams.rand_xor_mask(searchParamsMS, randXorMask); + } + + public int getMax_queries() { + return maxQueries; + } + + public int getItopk_size() { + return itopkSize; + } + + public int getMax_iterations() { + return maxIterations; + } + + public CuvsCagraSearchAlgo getAlgo() { + return algo; + } + + public int getTeam_size() { + return teamSize; + } + + public int getSearch_width() { + return searchWidth; + } + + public int getMin_iterations() { + return minIterations; + } + + public int getThread_block_size() { + return threadBlockSize; + } + + public CuvsCagraHashMode getHashmap_mode() { + return hashmapMode; + } + + public int getHashmap_min_bitlen() { + return hashmapMinBitlen; + } + + public float getHashmap_max_fill_rate() { + return hashmapMaxFillRate; + } + + public int getNum_random_samplings() { + return numRandomSamplings; + } + + public long getRand_xor_mask() { + return randXorMask; + } + + @Override + public String toString() { + return "CagraSearchParams [max_queries=" + maxQueries + ", itopk_size=" + itopkSize + ", max_iterations=" + + maxIterations + ", algo=" + algo + ", team_size=" + teamSize + ", search_width=" + searchWidth + + ", min_iterations=" + minIterations + ", thread_block_size=" + threadBlockSize + ", hashmap_mode=" + + hashmapMode + ", hashmap_min_bitlen=" + hashmapMinBitlen + ", hashmap_max_fill_rate=" + + hashmapMaxFillRate + ", num_random_samplings=" + numRandomSamplings + ", rand_xor_mask=" + randXorMask + + "]"; + } + + public static class Builder { + + Arena arena; + int maxQueries = 1; + int itopkSize = 2; + int maxIterations = 3; + CuvsCagraSearchAlgo algo = CuvsCagraSearchAlgo.MULTI_KERNEL; + int teamSize = 4; + int searchWidth = 5; + int minIterations = 6; + int threadBlockSize = 7; + CuvsCagraHashMode hashmapMode = CuvsCagraHashMode.AUTO_HASH; + int hashmapMinBitlen = 8; + float hashmapMaxFillRate = 9.0f; + int numRandomSamplings = 10; + long randXorMask = 11L; + + public Builder() { + this.arena = Arena.ofConfined(); + } + + public Builder withMaxQueries(int max_queries) { + this.maxQueries = max_queries; + return this; + } + + public Builder withItopkSize(int itopk_size) { + this.itopkSize = itopk_size; + return this; + } + + public Builder withMaxIterations(int max_iterations) { + this.maxIterations = max_iterations; + return this; + } + + public Builder withAlgo(CuvsCagraSearchAlgo algo) { + this.algo = algo; + return this; + } + + public Builder withTeamSize(int team_size) { + this.teamSize = team_size; + return this; + } + + public Builder withSearchWidth(int search_width) { + this.searchWidth = search_width; + return this; + } + + public Builder withMinIterations(int min_iterations) { + this.minIterations = min_iterations; + return this; + } + + public Builder withThreadBlockSize(int thread_block_size) { + this.threadBlockSize = thread_block_size; + return this; + } + + public Builder withHashmapMode(CuvsCagraHashMode hashmap_mode) { + this.hashmapMode = hashmap_mode; + return this; + } + + public Builder withHashmapMinBitlen(int hashmap_min_bitlen) { + this.hashmapMinBitlen = hashmap_min_bitlen; + return this; + } + + public Builder withHashmapMaxFillRate(float hashmap_max_fill_rate) { + this.hashmapMaxFillRate = hashmap_max_fill_rate; + return this; + } + + public Builder withNumRandomSamplings(int num_random_samplings) { + this.numRandomSamplings = num_random_samplings; + return this; + } + + public Builder withRandXorMask(long rand_xor_mask) { + this.randXorMask = rand_xor_mask; + return this; + } + + public CagraSearchParams build() throws Throwable { + return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, algo, teamSize, searchWidth, + minIterations, threadBlockSize, hashmapMode, hashmapMinBitlen, hashmapMaxFillRate, + numRandomSamplings, randXorMask); + } + + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java new file mode 100644 index 000000000..df0cc3f2d --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java @@ -0,0 +1,335 @@ +package com.nvidia.cuvs.cagra; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemoryLayout.PathElement; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.VarHandle; +import java.util.UUID; + +public class CuVSIndex { + + private IndexParams indexParams; + private final float[][] dataset; + private final CuVSResources res; + private CagraIndexReference ref; + private ANNAlgorithms algo; + + public enum ANNAlgorithms { + BRUTEFORCE, CAGRA, IVF_PQ, IVF_FLAT + } + + Linker linker; + Arena arena; + MethodHandle cresMH; + MethodHandle indexMH; + MethodHandle searchMH; + MethodHandle serializeMH; + MethodHandle deserializeMH; + MemorySegment dataMS; + SymbolLookup bridge; + + /** + * + * @param indexParams + * @param dataset + * @param mapping + * @param res + * @throws Throwable + */ + private CuVSIndex(IndexParams indexParams, float[][] dataset, CuVSResources res, ANNAlgorithms algo) + throws Throwable { + this.indexParams = indexParams; + this.dataset = dataset; + this.init(); + this.res = res; + this.ref = build(); + this.algo = algo; + } + + /** + * + * @param in + * @param res + * @throws Throwable + */ + private CuVSIndex(InputStream in, CuVSResources res) throws Throwable { + this.indexParams = null; + this.dataset = null; + this.res = res; + this.init(); + this.ref = deserialize(in); + } + + /** + * + * @throws Throwable + */ + private void init() throws Throwable { + linker = Linker.nativeLinker(); + arena = Arena.ofConfined(); + + File wd = new File(System.getProperty("user.dir")); + bridge = SymbolLookup.libraryLookup(wd.getParent() + "/api-sys/build/libcuvs_wrapper.so", arena); + + indexMH = linker.downcallHandle(bridge.findOrThrow("build_index"), + FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), + linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + searchMH = linker.downcallHandle(bridge.findOrThrow("search_index"), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), + linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, + ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + serializeMH = linker.downcallHandle(bridge.findOrThrow("serialize_index"), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + deserializeMH = linker.downcallHandle(bridge.findOrThrow("deserialize_index"), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + } + + /** + * Java String -> C char* + * + * @param str + * @return MemorySegment + */ + public MemorySegment getStringSegment(StringBuilder str) { + str.append('\0'); + MemoryLayout sq = MemoryLayout.sequenceLayout(str.length(), linker.canonicalLayouts().get("char")); + MemorySegment fln = arena.allocate(sq); + + for (int i = 0; i < str.length(); i++) { + VarHandle flnVH = sq.varHandle(PathElement.sequenceElement(i)); + flnVH.set(fln, 0L, (byte) str.charAt(i)); + } + return fln; + } + + /** + * + * @param data + * @return + */ + private MemorySegment getMemorySegment(float[][] data) { + long rows = data.length; + long cols = data[0].length; + + MemoryLayout dataML = MemoryLayout.sequenceLayout(rows, + MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); + MemorySegment dataMS = arena.allocate(dataML); + + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + VarHandle element = dataML.arrayElementVarHandle(PathElement.sequenceElement(r), + PathElement.sequenceElement(c)); + element.set(dataMS, 0, 0, data[r][c]); + } + } + + return dataMS; + } + + /** + * + * @return + * @throws Throwable + */ + private CagraIndexReference build() throws Throwable { + long rows = dataset.length; + long cols = dataset[0].length; + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + + ref = new CagraIndexReference((MemorySegment) indexMH.invokeExact(getMemorySegment(dataset), rows, cols, + res.resource, rvMS, indexParams.indexParamsMS)); + + System.out.println("Build call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + + return ref; + } + + /** + * + * @param params + * @param queryVectors + * @return + * @throws Throwable + */ + public SearchResult search(CuVSQuery query) throws Throwable { + + SequenceLayout neighborsSL = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); + SequenceLayout distancesSL = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); + MemorySegment neighborsMS = arena.allocate(neighborsSL); + MemorySegment distancesMS = arena.allocate(distancesSL); + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + + searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.queryVectors), 2, 4L, 2L, res.resource, + neighborsMS, distancesMS, rvMS, query.searchParams.searchParamsMS); + + System.out.println("Search call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + + return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, 2, query.mapping); + } + + /** + * + * @param out + * @param tmpFilePath + * @throws Throwable + */ + public void serialize(OutputStream out, String tmpFilePath) throws Throwable { + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + serializeMH.invokeExact(res.resource, ref.indexMemorySegment, rvMS, + getStringSegment(new StringBuilder(tmpFilePath))); + System.out.println("Serialize call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + + File tempFile = new File(tmpFilePath); + FileInputStream is = new FileInputStream(tempFile); + byte[] chunk = new byte[1024]; + int chunkLen = 0; + while ((chunkLen = is.read(chunk)) != -1) { + out.write(chunk, 0, chunkLen); + } + is.close(); + tempFile.delete(); + } + + /** + * + * @param in + * @return + * @throws Throwable + */ + private CagraIndexReference deserialize(InputStream in) throws Throwable { + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; + CagraIndexReference ref = new CagraIndexReference(); + + File tempFile = new File(tmpIndexFile); + FileOutputStream out = new FileOutputStream(tempFile); + byte[] chunk = new byte[1024]; + int chunkLen = 0; + while ((chunkLen = in.read(chunk)) != -1) { + out.write(chunk, 0, chunkLen); + } + deserializeMH.invokeExact(res.resource, ref.indexMemorySegment, rvMS, + getStringSegment(new StringBuilder(tmpIndexFile))); + + in.close(); + out.close(); + tempFile.delete(); + + return ref; + } + + /** + * + * @return + */ + public IndexParams getParams() { + return indexParams; + } + + /** + * + * @return + */ + public PointerToDataset getDataset() { + return null; + } + + /** + * + * @return + */ + public CuVSResources getResources() { + return res; + } + + public static class Builder { + private IndexParams indexParams; + float[][] dataset; + CuVSResources res; + ANNAlgorithms algo = ANNAlgorithms.CAGRA; + + InputStream in; + + /** + * + * @param res + */ + public Builder(CuVSResources res) { + this.res = res; + } + + /** + * + * @param in + * @return + */ + public Builder from(InputStream in) { + this.in = in; + return this; + } + + /** + * + * @param dataset + * @return + */ + public Builder withDataset(float[][] dataset) { + this.dataset = dataset; + return this; + } + + /** + * + * @param params + * @return + */ + public Builder withIndexParams(IndexParams indexParams) { + this.indexParams = indexParams; + return this; + } + + /** + * + * @param params + * @return + */ + public Builder withANNAlgorithm(ANNAlgorithms algo) { + this.algo = algo; + return this; + } + + /** + * + * @return + * @throws Throwable + */ + public CuVSIndex build() throws Throwable { + if (in != null) { + return new CuVSIndex(in, res); + } else { + return new CuVSIndex(indexParams, dataset, res, algo); + } + } + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java new file mode 100644 index 000000000..96111b0eb --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -0,0 +1,118 @@ +package com.nvidia.cuvs.cagra; + +import java.util.Arrays; +import java.util.Map; + +import com.nvidia.cuvs.cagra.CuVSIndex.ANNAlgorithms; + +public class CuVSQuery { + + SearchParams searchParams; + PreFilter preFilter; + float[][] queryVectors; + public Map mapping; + ANNAlgorithms algo; + + public CuVSQuery(SearchParams searchParams, PreFilter preFilter, float[][] queryVectors, + Map mapping, ANNAlgorithms algo) { + super(); + this.searchParams = searchParams; + this.preFilter = preFilter; + this.queryVectors = queryVectors; + this.mapping = mapping; + this.algo = algo; + } + + @Override + public String toString() { + return "CuVSQuery [searchParams=" + searchParams + ", preFilter=" + preFilter + ", queries=" + + Arrays.toString(queryVectors) + "]"; + } + + public SearchParams getSearchParams() { + return searchParams; + } + + public PreFilter getPreFilter() { + return preFilter; + } + + public float[][] getQueries() { + return queryVectors; + } + + public static class Builder { + SearchParams searchParams; + PreFilter preFilter; + float[][] queryVectors; + Map mapping; + ANNAlgorithms algo = ANNAlgorithms.CAGRA; + + /** + * + * @param res + */ + public Builder() { + } + + /** + * + * @param dataset + * @return + */ + public Builder withSearchParams(SearchParams searchParams) { + this.searchParams = searchParams; + return this; + } + + /** + * + * @param queryVectors + * @return + */ + public Builder withQueryVectors(float[][] queryVectors) { + this.queryVectors = queryVectors; + return this; + } + + /** + * + * @param preFilter + * @return + */ + public Builder withPreFilter(PreFilter preFilter) { + this.preFilter = preFilter; + return this; + } + + /** + * + * @param mapping + * @return + */ + public Builder withMapping(Map mapping) { + this.mapping = mapping; + return this; + } + + /** + * + * @param params + * @return + */ + public Builder withANNAlgorithm(ANNAlgorithms algo) { + this.algo = algo; + return this; + } + + /** + * + * @return + * @throws Throwable + */ + public CuVSQuery build() throws Throwable { + return new CuVSQuery(searchParams, preFilter, queryVectors, mapping, algo); + } + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java new file mode 100644 index 000000000..14affd3b8 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -0,0 +1,43 @@ +package com.nvidia.cuvs.cagra; + +import java.io.File; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; + +public class CuVSResources { + + private Linker linker; + private Arena arena; + private MethodHandle cresMH; + private SymbolLookup bridge; + public MemorySegment resource; + + /** + * + * @throws Throwable + */ + public CuVSResources() throws Throwable { + linker = Linker.nativeLinker(); + arena = Arena.ofConfined(); + + File wd = new File(System.getProperty("user.dir")); + bridge = SymbolLookup.libraryLookup(wd.getParent() + "/api-sys/build/libcuvs_wrapper.so", arena); + + cresMH = linker.downcallHandle(bridge.findOrThrow("create_resource"), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + + resource = (MemorySegment) cresMH.invokeExact(rvMS); + + System.out.println("Create resource call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java new file mode 100644 index 000000000..df073f36e --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java @@ -0,0 +1,9 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.MemorySegment; + +public class IndexParams { + + public MemorySegment indexParamsMS; + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java new file mode 100644 index 000000000..c5fc4f074 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java @@ -0,0 +1,5 @@ +package com.nvidia.cuvs.cagra; + +public class PointerToDataset { + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java new file mode 100644 index 000000000..b8310af31 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java @@ -0,0 +1,5 @@ +package com.nvidia.cuvs.cagra; + +public class PreFilter { + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java new file mode 100644 index 000000000..6cca9bf49 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java @@ -0,0 +1,9 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.MemorySegment; + +public class SearchParams { + + public MemorySegment searchParamsMS; + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java new file mode 100644 index 000000000..ccc722267 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -0,0 +1,49 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.MemoryLayout.PathElement; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SequenceLayout; +import java.lang.invoke.VarHandle; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SearchResult { + + public List neighbours; // TODO: Get clarity on these two. + public List distances; + public Map results; + public Map mapping; + SequenceLayout neighboursSL; + SequenceLayout distancesSL; + MemorySegment neighboursMS; + MemorySegment distancesMS; + int topK; + + public SearchResult(SequenceLayout neighboursSL, SequenceLayout distancesSL, MemorySegment neighboursMS, + MemorySegment distancesMS, int topK, Map mapping) { + super(); + this.topK = topK; + this.neighboursSL = neighboursSL; + this.distancesSL = distancesSL; + this.neighboursMS = neighboursMS; + this.distancesMS = distancesMS; + this.mapping = mapping; + neighbours = new ArrayList(); + distances = new ArrayList(); + results = new HashMap(); + this.load(); + } + + private void load() { + VarHandle neighboursVH = neighboursSL.varHandle(PathElement.sequenceElement()); + VarHandle distancesVH = distancesSL.varHandle(PathElement.sequenceElement()); + + for (long i = 0; i < topK; i++) { + int id = (int) neighboursVH.get(neighboursMS, 0L, i); + results.put(mapping != null ? mapping.get(id) : id, (float) distancesVH.get(distancesMS, 0L, i)); + } + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java new file mode 100644 index 000000000..0326aa8f4 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java @@ -0,0 +1,218 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfShort; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * uint8_t code; + * uint8_t bits; + * uint16_t lanes; + * } + * } + */ +public class DLDataType { + + DLDataType() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_CHAR.withName("code"), + dlpack_h.C_CHAR.withName("bits"), + dlpack_h.C_SHORT.withName("lanes") + ).withName("$anon$174:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfByte code$LAYOUT = (OfByte)$LAYOUT.select(groupElement("code")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint8_t code + * } + */ + public static final OfByte code$layout() { + return code$LAYOUT; + } + + private static final long code$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * uint8_t code + * } + */ + public static final long code$offset() { + return code$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint8_t code + * } + */ + public static byte code(MemorySegment struct) { + return struct.get(code$LAYOUT, code$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint8_t code + * } + */ + public static void code(MemorySegment struct, byte fieldValue) { + struct.set(code$LAYOUT, code$OFFSET, fieldValue); + } + + private static final OfByte bits$LAYOUT = (OfByte)$LAYOUT.select(groupElement("bits")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint8_t bits + * } + */ + public static final OfByte bits$layout() { + return bits$LAYOUT; + } + + private static final long bits$OFFSET = 1; + + /** + * Offset for field: + * {@snippet lang=c : + * uint8_t bits + * } + */ + public static final long bits$offset() { + return bits$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint8_t bits + * } + */ + public static byte bits(MemorySegment struct) { + return struct.get(bits$LAYOUT, bits$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint8_t bits + * } + */ + public static void bits(MemorySegment struct, byte fieldValue) { + struct.set(bits$LAYOUT, bits$OFFSET, fieldValue); + } + + private static final OfShort lanes$LAYOUT = (OfShort)$LAYOUT.select(groupElement("lanes")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint16_t lanes + * } + */ + public static final OfShort lanes$layout() { + return lanes$LAYOUT; + } + + private static final long lanes$OFFSET = 2; + + /** + * Offset for field: + * {@snippet lang=c : + * uint16_t lanes + * } + */ + public static final long lanes$offset() { + return lanes$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint16_t lanes + * } + */ + public static short lanes(MemorySegment struct) { + return struct.get(lanes$LAYOUT, lanes$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint16_t lanes + * } + */ + public static void lanes(MemorySegment struct, short fieldValue) { + struct.set(lanes$LAYOUT, lanes$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java new file mode 100644 index 000000000..3e9341f6a --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java @@ -0,0 +1,171 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * DLDeviceType device_type; + * int32_t device_id; + * } + * } + */ +public class DLDevice { + + DLDevice() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_INT.withName("device_type"), + dlpack_h.C_INT.withName("device_id") + ).withName("$anon$126:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt device_type$LAYOUT = (OfInt)$LAYOUT.select(groupElement("device_type")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLDeviceType device_type + * } + */ + public static final OfInt device_type$layout() { + return device_type$LAYOUT; + } + + private static final long device_type$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * DLDeviceType device_type + * } + */ + public static final long device_type$offset() { + return device_type$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLDeviceType device_type + * } + */ + public static int device_type(MemorySegment struct) { + return struct.get(device_type$LAYOUT, device_type$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLDeviceType device_type + * } + */ + public static void device_type(MemorySegment struct, int fieldValue) { + struct.set(device_type$LAYOUT, device_type$OFFSET, fieldValue); + } + + private static final OfInt device_id$LAYOUT = (OfInt)$LAYOUT.select(groupElement("device_id")); + + /** + * Layout for field: + * {@snippet lang=c : + * int32_t device_id + * } + */ + public static final OfInt device_id$layout() { + return device_id$LAYOUT; + } + + private static final long device_id$OFFSET = 4; + + /** + * Offset for field: + * {@snippet lang=c : + * int32_t device_id + * } + */ + public static final long device_id$offset() { + return device_id$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * int32_t device_id + * } + */ + public static int device_id(MemorySegment struct) { + return struct.get(device_id$LAYOUT, device_id$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * int32_t device_id + * } + */ + public static void device_id(MemorySegment struct, int fieldValue) { + struct.set(device_id$LAYOUT, device_id$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java new file mode 100644 index 000000000..6d082d344 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java @@ -0,0 +1,273 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.invoke.MethodHandle; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct DLManagedTensor { + * DLTensor dl_tensor; + * void *manager_ctx; + * void (*deleter)(struct DLManagedTensor *); + * } + * } + */ +public class DLManagedTensor { + + DLManagedTensor() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + DLTensor.layout().withName("dl_tensor"), + dlpack_h.C_POINTER.withName("manager_ctx"), + dlpack_h.C_POINTER.withName("deleter") + ).withName("DLManagedTensor"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final GroupLayout dl_tensor$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dl_tensor")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static final GroupLayout dl_tensor$layout() { + return dl_tensor$LAYOUT; + } + + private static final long dl_tensor$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static final long dl_tensor$offset() { + return dl_tensor$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static MemorySegment dl_tensor(MemorySegment struct) { + return struct.asSlice(dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static void dl_tensor(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); + } + + private static final AddressLayout manager_ctx$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("manager_ctx")); + + /** + * Layout for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static final AddressLayout manager_ctx$layout() { + return manager_ctx$LAYOUT; + } + + private static final long manager_ctx$OFFSET = 48; + + /** + * Offset for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static final long manager_ctx$offset() { + return manager_ctx$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static MemorySegment manager_ctx(MemorySegment struct) { + return struct.get(manager_ctx$LAYOUT, manager_ctx$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static void manager_ctx(MemorySegment struct, MemorySegment fieldValue) { + struct.set(manager_ctx$LAYOUT, manager_ctx$OFFSET, fieldValue); + } + + /** + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static class deleter { + + deleter() { + // Should not be called directly + } + + /** + * The function pointer signature, expressed as a functional interface + */ + public interface Function { + void apply(MemorySegment _x0); + } + + private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( + dlpack_h.C_POINTER + ); + + /** + * The descriptor of this function pointer + */ + public static FunctionDescriptor descriptor() { + return $DESC; + } + + private static final MethodHandle UP$MH = dlpack_h.upcallHandle(deleter.Function.class, "apply", $DESC); + + /** + * Allocates a new upcall stub, whose implementation is defined by {@code fi}. + * The lifetime of the returned segment is managed by {@code arena} + */ + public static MemorySegment allocate(deleter.Function fi, Arena arena) { + return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); + } + + private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); + + /** + * Invoke the upcall stub {@code funcPtr}, with given parameters + */ + public static void invoke(MemorySegment funcPtr,MemorySegment _x0) { + try { + DOWN$MH.invokeExact(funcPtr, _x0); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + } + + private static final AddressLayout deleter$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("deleter")); + + /** + * Layout for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static final AddressLayout deleter$layout() { + return deleter$LAYOUT; + } + + private static final long deleter$OFFSET = 56; + + /** + * Offset for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static final long deleter$offset() { + return deleter$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static MemorySegment deleter(MemorySegment struct) { + return struct.get(deleter$LAYOUT, deleter$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static void deleter(MemorySegment struct, MemorySegment fieldValue) { + struct.set(deleter$LAYOUT, deleter$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java new file mode 100644 index 000000000..ca8716551 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java @@ -0,0 +1,366 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.invoke.MethodHandle; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct DLManagedTensorVersioned { + * DLPackVersion version; + * void *manager_ctx; + * void (*deleter)(struct DLManagedTensorVersioned *); + * uint64_t flags; + * DLTensor dl_tensor; + * } + * } + */ +public class DLManagedTensorVersioned { + + DLManagedTensorVersioned() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + DLPackVersion.layout().withName("version"), + dlpack_h.C_POINTER.withName("manager_ctx"), + dlpack_h.C_POINTER.withName("deleter"), + dlpack_h.C_LONG.withName("flags"), + DLTensor.layout().withName("dl_tensor") + ).withName("DLManagedTensorVersioned"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final GroupLayout version$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("version")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLPackVersion version + * } + */ + public static final GroupLayout version$layout() { + return version$LAYOUT; + } + + private static final long version$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * DLPackVersion version + * } + */ + public static final long version$offset() { + return version$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLPackVersion version + * } + */ + public static MemorySegment version(MemorySegment struct) { + return struct.asSlice(version$OFFSET, version$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLPackVersion version + * } + */ + public static void version(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, version$OFFSET, version$LAYOUT.byteSize()); + } + + private static final AddressLayout manager_ctx$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("manager_ctx")); + + /** + * Layout for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static final AddressLayout manager_ctx$layout() { + return manager_ctx$LAYOUT; + } + + private static final long manager_ctx$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static final long manager_ctx$offset() { + return manager_ctx$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static MemorySegment manager_ctx(MemorySegment struct) { + return struct.get(manager_ctx$LAYOUT, manager_ctx$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static void manager_ctx(MemorySegment struct, MemorySegment fieldValue) { + struct.set(manager_ctx$LAYOUT, manager_ctx$OFFSET, fieldValue); + } + + /** + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static class deleter { + + deleter() { + // Should not be called directly + } + + /** + * The function pointer signature, expressed as a functional interface + */ + public interface Function { + void apply(MemorySegment _x0); + } + + private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( + dlpack_h.C_POINTER + ); + + /** + * The descriptor of this function pointer + */ + public static FunctionDescriptor descriptor() { + return $DESC; + } + + private static final MethodHandle UP$MH = dlpack_h.upcallHandle(deleter.Function.class, "apply", $DESC); + + /** + * Allocates a new upcall stub, whose implementation is defined by {@code fi}. + * The lifetime of the returned segment is managed by {@code arena} + */ + public static MemorySegment allocate(deleter.Function fi, Arena arena) { + return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); + } + + private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); + + /** + * Invoke the upcall stub {@code funcPtr}, with given parameters + */ + public static void invoke(MemorySegment funcPtr,MemorySegment _x0) { + try { + DOWN$MH.invokeExact(funcPtr, _x0); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + } + + private static final AddressLayout deleter$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("deleter")); + + /** + * Layout for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static final AddressLayout deleter$layout() { + return deleter$LAYOUT; + } + + private static final long deleter$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static final long deleter$offset() { + return deleter$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static MemorySegment deleter(MemorySegment struct) { + return struct.get(deleter$LAYOUT, deleter$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static void deleter(MemorySegment struct, MemorySegment fieldValue) { + struct.set(deleter$LAYOUT, deleter$OFFSET, fieldValue); + } + + private static final OfLong flags$LAYOUT = (OfLong)$LAYOUT.select(groupElement("flags")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint64_t flags + * } + */ + public static final OfLong flags$layout() { + return flags$LAYOUT; + } + + private static final long flags$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * uint64_t flags + * } + */ + public static final long flags$offset() { + return flags$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint64_t flags + * } + */ + public static long flags(MemorySegment struct) { + return struct.get(flags$LAYOUT, flags$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint64_t flags + * } + */ + public static void flags(MemorySegment struct, long fieldValue) { + struct.set(flags$LAYOUT, flags$OFFSET, fieldValue); + } + + private static final GroupLayout dl_tensor$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dl_tensor")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static final GroupLayout dl_tensor$layout() { + return dl_tensor$LAYOUT; + } + + private static final long dl_tensor$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static final long dl_tensor$offset() { + return dl_tensor$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static MemorySegment dl_tensor(MemorySegment struct) { + return struct.asSlice(dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static void dl_tensor(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java new file mode 100644 index 000000000..56dec2bae --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java @@ -0,0 +1,171 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * uint32_t major; + * uint32_t minor; + * } + * } + */ +public class DLPackVersion { + + DLPackVersion() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_INT.withName("major"), + dlpack_h.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/java/com/nvidia/cuvs/panama/DLTensor.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java new file mode 100644 index 000000000..cb3aad4fc --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java @@ -0,0 +1,402 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * void *data; + * DLDevice device; + * int32_t ndim; + * DLDataType dtype; + * int64_t *shape; + * int64_t *strides; + * uint64_t byte_offset; + * } + * } + */ +public class DLTensor { + + DLTensor() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_POINTER.withName("data"), + DLDevice.layout().withName("device"), + dlpack_h.C_INT.withName("ndim"), + DLDataType.layout().withName("dtype"), + dlpack_h.C_POINTER.withName("shape"), + dlpack_h.C_POINTER.withName("strides"), + dlpack_h.C_LONG.withName("byte_offset") + ).withName("$anon$192:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final AddressLayout data$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("data")); + + /** + * Layout for field: + * {@snippet lang=c : + * void *data + * } + */ + public static final AddressLayout data$layout() { + return data$LAYOUT; + } + + private static final long data$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * void *data + * } + */ + public static final long data$offset() { + return data$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void *data + * } + */ + public static MemorySegment data(MemorySegment struct) { + return struct.get(data$LAYOUT, data$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void *data + * } + */ + public static void data(MemorySegment struct, MemorySegment fieldValue) { + struct.set(data$LAYOUT, data$OFFSET, fieldValue); + } + + private static final GroupLayout device$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("device")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLDevice device + * } + */ + public static final GroupLayout device$layout() { + return device$LAYOUT; + } + + private static final long device$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * DLDevice device + * } + */ + public static final long device$offset() { + return device$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLDevice device + * } + */ + public static MemorySegment device(MemorySegment struct) { + return struct.asSlice(device$OFFSET, device$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLDevice device + * } + */ + public static void device(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, device$OFFSET, device$LAYOUT.byteSize()); + } + + private static final OfInt ndim$LAYOUT = (OfInt)$LAYOUT.select(groupElement("ndim")); + + /** + * Layout for field: + * {@snippet lang=c : + * int32_t ndim + * } + */ + public static final OfInt ndim$layout() { + return ndim$LAYOUT; + } + + private static final long ndim$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * int32_t ndim + * } + */ + public static final long ndim$offset() { + return ndim$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * int32_t ndim + * } + */ + public static int ndim(MemorySegment struct) { + return struct.get(ndim$LAYOUT, ndim$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * int32_t ndim + * } + */ + public static void ndim(MemorySegment struct, int fieldValue) { + struct.set(ndim$LAYOUT, ndim$OFFSET, fieldValue); + } + + private static final GroupLayout dtype$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dtype")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static final GroupLayout dtype$layout() { + return dtype$LAYOUT; + } + + private static final long dtype$OFFSET = 20; + + /** + * Offset for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static final long dtype$offset() { + return dtype$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static MemorySegment dtype(MemorySegment struct) { + return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static void dtype(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + private static final AddressLayout shape$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("shape")); + + /** + * Layout for field: + * {@snippet lang=c : + * int64_t *shape + * } + */ + public static final AddressLayout shape$layout() { + return shape$LAYOUT; + } + + private static final long shape$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * int64_t *shape + * } + */ + public static final long shape$offset() { + return shape$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * int64_t *shape + * } + */ + public static MemorySegment shape(MemorySegment struct) { + return struct.get(shape$LAYOUT, shape$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * int64_t *shape + * } + */ + public static void shape(MemorySegment struct, MemorySegment fieldValue) { + struct.set(shape$LAYOUT, shape$OFFSET, fieldValue); + } + + private static final AddressLayout strides$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("strides")); + + /** + * Layout for field: + * {@snippet lang=c : + * int64_t *strides + * } + */ + public static final AddressLayout strides$layout() { + return strides$LAYOUT; + } + + private static final long strides$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang=c : + * int64_t *strides + * } + */ + public static final long strides$offset() { + return strides$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * int64_t *strides + * } + */ + public static MemorySegment strides(MemorySegment struct) { + return struct.get(strides$LAYOUT, strides$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * int64_t *strides + * } + */ + public static void strides(MemorySegment struct, MemorySegment fieldValue) { + struct.set(strides$LAYOUT, strides$OFFSET, fieldValue); + } + + private static final OfLong byte_offset$LAYOUT = (OfLong)$LAYOUT.select(groupElement("byte_offset")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint64_t byte_offset + * } + */ + public static final OfLong byte_offset$layout() { + return byte_offset$LAYOUT; + } + + private static final long byte_offset$OFFSET = 40; + + /** + * Offset for field: + * {@snippet lang=c : + * uint64_t byte_offset + * } + */ + public static final long byte_offset$offset() { + return byte_offset$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint64_t byte_offset + * } + */ + public static long byte_offset(MemorySegment struct) { + return struct.get(byte_offset$LAYOUT, byte_offset$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint64_t byte_offset + * } + */ + public static void byte_offset(MemorySegment struct, long fieldValue) { + struct.set(byte_offset$LAYOUT, byte_offset$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java new file mode 100644 index 000000000..714aed5e9 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java @@ -0,0 +1,159 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; +import static java.lang.foreign.MemoryLayout.PathElement.sequenceElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.SequenceLayout; +import java.lang.invoke.VarHandle; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct { + * int __val[2]; + * } + * } + */ +public class __fsid_t { + + __fsid_t() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(MemoryLayout.sequenceLayout(2, dlpack_h.C_INT).withName("__val")).withName("$anon$155:12"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final SequenceLayout __val$LAYOUT = (SequenceLayout) $LAYOUT.select(groupElement("__val")); + + /** + * Layout for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static final SequenceLayout __val$layout() { + return __val$LAYOUT; + } + + private static final long __val$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static final long __val$offset() { + return __val$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static MemorySegment __val(MemorySegment struct) { + return struct.asSlice(__val$OFFSET, __val$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static void __val(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, __val$OFFSET, __val$LAYOUT.byteSize()); + } + + private static long[] __val$DIMS = { 2 }; + + /** + * Dimensions for array field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static long[] __val$dimensions() { + return __val$DIMS; + } + + private static final VarHandle __val$ELEM_HANDLE = __val$LAYOUT.varHandle(sequenceElement()); + + /** + * Indexed getter for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static int __val(MemorySegment struct, long index0) { + return (int) __val$ELEM_HANDLE.get(struct, 0L, index0); + } + + /** + * Indexed setter for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static void __val(MemorySegment struct, long index0, int fieldValue) { + __val$ELEM_HANDLE.set(struct, 0L, index0, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java new file mode 100644 index 000000000..0af404e19 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java @@ -0,0 +1,2357 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +public class brute_force_h { + + brute_force_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = brute_force_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = brute_force_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = brute_force_h.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 = brute_force_h.C_LONG; + private static final int L2Expanded = (int)0L; + /** + * {@snippet lang=c : + * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + private static final int L2SqrtExpanded = (int)1L; + /** + * {@snippet lang=c : + * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + private static final int CosineExpanded = (int)2L; + /** + * {@snippet lang=c : + * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + private static final int L1 = (int)3L; + /** + * {@snippet lang=c : + * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + private static final int L2Unexpanded = (int)4L; + /** + * {@snippet lang=c : + * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + private static final int L2SqrtUnexpanded = (int)5L; + /** + * {@snippet lang=c : + * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + private static final int InnerProduct = (int)6L; + /** + * {@snippet lang=c : + * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + private static final int Linf = (int)7L; + /** + * {@snippet lang=c : + * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + private static final int Canberra = (int)8L; + /** + * {@snippet lang=c : + * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + private static final int LpUnexpanded = (int)9L; + /** + * {@snippet lang=c : + * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + private static final int CorrelationExpanded = (int)10L; + /** + * {@snippet lang=c : + * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + private static final int JaccardExpanded = (int)11L; + /** + * {@snippet lang=c : + * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + private static final int HellingerExpanded = (int)12L; + /** + * {@snippet lang=c : + * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + private static final int Haversine = (int)13L; + /** + * {@snippet lang=c : + * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + private static final int BrayCurtis = (int)14L; + /** + * {@snippet lang=c : + * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + private static final int JensenShannon = (int)15L; + /** + * {@snippet lang=c : + * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + private static final int HammingUnexpanded = (int)16L; + /** + * {@snippet lang=c : + * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + private static final int KLDivergence = (int)17L; + /** + * {@snippet lang=c : + * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + private static final int RusselRaoExpanded = (int)18L; + /** + * {@snippet lang=c : + * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + private static final int DiceExpanded = (int)19L; + /** + * {@snippet lang=c : + * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + private static final int Precomputed = (int)100L; + /** + * {@snippet lang=c : + * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = brute_force_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + private static final int NO_FILTER = (int)0L; + /** + * {@snippet lang=c : + * enum cuvsFilterType.NO_FILTER = 0 + * } + */ + public static int NO_FILTER() { + return NO_FILTER; + } + private static final int BITSET = (int)1L; + /** + * {@snippet lang=c : + * enum cuvsFilterType.BITSET = 1 + * } + */ + public static int BITSET() { + return BITSET; + } + private static final int BITMAP = (int)2L; + /** + * {@snippet lang=c : + * enum cuvsFilterType.BITMAP = 2 + * } + */ + public static int BITMAP() { + return BITMAP; + } + /** + * {@snippet lang=c : + * typedef cuvsBruteForceIndex *cuvsBruteForceIndex_t + * } + */ + public static final AddressLayout cuvsBruteForceIndex_t = brute_force_h.C_POINTER; + + private static class cuvsBruteForceIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + brute_force_h.C_INT, + brute_force_h.C_POINTER + ); + + public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsBruteForceIndexCreate$descriptor() { + return cuvsBruteForceIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) + * } + */ + public static MethodHandle cuvsBruteForceIndexCreate$handle() { + return cuvsBruteForceIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) + * } + */ + public static MemorySegment cuvsBruteForceIndexCreate$address() { + return cuvsBruteForceIndexCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) + * } + */ + public static int cuvsBruteForceIndexCreate(MemorySegment index) { + var mh$ = cuvsBruteForceIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsBruteForceIndexCreate", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsBruteForceIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + brute_force_h.C_INT, + brute_force_h.C_POINTER + ); + + public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) + * } + */ + public static FunctionDescriptor cuvsBruteForceIndexDestroy$descriptor() { + return cuvsBruteForceIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) + * } + */ + public static MethodHandle cuvsBruteForceIndexDestroy$handle() { + return cuvsBruteForceIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) + * } + */ + public static MemorySegment cuvsBruteForceIndexDestroy$address() { + return cuvsBruteForceIndexDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) + * } + */ + public static int cuvsBruteForceIndexDestroy(MemorySegment index) { + var mh$ = cuvsBruteForceIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsBruteForceIndexDestroy", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsBruteForceBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + brute_force_h.C_INT, + brute_force_h.C_LONG, + brute_force_h.C_POINTER, + brute_force_h.C_INT, + brute_force_h.C_FLOAT, + brute_force_h.C_POINTER + ); + + public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) + * } + */ + public static FunctionDescriptor cuvsBruteForceBuild$descriptor() { + return cuvsBruteForceBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) + * } + */ + public static MethodHandle cuvsBruteForceBuild$handle() { + return cuvsBruteForceBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) + * } + */ + public static MemorySegment cuvsBruteForceBuild$address() { + return cuvsBruteForceBuild.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) + * } + */ + public static int cuvsBruteForceBuild(long res, MemorySegment dataset, int metric, float metric_arg, MemorySegment index) { + var mh$ = cuvsBruteForceBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsBruteForceBuild", res, dataset, metric, metric_arg, index); + } + return (int)mh$.invokeExact(res, dataset, metric, metric_arg, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsBruteForceSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + brute_force_h.C_INT, + brute_force_h.C_LONG, + brute_force_h.C_POINTER, + brute_force_h.C_POINTER, + brute_force_h.C_POINTER, + brute_force_h.C_POINTER, + cuvsFilter.layout() + ); + + public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) + * } + */ + public static FunctionDescriptor cuvsBruteForceSearch$descriptor() { + return cuvsBruteForceSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) + * } + */ + public static MethodHandle cuvsBruteForceSearch$handle() { + return cuvsBruteForceSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) + * } + */ + public static MemorySegment cuvsBruteForceSearch$address() { + return cuvsBruteForceSearch.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) + * } + */ + public static int cuvsBruteForceSearch(long res, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances, MemorySegment prefilter) { + var mh$ = cuvsBruteForceSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsBruteForceSearch", res, index, queries, neighbors, distances, prefilter); + } + return (int)mh$.invokeExact(res, index, queries, neighbors, distances, prefilter); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java new file mode 100644 index 000000000..27e7888bc --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java @@ -0,0 +1,2051 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; + +public class cagra_h { + + cagra_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int true_ = (int)1L; + /** + * {@snippet lang=c : + * #define true 1 + * } + */ + public static int true_() { + return true_; + } + private static final int false_ = (int)0L; + /** + * {@snippet lang=c : + * #define false 0 + * } + */ + public static int false_() { + return false_; + } + private static final int __bool_true_false_are_defined = (int)1L; + /** + * {@snippet lang=c : + * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = cagra_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = cagra_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = cagra_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + private static final int AUTO_SELECT = (int)0L; + /** + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 + * } + */ + public static int AUTO_SELECT() { + return AUTO_SELECT; + } + private static final int IVF_PQ = (int)1L; + /** + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 + * } + */ + public static int IVF_PQ() { + return IVF_PQ; + } + private static final int NN_DESCENT = (int)2L; + /** + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 + * } + */ + public static int NN_DESCENT() { + return NN_DESCENT; + } + /** + * {@snippet lang=c : + * typedef struct cuvsCagraCompressionParams { + * uint32_t pq_bits; + * uint32_t pq_dim; + * uint32_t vq_n_centers; + * uint32_t kmeans_n_iters; + * double vq_kmeans_trainset_fraction; + * double pq_kmeans_trainset_fraction; + * } *cuvsCagraCompressionParams_t + * } + */ + public static final AddressLayout cuvsCagraCompressionParams_t = cagra_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef struct cuvsCagraIndexParams { + * size_t intermediate_graph_degree; + * size_t graph_degree; + * enum cuvsCagraGraphBuildAlgo build_algo; + * size_t nn_descent_niter; + * cuvsCagraCompressionParams_t compression; + * } *cuvsCagraIndexParams_t + * } + */ + public static final AddressLayout cuvsCagraIndexParams_t = cagra_h.C_POINTER; + private static final int SINGLE_CTA = (int)0L; + /** + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo.SINGLE_CTA = 0 + * } + */ + public static int SINGLE_CTA() { + return SINGLE_CTA; + } + private static final int MULTI_CTA = (int)1L; + /** + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo.MULTI_CTA = 1 + * } + */ + public static int MULTI_CTA() { + return MULTI_CTA; + } + private static final int MULTI_KERNEL = (int)2L; + /** + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo.MULTI_KERNEL = 2 + * } + */ + public static int MULTI_KERNEL() { + return MULTI_KERNEL; + } + private static final int AUTO = (int)3L; + /** + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo.AUTO = 3 + * } + */ + public static int AUTO() { + return AUTO; + } + private static final int HASH = (int)0L; + /** + * {@snippet lang=c : + * enum cuvsCagraHashMode.HASH = 0 + * } + */ + public static int HASH() { + return HASH; + } + private static final int SMALL = (int)1L; + /** + * {@snippet lang=c : + * enum cuvsCagraHashMode.SMALL = 1 + * } + */ + public static int SMALL() { + return SMALL; + } + private static final int AUTO_HASH = (int)2L; + /** + * {@snippet lang=c : + * enum cuvsCagraHashMode.AUTO_HASH = 2 + * } + */ + public static int AUTO_HASH() { + return AUTO_HASH; + } + /** + * {@snippet lang=c : + * typedef struct cuvsCagraSearchParams { + * size_t max_queries; + * size_t itopk_size; + * size_t max_iterations; + * enum cuvsCagraSearchAlgo algo; + * size_t team_size; + * size_t search_width; + * size_t min_iterations; + * size_t thread_block_size; + * enum cuvsCagraHashMode hashmap_mode; + * size_t hashmap_min_bitlen; + * float hashmap_max_fill_rate; + * uint32_t num_random_samplings; + * uint64_t rand_xor_mask; + * } *cuvsCagraSearchParams_t + * } + */ + public static final AddressLayout cuvsCagraSearchParams_t = cagra_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef cuvsCagraIndex *cuvsCagraIndex_t + * } + */ + public static final AddressLayout cuvsCagraIndex_t = cagra_h.C_POINTER; + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + 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/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java new file mode 100644 index 000000000..b81d453cf --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java @@ -0,0 +1,356 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfDouble; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct cuvsCagraCompressionParams { + * uint32_t pq_bits; + * uint32_t pq_dim; + * uint32_t vq_n_centers; + * uint32_t kmeans_n_iters; + * double vq_kmeans_trainset_fraction; + * double pq_kmeans_trainset_fraction; + * } + * } + */ +public class cuvsCagraCompressionParams { + + cuvsCagraCompressionParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + cagra_h.C_INT.withName("pq_bits"), + cagra_h.C_INT.withName("pq_dim"), + cagra_h.C_INT.withName("vq_n_centers"), + cagra_h.C_INT.withName("kmeans_n_iters"), + cagra_h.C_DOUBLE.withName("vq_kmeans_trainset_fraction"), + cagra_h.C_DOUBLE.withName("pq_kmeans_trainset_fraction") + ).withName("cuvsCagraCompressionParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt pq_bits$LAYOUT = (OfInt)$LAYOUT.select(groupElement("pq_bits")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t pq_bits + * } + */ + public static final OfInt pq_bits$layout() { + return pq_bits$LAYOUT; + } + + private static final long pq_bits$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t pq_bits + * } + */ + public static final long pq_bits$offset() { + return pq_bits$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t pq_bits + * } + */ + public static int pq_bits(MemorySegment struct) { + return struct.get(pq_bits$LAYOUT, pq_bits$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t pq_bits + * } + */ + public static void pq_bits(MemorySegment struct, int fieldValue) { + struct.set(pq_bits$LAYOUT, pq_bits$OFFSET, fieldValue); + } + + private static final OfInt pq_dim$LAYOUT = (OfInt)$LAYOUT.select(groupElement("pq_dim")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t pq_dim + * } + */ + public static final OfInt pq_dim$layout() { + return pq_dim$LAYOUT; + } + + private static final long pq_dim$OFFSET = 4; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t pq_dim + * } + */ + public static final long pq_dim$offset() { + return pq_dim$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t pq_dim + * } + */ + public static int pq_dim(MemorySegment struct) { + return struct.get(pq_dim$LAYOUT, pq_dim$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t pq_dim + * } + */ + public static void pq_dim(MemorySegment struct, int fieldValue) { + struct.set(pq_dim$LAYOUT, pq_dim$OFFSET, fieldValue); + } + + private static final OfInt vq_n_centers$LAYOUT = (OfInt)$LAYOUT.select(groupElement("vq_n_centers")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t vq_n_centers + * } + */ + public static final OfInt vq_n_centers$layout() { + return vq_n_centers$LAYOUT; + } + + private static final long vq_n_centers$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t vq_n_centers + * } + */ + public static final long vq_n_centers$offset() { + return vq_n_centers$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t vq_n_centers + * } + */ + public static int vq_n_centers(MemorySegment struct) { + return struct.get(vq_n_centers$LAYOUT, vq_n_centers$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t vq_n_centers + * } + */ + public static void vq_n_centers(MemorySegment struct, int fieldValue) { + struct.set(vq_n_centers$LAYOUT, vq_n_centers$OFFSET, fieldValue); + } + + private static final OfInt kmeans_n_iters$LAYOUT = (OfInt)$LAYOUT.select(groupElement("kmeans_n_iters")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t kmeans_n_iters + * } + */ + public static final OfInt kmeans_n_iters$layout() { + return kmeans_n_iters$LAYOUT; + } + + private static final long kmeans_n_iters$OFFSET = 12; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t kmeans_n_iters + * } + */ + public static final long kmeans_n_iters$offset() { + return kmeans_n_iters$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t kmeans_n_iters + * } + */ + public static int kmeans_n_iters(MemorySegment struct) { + return struct.get(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t kmeans_n_iters + * } + */ + public static void kmeans_n_iters(MemorySegment struct, int fieldValue) { + struct.set(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET, fieldValue); + } + + private static final OfDouble vq_kmeans_trainset_fraction$LAYOUT = (OfDouble)$LAYOUT.select(groupElement("vq_kmeans_trainset_fraction")); + + /** + * Layout for field: + * {@snippet lang=c : + * double vq_kmeans_trainset_fraction + * } + */ + public static final OfDouble vq_kmeans_trainset_fraction$layout() { + return vq_kmeans_trainset_fraction$LAYOUT; + } + + private static final long vq_kmeans_trainset_fraction$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * double vq_kmeans_trainset_fraction + * } + */ + public static final long vq_kmeans_trainset_fraction$offset() { + return vq_kmeans_trainset_fraction$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * double vq_kmeans_trainset_fraction + * } + */ + public static double vq_kmeans_trainset_fraction(MemorySegment struct) { + return struct.get(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * double vq_kmeans_trainset_fraction + * } + */ + public static void vq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { + struct.set(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET, fieldValue); + } + + private static final OfDouble pq_kmeans_trainset_fraction$LAYOUT = (OfDouble)$LAYOUT.select(groupElement("pq_kmeans_trainset_fraction")); + + /** + * Layout for field: + * {@snippet lang=c : + * double pq_kmeans_trainset_fraction + * } + */ + public static final OfDouble pq_kmeans_trainset_fraction$layout() { + return pq_kmeans_trainset_fraction$LAYOUT; + } + + private static final long pq_kmeans_trainset_fraction$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * double pq_kmeans_trainset_fraction + * } + */ + public static final long pq_kmeans_trainset_fraction$offset() { + return pq_kmeans_trainset_fraction$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * double pq_kmeans_trainset_fraction + * } + */ + public static double pq_kmeans_trainset_fraction(MemorySegment struct) { + return struct.get(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * double pq_kmeans_trainset_fraction + * } + */ + public static void pq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { + struct.set(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java new file mode 100644 index 000000000..a18ebae86 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java @@ -0,0 +1,172 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * uintptr_t addr; + * DLDataType dtype; + * } + * } + */ +public class cuvsCagraIndex { + + cuvsCagraIndex() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + cagra_h.C_LONG.withName("addr"), + DLDataType.layout().withName("dtype"), + MemoryLayout.paddingLayout(4) + ).withName("$anon$175:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong addr$LAYOUT = (OfLong)$LAYOUT.select(groupElement("addr")); + + /** + * Layout for field: + * {@snippet lang=c : + * uintptr_t addr + * } + */ + public static final OfLong addr$layout() { + return addr$LAYOUT; + } + + private static final long addr$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * uintptr_t addr + * } + */ + public static final long addr$offset() { + return addr$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uintptr_t addr + * } + */ + public static long addr(MemorySegment struct) { + return struct.get(addr$LAYOUT, addr$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uintptr_t addr + * } + */ + public static void addr(MemorySegment struct, long fieldValue) { + struct.set(addr$LAYOUT, addr$OFFSET, fieldValue); + } + + private static final GroupLayout dtype$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dtype")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static final GroupLayout dtype$layout() { + return dtype$LAYOUT; + } + + private static final long dtype$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static final long dtype$offset() { + return dtype$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static MemorySegment dtype(MemorySegment struct) { + return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static void dtype(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java new file mode 100644 index 000000000..aaa87af8e --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java @@ -0,0 +1,265 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct cuvsCagraIndexParams { + * size_t intermediate_graph_degree; + * size_t graph_degree; + * enum cuvsCagraGraphBuildAlgo build_algo; + * size_t nn_descent_niter; + * } + * } + */ +public class cuvsCagraIndexParams { + + cuvsCagraIndexParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + cagra_h.C_LONG.withName("intermediate_graph_degree"), + cagra_h.C_LONG.withName("graph_degree"), + cagra_h.C_INT.withName("build_algo"), + MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("nn_descent_niter") + ).withName("cuvsCagraIndexParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong intermediate_graph_degree$LAYOUT = (OfLong)$LAYOUT.select(groupElement("intermediate_graph_degree")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t intermediate_graph_degree + * } + */ + public static final OfLong intermediate_graph_degree$layout() { + return intermediate_graph_degree$LAYOUT; + } + + private static final long intermediate_graph_degree$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t intermediate_graph_degree + * } + */ + public static final long intermediate_graph_degree$offset() { + return intermediate_graph_degree$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t intermediate_graph_degree + * } + */ + public static long intermediate_graph_degree(MemorySegment struct) { + return struct.get(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t intermediate_graph_degree + * } + */ + public static void intermediate_graph_degree(MemorySegment struct, long fieldValue) { + struct.set(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET, fieldValue); + } + + private static final OfLong graph_degree$LAYOUT = (OfLong)$LAYOUT.select(groupElement("graph_degree")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t graph_degree + * } + */ + public static final OfLong graph_degree$layout() { + return graph_degree$LAYOUT; + } + + private static final long graph_degree$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t graph_degree + * } + */ + public static final long graph_degree$offset() { + return graph_degree$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t graph_degree + * } + */ + public static long graph_degree(MemorySegment struct) { + return struct.get(graph_degree$LAYOUT, graph_degree$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t graph_degree + * } + */ + public static void graph_degree(MemorySegment struct, long fieldValue) { + struct.set(graph_degree$LAYOUT, graph_degree$OFFSET, fieldValue); + } + + private static final OfInt build_algo$LAYOUT = (OfInt)$LAYOUT.select(groupElement("build_algo")); + + /** + * Layout for field: + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static final OfInt build_algo$layout() { + return build_algo$LAYOUT; + } + + private static final long build_algo$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static final long build_algo$offset() { + return build_algo$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static int build_algo(MemorySegment struct) { + return struct.get(build_algo$LAYOUT, build_algo$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static void build_algo(MemorySegment struct, int fieldValue) { + struct.set(build_algo$LAYOUT, build_algo$OFFSET, fieldValue); + } + + private static final OfLong nn_descent_niter$LAYOUT = (OfLong)$LAYOUT.select(groupElement("nn_descent_niter")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t nn_descent_niter + * } + */ + public static final OfLong nn_descent_niter$layout() { + return nn_descent_niter$LAYOUT; + } + + private static final long nn_descent_niter$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t nn_descent_niter + * } + */ + public static final long nn_descent_niter$offset() { + return nn_descent_niter$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t nn_descent_niter + * } + */ + public static long nn_descent_niter(MemorySegment struct) { + return struct.get(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t nn_descent_niter + * } + */ + public static void nn_descent_niter(MemorySegment struct, long fieldValue) { + struct.set(nn_descent_niter$LAYOUT, nn_descent_niter$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/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java new file mode 100644 index 000000000..4011df7e5 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java @@ -0,0 +1,681 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfFloat; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct cuvsCagraSearchParams { + * size_t max_queries; + * size_t itopk_size; + * size_t max_iterations; + * enum cuvsCagraSearchAlgo algo; + * size_t team_size; + * size_t search_width; + * size_t min_iterations; + * size_t thread_block_size; + * enum cuvsCagraHashMode hashmap_mode; + * size_t hashmap_min_bitlen; + * float hashmap_max_fill_rate; + * uint32_t num_random_samplings; + * uint64_t rand_xor_mask; + * } + * } + */ +public class cuvsCagraSearchParams { + + cuvsCagraSearchParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + cagra_h.C_LONG.withName("max_queries"), + cagra_h.C_LONG.withName("itopk_size"), + cagra_h.C_LONG.withName("max_iterations"), + cagra_h.C_INT.withName("algo"), + MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("team_size"), + cagra_h.C_LONG.withName("search_width"), + cagra_h.C_LONG.withName("min_iterations"), + cagra_h.C_LONG.withName("thread_block_size"), + cagra_h.C_INT.withName("hashmap_mode"), + MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("hashmap_min_bitlen"), + cagra_h.C_FLOAT.withName("hashmap_max_fill_rate"), + cagra_h.C_INT.withName("num_random_samplings"), + cagra_h.C_LONG.withName("rand_xor_mask") + ).withName("cuvsCagraSearchParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong max_queries$LAYOUT = (OfLong)$LAYOUT.select(groupElement("max_queries")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t max_queries + * } + */ + public static final OfLong max_queries$layout() { + return max_queries$LAYOUT; + } + + private static final long max_queries$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t max_queries + * } + */ + public static final long max_queries$offset() { + return max_queries$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t max_queries + * } + */ + public static long max_queries(MemorySegment struct) { + return struct.get(max_queries$LAYOUT, max_queries$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t max_queries + * } + */ + public static void max_queries(MemorySegment struct, long fieldValue) { + struct.set(max_queries$LAYOUT, max_queries$OFFSET, fieldValue); + } + + private static final OfLong itopk_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("itopk_size")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t itopk_size + * } + */ + public static final OfLong itopk_size$layout() { + return itopk_size$LAYOUT; + } + + private static final long itopk_size$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t itopk_size + * } + */ + public static final long itopk_size$offset() { + return itopk_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t itopk_size + * } + */ + public static long itopk_size(MemorySegment struct) { + return struct.get(itopk_size$LAYOUT, itopk_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t itopk_size + * } + */ + public static void itopk_size(MemorySegment struct, long fieldValue) { + struct.set(itopk_size$LAYOUT, itopk_size$OFFSET, fieldValue); + } + + private static final OfLong max_iterations$LAYOUT = (OfLong)$LAYOUT.select(groupElement("max_iterations")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t max_iterations + * } + */ + public static final OfLong max_iterations$layout() { + return max_iterations$LAYOUT; + } + + private static final long max_iterations$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t max_iterations + * } + */ + public static final long max_iterations$offset() { + return max_iterations$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t max_iterations + * } + */ + public static long max_iterations(MemorySegment struct) { + return struct.get(max_iterations$LAYOUT, max_iterations$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t max_iterations + * } + */ + public static void max_iterations(MemorySegment struct, long fieldValue) { + struct.set(max_iterations$LAYOUT, max_iterations$OFFSET, fieldValue); + } + + private static final OfInt algo$LAYOUT = (OfInt)$LAYOUT.select(groupElement("algo")); + + /** + * Layout for field: + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo algo + * } + */ + public static final OfInt algo$layout() { + return algo$LAYOUT; + } + + private static final long algo$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo algo + * } + */ + public static final long algo$offset() { + return algo$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo algo + * } + */ + public static int algo(MemorySegment struct) { + return struct.get(algo$LAYOUT, algo$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo algo + * } + */ + public static void algo(MemorySegment struct, int fieldValue) { + struct.set(algo$LAYOUT, algo$OFFSET, fieldValue); + } + + private static final OfLong team_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("team_size")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t team_size + * } + */ + public static final OfLong team_size$layout() { + return team_size$LAYOUT; + } + + private static final long team_size$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t team_size + * } + */ + public static final long team_size$offset() { + return team_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t team_size + * } + */ + public static long team_size(MemorySegment struct) { + return struct.get(team_size$LAYOUT, team_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t team_size + * } + */ + public static void team_size(MemorySegment struct, long fieldValue) { + struct.set(team_size$LAYOUT, team_size$OFFSET, fieldValue); + } + + private static final OfLong search_width$LAYOUT = (OfLong)$LAYOUT.select(groupElement("search_width")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t search_width + * } + */ + public static final OfLong search_width$layout() { + return search_width$LAYOUT; + } + + private static final long search_width$OFFSET = 40; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t search_width + * } + */ + public static final long search_width$offset() { + return search_width$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t search_width + * } + */ + public static long search_width(MemorySegment struct) { + return struct.get(search_width$LAYOUT, search_width$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t search_width + * } + */ + public static void search_width(MemorySegment struct, long fieldValue) { + struct.set(search_width$LAYOUT, search_width$OFFSET, fieldValue); + } + + private static final OfLong min_iterations$LAYOUT = (OfLong)$LAYOUT.select(groupElement("min_iterations")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t min_iterations + * } + */ + public static final OfLong min_iterations$layout() { + return min_iterations$LAYOUT; + } + + private static final long min_iterations$OFFSET = 48; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t min_iterations + * } + */ + public static final long min_iterations$offset() { + return min_iterations$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t min_iterations + * } + */ + public static long min_iterations(MemorySegment struct) { + return struct.get(min_iterations$LAYOUT, min_iterations$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t min_iterations + * } + */ + public static void min_iterations(MemorySegment struct, long fieldValue) { + struct.set(min_iterations$LAYOUT, min_iterations$OFFSET, fieldValue); + } + + private static final OfLong thread_block_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("thread_block_size")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t thread_block_size + * } + */ + public static final OfLong thread_block_size$layout() { + return thread_block_size$LAYOUT; + } + + private static final long thread_block_size$OFFSET = 56; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t thread_block_size + * } + */ + public static final long thread_block_size$offset() { + return thread_block_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t thread_block_size + * } + */ + public static long thread_block_size(MemorySegment struct) { + return struct.get(thread_block_size$LAYOUT, thread_block_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t thread_block_size + * } + */ + public static void thread_block_size(MemorySegment struct, long fieldValue) { + struct.set(thread_block_size$LAYOUT, thread_block_size$OFFSET, fieldValue); + } + + private static final OfInt hashmap_mode$LAYOUT = (OfInt)$LAYOUT.select(groupElement("hashmap_mode")); + + /** + * Layout for field: + * {@snippet lang=c : + * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static final OfInt hashmap_mode$layout() { + return hashmap_mode$LAYOUT; + } + + private static final long hashmap_mode$OFFSET = 64; + + /** + * Offset for field: + * {@snippet lang=c : + * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static final long hashmap_mode$offset() { + return hashmap_mode$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static int hashmap_mode(MemorySegment struct) { + return struct.get(hashmap_mode$LAYOUT, hashmap_mode$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static void hashmap_mode(MemorySegment struct, int fieldValue) { + struct.set(hashmap_mode$LAYOUT, hashmap_mode$OFFSET, fieldValue); + } + + private static final OfLong hashmap_min_bitlen$LAYOUT = (OfLong)$LAYOUT.select(groupElement("hashmap_min_bitlen")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t hashmap_min_bitlen + * } + */ + public static final OfLong hashmap_min_bitlen$layout() { + return hashmap_min_bitlen$LAYOUT; + } + + private static final long hashmap_min_bitlen$OFFSET = 72; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t hashmap_min_bitlen + * } + */ + public static final long hashmap_min_bitlen$offset() { + return hashmap_min_bitlen$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t hashmap_min_bitlen + * } + */ + public static long hashmap_min_bitlen(MemorySegment struct) { + return struct.get(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t hashmap_min_bitlen + * } + */ + public static void hashmap_min_bitlen(MemorySegment struct, long fieldValue) { + struct.set(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET, fieldValue); + } + + private static final OfFloat hashmap_max_fill_rate$LAYOUT = (OfFloat)$LAYOUT.select(groupElement("hashmap_max_fill_rate")); + + /** + * Layout for field: + * {@snippet lang=c : + * float hashmap_max_fill_rate + * } + */ + public static final OfFloat hashmap_max_fill_rate$layout() { + return hashmap_max_fill_rate$LAYOUT; + } + + private static final long hashmap_max_fill_rate$OFFSET = 80; + + /** + * Offset for field: + * {@snippet lang=c : + * float hashmap_max_fill_rate + * } + */ + public static final long hashmap_max_fill_rate$offset() { + return hashmap_max_fill_rate$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * float hashmap_max_fill_rate + * } + */ + public static float hashmap_max_fill_rate(MemorySegment struct) { + return struct.get(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * float hashmap_max_fill_rate + * } + */ + public static void hashmap_max_fill_rate(MemorySegment struct, float fieldValue) { + struct.set(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET, fieldValue); + } + + private static final OfInt num_random_samplings$LAYOUT = (OfInt)$LAYOUT.select(groupElement("num_random_samplings")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t num_random_samplings + * } + */ + public static final OfInt num_random_samplings$layout() { + return num_random_samplings$LAYOUT; + } + + private static final long num_random_samplings$OFFSET = 84; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t num_random_samplings + * } + */ + public static final long num_random_samplings$offset() { + return num_random_samplings$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t num_random_samplings + * } + */ + public static int num_random_samplings(MemorySegment struct) { + return struct.get(num_random_samplings$LAYOUT, num_random_samplings$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t num_random_samplings + * } + */ + public static void num_random_samplings(MemorySegment struct, int fieldValue) { + struct.set(num_random_samplings$LAYOUT, num_random_samplings$OFFSET, fieldValue); + } + + private static final OfLong rand_xor_mask$LAYOUT = (OfLong)$LAYOUT.select(groupElement("rand_xor_mask")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint64_t rand_xor_mask + * } + */ + public static final OfLong rand_xor_mask$layout() { + return rand_xor_mask$LAYOUT; + } + + private static final long rand_xor_mask$OFFSET = 88; + + /** + * Offset for field: + * {@snippet lang=c : + * uint64_t rand_xor_mask + * } + */ + public static final long rand_xor_mask$offset() { + return rand_xor_mask$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint64_t rand_xor_mask + * } + */ + public static long rand_xor_mask(MemorySegment struct) { + return struct.get(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint64_t rand_xor_mask + * } + */ + public static void rand_xor_mask(MemorySegment struct, long fieldValue) { + struct.set(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java new file mode 100644 index 000000000..61d0e4625 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java @@ -0,0 +1,172 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +/** + * {@snippet lang=c : + * struct { + * uintptr_t addr; + * enum cuvsFilterType type; + * } + * } + */ +public class cuvsFilter { + + cuvsFilter() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + brute_force_h.C_LONG.withName("addr"), + brute_force_h.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/java/com/nvidia/cuvs/panama/dlpack_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java new file mode 100644 index 000000000..3afc5c792 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java @@ -0,0 +1,1883 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; + +public class dlpack_h { + + dlpack_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = dlpack_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = dlpack_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = dlpack_h.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/java/com/nvidia/cuvs/panama/hnsw_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java new file mode 100644 index 000000000..4835982f1 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java @@ -0,0 +1,2482 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +public class hnsw_h { + + hnsw_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int true_ = (int)1L; + /** + * {@snippet lang=c : + * #define true 1 + * } + */ + public static int true_() { + return true_; + } + private static final int false_ = (int)0L; + /** + * {@snippet lang=c : + * #define false 0 + * } + */ + public static int false_() { + return false_; + } + private static final int __bool_true_false_are_defined = (int)1L; + /** + * {@snippet lang=c : + * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = hnsw_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = hnsw_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = hnsw_h.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 = hnsw_h.C_LONG; + private static final int L2Expanded = (int)0L; + /** + * {@snippet lang=c : + * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + private static final int L2SqrtExpanded = (int)1L; + /** + * {@snippet lang=c : + * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + private static final int CosineExpanded = (int)2L; + /** + * {@snippet lang=c : + * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + private static final int L1 = (int)3L; + /** + * {@snippet lang=c : + * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + private static final int L2Unexpanded = (int)4L; + /** + * {@snippet lang=c : + * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + private static final int L2SqrtUnexpanded = (int)5L; + /** + * {@snippet lang=c : + * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + private static final int InnerProduct = (int)6L; + /** + * {@snippet lang=c : + * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + private static final int Linf = (int)7L; + /** + * {@snippet lang=c : + * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + private static final int Canberra = (int)8L; + /** + * {@snippet lang=c : + * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + private static final int LpUnexpanded = (int)9L; + /** + * {@snippet lang=c : + * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + private static final int CorrelationExpanded = (int)10L; + /** + * {@snippet lang=c : + * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + private static final int JaccardExpanded = (int)11L; + /** + * {@snippet lang=c : + * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + private static final int HellingerExpanded = (int)12L; + /** + * {@snippet lang=c : + * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + private static final int Haversine = (int)13L; + /** + * {@snippet lang=c : + * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + private static final int BrayCurtis = (int)14L; + /** + * {@snippet lang=c : + * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + private static final int JensenShannon = (int)15L; + /** + * {@snippet lang=c : + * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + private static final int HammingUnexpanded = (int)16L; + /** + * {@snippet lang=c : + * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + private static final int KLDivergence = (int)17L; + /** + * {@snippet lang=c : + * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + private static final int RusselRaoExpanded = (int)18L; + /** + * {@snippet lang=c : + * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + private static final int DiceExpanded = (int)19L; + /** + * {@snippet lang=c : + * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + private static final int Precomputed = (int)100L; + /** + * {@snippet lang=c : + * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = hnsw_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + /** + * {@snippet lang=c : + * typedef struct cuvsHnswSearchParams { + * int32_t ef; + * int32_t numThreads; + * } *cuvsHnswSearchParams_t + * } + */ + public static final AddressLayout cuvsHnswSearchParams_t = hnsw_h.C_POINTER; + + private static class cuvsHnswSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsHnswSearchParamsCreate$descriptor() { + return cuvsHnswSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static MethodHandle cuvsHnswSearchParamsCreate$handle() { + return cuvsHnswSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static MemorySegment cuvsHnswSearchParamsCreate$address() { + return cuvsHnswSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static int cuvsHnswSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsHnswSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearchParamsCreate", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsHnswSearchParamsDestroy$descriptor() { + return cuvsHnswSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static MethodHandle cuvsHnswSearchParamsDestroy$handle() { + return cuvsHnswSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static MemorySegment cuvsHnswSearchParamsDestroy$address() { + return cuvsHnswSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static int cuvsHnswSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsHnswSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearchParamsDestroy", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef cuvsHnswIndex *cuvsHnswIndex_t + * } + */ + public static final AddressLayout cuvsHnswIndex_t = hnsw_h.C_POINTER; + + private static class cuvsHnswIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsHnswIndexCreate$descriptor() { + return cuvsHnswIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static MethodHandle cuvsHnswIndexCreate$handle() { + return cuvsHnswIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static MemorySegment cuvsHnswIndexCreate$address() { + return cuvsHnswIndexCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static int cuvsHnswIndexCreate(MemorySegment index) { + var mh$ = cuvsHnswIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswIndexCreate", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static FunctionDescriptor cuvsHnswIndexDestroy$descriptor() { + return cuvsHnswIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static MethodHandle cuvsHnswIndexDestroy$handle() { + return cuvsHnswIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static MemorySegment cuvsHnswIndexDestroy$address() { + return cuvsHnswIndexDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static int cuvsHnswIndexDestroy(MemorySegment index) { + var mh$ = cuvsHnswIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswIndexDestroy", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_LONG, + hnsw_h.C_POINTER, + hnsw_h.C_POINTER, + hnsw_h.C_POINTER, + hnsw_h.C_POINTER, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsHnswSearch$descriptor() { + return cuvsHnswSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsHnswSearch$handle() { + return cuvsHnswSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsHnswSearch$address() { + return cuvsHnswSearch.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsHnswSearch(long res, MemorySegment params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsHnswSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearch", res, params, index, queries, neighbors, distances); + } + return (int)mh$.invokeExact(res, params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_LONG, + hnsw_h.C_POINTER, + hnsw_h.C_INT, + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static FunctionDescriptor cuvsHnswDeserialize$descriptor() { + return cuvsHnswDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static MethodHandle cuvsHnswDeserialize$handle() { + return cuvsHnswDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static MemorySegment cuvsHnswDeserialize$address() { + return cuvsHnswDeserialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static int cuvsHnswDeserialize(long res, MemorySegment filename, int dim, int metric, MemorySegment index) { + var mh$ = cuvsHnswDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswDeserialize", res, filename, dim, metric, index); + } + return (int)mh$.invokeExact(res, filename, dim, metric, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java new file mode 100644 index 000000000..0848589b6 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java @@ -0,0 +1,2792 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +public class ivf_flat_h { + + ivf_flat_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int true_ = (int)1L; + /** + * {@snippet lang=c : + * #define true 1 + * } + */ + public static int true_() { + return true_; + } + private static final int false_ = (int)0L; + /** + * {@snippet lang=c : + * #define false 0 + * } + */ + public static int false_() { + return false_; + } + private static final int __bool_true_false_are_defined = (int)1L; + /** + * {@snippet lang=c : + * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = ivf_flat_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = ivf_flat_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = ivf_flat_h.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 = ivf_flat_h.C_LONG; + private static final int L2Expanded = (int)0L; + /** + * {@snippet lang=c : + * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + private static final int L2SqrtExpanded = (int)1L; + /** + * {@snippet lang=c : + * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + private static final int CosineExpanded = (int)2L; + /** + * {@snippet lang=c : + * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + private static final int L1 = (int)3L; + /** + * {@snippet lang=c : + * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + private static final int L2Unexpanded = (int)4L; + /** + * {@snippet lang=c : + * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + private static final int L2SqrtUnexpanded = (int)5L; + /** + * {@snippet lang=c : + * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + private static final int InnerProduct = (int)6L; + /** + * {@snippet lang=c : + * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + private static final int Linf = (int)7L; + /** + * {@snippet lang=c : + * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + private static final int Canberra = (int)8L; + /** + * {@snippet lang=c : + * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + private static final int LpUnexpanded = (int)9L; + /** + * {@snippet lang=c : + * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + private static final int CorrelationExpanded = (int)10L; + /** + * {@snippet lang=c : + * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + private static final int JaccardExpanded = (int)11L; + /** + * {@snippet lang=c : + * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + private static final int HellingerExpanded = (int)12L; + /** + * {@snippet lang=c : + * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + private static final int Haversine = (int)13L; + /** + * {@snippet lang=c : + * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + private static final int BrayCurtis = (int)14L; + /** + * {@snippet lang=c : + * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + private static final int JensenShannon = (int)15L; + /** + * {@snippet lang=c : + * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + private static final int HammingUnexpanded = (int)16L; + /** + * {@snippet lang=c : + * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + private static final int KLDivergence = (int)17L; + /** + * {@snippet lang=c : + * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + private static final int RusselRaoExpanded = (int)18L; + /** + * {@snippet lang=c : + * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + private static final int DiceExpanded = (int)19L; + /** + * {@snippet lang=c : + * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + private static final int Precomputed = (int)100L; + /** + * {@snippet lang=c : + * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = ivf_flat_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + /** + * {@snippet lang=c : + * typedef struct cuvsIvfFlatIndexParams { + * cuvsDistanceType metric; + * float metric_arg; + * _Bool add_data_on_build; + * uint32_t n_lists; + * uint32_t kmeans_n_iters; + * double kmeans_trainset_fraction; + * _Bool adaptive_centers; + * _Bool conservative_memory_allocation; + * } *cuvsIvfFlatIndexParams_t + * } + */ + public static final AddressLayout cuvsIvfFlatIndexParams_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexParamsCreate$descriptor() { + return cuvsIvfFlatIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static MethodHandle cuvsIvfFlatIndexParamsCreate$handle() { + return cuvsIvfFlatIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static MemorySegment cuvsIvfFlatIndexParamsCreate$address() { + return cuvsIvfFlatIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static int cuvsIvfFlatIndexParamsCreate(MemorySegment index_params) { + var mh$ = cuvsIvfFlatIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexParamsCreate", index_params); + } + return (int)mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexParamsDestroy$descriptor() { + return cuvsIvfFlatIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static MethodHandle cuvsIvfFlatIndexParamsDestroy$handle() { + return cuvsIvfFlatIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static MemorySegment cuvsIvfFlatIndexParamsDestroy$address() { + return cuvsIvfFlatIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static int cuvsIvfFlatIndexParamsDestroy(MemorySegment index_params) { + var mh$ = cuvsIvfFlatIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexParamsDestroy", index_params); + } + return (int)mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef struct cuvsIvfFlatSearchParams { + * uint32_t n_probes; + * } *cuvsIvfFlatSearchParams_t + * } + */ + public static final AddressLayout cuvsIvfFlatSearchParams_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearchParamsCreate$descriptor() { + return cuvsIvfFlatSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static MethodHandle cuvsIvfFlatSearchParamsCreate$handle() { + return cuvsIvfFlatSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static MemorySegment cuvsIvfFlatSearchParamsCreate$address() { + return cuvsIvfFlatSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static int cuvsIvfFlatSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsIvfFlatSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearchParamsCreate", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearchParamsDestroy$descriptor() { + return cuvsIvfFlatSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static MethodHandle cuvsIvfFlatSearchParamsDestroy$handle() { + return cuvsIvfFlatSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static MemorySegment cuvsIvfFlatSearchParamsDestroy$address() { + return cuvsIvfFlatSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static int cuvsIvfFlatSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsIvfFlatSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearchParamsDestroy", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef cuvsIvfFlatIndex *cuvsIvfFlatIndex_t + * } + */ + public static final AddressLayout cuvsIvfFlatIndex_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexCreate$descriptor() { + return cuvsIvfFlatIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static MethodHandle cuvsIvfFlatIndexCreate$handle() { + return cuvsIvfFlatIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static MemorySegment cuvsIvfFlatIndexCreate$address() { + return cuvsIvfFlatIndexCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static int cuvsIvfFlatIndexCreate(MemorySegment index) { + var mh$ = cuvsIvfFlatIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexCreate", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexDestroy$descriptor() { + return cuvsIvfFlatIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatIndexDestroy$handle() { + return cuvsIvfFlatIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatIndexDestroy$address() { + return cuvsIvfFlatIndexDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatIndexDestroy(MemorySegment index) { + var mh$ = cuvsIvfFlatIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexDestroy", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatBuild$descriptor() { + return cuvsIvfFlatBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatBuild$handle() { + return cuvsIvfFlatBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatBuild$address() { + return cuvsIvfFlatBuild.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatBuild(long res, MemorySegment index_params, MemorySegment dataset, MemorySegment index) { + var mh$ = cuvsIvfFlatBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatBuild", res, index_params, dataset, index); + } + return (int)mh$.invokeExact(res, index_params, dataset, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearch$descriptor() { + return cuvsIvfFlatSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsIvfFlatSearch$handle() { + return cuvsIvfFlatSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsIvfFlatSearch$address() { + return cuvsIvfFlatSearch.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsIvfFlatSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsIvfFlatSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearch", res, search_params, index, queries, neighbors, distances); + } + return (int)mh$.invokeExact(res, search_params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSerialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSerialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSerialize$descriptor() { + return cuvsIvfFlatSerialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatSerialize$handle() { + return cuvsIvfFlatSerialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatSerialize$address() { + return cuvsIvfFlatSerialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatSerialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfFlatSerialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSerialize", res, filename, index); + } + return (int)mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatDeserialize$descriptor() { + return cuvsIvfFlatDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatDeserialize$handle() { + return cuvsIvfFlatDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatDeserialize$address() { + return cuvsIvfFlatDeserialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatDeserialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfFlatDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatDeserialize", res, filename, index); + } + return (int)mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatExtend { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatExtend"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatExtend$descriptor() { + return cuvsIvfFlatExtend.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatExtend$handle() { + return cuvsIvfFlatExtend.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatExtend$address() { + return cuvsIvfFlatExtend.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, MemorySegment index) { + var mh$ = cuvsIvfFlatExtend.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatExtend", res, new_vectors, new_indices, index); + } + return (int)mh$.invokeExact(res, new_vectors, new_indices, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java new file mode 100644 index 000000000..fd57078b6 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java @@ -0,0 +1,3096 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +public class ivf_pq_h { + + ivf_pq_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int true_ = (int)1L; + /** + * {@snippet lang=c : + * #define true 1 + * } + */ + public static int true_() { + return true_; + } + private static final int false_ = (int)0L; + /** + * {@snippet lang=c : + * #define false 0 + * } + */ + public static int false_() { + return false_; + } + private static final int __bool_true_false_are_defined = (int)1L; + /** + * {@snippet lang=c : + * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = ivf_pq_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = ivf_pq_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = ivf_pq_h.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 = ivf_pq_h.C_LONG; + private static final int L2Expanded = (int)0L; + /** + * {@snippet lang=c : + * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + private static final int L2SqrtExpanded = (int)1L; + /** + * {@snippet lang=c : + * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + private static final int CosineExpanded = (int)2L; + /** + * {@snippet lang=c : + * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + private static final int L1 = (int)3L; + /** + * {@snippet lang=c : + * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + private static final int L2Unexpanded = (int)4L; + /** + * {@snippet lang=c : + * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + private static final int L2SqrtUnexpanded = (int)5L; + /** + * {@snippet lang=c : + * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + private static final int InnerProduct = (int)6L; + /** + * {@snippet lang=c : + * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + private static final int Linf = (int)7L; + /** + * {@snippet lang=c : + * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + private static final int Canberra = (int)8L; + /** + * {@snippet lang=c : + * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + private static final int LpUnexpanded = (int)9L; + /** + * {@snippet lang=c : + * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + private static final int CorrelationExpanded = (int)10L; + /** + * {@snippet lang=c : + * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + private static final int JaccardExpanded = (int)11L; + /** + * {@snippet lang=c : + * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + private static final int HellingerExpanded = (int)12L; + /** + * {@snippet lang=c : + * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + private static final int Haversine = (int)13L; + /** + * {@snippet lang=c : + * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + private static final int BrayCurtis = (int)14L; + /** + * {@snippet lang=c : + * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + private static final int JensenShannon = (int)15L; + /** + * {@snippet lang=c : + * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + private static final int HammingUnexpanded = (int)16L; + /** + * {@snippet lang=c : + * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + private static final int KLDivergence = (int)17L; + /** + * {@snippet lang=c : + * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + private static final int RusselRaoExpanded = (int)18L; + /** + * {@snippet lang=c : + * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + private static final int DiceExpanded = (int)19L; + /** + * {@snippet lang=c : + * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + private static final int Precomputed = (int)100L; + /** + * {@snippet lang=c : + * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = ivf_pq_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + private static final int CUDA_R_16F = (int)2L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_16F = 2 + * } + */ + public static int CUDA_R_16F() { + return CUDA_R_16F; + } + private static final int CUDA_C_16F = (int)6L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_16F = 6 + * } + */ + public static int CUDA_C_16F() { + return CUDA_C_16F; + } + private static final int CUDA_R_16BF = (int)14L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_16BF = 14 + * } + */ + public static int CUDA_R_16BF() { + return CUDA_R_16BF; + } + private static final int CUDA_C_16BF = (int)15L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_16BF = 15 + * } + */ + public static int CUDA_C_16BF() { + return CUDA_C_16BF; + } + private static final int CUDA_R_32F = (int)0L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_32F = 0 + * } + */ + public static int CUDA_R_32F() { + return CUDA_R_32F; + } + private static final int CUDA_C_32F = (int)4L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_32F = 4 + * } + */ + public static int CUDA_C_32F() { + return CUDA_C_32F; + } + private static final int CUDA_R_64F = (int)1L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_64F = 1 + * } + */ + public static int CUDA_R_64F() { + return CUDA_R_64F; + } + private static final int CUDA_C_64F = (int)5L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_64F = 5 + * } + */ + public static int CUDA_C_64F() { + return CUDA_C_64F; + } + private static final int CUDA_R_4I = (int)16L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_4I = 16 + * } + */ + public static int CUDA_R_4I() { + return CUDA_R_4I; + } + private static final int CUDA_C_4I = (int)17L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_4I = 17 + * } + */ + public static int CUDA_C_4I() { + return CUDA_C_4I; + } + private static final int CUDA_R_4U = (int)18L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_4U = 18 + * } + */ + public static int CUDA_R_4U() { + return CUDA_R_4U; + } + private static final int CUDA_C_4U = (int)19L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_4U = 19 + * } + */ + public static int CUDA_C_4U() { + return CUDA_C_4U; + } + private static final int CUDA_R_8I = (int)3L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_8I = 3 + * } + */ + public static int CUDA_R_8I() { + return CUDA_R_8I; + } + private static final int CUDA_C_8I = (int)7L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_8I = 7 + * } + */ + public static int CUDA_C_8I() { + return CUDA_C_8I; + } + private static final int CUDA_R_8U = (int)8L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_8U = 8 + * } + */ + public static int CUDA_R_8U() { + return CUDA_R_8U; + } + private static final int CUDA_C_8U = (int)9L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_8U = 9 + * } + */ + public static int CUDA_C_8U() { + return CUDA_C_8U; + } + private static final int CUDA_R_16I = (int)20L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_16I = 20 + * } + */ + public static int CUDA_R_16I() { + return CUDA_R_16I; + } + private static final int CUDA_C_16I = (int)21L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_16I = 21 + * } + */ + public static int CUDA_C_16I() { + return CUDA_C_16I; + } + private static final int CUDA_R_16U = (int)22L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_16U = 22 + * } + */ + public static int CUDA_R_16U() { + return CUDA_R_16U; + } + private static final int CUDA_C_16U = (int)23L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_16U = 23 + * } + */ + public static int CUDA_C_16U() { + return CUDA_C_16U; + } + private static final int CUDA_R_32I = (int)10L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_32I = 10 + * } + */ + public static int CUDA_R_32I() { + return CUDA_R_32I; + } + private static final int CUDA_C_32I = (int)11L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_32I = 11 + * } + */ + public static int CUDA_C_32I() { + return CUDA_C_32I; + } + private static final int CUDA_R_32U = (int)12L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_32U = 12 + * } + */ + public static int CUDA_R_32U() { + return CUDA_R_32U; + } + private static final int CUDA_C_32U = (int)13L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_32U = 13 + * } + */ + public static int CUDA_C_32U() { + return CUDA_C_32U; + } + private static final int CUDA_R_64I = (int)24L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_64I = 24 + * } + */ + public static int CUDA_R_64I() { + return CUDA_R_64I; + } + private static final int CUDA_C_64I = (int)25L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_64I = 25 + * } + */ + public static int CUDA_C_64I() { + return CUDA_C_64I; + } + private static final int CUDA_R_64U = (int)26L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_64U = 26 + * } + */ + public static int CUDA_R_64U() { + return CUDA_R_64U; + } + private static final int CUDA_C_64U = (int)27L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_64U = 27 + * } + */ + public static int CUDA_C_64U() { + return CUDA_C_64U; + } + private static final int MAJOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * enum libraryPropertyType_t.MAJOR_VERSION = 0 + * } + */ + public static int MAJOR_VERSION() { + return MAJOR_VERSION; + } + private static final int MINOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * enum libraryPropertyType_t.MINOR_VERSION = 1 + * } + */ + public static int MINOR_VERSION() { + return MINOR_VERSION; + } + private static final int PATCH_LEVEL = (int)2L; + /** + * {@snippet lang=c : + * enum libraryPropertyType_t.PATCH_LEVEL = 2 + * } + */ + public static int PATCH_LEVEL() { + return PATCH_LEVEL; + } + private static final int PER_SUBSPACE = (int)0L; + /** + * {@snippet lang=c : + * enum codebook_gen.PER_SUBSPACE = 0 + * } + */ + public static int PER_SUBSPACE() { + return PER_SUBSPACE; + } + private static final int PER_CLUSTER = (int)1L; + /** + * {@snippet lang=c : + * enum codebook_gen.PER_CLUSTER = 1 + * } + */ + public static int PER_CLUSTER() { + return PER_CLUSTER; + } + /** + * {@snippet lang=c : + * typedef struct cuvsIvfPqIndexParams { + * cuvsDistanceType metric; + * float metric_arg; + * _Bool add_data_on_build; + * uint32_t n_lists; + * uint32_t kmeans_n_iters; + * double kmeans_trainset_fraction; + * uint32_t pq_bits; + * uint32_t pq_dim; + * enum codebook_gen codebook_kind; + * _Bool force_random_rotation; + * _Bool conservative_memory_allocation; + * uint32_t max_train_points_per_pq_code; + * } *cuvsIvfPqIndexParams_t + * } + */ + public static final AddressLayout cuvsIvfPqIndexParams_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexParamsCreate$descriptor() { + return cuvsIvfPqIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static MethodHandle cuvsIvfPqIndexParamsCreate$handle() { + return cuvsIvfPqIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static MemorySegment cuvsIvfPqIndexParamsCreate$address() { + return cuvsIvfPqIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static int cuvsIvfPqIndexParamsCreate(MemorySegment index_params) { + var mh$ = cuvsIvfPqIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexParamsCreate", index_params); + } + return (int)mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexParamsDestroy$descriptor() { + return cuvsIvfPqIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static MethodHandle cuvsIvfPqIndexParamsDestroy$handle() { + return cuvsIvfPqIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static MemorySegment cuvsIvfPqIndexParamsDestroy$address() { + return cuvsIvfPqIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static int cuvsIvfPqIndexParamsDestroy(MemorySegment index_params) { + var mh$ = cuvsIvfPqIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexParamsDestroy", index_params); + } + return (int)mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef struct cuvsIvfPqSearchParams { + * uint32_t n_probes; + * cudaDataType_t lut_dtype; + * cudaDataType_t internal_distance_dtype; + * double preferred_shmem_carveout; + * } *cuvsIvfPqSearchParams_t + * } + */ + public static final AddressLayout cuvsIvfPqSearchParams_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearchParamsCreate$descriptor() { + return cuvsIvfPqSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static MethodHandle cuvsIvfPqSearchParamsCreate$handle() { + return cuvsIvfPqSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static MemorySegment cuvsIvfPqSearchParamsCreate$address() { + return cuvsIvfPqSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static int cuvsIvfPqSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsIvfPqSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearchParamsCreate", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearchParamsDestroy$descriptor() { + return cuvsIvfPqSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static MethodHandle cuvsIvfPqSearchParamsDestroy$handle() { + return cuvsIvfPqSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static MemorySegment cuvsIvfPqSearchParamsDestroy$address() { + return cuvsIvfPqSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static int cuvsIvfPqSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsIvfPqSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearchParamsDestroy", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef cuvsIvfPq *cuvsIvfPqIndex_t + * } + */ + public static final AddressLayout cuvsIvfPqIndex_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexCreate$descriptor() { + return cuvsIvfPqIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static MethodHandle cuvsIvfPqIndexCreate$handle() { + return cuvsIvfPqIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static MemorySegment cuvsIvfPqIndexCreate$address() { + return cuvsIvfPqIndexCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static int cuvsIvfPqIndexCreate(MemorySegment index) { + var mh$ = cuvsIvfPqIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexCreate", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexDestroy$descriptor() { + return cuvsIvfPqIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqIndexDestroy$handle() { + return cuvsIvfPqIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqIndexDestroy$address() { + return cuvsIvfPqIndexDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqIndexDestroy(MemorySegment index) { + var mh$ = cuvsIvfPqIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexDestroy", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqBuild$descriptor() { + return cuvsIvfPqBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqBuild$handle() { + return cuvsIvfPqBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqBuild$address() { + return cuvsIvfPqBuild.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqBuild(long res, MemorySegment params, MemorySegment dataset, MemorySegment index) { + var mh$ = cuvsIvfPqBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqBuild", res, params, dataset, index); + } + return (int)mh$.invokeExact(res, params, dataset, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearch$descriptor() { + return cuvsIvfPqSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsIvfPqSearch$handle() { + return cuvsIvfPqSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsIvfPqSearch$address() { + return cuvsIvfPqSearch.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsIvfPqSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsIvfPqSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearch", res, search_params, index, queries, neighbors, distances); + } + return (int)mh$.invokeExact(res, search_params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSerialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSerialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqSerialize$descriptor() { + return cuvsIvfPqSerialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqSerialize$handle() { + return cuvsIvfPqSerialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqSerialize$address() { + return cuvsIvfPqSerialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqSerialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfPqSerialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSerialize", res, filename, index); + } + return (int)mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqDeserialize$descriptor() { + return cuvsIvfPqDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqDeserialize$handle() { + return cuvsIvfPqDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqDeserialize$address() { + return cuvsIvfPqDeserialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqDeserialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfPqDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqDeserialize", res, filename, index); + } + return (int)mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqExtend { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqExtend"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqExtend$descriptor() { + return cuvsIvfPqExtend.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqExtend$handle() { + return cuvsIvfPqExtend.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqExtend$address() { + return cuvsIvfPqExtend.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, MemorySegment index) { + var mh$ = cuvsIvfPqExtend.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqExtend", res, new_vectors, new_indices, index); + } + return (int)mh$.invokeExact(res, new_vectors, new_indices, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java new file mode 100644 index 000000000..555a4316e --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java @@ -0,0 +1,127 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * long long __clang_max_align_nonce1; + * long double __clang_max_align_nonce2; + * } + * } + */ +public class max_align_t { + + max_align_t() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_LONG_LONG.withName("__clang_max_align_nonce1"), + MemoryLayout.paddingLayout(24) + ).withName("$anon$19:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong __clang_max_align_nonce1$LAYOUT = (OfLong)$LAYOUT.select(groupElement("__clang_max_align_nonce1")); + + /** + * Layout for field: + * {@snippet lang=c : + * long long __clang_max_align_nonce1 + * } + */ + public static final OfLong __clang_max_align_nonce1$layout() { + return __clang_max_align_nonce1$LAYOUT; + } + + private static final long __clang_max_align_nonce1$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * long long __clang_max_align_nonce1 + * } + */ + public static final long __clang_max_align_nonce1$offset() { + return __clang_max_align_nonce1$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * long long __clang_max_align_nonce1 + * } + */ + public static long __clang_max_align_nonce1(MemorySegment struct) { + return struct.get(__clang_max_align_nonce1$LAYOUT, __clang_max_align_nonce1$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * long long __clang_max_align_nonce1 + * } + */ + public static void __clang_max_align_nonce1(MemorySegment struct, long fieldValue) { + struct.set(__clang_max_align_nonce1$LAYOUT, __clang_max_align_nonce1$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java new file mode 100644 index 000000000..6f4b031bb --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java @@ -0,0 +1,211 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct results { + * int test; + * int *neighbors_h; + * float *distances_h; + * } + * } + */ +public class results { + + results() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(results_h.C_INT.withName("test"), MemoryLayout.paddingLayout(4), + results_h.C_POINTER.withName("neighbors_h"), results_h.C_POINTER.withName("distances_h")) + .withName("results"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt test$LAYOUT = (OfInt) $LAYOUT.select(groupElement("test")); + + /** + * Layout for field: + * {@snippet lang = c : * int test + * } + */ + public static final OfInt test$layout() { + return test$LAYOUT; + } + + private static final long test$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * int test + * } + */ + public static final long test$offset() { + return test$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * int test + * } + */ + public static int test(MemorySegment struct) { + return struct.get(test$LAYOUT, test$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * int test + * } + */ + public static void test(MemorySegment struct, int fieldValue) { + struct.set(test$LAYOUT, test$OFFSET, fieldValue); + } + + private static final AddressLayout neighbors_h$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("neighbors_h")); + + /** + * Layout for field: + * {@snippet lang = c : * int *neighbors_h + * } + */ + public static final AddressLayout neighbors_h$layout() { + return neighbors_h$LAYOUT; + } + + private static final long neighbors_h$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * int *neighbors_h + * } + */ + public static final long neighbors_h$offset() { + return neighbors_h$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * int *neighbors_h + * } + */ + public static MemorySegment neighbors_h(MemorySegment struct) { + return struct.get(neighbors_h$LAYOUT, neighbors_h$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * int *neighbors_h + * } + */ + public static void neighbors_h(MemorySegment struct, MemorySegment fieldValue) { + struct.set(neighbors_h$LAYOUT, neighbors_h$OFFSET, fieldValue); + } + + private static final AddressLayout distances_h$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("distances_h")); + + /** + * Layout for field: + * {@snippet lang = c : * float *distances_h + * } + */ + public static final AddressLayout distances_h$layout() { + return distances_h$LAYOUT; + } + + private static final long distances_h$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * float *distances_h + * } + */ + public static final long distances_h$offset() { + return distances_h$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * float *distances_h + * } + */ + public static MemorySegment distances_h(MemorySegment struct) { + return struct.get(distances_h$LAYOUT, distances_h$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * float *distances_h + * } + */ + public static void distances_h(MemorySegment struct, MemorySegment fieldValue) { + struct.set(distances_h$LAYOUT, distances_h$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/java/com/nvidia/cuvs/panama/results_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java new file mode 100644 index 000000000..aabd8b41b --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java @@ -0,0 +1,83 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; + +public class results_h { + + results_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) + : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + /** + * {@snippet lang = c : + * typedef struct results { + * int test; + * int *neighbors_h; + * float *distances_h; + * } *rsltp + * } + */ + public static final AddressLayout rsltp = results_h.C_POINTER; +} diff --git a/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java b/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java new file mode 100644 index 000000000..73037fabb --- /dev/null +++ b/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java @@ -0,0 +1,19 @@ +package ai.rapids.cuvs; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +/** + * Unit test for simple App. + */ +public class AppTest { + + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() { + assertTrue(true); + } +} diff --git a/java/internal/CMakeLists.txt b/java/internal/CMakeLists.txt new file mode 100644 index 000000000..d9a851872 --- /dev/null +++ b/java/internal/CMakeLists.txt @@ -0,0 +1,56 @@ +# ============================================================================= +# Copyright (c) 2024, 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. +# ============================================================================= + +cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) + +include(rapids_config.cmake) +include(rapids-cmake) +include(rapids-cpm) +include(rapids-export) +include(rapids-find) +rapids_cpm_init() + +project( + cuvs-java + VERSION "${RAPIDS_VERSION}" + LANGUAGES CXX C +) + +option(FIND_CUVS_CPP "Search for existing CUVS C++ installations before defaulting to local files" + ON +) + +if(FIND_CUVS_CPP) + find_package(cuvs "${RAPIDS_VERSION}" REQUIRED COMPONENTS c_api) + if(NOT TARGET cuvs::c_api) + message( + FATAL_ERROR + "Building against a preexisting libcuvs library requires the compiled libcuvs to have been built!" + ) + endif() +else() + set(cuvs_FOUND OFF) +endif() + +if(NOT cuvs_FOUND) + set(BUILD_TESTS OFF) + set(BUILD_C_LIBRARY ON) + add_subdirectory(../../cpp cuvs-cpp EXCLUDE_FROM_ALL) +endif() + +include(get_dlpack.cmake) + +ADD_LIBRARY(cuvs_java SHARED src/cuvs_java.c) +target_include_directories(cuvs_java PUBLIC "$") +target_link_libraries(cuvs_java PRIVATE cuvs::c_api $) diff --git a/java/internal/VERSION b/java/internal/VERSION new file mode 120000 index 000000000..558194c5a --- /dev/null +++ b/java/internal/VERSION @@ -0,0 +1 @@ +../../VERSION \ No newline at end of file diff --git a/java/internal/get_dlpack.cmake b/java/internal/get_dlpack.cmake new file mode 120000 index 000000000..93a54ca4d --- /dev/null +++ b/java/internal/get_dlpack.cmake @@ -0,0 +1 @@ +../../cpp/cmake/thirdparty/get_dlpack.cmake \ No newline at end of file diff --git a/java/internal/rapids_config.cmake b/java/internal/rapids_config.cmake new file mode 120000 index 000000000..398eea52d --- /dev/null +++ b/java/internal/rapids_config.cmake @@ -0,0 +1 @@ +../../rapids_config.cmake \ No newline at end of file diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c new file mode 100644 index 000000000..da11cfd15 --- /dev/null +++ b/java/internal/src/cuvs_java.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include +#include + +cuvsResources_t create_resource(int *rv) { + cuvsResources_t res; + *rv = cuvsResourcesCreate(&res); + return res; +} + +DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) { + DLManagedTensor tensor; + + tensor.dl_tensor.data = data; + tensor.dl_tensor.device.device_type = kDLCUDA; + tensor.dl_tensor.ndim = 2; + tensor.dl_tensor.dtype.code = code; + tensor.dl_tensor.dtype.bits = 32; + tensor.dl_tensor.dtype.lanes = 1; + tensor.dl_tensor.shape = shape; + tensor.dl_tensor.strides = NULL; + + return tensor; +} + +cuvsCagraIndex_t build_index(float *dataset, long rows, long dimension, cuvsResources_t res, int *rv, + cuvsCagraIndexParams_t index_params) { + + int64_t dataset_shape[2] = {rows, dimension}; + DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat); + + cuvsCagraIndex_t index; + cuvsCagraIndexCreate(&index); + + *rv = cuvsCagraBuild(res, index_params, &dataset_tensor, index); + return index; +} + +void serialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, char* filename) { + *rv = cuvsCagraSerialize(res, filename, index, true); +} + +void deserialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, char* filename) { + *rv = cuvsCagraDeserialize(res, filename, index); +} + +void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimension, + cuvsResources_t res, int *neighbors_h, float *distances_h, int *rv, cuvsCagraSearchParams_t search_params1) { + + uint32_t *neighbors; + float *distances, *queries_d; + cuvsRMMAlloc(res, (void**) &queries_d, sizeof(float) * n_queries * dimension); + cuvsRMMAlloc(res, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); + cuvsRMMAlloc(res, (void**) &distances, sizeof(float) * n_queries * topk); + + cudaMemcpy(queries_d, queries, sizeof(float) * 4 * 2, cudaMemcpyDefault); + + int64_t queries_shape[2] = {n_queries, dimension}; + DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat); + + int64_t neighbors_shape[2] = {n_queries, topk}; + DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt); + + int64_t distances_shape[2] = {n_queries, topk}; + DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat); + + cuvsCagraSearchParams_t search_params; + cuvsCagraSearchParamsCreate(&search_params); + + *rv = cuvsCagraSearch(res, search_params, index, &queries_tensor, &neighbors_tensor, + &distances_tensor); + + cudaMemcpy(neighbors_h, neighbors, sizeof(uint32_t) * n_queries * topk, cudaMemcpyDefault); + cudaMemcpy(distances_h, distances, sizeof(float) * n_queries * topk, cudaMemcpyDefault); +} From f9c2df71a195361a06a339cb50d0d6681df78d05 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Sat, 9 Nov 2024 07:11:57 -0500 Subject: [PATCH 02/53] API changes, serialize optional tmpFile param + other changes --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 15 ++-- .../cagra/{CuVSIndex.java => CagraIndex.java} | 79 +++++++++---------- .../nvidia/cuvs/cagra/CagraIndexParams.java | 19 ++--- .../cuvs/cagra/CagraIndexReference.java | 2 +- .../nvidia/cuvs/cagra/CagraSearchParams.java | 40 +++++----- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 31 ++------ .../com/nvidia/cuvs/cagra/CuVSResources.java | 18 +++-- .../com/nvidia/cuvs/cagra/IndexParams.java | 9 --- .../com/nvidia/cuvs/cagra/SearchParams.java | 9 --- .../com/nvidia/cuvs/cagra/SearchResult.java | 14 ++-- 10 files changed, 100 insertions(+), 136 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/{CuVSIndex.java => CagraIndex.java} (81%) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 3497810bf..8f2e5ec2e 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -6,8 +6,7 @@ import java.io.InputStream; import java.util.Map; -import com.nvidia.cuvs.cagra.CuVSIndex; -import com.nvidia.cuvs.cagra.CuVSIndex.ANNAlgorithms; +import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; import com.nvidia.cuvs.cagra.CagraIndexParams.CuvsCagraGraphBuildAlgo; import com.nvidia.cuvs.cagra.CagraSearchParams; @@ -39,24 +38,22 @@ public static void main(String[] args) throws Throwable { .build(); // Creating a new index - CuVSIndex index = new CuVSIndex.Builder(res) + CagraIndex index = new CagraIndex.Builder(res) .withDataset(dataset) - .withANNAlgorithm(ANNAlgorithms.CAGRA) .withIndexParams(cagraIndexParams) .build(); // Saving the index on to the disk. - index.serialize(new FileOutputStream("abc.cag"), "/tmp/index.cag"); + index.serialize(new FileOutputStream("abc.cag")); // Loading a cagra index from disk. InputStream fin = new FileInputStream(new File("abc.cag")); - CuVSIndex index2 = new CuVSIndex.Builder(res) + CagraIndex index2 = new CagraIndex.Builder(res) .from(fin) .build(); // Query CuVSQuery query = new CuVSQuery.Builder() - .withANNAlgorithm(ANNAlgorithms.CAGRA) .withSearchParams(cagraSearchParams) .withQueryVectors(queries) .withMapping(map) @@ -64,11 +61,11 @@ public static void main(String[] args) throws Throwable { // Search SearchResult rslt = index.search(query); - System.out.println(rslt.results); + System.out.println(rslt.getResults()); // Search from de-serialized index SearchResult rslt2 = index2.search(query); - System.out.println(rslt2.results); + System.out.println(rslt2.getResults()); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java similarity index 81% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index df0cc3f2d..440ada990 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -18,17 +18,12 @@ import java.lang.invoke.VarHandle; import java.util.UUID; -public class CuVSIndex { +public class CagraIndex { - private IndexParams indexParams; + private CagraIndexParams indexParams; private final float[][] dataset; private final CuVSResources res; private CagraIndexReference ref; - private ANNAlgorithms algo; - - public enum ANNAlgorithms { - BRUTEFORCE, CAGRA, IVF_PQ, IVF_FLAT - } Linker linker; Arena arena; @@ -48,14 +43,12 @@ public enum ANNAlgorithms { * @param res * @throws Throwable */ - private CuVSIndex(IndexParams indexParams, float[][] dataset, CuVSResources res, ANNAlgorithms algo) - throws Throwable { + private CagraIndex(CagraIndexParams indexParams, float[][] dataset, CuVSResources res) throws Throwable { this.indexParams = indexParams; this.dataset = dataset; this.init(); this.res = res; this.ref = build(); - this.algo = algo; } /** @@ -64,7 +57,7 @@ private CuVSIndex(IndexParams indexParams, float[][] dataset, CuVSResources res, * @param res * @throws Throwable */ - private CuVSIndex(InputStream in, CuVSResources res) throws Throwable { + private CagraIndex(InputStream in, CuVSResources res) throws Throwable { this.indexParams = null; this.dataset = null; this.res = res; @@ -81,7 +74,7 @@ private void init() throws Throwable { arena = Arena.ofConfined(); File wd = new File(System.getProperty("user.dir")); - bridge = SymbolLookup.libraryLookup(wd.getParent() + "/api-sys/build/libcuvs_wrapper.so", arena); + bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); indexMH = linker.downcallHandle(bridge.findOrThrow("build_index"), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), @@ -154,9 +147,7 @@ private CagraIndexReference build() throws Throwable { MemorySegment rvMS = arena.allocate(rvML); ref = new CagraIndexReference((MemorySegment) indexMH.invokeExact(getMemorySegment(dataset), rows, cols, - res.resource, rvMS, indexParams.indexParamsMS)); - - System.out.println("Build call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + res.getResource(), rvMS, indexParams.cagraIndexParamsMS)); return ref; } @@ -177,14 +168,35 @@ public SearchResult search(CuVSQuery query) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.queryVectors), 2, 4L, 2L, res.resource, - neighborsMS, distancesMS, rvMS, query.searchParams.searchParamsMS); - - System.out.println("Search call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.queryVectors), 2, 4L, 2L, res.getResource(), + neighborsMS, distancesMS, rvMS, query.searchParams.cagraSearchParamsMS); return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, 2, query.mapping); } + /** + * + * @param out + * @param tmpFilePath + * @throws Throwable + */ + public void serialize(OutputStream out) throws Throwable { + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; + serializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, + getStringSegment(new StringBuilder(tmpIndexFile))); + File tempFile = new File(tmpIndexFile); + FileInputStream is = new FileInputStream(tempFile); + byte[] chunk = new byte[1024]; + int chunkLen = 0; + while ((chunkLen = is.read(chunk)) != -1) { + out.write(chunk, 0, chunkLen); + } + is.close(); + tempFile.delete(); + } + /** * * @param out @@ -194,10 +206,8 @@ public SearchResult search(CuVSQuery query) throws Throwable { public void serialize(OutputStream out, String tmpFilePath) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - serializeMH.invokeExact(res.resource, ref.indexMemorySegment, rvMS, + serializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, getStringSegment(new StringBuilder(tmpFilePath))); - System.out.println("Serialize call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); - File tempFile = new File(tmpFilePath); FileInputStream is = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; @@ -228,7 +238,7 @@ private CagraIndexReference deserialize(InputStream in) throws Throwable { while ((chunkLen = in.read(chunk)) != -1) { out.write(chunk, 0, chunkLen); } - deserializeMH.invokeExact(res.resource, ref.indexMemorySegment, rvMS, + deserializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, getStringSegment(new StringBuilder(tmpIndexFile))); in.close(); @@ -242,7 +252,7 @@ private CagraIndexReference deserialize(InputStream in) throws Throwable { * * @return */ - public IndexParams getParams() { + public CagraIndexParams getParams() { return indexParams; } @@ -263,10 +273,9 @@ public CuVSResources getResources() { } public static class Builder { - private IndexParams indexParams; + private CagraIndexParams indexParams; float[][] dataset; CuVSResources res; - ANNAlgorithms algo = ANNAlgorithms.CAGRA; InputStream in; @@ -303,31 +312,21 @@ public Builder withDataset(float[][] dataset) { * @param params * @return */ - public Builder withIndexParams(IndexParams indexParams) { + public Builder withIndexParams(CagraIndexParams indexParams) { this.indexParams = indexParams; return this; } - /** - * - * @param params - * @return - */ - public Builder withANNAlgorithm(ANNAlgorithms algo) { - this.algo = algo; - return this; - } - /** * * @return * @throws Throwable */ - public CuVSIndex build() throws Throwable { + public CagraIndex build() throws Throwable { if (in != null) { - return new CuVSIndex(in, res); + return new CagraIndex(in, res); } else { - return new CuVSIndex(indexParams, dataset, res, algo); + return new CagraIndex(indexParams, dataset, res); } } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index 1c99bdfdf..8f8e9c3ff 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -13,13 +13,14 @@ * size_t nn_descent_niter; * } */ -public class CagraIndexParams extends IndexParams { +public class CagraIndexParams { Arena arena; int intermediateGraphDegree; int graphDegree; CuvsCagraGraphBuildAlgo buildAlgo; int nnDescentNiter; + public MemorySegment cagraIndexParamsMS; public enum CuvsCagraGraphBuildAlgo { AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); @@ -31,8 +32,8 @@ private CuvsCagraGraphBuildAlgo(int label) { } } - public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, - CuvsCagraGraphBuildAlgo buildAlgo, int nnDescentNiter) { + public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, CuvsCagraGraphBuildAlgo buildAlgo, + int nnDescentNiter) { this.arena = arena; this.intermediateGraphDegree = intermediateGraphDegree; this.graphDegree = graphDegree; @@ -42,11 +43,11 @@ public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegre } private void set() { - indexParamsMS = cuvsCagraIndexParams.allocate(arena); - cuvsCagraIndexParams.intermediate_graph_degree(indexParamsMS, intermediateGraphDegree); - cuvsCagraIndexParams.graph_degree(indexParamsMS, graphDegree); - cuvsCagraIndexParams.build_algo(indexParamsMS, buildAlgo.label); - cuvsCagraIndexParams.nn_descent_niter(indexParamsMS, nnDescentNiter); + cagraIndexParamsMS = cuvsCagraIndexParams.allocate(arena); + cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMS, intermediateGraphDegree); + cuvsCagraIndexParams.graph_degree(cagraIndexParamsMS, graphDegree); + cuvsCagraIndexParams.build_algo(cagraIndexParamsMS, buildAlgo.label); + cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMS, nnDescentNiter); } public int getIntermediate_graph_degree() { @@ -103,7 +104,7 @@ public Builder withNNDescentNiter(int nnDescentNiter) { this.nnDescentNiter = nnDescentNiter; return this; } - + public Builder withWriterThreads(int writerThreads) { this.writerThreads = writerThreads; return this; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java index bbcca2407..897ab5d0f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -8,7 +8,7 @@ public class CagraIndexReference { public MemorySegment indexMemorySegment; - + /** * */ diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index 3dd5aebd2..dcf856ff9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -22,7 +22,7 @@ * uint64_t rand_xor_mask; * } */ -public class CagraSearchParams extends SearchParams { +public class CagraSearchParams { Arena arena; int maxQueries; @@ -38,6 +38,7 @@ public class CagraSearchParams extends SearchParams { float hashmapMaxFillRate; int numRandomSamplings; long randXorMask; + public MemorySegment cagraSearchParamsMS; enum CuvsCagraSearchAlgo { SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); @@ -82,20 +83,20 @@ public CagraSearchParams(Arena arena, int max_queries, int itopk_size, int max_i } public void set() { - searchParamsMS = cuvsCagraSearchParams.allocate(arena); - cuvsCagraSearchParams.max_queries(searchParamsMS, maxQueries); - cuvsCagraSearchParams.itopk_size(searchParamsMS, itopkSize); - cuvsCagraSearchParams.max_iterations(searchParamsMS, maxIterations); - cuvsCagraSearchParams.algo(searchParamsMS, algo.label); - cuvsCagraSearchParams.team_size(searchParamsMS, teamSize); - cuvsCagraSearchParams.search_width(searchParamsMS, searchWidth); - cuvsCagraSearchParams.min_iterations(searchParamsMS, minIterations); - cuvsCagraSearchParams.thread_block_size(searchParamsMS, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(searchParamsMS, hashmapMode.label); - cuvsCagraSearchParams.hashmap_min_bitlen(searchParamsMS, hashmapMinBitlen); - cuvsCagraSearchParams.hashmap_max_fill_rate(searchParamsMS, hashmapMaxFillRate); - cuvsCagraSearchParams.num_random_samplings(searchParamsMS, numRandomSamplings); - cuvsCagraSearchParams.rand_xor_mask(searchParamsMS, randXorMask); + cagraSearchParamsMS = cuvsCagraSearchParams.allocate(arena); + cuvsCagraSearchParams.max_queries(cagraSearchParamsMS, maxQueries); + cuvsCagraSearchParams.itopk_size(cagraSearchParamsMS, itopkSize); + cuvsCagraSearchParams.max_iterations(cagraSearchParamsMS, maxIterations); + cuvsCagraSearchParams.algo(cagraSearchParamsMS, algo.label); + cuvsCagraSearchParams.team_size(cagraSearchParamsMS, teamSize); + cuvsCagraSearchParams.search_width(cagraSearchParamsMS, searchWidth); + cuvsCagraSearchParams.min_iterations(cagraSearchParamsMS, minIterations); + cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMS, threadBlockSize); + cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMS, hashmapMode.label); + cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMS, hashmapMinBitlen); + cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMS, hashmapMaxFillRate); + cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMS, numRandomSamplings); + cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMS, randXorMask); } public int getMax_queries() { @@ -155,9 +156,8 @@ public String toString() { return "CagraSearchParams [max_queries=" + maxQueries + ", itopk_size=" + itopkSize + ", max_iterations=" + maxIterations + ", algo=" + algo + ", team_size=" + teamSize + ", search_width=" + searchWidth + ", min_iterations=" + minIterations + ", thread_block_size=" + threadBlockSize + ", hashmap_mode=" - + hashmapMode + ", hashmap_min_bitlen=" + hashmapMinBitlen + ", hashmap_max_fill_rate=" - + hashmapMaxFillRate + ", num_random_samplings=" + numRandomSamplings + ", rand_xor_mask=" + randXorMask - + "]"; + + hashmapMode + ", hashmap_min_bitlen=" + hashmapMinBitlen + ", hashmap_max_fill_rate=" + hashmapMaxFillRate + + ", num_random_samplings=" + numRandomSamplings + ", rand_xor_mask=" + randXorMask + "]"; } public static class Builder { @@ -248,8 +248,8 @@ public Builder withRandXorMask(long rand_xor_mask) { public CagraSearchParams build() throws Throwable { return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, algo, teamSize, searchWidth, - minIterations, threadBlockSize, hashmapMode, hashmapMinBitlen, hashmapMaxFillRate, - numRandomSamplings, randXorMask); + minIterations, threadBlockSize, hashmapMode, hashmapMinBitlen, hashmapMaxFillRate, numRandomSamplings, + randXorMask); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index 96111b0eb..027ceebe8 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -3,24 +3,20 @@ import java.util.Arrays; import java.util.Map; -import com.nvidia.cuvs.cagra.CuVSIndex.ANNAlgorithms; - public class CuVSQuery { - SearchParams searchParams; + CagraSearchParams searchParams; PreFilter preFilter; float[][] queryVectors; public Map mapping; - ANNAlgorithms algo; - - public CuVSQuery(SearchParams searchParams, PreFilter preFilter, float[][] queryVectors, - Map mapping, ANNAlgorithms algo) { + + public CuVSQuery(CagraSearchParams searchParams, PreFilter preFilter, float[][] queryVectors, + Map mapping) { super(); this.searchParams = searchParams; this.preFilter = preFilter; this.queryVectors = queryVectors; this.mapping = mapping; - this.algo = algo; } @Override @@ -29,7 +25,7 @@ public String toString() { + Arrays.toString(queryVectors) + "]"; } - public SearchParams getSearchParams() { + public CagraSearchParams getSearchParams() { return searchParams; } @@ -42,11 +38,10 @@ public float[][] getQueries() { } public static class Builder { - SearchParams searchParams; + CagraSearchParams searchParams; PreFilter preFilter; float[][] queryVectors; Map mapping; - ANNAlgorithms algo = ANNAlgorithms.CAGRA; /** * @@ -60,7 +55,7 @@ public Builder() { * @param dataset * @return */ - public Builder withSearchParams(SearchParams searchParams) { + public Builder withSearchParams(CagraSearchParams searchParams) { this.searchParams = searchParams; return this; } @@ -95,23 +90,13 @@ public Builder withMapping(Map mapping) { return this; } - /** - * - * @param params - * @return - */ - public Builder withANNAlgorithm(ANNAlgorithms algo) { - this.algo = algo; - return this; - } - /** * * @return * @throws Throwable */ public CuVSQuery build() throws Throwable { - return new CuVSQuery(searchParams, preFilter, queryVectors, mapping, algo); + return new CuVSQuery(searchParams, preFilter, queryVectors, mapping); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java index 14affd3b8..77fb36ff2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -16,7 +16,7 @@ public class CuVSResources { private Arena arena; private MethodHandle cresMH; private SymbolLookup bridge; - public MemorySegment resource; + private MemorySegment resource; /** * @@ -27,17 +27,19 @@ public CuVSResources() throws Throwable { arena = Arena.ofConfined(); File wd = new File(System.getProperty("user.dir")); - bridge = SymbolLookup.libraryLookup(wd.getParent() + "/api-sys/build/libcuvs_wrapper.so", arena); + bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); + + cresMH = linker.downcallHandle(bridge.findOrThrow("create_resource"), + FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - cresMH = linker.downcallHandle(bridge.findOrThrow("create_resource"), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - + resource = (MemorySegment) cresMH.invokeExact(rvMS); - - System.out.println("Create resource call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); - + } + + public MemorySegment getResource() { + return resource; } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java deleted file mode 100644 index df073f36e..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.nvidia.cuvs.cagra; - -import java.lang.foreign.MemorySegment; - -public class IndexParams { - - public MemorySegment indexParamsMS; - -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java deleted file mode 100644 index 6cca9bf49..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.nvidia.cuvs.cagra; - -import java.lang.foreign.MemorySegment; - -public class SearchParams { - - public MemorySegment searchParamsMS; - -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index ccc722267..8f9dc360f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -4,17 +4,13 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.invoke.VarHandle; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; public class SearchResult { - public List neighbours; // TODO: Get clarity on these two. - public List distances; - public Map results; - public Map mapping; + private Map results; + private Map mapping; SequenceLayout neighboursSL; SequenceLayout distancesSL; MemorySegment neighboursMS; @@ -30,8 +26,6 @@ public SearchResult(SequenceLayout neighboursSL, SequenceLayout distancesSL, Mem this.neighboursMS = neighboursMS; this.distancesMS = distancesMS; this.mapping = mapping; - neighbours = new ArrayList(); - distances = new ArrayList(); results = new HashMap(); this.load(); } @@ -46,4 +40,8 @@ private void load() { } } + public Map getResults() { + return results; + } + } From 1597158fdef4499c69b72e315ac522cd7ad6d0f3 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Mon, 11 Nov 2024 09:58:22 -0500 Subject: [PATCH 03/53] make topK configurable --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 1 + .../com/nvidia/cuvs/cagra/CagraIndex.java | 6 ++--- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 25 +++++++++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 8f2e5ec2e..aa8f3dbd9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -54,6 +54,7 @@ public static void main(String[] args) throws Throwable { // Query CuVSQuery query = new CuVSQuery.Builder() + .withTopK(1) .withSearchParams(cagraSearchParams) .withQueryVectors(queries) .withMapping(map) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 440ada990..5b8557d20 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -168,10 +168,10 @@ public SearchResult search(CuVSQuery query) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.queryVectors), 2, 4L, 2L, res.getResource(), - neighborsMS, distancesMS, rvMS, query.searchParams.cagraSearchParamsMS); + searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, res.getResource(), + neighborsMS, distancesMS, rvMS, query.getSearchParams().cagraSearchParamsMS); - return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, 2, query.mapping); + return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping()); } /** diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index 027ceebe8..b99314503 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -9,14 +9,16 @@ public class CuVSQuery { PreFilter preFilter; float[][] queryVectors; public Map mapping; + int topK; public CuVSQuery(CagraSearchParams searchParams, PreFilter preFilter, float[][] queryVectors, - Map mapping) { + Map mapping, int topK) { super(); this.searchParams = searchParams; this.preFilter = preFilter; this.queryVectors = queryVectors; this.mapping = mapping; + this.topK = topK; } @Override @@ -37,11 +39,20 @@ public float[][] getQueries() { return queryVectors; } + public Map getMapping() { + return mapping; + } + + public int getTopK() { + return topK; + } + public static class Builder { CagraSearchParams searchParams; PreFilter preFilter; float[][] queryVectors; Map mapping; + int topK = 2; /** * @@ -89,6 +100,16 @@ public Builder withMapping(Map mapping) { this.mapping = mapping; return this; } + + /** + * + * @param topK + * @return + */ + public Builder withTopK(int topK) { + this.topK = topK; + return this; + } /** * @@ -96,7 +117,7 @@ public Builder withMapping(Map mapping) { * @throws Throwable */ public CuVSQuery build() throws Throwable { - return new CuVSQuery(searchParams, preFilter, queryVectors, mapping); + return new CuVSQuery(searchParams, preFilter, queryVectors, mapping, topK); } } From 6f405e939400502d54014d030c08af820cad2e03 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 05:39:47 -0500 Subject: [PATCH 04/53] multiple fixes --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 6 +-- .../com/nvidia/cuvs/cagra/CagraIndex.java | 39 +++++++++---------- .../nvidia/cuvs/cagra/CagraIndexParams.java | 16 +++++--- .../cuvs/cagra/CagraIndexReference.java | 6 ++- .../nvidia/cuvs/cagra/CagraSearchParams.java | 34 +++++++++------- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 12 +++--- .../com/nvidia/cuvs/cagra/CuVSResources.java | 6 +-- .../com/nvidia/cuvs/cagra/SearchResult.java | 35 +++++++++++------ .../src/test/java/ai/rapids/cuvs/AppTest.java | 19 --------- java/internal/src/cuvs_java.c | 29 +++++++------- 10 files changed, 101 insertions(+), 101 deletions(-) delete mode 100644 java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index aa8f3dbd9..516ec5797 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -29,15 +29,13 @@ public static void main(String[] args) throws Throwable { CagraIndexParams cagraIndexParams = new CagraIndexParams.Builder() .withIntermediateGraphDegree(10) .withBuildAlgo(CuvsCagraGraphBuildAlgo.IVF_PQ) - .withWriterThreads(1) .build(); CagraSearchParams cagraSearchParams = new CagraSearchParams .Builder() - .withMaxQueries(15) .build(); - // Creating a new index + // Creating a new CAGRA index CagraIndex index = new CagraIndex.Builder(res) .withDataset(dataset) .withIndexParams(cagraIndexParams) @@ -46,7 +44,7 @@ public static void main(String[] args) throws Throwable { // Saving the index on to the disk. index.serialize(new FileOutputStream("abc.cag")); - // Loading a cagra index from disk. + // Loading a CAGRA index from disk. InputStream fin = new FileInputStream(new File("abc.cag")); CagraIndex index2 = new CagraIndex.Builder(res) .from(fin) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 5b8557d20..a3b0d108d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -20,20 +20,17 @@ public class CagraIndex { + private Arena arena; private CagraIndexParams indexParams; private final float[][] dataset; private final CuVSResources res; private CagraIndexReference ref; - - Linker linker; - Arena arena; - MethodHandle cresMH; - MethodHandle indexMH; - MethodHandle searchMH; - MethodHandle serializeMH; - MethodHandle deserializeMH; - MemorySegment dataMS; - SymbolLookup bridge; + private Linker linker; + private MethodHandle indexMH; + private MethodHandle searchMH; + private MethodHandle serializeMH; + private MethodHandle deserializeMH; + private SymbolLookup bridge; /** * @@ -76,19 +73,19 @@ private void init() throws Throwable { File wd = new File(System.getProperty("user.dir")); bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); - indexMH = linker.downcallHandle(bridge.findOrThrow("build_index"), + indexMH = linker.downcallHandle(bridge.find("build_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - searchMH = linker.downcallHandle(bridge.findOrThrow("search_index"), + searchMH = linker.downcallHandle(bridge.find("search_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMH = linker.downcallHandle(bridge.findOrThrow("serialize_index"), + serializeMH = linker.downcallHandle(bridge.find("serialize_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMH = linker.downcallHandle(bridge.findOrThrow("deserialize_index"), + deserializeMH = linker.downcallHandle(bridge.find("deserialize_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } @@ -147,7 +144,7 @@ private CagraIndexReference build() throws Throwable { MemorySegment rvMS = arena.allocate(rvML); ref = new CagraIndexReference((MemorySegment) indexMH.invokeExact(getMemorySegment(dataset), rows, cols, - res.getResource(), rvMS, indexParams.cagraIndexParamsMS)); + res.getResource(), rvMS, indexParams.getCagraIndexParamsMS())); return ref; } @@ -168,10 +165,10 @@ public SearchResult search(CuVSQuery query) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, res.getResource(), - neighborsMS, distancesMS, rvMS, query.getSearchParams().cagraSearchParamsMS); + searchMH.invokeExact(ref.getIndexMemorySegment(), getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, + res.getResource(), neighborsMS, distancesMS, rvMS, query.getSearchParams().getCagraSearchParamsMS()); - return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping()); + return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping(), query.getQueries().length); } /** @@ -184,7 +181,7 @@ public void serialize(OutputStream out) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - serializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, + serializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, getStringSegment(new StringBuilder(tmpIndexFile))); File tempFile = new File(tmpIndexFile); FileInputStream is = new FileInputStream(tempFile); @@ -206,7 +203,7 @@ public void serialize(OutputStream out) throws Throwable { public void serialize(OutputStream out, String tmpFilePath) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - serializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, + serializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, getStringSegment(new StringBuilder(tmpFilePath))); File tempFile = new File(tmpFilePath); FileInputStream is = new FileInputStream(tempFile); @@ -238,7 +235,7 @@ private CagraIndexReference deserialize(InputStream in) throws Throwable { while ((chunkLen = in.read(chunk)) != -1) { out.write(chunk, 0, chunkLen); } - deserializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, + deserializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, getStringSegment(new StringBuilder(tmpIndexFile))); in.close(); diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index 8f8e9c3ff..be9991034 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -15,12 +15,12 @@ */ public class CagraIndexParams { - Arena arena; - int intermediateGraphDegree; - int graphDegree; - CuvsCagraGraphBuildAlgo buildAlgo; - int nnDescentNiter; - public MemorySegment cagraIndexParamsMS; + private Arena arena; + private int intermediateGraphDegree; + private int graphDegree; + private CuvsCagraGraphBuildAlgo buildAlgo; + private int nnDescentNiter; + private MemorySegment cagraIndexParamsMS; public enum CuvsCagraGraphBuildAlgo { AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); @@ -66,6 +66,10 @@ public int getNn_descent_niter() { return nnDescentNiter; } + public MemorySegment getCagraIndexParamsMS() { + return cagraIndexParamsMS; + } + @Override public String toString() { return "CagraIndexParams [intermediate_graph_degree=" + intermediateGraphDegree + ", graph_degree=" + graphDegree diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java index 897ab5d0f..ab186933f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -7,7 +7,7 @@ public class CagraIndexReference { - public MemorySegment indexMemorySegment; + private MemorySegment indexMemorySegment; /** * @@ -25,4 +25,8 @@ public CagraIndexReference(MemorySegment indexMemorySegment) { this.indexMemorySegment = indexMemorySegment; } + public MemorySegment getIndexMemorySegment() { + return indexMemorySegment; + } + } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index dcf856ff9..0b2af56f5 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -24,21 +24,21 @@ */ public class CagraSearchParams { - Arena arena; - int maxQueries; - int itopkSize; - int maxIterations; - CuvsCagraSearchAlgo algo; - int teamSize; - int searchWidth; - int minIterations; - int threadBlockSize; - CuvsCagraHashMode hashmapMode; - int hashmapMinBitlen; - float hashmapMaxFillRate; - int numRandomSamplings; - long randXorMask; - public MemorySegment cagraSearchParamsMS; + private Arena arena; + private int maxQueries; + private int itopkSize; + private int maxIterations; + private CuvsCagraSearchAlgo algo; + private int teamSize; + private int searchWidth; + private int minIterations; + private int threadBlockSize; + private CuvsCagraHashMode hashmapMode; + private int hashmapMinBitlen; + private float hashmapMaxFillRate; + private int numRandomSamplings; + private long randXorMask; + private MemorySegment cagraSearchParamsMS; enum CuvsCagraSearchAlgo { SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); @@ -151,6 +151,10 @@ public long getRand_xor_mask() { return randXorMask; } + public MemorySegment getCagraSearchParamsMS() { + return cagraSearchParamsMS; + } + @Override public String toString() { return "CagraSearchParams [max_queries=" + maxQueries + ", itopk_size=" + itopkSize + ", max_iterations=" diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index b99314503..672e0c5b9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -5,11 +5,11 @@ public class CuVSQuery { - CagraSearchParams searchParams; - PreFilter preFilter; - float[][] queryVectors; - public Map mapping; - int topK; + private CagraSearchParams searchParams; + private PreFilter preFilter; + private float[][] queryVectors; + private Map mapping; + private int topK; public CuVSQuery(CagraSearchParams searchParams, PreFilter preFilter, float[][] queryVectors, Map mapping, int topK) { @@ -100,7 +100,7 @@ public Builder withMapping(Map mapping) { this.mapping = mapping; return this; } - + /** * * @param topK diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java index 77fb36ff2..ffbd5b176 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -12,11 +12,11 @@ public class CuVSResources { - private Linker linker; private Arena arena; + private Linker linker; private MethodHandle cresMH; - private SymbolLookup bridge; private MemorySegment resource; + private SymbolLookup bridge; /** * @@ -29,7 +29,7 @@ public CuVSResources() throws Throwable { File wd = new File(System.getProperty("user.dir")); bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); - cresMH = linker.downcallHandle(bridge.findOrThrow("create_resource"), + cresMH = linker.downcallHandle(bridge.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); MemoryLayout rvML = linker.canonicalLayouts().get("int"); diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index 8f9dc360f..00da62f9c 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -5,28 +5,32 @@ import java.lang.foreign.SequenceLayout; import java.lang.invoke.VarHandle; import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; public class SearchResult { - private Map results; + private List> results; private Map mapping; - SequenceLayout neighboursSL; - SequenceLayout distancesSL; - MemorySegment neighboursMS; - MemorySegment distancesMS; - int topK; + private SequenceLayout neighboursSL; + private SequenceLayout distancesSL; + private MemorySegment neighboursMS; + private MemorySegment distancesMS; + private int topK; + private int numQueries; public SearchResult(SequenceLayout neighboursSL, SequenceLayout distancesSL, MemorySegment neighboursMS, - MemorySegment distancesMS, int topK, Map mapping) { + MemorySegment distancesMS, int topK, Map mapping, int numQueries) { super(); this.topK = topK; + this.numQueries = numQueries; this.neighboursSL = neighboursSL; this.distancesSL = distancesSL; this.neighboursMS = neighboursMS; this.distancesMS = distancesMS; this.mapping = mapping; - results = new HashMap(); + results = new LinkedList>(); this.load(); } @@ -34,13 +38,22 @@ private void load() { VarHandle neighboursVH = neighboursSL.varHandle(PathElement.sequenceElement()); VarHandle distancesVH = distancesSL.varHandle(PathElement.sequenceElement()); - for (long i = 0; i < topK; i++) { + Map irm = new HashMap(); + int count = 0; + for (long i = 0; i < topK * numQueries; i++) { int id = (int) neighboursVH.get(neighboursMS, 0L, i); - results.put(mapping != null ? mapping.get(id) : id, (float) distancesVH.get(distancesMS, 0L, i)); + float dst = (float) distancesVH.get(distancesMS, 0L, i); + irm.put(mapping != null ? mapping.get(id) : id, dst); + count += 1; + if (count == topK) { + results.add(irm); + irm = new HashMap(); + count = 0; + } } } - public Map getResults() { + public List> getResults() { return results; } diff --git a/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java b/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java deleted file mode 100644 index 73037fabb..000000000 --- a/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package ai.rapids.cuvs; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import org.junit.jupiter.api.Test; - -/** - * Unit test for simple App. - */ -public class AppTest { - - /** - * Rigorous Test :-) - */ - @Test - public void shouldAnswerWithTrue() { - assertTrue(true); - } -} diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index da11cfd15..db8177e6e 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -11,12 +11,12 @@ cuvsResources_t create_resource(int *rv) { return res; } -DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) { +DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, long dimensions) { DLManagedTensor tensor; tensor.dl_tensor.data = data; tensor.dl_tensor.device.device_type = kDLCUDA; - tensor.dl_tensor.ndim = 2; + tensor.dl_tensor.ndim = dimensions; tensor.dl_tensor.dtype.code = code; tensor.dl_tensor.dtype.bits = 32; tensor.dl_tensor.dtype.lanes = 1; @@ -25,12 +25,12 @@ DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) return tensor; } - -cuvsCagraIndex_t build_index(float *dataset, long rows, long dimension, cuvsResources_t res, int *rv, + +cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsResources_t res, int *rv, cuvsCagraIndexParams_t index_params) { - int64_t dataset_shape[2] = {rows, dimension}; - DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat); + int64_t dataset_shape[2] = {rows, dimensions}; + DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat, dimensions); cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); @@ -47,27 +47,26 @@ void deserialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, cha *rv = cuvsCagraDeserialize(res, filename, index); } -void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimension, - cuvsResources_t res, int *neighbors_h, float *distances_h, int *rv, cuvsCagraSearchParams_t search_params1) { +void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, + cuvsResources_t res, int *neighbors_h, float *distances_h, int *rv, cuvsCagraSearchParams_t search_params) { uint32_t *neighbors; float *distances, *queries_d; - cuvsRMMAlloc(res, (void**) &queries_d, sizeof(float) * n_queries * dimension); + cuvsRMMAlloc(res, (void**) &queries_d, sizeof(float) * n_queries * dimensions); cuvsRMMAlloc(res, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); cuvsRMMAlloc(res, (void**) &distances, sizeof(float) * n_queries * topk); - cudaMemcpy(queries_d, queries, sizeof(float) * 4 * 2, cudaMemcpyDefault); + cudaMemcpy(queries_d, queries, sizeof(float) * n_queries * dimensions, cudaMemcpyDefault); - int64_t queries_shape[2] = {n_queries, dimension}; - DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat); + int64_t queries_shape[2] = {n_queries, dimensions}; + DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat, dimensions); int64_t neighbors_shape[2] = {n_queries, topk}; - DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt); + DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt, dimensions); int64_t distances_shape[2] = {n_queries, topk}; - DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat); + DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat, dimensions); - cuvsCagraSearchParams_t search_params; cuvsCagraSearchParamsCreate(&search_params); *rv = cuvsCagraSearch(res, search_params, index, &queries_tensor, &neighbors_tensor, From 8531be2196b41ff26feefe43dfcbb90a2ef3f3fe Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 05:57:23 -0500 Subject: [PATCH 05/53] pom file update --- java/cuvs-java/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 4bf91702f..78c3de33c 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -9,8 +9,8 @@ jar - 21 - 21 + 22 + 22 From c9b8891f6a55c6082cc71b2129fb2732d1e4bf0e Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 08:15:28 -0500 Subject: [PATCH 06/53] sample test --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 2 +- .../com/nvidia/cuvs/cagra/SearchResult.java | 6 +- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 144 ++++++++++++++++++ 3 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 516ec5797..6ccb5f5bf 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -52,7 +52,7 @@ public static void main(String[] args) throws Throwable { // Query CuVSQuery query = new CuVSQuery.Builder() - .withTopK(1) + .withTopK(3) .withSearchParams(cagraSearchParams) .withQueryVectors(queries) .withMapping(map) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index 00da62f9c..bfc7a8ba1 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -5,9 +5,11 @@ import java.lang.foreign.SequenceLayout; import java.lang.invoke.VarHandle; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.stream.Stream; public class SearchResult { @@ -38,7 +40,7 @@ private void load() { VarHandle neighboursVH = neighboursSL.varHandle(PathElement.sequenceElement()); VarHandle distancesVH = distancesSL.varHandle(PathElement.sequenceElement()); - Map irm = new HashMap(); + Map irm = new LinkedHashMap(); int count = 0; for (long i = 0; i < topK * numQueries; i++) { int id = (int) neighboursVH.get(neighboursMS, 0L, i); @@ -47,7 +49,7 @@ private void load() { count += 1; if (count == topK) { results.add(irm); - irm = new HashMap(); + irm = new LinkedHashMap(); count = 0; } } diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java new file mode 100644 index 000000000..075f0388c --- /dev/null +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -0,0 +1,144 @@ +package com.nvidia.cuvs; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.AbstractMap; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.PriorityQueue; +import java.util.Random; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import org.junit.jupiter.api.Test; + +import com.nvidia.cuvs.cagra.CagraIndex; +import com.nvidia.cuvs.cagra.CagraIndexParams; +import com.nvidia.cuvs.cagra.CagraSearchParams; +import com.nvidia.cuvs.cagra.CuVSQuery; +import com.nvidia.cuvs.cagra.CuVSResources; +import com.nvidia.cuvs.cagra.SearchResult; + +public class CagraBuildAndSearchTest { + + private static final int VECTOR_DIMENSION = 2; + private static final int DATASET_SIZE = 11; + private static final int QUERY_SIZE = 2; + private static final int TOP_K = 4; + + // Helper method to generate random vectors + private float[][] generateRandomVectors(int size) { + Random rand = new Random(); + float[][] vectors = new float[size][VECTOR_DIMENSION]; + for (int i = 0; i < size; i++) { + for (int j = 0; j < VECTOR_DIMENSION; j++) { + vectors[i][j] = rand.nextFloat(); + } + } + return vectors; + } + + // Helper method to calculate Euclidean distance + private double calculateDistance(float[] v1, float[] v2) { + double sum = 0.0; + for (int i = 0; i < v1.length; i++) { + sum += Math.pow(v1[i] - v2[i], 2); + } + return Math.sqrt(sum); + } + + // Helper method to calculate top-K distances manually + private List> getExpectedTopKItems(float[] query, float[][] dataset, int k) { + PriorityQueue> heap = new PriorityQueue<>( + Comparator.>comparingDouble(Map.Entry::getValue).reversed()); + + for (int i = 0; i < dataset.length; i++) { + double distance = calculateDistance(query, dataset[i]); + if (heap.size() < k) { + heap.offer(new AbstractMap.SimpleEntry<>(i, distance)); + } else if (distance < heap.peek().getValue()) { + heap.poll(); + heap.offer(new AbstractMap.SimpleEntry<>(i, distance)); + } + } + + return heap.stream().sorted(Comparator.comparingDouble(Map.Entry::getValue)).collect(Collectors.toList()); + } + + /** + * A basic test that checks the whole flow - from indexing to search. + * + * @throws Throwable + */ + @Test + public void testIndexingAndSearchingFlow() throws Throwable { + + float[][] dataset = generateRandomVectors(DATASET_SIZE); + float[][] queries = generateRandomVectors(QUERY_SIZE); + + // Create map for dataset IDs + Map map = IntStream + .range(0, dataset.length) + .boxed() + .collect(Collectors.toMap(i -> i, i -> i)); + + CuVSResources res = new CuVSResources(); + + // Configure index parameters + CagraIndexParams cagraIndexParams = new CagraIndexParams + .Builder() + .withIntermediateGraphDegree(10) + .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.IVF_PQ) + .build(); + + // Create the index with the dataset + CagraIndex index = new CagraIndex + .Builder(res) + .withDataset(dataset) + .withIndexParams(cagraIndexParams) + .build(); + + // Configure search parameters + CagraSearchParams cagraSearchParams = new CagraSearchParams + .Builder() + .build(); + + // Create a query object with the query vectors + CuVSQuery query = new CuVSQuery + .Builder() + .withTopK(TOP_K) + .withSearchParams(cagraSearchParams) + .withQueryVectors(queries) + .withMapping(map) + .build(); + + // Perform the search + SearchResult rslt = index.search(query); + List> queryResults = rslt.getResults(); + + // Validate the results for each query + for (int queryIndex = 0; queryIndex < QUERY_SIZE; queryIndex++) { + + // Calculate expected top-K items for the current query + List> expectedTopK = getExpectedTopKItems(queries[queryIndex], dataset, TOP_K); + + // printing expected and actual results + System.out.println("\nQuery " + queryIndex + ":"); + System.out.println("Expected Top-K Results:"); + expectedTopK.forEach(entry -> System.out.println("ID: " + entry.getKey())); + + System.out.println("Actual Top-K Results:"); + queryResults.get(queryIndex).entrySet().stream().limit(TOP_K) + .forEach(entry -> System.out.println("ID: " + entry.getKey())); + + // Check each of the topK IDs retrieved for the current query + List returnedIDs = new LinkedList(queryResults.get(queryIndex).keySet()); + for (int i = 0; i < TOP_K; i++) { + assertEquals(expectedTopK.get(i).getKey(), returnedIDs.get(i), + "Returned ID does not match with expected ID (missing or not in order)"); + } + } + } +} \ No newline at end of file From 9bb865a385856a70a8f484643de01152748eadfa Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 09:32:01 -0500 Subject: [PATCH 07/53] sample test update + other changes --- .../com/nvidia/cuvs/cagra/CagraIndex.java | 3 +- .../com/nvidia/cuvs/cagra/SearchResult.java | 2 - .../nvidia/cuvs/CagraBuildAndSearchTest.java | 106 ++++-------------- 3 files changed, 21 insertions(+), 90 deletions(-) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index a3b0d108d..39e62ca5a 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -168,7 +168,8 @@ public SearchResult search(CuVSQuery query) throws Throwable { searchMH.invokeExact(ref.getIndexMemorySegment(), getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, res.getResource(), neighborsMS, distancesMS, rvMS, query.getSearchParams().getCagraSearchParamsMS()); - return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping(), query.getQueries().length); + return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping(), + query.getQueries().length); } /** diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index bfc7a8ba1..e75518fca 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -4,12 +4,10 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.invoke.VarHandle; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.stream.Stream; public class SearchResult { diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index 075f0388c..822c3300e 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -2,15 +2,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import java.util.AbstractMap; -import java.util.Comparator; -import java.util.LinkedList; +import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.PriorityQueue; -import java.util.Random; -import java.util.stream.Collectors; -import java.util.stream.IntStream; import org.junit.jupiter.api.Test; @@ -23,50 +17,6 @@ public class CagraBuildAndSearchTest { - private static final int VECTOR_DIMENSION = 2; - private static final int DATASET_SIZE = 11; - private static final int QUERY_SIZE = 2; - private static final int TOP_K = 4; - - // Helper method to generate random vectors - private float[][] generateRandomVectors(int size) { - Random rand = new Random(); - float[][] vectors = new float[size][VECTOR_DIMENSION]; - for (int i = 0; i < size; i++) { - for (int j = 0; j < VECTOR_DIMENSION; j++) { - vectors[i][j] = rand.nextFloat(); - } - } - return vectors; - } - - // Helper method to calculate Euclidean distance - private double calculateDistance(float[] v1, float[] v2) { - double sum = 0.0; - for (int i = 0; i < v1.length; i++) { - sum += Math.pow(v1[i] - v2[i], 2); - } - return Math.sqrt(sum); - } - - // Helper method to calculate top-K distances manually - private List> getExpectedTopKItems(float[] query, float[][] dataset, int k) { - PriorityQueue> heap = new PriorityQueue<>( - Comparator.>comparingDouble(Map.Entry::getValue).reversed()); - - for (int i = 0; i < dataset.length; i++) { - double distance = calculateDistance(query, dataset[i]); - if (heap.size() < k) { - heap.offer(new AbstractMap.SimpleEntry<>(i, distance)); - } else if (distance < heap.peek().getValue()) { - heap.poll(); - heap.offer(new AbstractMap.SimpleEntry<>(i, distance)); - } - } - - return heap.stream().sorted(Comparator.comparingDouble(Map.Entry::getValue)).collect(Collectors.toList()); - } - /** * A basic test that checks the whole flow - from indexing to search. * @@ -75,21 +25,24 @@ private List> getExpectedTopKItems(float[] query, flo @Test public void testIndexingAndSearchingFlow() throws Throwable { - float[][] dataset = generateRandomVectors(DATASET_SIZE); - float[][] queries = generateRandomVectors(QUERY_SIZE); - - // Create map for dataset IDs - Map map = IntStream - .range(0, dataset.length) - .boxed() - .collect(Collectors.toMap(i -> i, i -> i)); - + // Sample data and query + float[][] dataset = {{ 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, { 0.6673192f, 0.10993068f }}; + Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); + float[][] queries = {{ 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f }}; + + // Expected search result + List> expectedQueryResults = Arrays.asList( + Map.of(3, 0.038782578f, 2, 0.3590463f, 0, 0.83774555f), + Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), + Map.of(3, 0.047766715f, 2, 0.20332818f, 0, 0.48305473f), + Map.of(1, 0.15224178f, 0, 0.59063464f, 3, 0.5986642f)); + + // Create resource CuVSResources res = new CuVSResources(); // Configure index parameters CagraIndexParams cagraIndexParams = new CagraIndexParams .Builder() - .withIntermediateGraphDegree(10) .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.IVF_PQ) .build(); @@ -108,37 +61,16 @@ public void testIndexingAndSearchingFlow() throws Throwable { // Create a query object with the query vectors CuVSQuery query = new CuVSQuery .Builder() - .withTopK(TOP_K) + .withTopK(3) .withSearchParams(cagraSearchParams) .withQueryVectors(queries) .withMapping(map) .build(); // Perform the search - SearchResult rslt = index.search(query); - List> queryResults = rslt.getResults(); - - // Validate the results for each query - for (int queryIndex = 0; queryIndex < QUERY_SIZE; queryIndex++) { - - // Calculate expected top-K items for the current query - List> expectedTopK = getExpectedTopKItems(queries[queryIndex], dataset, TOP_K); - - // printing expected and actual results - System.out.println("\nQuery " + queryIndex + ":"); - System.out.println("Expected Top-K Results:"); - expectedTopK.forEach(entry -> System.out.println("ID: " + entry.getKey())); - - System.out.println("Actual Top-K Results:"); - queryResults.get(queryIndex).entrySet().stream().limit(TOP_K) - .forEach(entry -> System.out.println("ID: " + entry.getKey())); - - // Check each of the topK IDs retrieved for the current query - List returnedIDs = new LinkedList(queryResults.get(queryIndex).keySet()); - for (int i = 0; i < TOP_K; i++) { - assertEquals(expectedTopK.get(i).getKey(), returnedIDs.get(i), - "Returned ID does not match with expected ID (missing or not in order)"); - } - } + SearchResult searchResults = index.search(query); + + // Check results + assertEquals(expectedQueryResults, searchResults.getResults(), "Results different than expected"); } } \ No newline at end of file From d40b3d0f5aeb7f7ea7aaa1cbf1eb01af84fd5649 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 12:28:52 -0500 Subject: [PATCH 08/53] sample test update + use logging --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 15 +++++--- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 37 ++++++++++++++++++- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 6ccb5f5bf..4aebe902d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -6,6 +6,9 @@ import java.io.InputStream; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; import com.nvidia.cuvs.cagra.CagraIndexParams.CuvsCagraGraphBuildAlgo; @@ -15,6 +18,9 @@ import com.nvidia.cuvs.cagra.SearchResult; public class ExampleApp { + + private static Logger LOGGER = LoggerFactory.getLogger(ExampleApp.class); + public static void main(String[] args) throws Throwable { // Sample data and query @@ -28,7 +34,7 @@ public static void main(String[] args) throws Throwable { CagraIndexParams cagraIndexParams = new CagraIndexParams.Builder() .withIntermediateGraphDegree(10) - .withBuildAlgo(CuvsCagraGraphBuildAlgo.IVF_PQ) + .withBuildAlgo(CuvsCagraGraphBuildAlgo.NN_DESCENT) .build(); CagraSearchParams cagraSearchParams = new CagraSearchParams @@ -60,11 +66,10 @@ public static void main(String[] args) throws Throwable { // Search SearchResult rslt = index.search(query); - System.out.println(rslt.getResults()); + LOGGER.info(rslt.getResults().toString()); // Search from de-serialized index SearchResult rslt2 = index2.search(query); - System.out.println(rslt2.getResults()); - + LOGGER.info(rslt2.getResults().toString()); } -} +} \ No newline at end of file diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index 822c3300e..b5f553108 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -2,11 +2,18 @@ import static org.junit.jupiter.api.Assertions.assertEquals; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.UUID; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; @@ -16,6 +23,8 @@ import com.nvidia.cuvs.cagra.SearchResult; public class CagraBuildAndSearchTest { + + private static Logger LOGGER = LoggerFactory.getLogger(CagraBuildAndSearchTest.class); /** * A basic test that checks the whole flow - from indexing to search. @@ -30,7 +39,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); float[][] queries = {{ 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f }}; - // Expected search result + // Expected search results List> expectedQueryResults = Arrays.asList( Map.of(3, 0.038782578f, 2, 0.3590463f, 0, 0.83774555f), Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), @@ -43,7 +52,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { // Configure index parameters CagraIndexParams cagraIndexParams = new CagraIndexParams .Builder() - .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.IVF_PQ) + .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.NN_DESCENT) .build(); // Create the index with the dataset @@ -53,6 +62,17 @@ public void testIndexingAndSearchingFlow() throws Throwable { .withIndexParams(cagraIndexParams) .build(); + // Saving the index on to the disk. + String fileName = UUID.randomUUID().toString() + ".cag"; + index.serialize(new FileOutputStream(fileName)); + + // Loading a CAGRA index from disk. + File testSerializedIndexFile = new File(fileName); + InputStream fin = new FileInputStream(testSerializedIndexFile); + CagraIndex index2 = new CagraIndex.Builder(res) + .from(fin) + .build(); + // Configure search parameters CagraSearchParams cagraSearchParams = new CagraSearchParams .Builder() @@ -71,6 +91,19 @@ public void testIndexingAndSearchingFlow() throws Throwable { SearchResult searchResults = index.search(query); // Check results + LOGGER.info(searchResults.getResults().toString()); assertEquals(expectedQueryResults, searchResults.getResults(), "Results different than expected"); + + // Search from de-serialized index + SearchResult searchResults2 = index2.search(query); + + // Check results + LOGGER.info(searchResults.getResults().toString()); + assertEquals(expectedQueryResults, searchResults2.getResults(), "Results different than expected"); + + // Cleanup + if (testSerializedIndexFile.exists()) { + testSerializedIndexFile.delete(); + } } } \ No newline at end of file From 1e035858c2747015aa718586c27ca6cddf2ec375 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Fri, 15 Nov 2024 11:29:56 -0500 Subject: [PATCH 09/53] variable name updates + other --- java/cuvs-java/pom.xml | 52 +- .../main/java/com/nvidia/cuvs/ExampleApp.java | 70 +- .../com/nvidia/cuvs/cagra/CagraIndex.java | 330 +- .../nvidia/cuvs/cagra/CagraIndexParams.java | 84 +- .../cuvs/cagra/CagraIndexReference.java | 24 +- .../nvidia/cuvs/cagra/CagraSearchParams.java | 204 +- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 95 +- .../com/nvidia/cuvs/cagra/CuVSResources.java | 47 +- .../nvidia/cuvs/cagra/PointerToDataset.java | 5 - .../java/com/nvidia/cuvs/cagra/PreFilter.java | 19 + .../com/nvidia/cuvs/cagra/SearchResult.java | 60 +- .../com/nvidia/cuvs/panama/DLDataType.java | 16 + .../java/com/nvidia/cuvs/panama/DLDevice.java | 16 + .../nvidia/cuvs/panama/DLManagedTensor.java | 16 + .../cuvs/panama/DLManagedTensorVersioned.java | 16 + .../com/nvidia/cuvs/panama/DLPackVersion.java | 16 + .../java/com/nvidia/cuvs/panama/DLTensor.java | 16 + .../java/com/nvidia/cuvs/panama/__fsid_t.java | 16 + .../com/nvidia/cuvs/panama/brute_force_h.java | 45 +- .../java/com/nvidia/cuvs/panama/cagra_h.java | 16 + .../panama/cuvsCagraCompressionParams.java | 16 + .../nvidia/cuvs/panama/cuvsCagraIndex.java | 16 + .../cuvs/panama/cuvsCagraIndexParams.java | 16 + .../cuvs/panama/cuvsCagraSearchParams.java | 16 + .../com/nvidia/cuvs/panama/cuvsFilter.java | 33 +- .../java/com/nvidia/cuvs/panama/dlpack_h.java | 16 + .../java/com/nvidia/cuvs/panama/hnsw_h.java | 4933 ++++++------- .../com/nvidia/cuvs/panama/ivf_flat_h.java | 5625 +++++++-------- .../java/com/nvidia/cuvs/panama/ivf_pq_h.java | 6266 +++++++++-------- .../com/nvidia/cuvs/panama/max_align_t.java | 16 + .../java/com/nvidia/cuvs/panama/results.java | 16 + .../com/nvidia/cuvs/panama/results_h.java | 16 + .../nvidia/cuvs/CagraBuildAndSearchTest.java | 61 +- java/internal/src/cuvs_java.c | 50 +- 34 files changed, 9413 insertions(+), 8846 deletions(-) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 78c3de33c..41ea18ca9 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -1,3 +1,20 @@ + @@ -11,6 +28,8 @@ 22 22 + UTF-8 + UTF-8 @@ -26,19 +45,19 @@ 1.1 - - org.slf4j - slf4j-api - 2.0.13 - + + org.slf4j + slf4j-api + 2.0.13 + + + + org.slf4j + slf4j-simple + 2.0.13 + runtime + - - org.slf4j - slf4j-simple - 2.0.13 - runtime - - org.junit.jupiter junit-jupiter-api @@ -130,6 +149,15 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.2 + + com.nvidia.cuvs,com.nvidia.cuvs.panama + ${project.build.directory} + + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 4aebe902d..592720827 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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 java.io.File; @@ -19,7 +35,7 @@ public class ExampleApp { - private static Logger LOGGER = LoggerFactory.getLogger(ExampleApp.class); + private static Logger logger = LoggerFactory.getLogger(ExampleApp.class); public static void main(String[] args) throws Throwable { @@ -30,46 +46,56 @@ public static void main(String[] args) throws Throwable { float[][] queries = { { 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f } }; - CuVSResources res = new CuVSResources(); + CuVSResources cuvsResources = new CuVSResources(); - CagraIndexParams cagraIndexParams = new CagraIndexParams.Builder() - .withIntermediateGraphDegree(10) - .withBuildAlgo(CuvsCagraGraphBuildAlgo.NN_DESCENT) - .build(); - - CagraSearchParams cagraSearchParams = new CagraSearchParams + CagraIndexParams cagraIndexParameters = new CagraIndexParams .Builder() + .withIntermediateGraphDegree(10) + .withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo.NN_DESCENT) .build(); // Creating a new CAGRA index - CagraIndex index = new CagraIndex.Builder(res) + CagraIndex cagraIndex = new CagraIndex + .Builder(cuvsResources) .withDataset(dataset) - .withIndexParams(cagraIndexParams) + .withIndexParams(cagraIndexParameters) .build(); - // Saving the index on to the disk. - index.serialize(new FileOutputStream("abc.cag")); + // Saving the CAGRA index on to the disk. + File indexFile = new File("sample_index.cag"); + cagraIndex.serialize(new FileOutputStream(indexFile)); // Loading a CAGRA index from disk. - InputStream fin = new FileInputStream(new File("abc.cag")); - CagraIndex index2 = new CagraIndex.Builder(res) - .from(fin) + InputStream fileInputStream = new FileInputStream(indexFile); + CagraIndex deserializedIndex = new CagraIndex + .Builder(cuvsResources) + .from(fileInputStream) + .build(); + + CagraSearchParams cagraSearchParameters = new CagraSearchParams + .Builder() .build(); // Query - CuVSQuery query = new CuVSQuery.Builder() + CuVSQuery cuvsQuery = new CuVSQuery + .Builder() .withTopK(3) - .withSearchParams(cagraSearchParams) + .withSearchParams(cagraSearchParameters) .withQueryVectors(queries) .withMapping(map) .build(); // Search - SearchResult rslt = index.search(query); - LOGGER.info(rslt.getResults().toString()); + SearchResult searchResult = cagraIndex.search(cuvsQuery); + logger.info(searchResult.getResults().toString()); - // Search from de-serialized index - SearchResult rslt2 = index2.search(query); - LOGGER.info(rslt2.getResults().toString()); + // Search from deserialized index + SearchResult searchResultFromDeserializedIndex = deserializedIndex.search(cuvsQuery); + logger.info(searchResultFromDeserializedIndex.getResults().toString()); + + // Cleanup + if (indexFile.exists()) { + indexFile.delete(); + } } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 39e62ca5a..75d12736e 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.io.File; @@ -18,313 +34,229 @@ import java.lang.invoke.VarHandle; import java.util.UUID; +/** + * CagraIndex encapsulates the implementation of crucial methods for interacting + * with the CAGRA index. + *

+ * CAGRA is a graph-based nearest neighbors algorithm that was built from the + * ground up for GPU acceleration. CAGRA demonstrates state-of-the art index + * build and query performance for both small- and large-batch sized search. + */ public class CagraIndex { - private Arena arena; - private CagraIndexParams indexParams; private final float[][] dataset; - private final CuVSResources res; - private CagraIndexReference ref; + private final CuVSResources cuvsResources; + private Arena arena; + private CagraIndexParams cagraIndexParameters; + private CagraIndexReference cagraIndesReference; private Linker linker; - private MethodHandle indexMH; - private MethodHandle searchMH; - private MethodHandle serializeMH; - private MethodHandle deserializeMH; - private SymbolLookup bridge; - - /** - * - * @param indexParams - * @param dataset - * @param mapping - * @param res - * @throws Throwable - */ - private CagraIndex(CagraIndexParams indexParams, float[][] dataset, CuVSResources res) throws Throwable { - this.indexParams = indexParams; + private MethodHandle indexMethodHandle; + private MethodHandle searchMethodHandle; + private MethodHandle serializeMethodHandle; + private MethodHandle deserializeMethodHandle; + private SymbolLookup symbolLookup; + + private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources cuvsResources) + throws Throwable { + this.cagraIndexParameters = indexParameters; this.dataset = dataset; this.init(); - this.res = res; - this.ref = build(); + this.cuvsResources = cuvsResources; + this.cagraIndesReference = build(); } - /** - * - * @param in - * @param res - * @throws Throwable - */ - private CagraIndex(InputStream in, CuVSResources res) throws Throwable { - this.indexParams = null; + private CagraIndex(InputStream inputStream, CuVSResources cuvsResources) throws Throwable { + this.cagraIndexParameters = null; this.dataset = null; - this.res = res; + this.cuvsResources = cuvsResources; this.init(); - this.ref = deserialize(in); + this.cagraIndesReference = deserialize(inputStream); } - /** - * - * @throws Throwable - */ private void init() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); - File wd = new File(System.getProperty("user.dir")); - bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); + File workingDirectory = new File(System.getProperty("user.dir")); + symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - indexMH = linker.downcallHandle(bridge.find("build_index").get(), + indexMethodHandle = linker.downcallHandle(symbolLookup.find("build_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - searchMH = linker.downcallHandle(bridge.find("search_index").get(), + searchMethodHandle = linker.downcallHandle(symbolLookup.find("search_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMH = linker.downcallHandle(bridge.find("serialize_index").get(), + serializeMethodHandle = linker.downcallHandle(symbolLookup.find("serialize_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMH = linker.downcallHandle(bridge.find("deserialize_index").get(), + deserializeMethodHandle = linker.downcallHandle(symbolLookup.find("deserialize_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } - /** - * Java String -> C char* - * - * @param str - * @return MemorySegment - */ - public MemorySegment getStringSegment(StringBuilder str) { - str.append('\0'); - MemoryLayout sq = MemoryLayout.sequenceLayout(str.length(), linker.canonicalLayouts().get("char")); + public MemorySegment getStringSegment(StringBuilder string) { + string.append('\0'); + MemoryLayout sq = MemoryLayout.sequenceLayout(string.length(), linker.canonicalLayouts().get("char")); MemorySegment fln = arena.allocate(sq); - for (int i = 0; i < str.length(); i++) { + for (int i = 0; i < string.length(); i++) { VarHandle flnVH = sq.varHandle(PathElement.sequenceElement(i)); - flnVH.set(fln, 0L, (byte) str.charAt(i)); + flnVH.set(fln, 0L, (byte) string.charAt(i)); } return fln; } - /** - * - * @param data - * @return - */ private MemorySegment getMemorySegment(float[][] data) { long rows = data.length; long cols = data[0].length; - MemoryLayout dataML = MemoryLayout.sequenceLayout(rows, + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); - MemorySegment dataMS = arena.allocate(dataML); + MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { - VarHandle element = dataML.arrayElementVarHandle(PathElement.sequenceElement(r), + VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), PathElement.sequenceElement(c)); - element.set(dataMS, 0, 0, data[r][c]); + element.set(dataMemorySegment, 0, 0, data[r][c]); } } - return dataMS; + return dataMemorySegment; } - /** - * - * @return - * @throws Throwable - */ private CagraIndexReference build() throws Throwable { long rows = dataset.length; long cols = dataset[0].length; - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); + MemoryLayout returnvalueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnvalueMemorySegment = arena.allocate(returnvalueMemoryLayout); - ref = new CagraIndexReference((MemorySegment) indexMH.invokeExact(getMemorySegment(dataset), rows, cols, - res.getResource(), rvMS, indexParams.getCagraIndexParamsMS())); + cagraIndesReference = new CagraIndexReference((MemorySegment) indexMethodHandle.invokeExact( + getMemorySegment(dataset), rows, cols, cuvsResources.getCuvsResourcesMemorySegment(), returnvalueMemorySegment, + cagraIndexParameters.getCagraIndexParamsMemorySegment())); - return ref; + return cagraIndesReference; } - /** - * - * @param params - * @param queryVectors - * @return - * @throws Throwable - */ - public SearchResult search(CuVSQuery query) throws Throwable { - - SequenceLayout neighborsSL = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); - SequenceLayout distancesSL = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); - MemorySegment neighborsMS = arena.allocate(neighborsSL); - MemorySegment distancesMS = arena.allocate(distancesSL); - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); - - searchMH.invokeExact(ref.getIndexMemorySegment(), getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, - res.getResource(), neighborsMS, distancesMS, rvMS, query.getSearchParams().getCagraSearchParamsMS()); - - return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping(), - query.getQueries().length); + public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { + + SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); + SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); + MemorySegment neighborsMemorySegment = arena.allocate(neighborsSequenceLayout); + MemorySegment distancesMemorySegment = arena.allocate(distancesSequenceLayout); + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); + + searchMethodHandle.invokeExact(cagraIndesReference.getIndexMemorySegment(), + getMemorySegment(cuvsQuery.getQueryVectors()), cuvsQuery.getTopK(), 4L, 2L, + cuvsResources.getCuvsResourcesMemorySegment(), neighborsMemorySegment, distancesMemorySegment, + returnValueMemorySegment, cuvsQuery.getCagraSearchParameters().getCagraSearchParamsMS()); + + return new SearchResult(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, + distancesMemorySegment, cuvsQuery.getTopK(), cuvsQuery.getMapping(), cuvsQuery.getQueryVectors().length); } - /** - * - * @param out - * @param tmpFilePath - * @throws Throwable - */ - public void serialize(OutputStream out) throws Throwable { - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); + public void serialize(OutputStream outputStream) throws Throwable { + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - serializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, + serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), + cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, getStringSegment(new StringBuilder(tmpIndexFile))); File tempFile = new File(tmpIndexFile); - FileInputStream is = new FileInputStream(tempFile); + FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; - int chunkLen = 0; - while ((chunkLen = is.read(chunk)) != -1) { - out.write(chunk, 0, chunkLen); + int chunkLength = 0; + while ((chunkLength = fileInputStream.read(chunk)) != -1) { + outputStream.write(chunk, 0, chunkLength); } - is.close(); + fileInputStream.close(); tempFile.delete(); } - /** - * - * @param out - * @param tmpFilePath - * @throws Throwable - */ - public void serialize(OutputStream out, String tmpFilePath) throws Throwable { - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); - serializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, + public void serialize(OutputStream outputStream, String tmpFilePath) throws Throwable { + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); + serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), + cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, getStringSegment(new StringBuilder(tmpFilePath))); File tempFile = new File(tmpFilePath); - FileInputStream is = new FileInputStream(tempFile); + FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; - int chunkLen = 0; - while ((chunkLen = is.read(chunk)) != -1) { - out.write(chunk, 0, chunkLen); + int chunkLength = 0; + while ((chunkLength = fileInputStream.read(chunk)) != -1) { + outputStream.write(chunk, 0, chunkLength); } - is.close(); + fileInputStream.close(); tempFile.delete(); } - /** - * - * @param in - * @return - * @throws Throwable - */ - private CagraIndexReference deserialize(InputStream in) throws Throwable { - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); + private CagraIndexReference deserialize(InputStream inputStream) throws Throwable { + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - CagraIndexReference ref = new CagraIndexReference(); + CagraIndexReference cagraIndexReference = new CagraIndexReference(); File tempFile = new File(tmpIndexFile); - FileOutputStream out = new FileOutputStream(tempFile); + FileOutputStream fileOutputStream = new FileOutputStream(tempFile); byte[] chunk = new byte[1024]; - int chunkLen = 0; - while ((chunkLen = in.read(chunk)) != -1) { - out.write(chunk, 0, chunkLen); + int chunkLength = 0; + while ((chunkLength = inputStream.read(chunk)) != -1) { + fileOutputStream.write(chunk, 0, chunkLength); } - deserializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, + deserializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), + cagraIndexReference.getIndexMemorySegment(), returnValueMemorySegment, getStringSegment(new StringBuilder(tmpIndexFile))); - in.close(); - out.close(); + inputStream.close(); + fileOutputStream.close(); tempFile.delete(); - return ref; + return cagraIndexReference; } - /** - * - * @return - */ public CagraIndexParams getParams() { - return indexParams; - } - - /** - * - * @return - */ - public PointerToDataset getDataset() { - return null; + return cagraIndexParameters; } - /** - * - * @return - */ public CuVSResources getResources() { - return res; + return cuvsResources; } public static class Builder { - private CagraIndexParams indexParams; - float[][] dataset; - CuVSResources res; - - InputStream in; - - /** - * - * @param res - */ - public Builder(CuVSResources res) { - this.res = res; + + private CagraIndexParams cagraIndexParams; + private float[][] dataset; + private CuVSResources cuvsResources; + private InputStream inputStream; + + public Builder(CuVSResources cuvsResources) { + this.cuvsResources = cuvsResources; } - /** - * - * @param in - * @return - */ - public Builder from(InputStream in) { - this.in = in; + public Builder from(InputStream inputStream) { + this.inputStream = inputStream; return this; } - /** - * - * @param dataset - * @return - */ public Builder withDataset(float[][] dataset) { this.dataset = dataset; return this; } - /** - * - * @param params - * @return - */ - public Builder withIndexParams(CagraIndexParams indexParams) { - this.indexParams = indexParams; + public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { + this.cagraIndexParams = cagraIndexParameters; return this; } - /** - * - * @return - * @throws Throwable - */ public CagraIndex build() throws Throwable { - if (in != null) { - return new CagraIndex(in, res); + if (inputStream != null) { + return new CagraIndex(inputStream, cuvsResources); } else { - return new CagraIndex(indexParams, dataset, res); + return new CagraIndex(cagraIndexParams, dataset, cuvsResources); } } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index be9991034..3030e458f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.lang.foreign.Arena; @@ -6,21 +22,16 @@ import com.nvidia.cuvs.panama.cuvsCagraIndexParams; /* -* struct cuvsCagraIndexParams { -* size_t intermediate_graph_degree; -* size_t graph_degree; -* enum cuvsCagraGraphBuildAlgo build_algo; -* size_t nn_descent_niter; -* } +* Supplemental parameters to build CAGRA Index. */ public class CagraIndexParams { private Arena arena; private int intermediateGraphDegree; private int graphDegree; - private CuvsCagraGraphBuildAlgo buildAlgo; + private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; private int nnDescentNiter; - private MemorySegment cagraIndexParamsMS; + private MemorySegment cagraIndexParamsMemorySegment; public enum CuvsCagraGraphBuildAlgo { AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); @@ -32,58 +43,59 @@ private CuvsCagraGraphBuildAlgo(int label) { } } - public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, CuvsCagraGraphBuildAlgo buildAlgo, - int nnDescentNiter) { + public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, + CuvsCagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter) { this.arena = arena; this.intermediateGraphDegree = intermediateGraphDegree; this.graphDegree = graphDegree; - this.buildAlgo = buildAlgo; + this.cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo; this.nnDescentNiter = nnDescentNiter; this.set(); } private void set() { - cagraIndexParamsMS = cuvsCagraIndexParams.allocate(arena); - cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMS, intermediateGraphDegree); - cuvsCagraIndexParams.graph_degree(cagraIndexParamsMS, graphDegree); - cuvsCagraIndexParams.build_algo(cagraIndexParamsMS, buildAlgo.label); - cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMS, nnDescentNiter); + cagraIndexParamsMemorySegment = cuvsCagraIndexParams.allocate(arena); + cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMemorySegment, intermediateGraphDegree); + cuvsCagraIndexParams.graph_degree(cagraIndexParamsMemorySegment, graphDegree); + cuvsCagraIndexParams.build_algo(cagraIndexParamsMemorySegment, cuvsCagraGraphBuildAlgo.label); + cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMemorySegment, nnDescentNiter); } - public int getIntermediate_graph_degree() { + public int getIntermediateGraphDegree() { return intermediateGraphDegree; } - public int getGraph_degree() { + public int getGraphDegree() { return graphDegree; } - public CuvsCagraGraphBuildAlgo getBuild_algo() { - return buildAlgo; + public CuvsCagraGraphBuildAlgo getCuvsCagraGraphBuildAlgo() { + return cuvsCagraGraphBuildAlgo; } - public int getNn_descent_niter() { + public int getNNDescentNiter() { return nnDescentNiter; } - public MemorySegment getCagraIndexParamsMS() { - return cagraIndexParamsMS; + public MemorySegment getCagraIndexParamsMemorySegment() { + return cagraIndexParamsMemorySegment; } @Override public String toString() { - return "CagraIndexParams [intermediate_graph_degree=" + intermediateGraphDegree + ", graph_degree=" + graphDegree - + ", build_algo=" + buildAlgo + ", nn_descent_niter=" + nnDescentNiter + "]"; + return "CagraIndexParams [arena=" + arena + ", intermediateGraphDegree=" + intermediateGraphDegree + + ", graphDegree=" + graphDegree + ", cuvsCagraGraphBuildAlgo=" + cuvsCagraGraphBuildAlgo + ", nnDescentNiter=" + + nnDescentNiter + ", cagraIndexParamsMemorySegment=" + cagraIndexParamsMemorySegment + "]"; } public static class Builder { - Arena arena; - int intermediateGraphDegree = 128; - int graphDegree = 64; - CuvsCagraGraphBuildAlgo buildAlgo = CuvsCagraGraphBuildAlgo.IVF_PQ; - int nnDescentNiter = 20; - int writerThreads = 1; + private Arena arena; + private int intermediateGraphDegree = 128; + private int graphDegree = 64; + private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo.NN_DESCENT; + private int nnDescentNiter = 20; + private int writerThreads = 1; public Builder() { this.arena = Arena.ofConfined(); @@ -99,8 +111,8 @@ public Builder withGraphDegree(int graphDegree) { return this; } - public Builder withBuildAlgo(CuvsCagraGraphBuildAlgo buildAlgo) { - this.buildAlgo = buildAlgo; + public Builder withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo) { + this.cuvsCagraGraphBuildAlgo = cuvsCagraGraphBuildAlgo; return this; } @@ -115,9 +127,7 @@ public Builder withWriterThreads(int writerThreads) { } public CagraIndexParams build() throws Throwable { - return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, buildAlgo, nnDescentNiter); + return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, nnDescentNiter); } - } - -} +} \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java index ab186933f..2eab62147 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.lang.foreign.Arena; @@ -9,18 +25,11 @@ public class CagraIndexReference { private MemorySegment indexMemorySegment; - /** - * - */ public CagraIndexReference() { Arena arena = Arena.ofConfined(); indexMemorySegment = cuvsCagraIndex.allocate(arena); } - /** - * - * @param indexMemorySegment - */ public CagraIndexReference(MemorySegment indexMemorySegment) { this.indexMemorySegment = indexMemorySegment; } @@ -28,5 +37,4 @@ public CagraIndexReference(MemorySegment indexMemorySegment) { public MemorySegment getIndexMemorySegment() { return indexMemorySegment; } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index 0b2af56f5..df4398fd2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.lang.foreign.Arena; @@ -5,40 +21,23 @@ import com.nvidia.cuvs.panama.cuvsCagraSearchParams; -/* -* struct cuvsCagraSearchParams { -* size_t max_queries; -* size_t itopk_size; -* size_t max_iterations; -* enum cuvsCagraSearchAlgo algo; -* size_t team_size; -* size_t search_width; -* size_t min_iterations; -* size_t thread_block_size; -* enum cuvsCagraHashMode hashmap_mode; -* size_t hashmap_min_bitlen; -* float hashmap_max_fill_rate; -* uint32_t num_random_samplings; -* uint64_t rand_xor_mask; -* } -*/ public class CagraSearchParams { private Arena arena; private int maxQueries; private int itopkSize; private int maxIterations; - private CuvsCagraSearchAlgo algo; + private CuvsCagraSearchAlgo cuvsCagraSearchAlgo; private int teamSize; private int searchWidth; private int minIterations; private int threadBlockSize; - private CuvsCagraHashMode hashmapMode; + private CuvsCagraHashMode cuvsCagraHashMode; private int hashmapMinBitlen; private float hashmapMaxFillRate; private int numRandomSamplings; private long randXorMask; - private MemorySegment cagraSearchParamsMS; + private MemorySegment cagraSearchParamsMemorySegment; enum CuvsCagraSearchAlgo { SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); @@ -48,7 +47,6 @@ enum CuvsCagraSearchAlgo { private CuvsCagraSearchAlgo(int label) { this.label = label; } - } enum CuvsCagraHashMode { @@ -61,42 +59,43 @@ private CuvsCagraHashMode(int label) { } } - public CagraSearchParams(Arena arena, int max_queries, int itopk_size, int max_iterations, CuvsCagraSearchAlgo algo, - int team_size, int search_width, int min_iterations, int thread_block_size, CuvsCagraHashMode hashmap_mode, - int hashmap_min_bitlen, float hashmap_max_fill_rate, int num_random_samplings, long rand_xor_mask) { + public CagraSearchParams(Arena arena, int maxQueries, int itopkSize, int maxIterations, + CuvsCagraSearchAlgo cuvsCagraSearchAlgo, int teamSize, int searchWidth, int minIterations, int threadBlockSize, + CuvsCagraHashMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, + long randXorMask) { super(); this.arena = arena; - this.maxQueries = max_queries; - this.itopkSize = itopk_size; - this.maxIterations = max_iterations; - this.algo = algo; - this.teamSize = team_size; - this.searchWidth = search_width; - this.minIterations = min_iterations; - this.threadBlockSize = thread_block_size; - this.hashmapMode = hashmap_mode; - this.hashmapMinBitlen = hashmap_min_bitlen; - this.hashmapMaxFillRate = hashmap_max_fill_rate; - this.numRandomSamplings = num_random_samplings; - this.randXorMask = rand_xor_mask; + this.maxQueries = maxQueries; + this.itopkSize = itopkSize; + this.maxIterations = maxIterations; + this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; + this.teamSize = teamSize; + this.searchWidth = searchWidth; + this.minIterations = minIterations; + this.threadBlockSize = threadBlockSize; + this.cuvsCagraHashMode = hashmapMode; + this.hashmapMinBitlen = hashmapMinBitlen; + this.hashmapMaxFillRate = hashmapMaxFillRate; + this.numRandomSamplings = numRandomSamplings; + this.randXorMask = randXorMask; this.set(); } public void set() { - cagraSearchParamsMS = cuvsCagraSearchParams.allocate(arena); - cuvsCagraSearchParams.max_queries(cagraSearchParamsMS, maxQueries); - cuvsCagraSearchParams.itopk_size(cagraSearchParamsMS, itopkSize); - cuvsCagraSearchParams.max_iterations(cagraSearchParamsMS, maxIterations); - cuvsCagraSearchParams.algo(cagraSearchParamsMS, algo.label); - cuvsCagraSearchParams.team_size(cagraSearchParamsMS, teamSize); - cuvsCagraSearchParams.search_width(cagraSearchParamsMS, searchWidth); - cuvsCagraSearchParams.min_iterations(cagraSearchParamsMS, minIterations); - cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMS, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMS, hashmapMode.label); - cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMS, hashmapMinBitlen); - cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMS, hashmapMaxFillRate); - cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMS, numRandomSamplings); - cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMS, randXorMask); + cagraSearchParamsMemorySegment = cuvsCagraSearchParams.allocate(arena); + cuvsCagraSearchParams.max_queries(cagraSearchParamsMemorySegment, maxQueries); + cuvsCagraSearchParams.itopk_size(cagraSearchParamsMemorySegment, itopkSize); + cuvsCagraSearchParams.max_iterations(cagraSearchParamsMemorySegment, maxIterations); + cuvsCagraSearchParams.algo(cagraSearchParamsMemorySegment, cuvsCagraSearchAlgo.label); + cuvsCagraSearchParams.team_size(cagraSearchParamsMemorySegment, teamSize); + cuvsCagraSearchParams.search_width(cagraSearchParamsMemorySegment, searchWidth); + cuvsCagraSearchParams.min_iterations(cagraSearchParamsMemorySegment, minIterations); + cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMemorySegment, threadBlockSize); + cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMemorySegment, cuvsCagraHashMode.label); + cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMemorySegment, hashmapMinBitlen); + cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMemorySegment, hashmapMaxFillRate); + cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMemorySegment, numRandomSamplings); + cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMemorySegment, randXorMask); } public int getMax_queries() { @@ -112,7 +111,7 @@ public int getMax_iterations() { } public CuvsCagraSearchAlgo getAlgo() { - return algo; + return cuvsCagraSearchAlgo; } public int getTeam_size() { @@ -132,7 +131,7 @@ public int getThread_block_size() { } public CuvsCagraHashMode getHashmap_mode() { - return hashmapMode; + return cuvsCagraHashMode; } public int getHashmap_min_bitlen() { @@ -152,108 +151,109 @@ public long getRand_xor_mask() { } public MemorySegment getCagraSearchParamsMS() { - return cagraSearchParamsMS; + return cagraSearchParamsMemorySegment; } @Override public String toString() { - return "CagraSearchParams [max_queries=" + maxQueries + ", itopk_size=" + itopkSize + ", max_iterations=" - + maxIterations + ", algo=" + algo + ", team_size=" + teamSize + ", search_width=" + searchWidth - + ", min_iterations=" + minIterations + ", thread_block_size=" + threadBlockSize + ", hashmap_mode=" - + hashmapMode + ", hashmap_min_bitlen=" + hashmapMinBitlen + ", hashmap_max_fill_rate=" + hashmapMaxFillRate - + ", num_random_samplings=" + numRandomSamplings + ", rand_xor_mask=" + randXorMask + "]"; + return "CagraSearchParams [arena=" + arena + ", maxQueries=" + maxQueries + ", itopkSize=" + itopkSize + + ", maxIterations=" + maxIterations + ", cuvsCagraSearchAlgo=" + cuvsCagraSearchAlgo + ", teamSize=" + teamSize + + ", searchWidth=" + searchWidth + ", minIterations=" + minIterations + ", threadBlockSize=" + threadBlockSize + + ", cuvsCagraHashMode=" + cuvsCagraHashMode + ", hashmapMinBitlen=" + hashmapMinBitlen + + ", hashmapMaxFillRate=" + hashmapMaxFillRate + ", numRandomSamplings=" + numRandomSamplings + ", randXorMask=" + + randXorMask + ", cagraSearchParamsMemorySegment=" + cagraSearchParamsMemorySegment + "]"; } public static class Builder { - Arena arena; - int maxQueries = 1; - int itopkSize = 2; - int maxIterations = 3; - CuvsCagraSearchAlgo algo = CuvsCagraSearchAlgo.MULTI_KERNEL; - int teamSize = 4; - int searchWidth = 5; - int minIterations = 6; - int threadBlockSize = 7; - CuvsCagraHashMode hashmapMode = CuvsCagraHashMode.AUTO_HASH; - int hashmapMinBitlen = 8; - float hashmapMaxFillRate = 9.0f; - int numRandomSamplings = 10; - long randXorMask = 11L; + private Arena arena; + private int maxQueries = 1; + private int itopkSize = 2; + private int maxIterations = 3; + private CuvsCagraSearchAlgo cuvsCagraSearchAlgo = CuvsCagraSearchAlgo.MULTI_KERNEL; + private int teamSize = 4; + private int searchWidth = 5; + private int minIterations = 6; + private int threadBlockSize = 7; + private CuvsCagraHashMode cuvsCagraHashMode = CuvsCagraHashMode.AUTO_HASH; + private int hashmapMinBitlen = 8; + private float hashmapMaxFillRate = 9.0f; + private int numRandomSamplings = 10; + private long randXorMask = 11L; public Builder() { this.arena = Arena.ofConfined(); } - public Builder withMaxQueries(int max_queries) { - this.maxQueries = max_queries; + public Builder withMaxQueries(int maxQueries) { + this.maxQueries = maxQueries; return this; } - public Builder withItopkSize(int itopk_size) { - this.itopkSize = itopk_size; + public Builder withItopkSize(int itopkSize) { + this.itopkSize = itopkSize; return this; } - public Builder withMaxIterations(int max_iterations) { - this.maxIterations = max_iterations; + public Builder withMaxIterations(int maxIterations) { + this.maxIterations = maxIterations; return this; } - public Builder withAlgo(CuvsCagraSearchAlgo algo) { - this.algo = algo; + public Builder withAlgo(CuvsCagraSearchAlgo cuvsCagraSearchAlgo) { + this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; return this; } - public Builder withTeamSize(int team_size) { - this.teamSize = team_size; + public Builder withTeamSize(int teamSize) { + this.teamSize = teamSize; return this; } - public Builder withSearchWidth(int search_width) { - this.searchWidth = search_width; + public Builder withSearchWidth(int searchWidth) { + this.searchWidth = searchWidth; return this; } - public Builder withMinIterations(int min_iterations) { - this.minIterations = min_iterations; + public Builder withMinIterations(int minIterations) { + this.minIterations = minIterations; return this; } - public Builder withThreadBlockSize(int thread_block_size) { - this.threadBlockSize = thread_block_size; + public Builder withThreadBlockSize(int threadBlockSize) { + this.threadBlockSize = threadBlockSize; return this; } - public Builder withHashmapMode(CuvsCagraHashMode hashmap_mode) { - this.hashmapMode = hashmap_mode; + public Builder withHashmapMode(CuvsCagraHashMode cuvsCagraHashMode) { + this.cuvsCagraHashMode = cuvsCagraHashMode; return this; } - public Builder withHashmapMinBitlen(int hashmap_min_bitlen) { - this.hashmapMinBitlen = hashmap_min_bitlen; + public Builder withHashmapMinBitlen(int hashmapMinBitlen) { + this.hashmapMinBitlen = hashmapMinBitlen; return this; } - public Builder withHashmapMaxFillRate(float hashmap_max_fill_rate) { - this.hashmapMaxFillRate = hashmap_max_fill_rate; + public Builder withHashmapMaxFillRate(float hashmapMaxFillRate) { + this.hashmapMaxFillRate = hashmapMaxFillRate; return this; } - public Builder withNumRandomSamplings(int num_random_samplings) { - this.numRandomSamplings = num_random_samplings; + public Builder withNumRandomSamplings(int numRandomSamplings) { + this.numRandomSamplings = numRandomSamplings; return this; } - public Builder withRandXorMask(long rand_xor_mask) { - this.randXorMask = rand_xor_mask; + public Builder withRandXorMask(long randXorMask) { + this.randXorMask = randXorMask; return this; } public CagraSearchParams build() throws Throwable { - return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, algo, teamSize, searchWidth, - minIterations, threadBlockSize, hashmapMode, hashmapMinBitlen, hashmapMaxFillRate, numRandomSamplings, - randXorMask); + return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, cuvsCagraSearchAlgo, teamSize, + searchWidth, minIterations, threadBlockSize, cuvsCagraHashMode, hashmapMinBitlen, hashmapMaxFillRate, + numRandomSamplings, randXorMask); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index 672e0c5b9..1fc3321de 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.util.Arrays; @@ -5,37 +21,31 @@ public class CuVSQuery { - private CagraSearchParams searchParams; + private CagraSearchParams cagraSearchParameters; private PreFilter preFilter; private float[][] queryVectors; private Map mapping; private int topK; - public CuVSQuery(CagraSearchParams searchParams, PreFilter preFilter, float[][] queryVectors, + public CuVSQuery(CagraSearchParams cagraSearchParameters, PreFilter preFilter, float[][] queryVectors, Map mapping, int topK) { super(); - this.searchParams = searchParams; + this.cagraSearchParameters = cagraSearchParameters; this.preFilter = preFilter; this.queryVectors = queryVectors; this.mapping = mapping; this.topK = topK; } - @Override - public String toString() { - return "CuVSQuery [searchParams=" + searchParams + ", preFilter=" + preFilter + ", queries=" - + Arrays.toString(queryVectors) + "]"; - } - - public CagraSearchParams getSearchParams() { - return searchParams; + public CagraSearchParams getCagraSearchParameters() { + return cagraSearchParameters; } public PreFilter getPreFilter() { return preFilter; } - public float[][] getQueries() { + public float[][] getQueryVectors() { return queryVectors; } @@ -47,78 +57,47 @@ public int getTopK() { return topK; } + @Override + public String toString() { + return "CuVSQuery [cagraSearchParameters=" + cagraSearchParameters + ", preFilter=" + preFilter + ", queryVectors=" + + Arrays.toString(queryVectors) + ", mapping=" + mapping + ", topK=" + topK + "]"; + } + public static class Builder { - CagraSearchParams searchParams; - PreFilter preFilter; - float[][] queryVectors; - Map mapping; - int topK = 2; - - /** - * - * @param res - */ - public Builder() { - } - /** - * - * @param dataset - * @return - */ - public Builder withSearchParams(CagraSearchParams searchParams) { - this.searchParams = searchParams; + private CagraSearchParams cagraSearchParams; + private PreFilter preFilter; + private float[][] queryVectors; + private Map mapping; + private int topK = 2; + + public Builder withSearchParams(CagraSearchParams cagraSearchParams) { + this.cagraSearchParams = cagraSearchParams; return this; } - /** - * - * @param queryVectors - * @return - */ public Builder withQueryVectors(float[][] queryVectors) { this.queryVectors = queryVectors; return this; } - /** - * - * @param preFilter - * @return - */ public Builder withPreFilter(PreFilter preFilter) { this.preFilter = preFilter; return this; } - /** - * - * @param mapping - * @return - */ public Builder withMapping(Map mapping) { this.mapping = mapping; return this; } - /** - * - * @param topK - * @return - */ public Builder withTopK(int topK) { this.topK = topK; return this; } - /** - * - * @return - * @throws Throwable - */ public CuVSQuery build() throws Throwable { - return new CuVSQuery(searchParams, preFilter, queryVectors, mapping, topK); + return new CuVSQuery(cagraSearchParams, preFilter, queryVectors, mapping, topK); } } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java index ffbd5b176..6ab5b7554 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.io.File; @@ -14,32 +30,27 @@ public class CuVSResources { private Arena arena; private Linker linker; - private MethodHandle cresMH; - private MemorySegment resource; - private SymbolLookup bridge; - - /** - * - * @throws Throwable - */ + private MethodHandle createResourcesMemoryHandler; + private MemorySegment cuvsResourcesMemorySegment; + private SymbolLookup symbolLookup; + public CuVSResources() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); - File wd = new File(System.getProperty("user.dir")); - bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); + File workingDirectory = new File(System.getProperty("user.dir")); + symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - cresMH = linker.downcallHandle(bridge.find("create_resource").get(), + createResourcesMemoryHandler = linker.downcallHandle(symbolLookup.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - resource = (MemorySegment) cresMH.invokeExact(rvMS); + cuvsResourcesMemorySegment = (MemorySegment) createResourcesMemoryHandler.invokeExact(returnValueMemorySegment); } - public MemorySegment getResource() { - return resource; + public MemorySegment getCuvsResourcesMemorySegment() { + return cuvsResourcesMemorySegment; } - -} +} \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java deleted file mode 100644 index c5fc4f074..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.nvidia.cuvs.cagra; - -public class PointerToDataset { - -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java index b8310af31..5034d2e45 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java @@ -1,5 +1,24 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; +/** + * TODO: Pending implementation + */ public class PreFilter { } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index e75518fca..0eea21c9a 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.lang.foreign.MemoryLayout.PathElement; @@ -13,41 +29,42 @@ public class SearchResult { private List> results; private Map mapping; - private SequenceLayout neighboursSL; - private SequenceLayout distancesSL; - private MemorySegment neighboursMS; - private MemorySegment distancesMS; + private SequenceLayout neighboursSequenceLayout; + private SequenceLayout distancesSequenceLayout; + private MemorySegment neighboursMemorySegment; + private MemorySegment distancesMemorySegment; private int topK; - private int numQueries; + private int numberOfQueries; - public SearchResult(SequenceLayout neighboursSL, SequenceLayout distancesSL, MemorySegment neighboursMS, - MemorySegment distancesMS, int topK, Map mapping, int numQueries) { + public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, + MemorySegment neighboursMemorySegment, MemorySegment distancesMemorySegment, int topK, + Map mapping, int numberOfQueries) { super(); this.topK = topK; - this.numQueries = numQueries; - this.neighboursSL = neighboursSL; - this.distancesSL = distancesSL; - this.neighboursMS = neighboursMS; - this.distancesMS = distancesMS; + this.numberOfQueries = numberOfQueries; + this.neighboursSequenceLayout = neighboursSequenceLayout; + this.distancesSequenceLayout = distancesSequenceLayout; + this.neighboursMemorySegment = neighboursMemorySegment; + this.distancesMemorySegment = distancesMemorySegment; this.mapping = mapping; results = new LinkedList>(); this.load(); } private void load() { - VarHandle neighboursVH = neighboursSL.varHandle(PathElement.sequenceElement()); - VarHandle distancesVH = distancesSL.varHandle(PathElement.sequenceElement()); + VarHandle neighboursVH = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); + VarHandle distancesVH = distancesSequenceLayout.varHandle(PathElement.sequenceElement()); - Map irm = new LinkedHashMap(); + Map intermediateResultMap = new LinkedHashMap(); int count = 0; - for (long i = 0; i < topK * numQueries; i++) { - int id = (int) neighboursVH.get(neighboursMS, 0L, i); - float dst = (float) distancesVH.get(distancesMS, 0L, i); - irm.put(mapping != null ? mapping.get(id) : id, dst); + for (long i = 0; i < topK * numberOfQueries; i++) { + int id = (int) neighboursVH.get(neighboursMemorySegment, 0L, i); + float dst = (float) distancesVH.get(distancesMemorySegment, 0L, i); + intermediateResultMap.put(mapping != null ? mapping.get(id) : id, dst); count += 1; if (count == topK) { - results.add(irm); - irm = new LinkedHashMap(); + results.add(intermediateResultMap); + intermediateResultMap = new LinkedHashMap(); count = 0; } } @@ -56,5 +73,4 @@ private void load() { public List> getResults() { return results; } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java index 0326aa8f4..68dfbbb33 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java index 3e9341f6a..9c92c68e9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java index 6d082d344..ac6b89a64 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java index ca8716551..2f357a459 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java index 56dec2bae..cd83ac54d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java index cb3aad4fc..8b000c6bc 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java index 714aed5e9..29cb7ba70 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java index 0af404e19..ab350eb93 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java @@ -1,14 +1,43 @@ +/* + * Copyright (c) 2023-2024, 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.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.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; public class brute_force_h { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java index 27e7888bc..f86edb0f2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.ValueLayout.JAVA_BYTE; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java index b81d453cf..981760359 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java index a18ebae86..c70555711 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java index aaa87af8e..022793289 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java index 4011df7e5..880ddda95 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java index 61d0e4625..8687407ce 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java @@ -1,14 +1,31 @@ +/* + * Copyright (c) 2023-2024, 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.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.MemoryLayout.PathElement.groupElement; -import static java.lang.foreign.ValueLayout.*; -import static java.lang.foreign.MemoryLayout.PathElement.*; +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; /** * {@snippet lang=c : diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java index 3afc5c792..283b3af9b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.ValueLayout.JAVA_BYTE; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java index 4835982f1..a5f203fc2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java @@ -1,2482 +1,2551 @@ +/* + * Copyright (c) 2023-2024, 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.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.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; public class hnsw_h { - hnsw_h() { - // Should not be called directly - } + hnsw_h() { + // 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 _STDINT_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - private static final int _FEATURES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - private static final int _DEFAULT_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - private static final int __GLIBC_USE_ISOC2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - private static final int __USE_ISOC11 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - private static final int __USE_ISOC99 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - private static final int __USE_ISOC95 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - private static final int __USE_POSIX_IMPLICITLY = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - private static final int _POSIX_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - private static final int __USE_POSIX = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - private static final int __USE_POSIX2 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - private static final int __USE_POSIX199309 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - private static final int __USE_POSIX199506 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - private static final int __USE_XOPEN2K = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - private static final int __USE_XOPEN2K8 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - private static final int _ATFILE_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - private static final int __WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; - /** - * {@snippet lang=c : - * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - private static final int __SYSCALL_WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - private static final int __USE_MISC = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - private static final int __USE_ATFILE = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - private static final int __USE_FORTIFY_LEVEL = (int)0L; - /** - * {@snippet lang=c : - * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - private static final int _STDC_PREDEF_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - private static final int __STDC_IEC_559__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - private static final int __GNU_LIBRARY__ = (int)6L; - /** - * {@snippet lang=c : - * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - private static final int __GLIBC__ = (int)2L; - /** - * {@snippet lang=c : - * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - private static final int __GLIBC_MINOR__ = (int)35L; - /** - * {@snippet lang=c : - * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - private static final int _SYS_CDEFS_H = (int)1L; - /** - * {@snippet lang=c : - * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - private static final int __glibc_c99_flexarr_available = (int)1L; - /** - * {@snippet lang=c : - * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; - /** - * {@snippet lang=c : - * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - private static final int __HAVE_GENERIC_SELECTION = (int)1L; - /** - * {@snippet lang=c : - * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - private static final int _BITS_TYPES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - private static final int _BITS_TYPESIZES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - private static final int __INO_T_MATCHES_INO64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - private static final int __STATFS_MATCHES_STATFS64 = (int)1L; - /** - * {@snippet lang=c : - * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; - /** - * {@snippet lang=c : - * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - private static final int __FD_SETSIZE = (int)1024L; - /** - * {@snippet lang=c : - * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - private static final int _BITS_TIME64_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - private static final int _BITS_WCHAR_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - private static final int _BITS_STDINT_INTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - private static final int _BITS_STDINT_UINTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - private static final int DLPACK_MAJOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - private static final int DLPACK_MINOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - private static final int true_ = (int)1L; - /** - * {@snippet lang=c : - * #define true 1 - * } - */ - public static int true_() { - return true_; - } - private static final int false_ = (int)0L; - /** - * {@snippet lang=c : - * #define false 0 - * } - */ - public static int false_() { - return false_; - } - private static final int __bool_true_false_are_defined = (int)1L; - /** - * {@snippet lang=c : - * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = hnsw_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = hnsw_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = hnsw_h.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 = hnsw_h.C_LONG; - private static final int L2Expanded = (int)0L; - /** - * {@snippet lang=c : - * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - private static final int L2SqrtExpanded = (int)1L; - /** - * {@snippet lang=c : - * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - private static final int CosineExpanded = (int)2L; - /** - * {@snippet lang=c : - * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - private static final int L1 = (int)3L; - /** - * {@snippet lang=c : - * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - private static final int L2Unexpanded = (int)4L; - /** - * {@snippet lang=c : - * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - private static final int L2SqrtUnexpanded = (int)5L; - /** - * {@snippet lang=c : - * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - private static final int InnerProduct = (int)6L; - /** - * {@snippet lang=c : - * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - private static final int Linf = (int)7L; - /** - * {@snippet lang=c : - * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - private static final int Canberra = (int)8L; - /** - * {@snippet lang=c : - * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - private static final int LpUnexpanded = (int)9L; - /** - * {@snippet lang=c : - * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - private static final int CorrelationExpanded = (int)10L; - /** - * {@snippet lang=c : - * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - private static final int JaccardExpanded = (int)11L; - /** - * {@snippet lang=c : - * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - private static final int HellingerExpanded = (int)12L; - /** - * {@snippet lang=c : - * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - private static final int Haversine = (int)13L; - /** - * {@snippet lang=c : - * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - private static final int BrayCurtis = (int)14L; - /** - * {@snippet lang=c : - * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - private static final int JensenShannon = (int)15L; - /** - * {@snippet lang=c : - * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - private static final int HammingUnexpanded = (int)16L; - /** - * {@snippet lang=c : - * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - private static final int KLDivergence = (int)17L; - /** - * {@snippet lang=c : - * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - private static final int RusselRaoExpanded = (int)18L; - /** - * {@snippet lang=c : - * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - private static final int DiceExpanded = (int)19L; - /** - * {@snippet lang=c : - * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - private static final int Precomputed = (int)100L; - /** - * {@snippet lang=c : - * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = hnsw_h.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - /** - * {@snippet lang=c : - * typedef struct cuvsHnswSearchParams { - * int32_t ef; - * int32_t numThreads; - * } *cuvsHnswSearchParams_t - * } - */ - public static final AddressLayout cuvsHnswSearchParams_t = hnsw_h.C_POINTER; - - private static class cuvsHnswSearchParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); - - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) - * } - */ - public static FunctionDescriptor cuvsHnswSearchParamsCreate$descriptor() { - return cuvsHnswSearchParamsCreate.DESC; - } + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int) 1L; - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) - * } - */ - public static MethodHandle cuvsHnswSearchParamsCreate$handle() { - return cuvsHnswSearchParamsCreate.HANDLE; - } + /** + * {@snippet lang = c : * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) - * } - */ - public static MemorySegment cuvsHnswSearchParamsCreate$address() { - return cuvsHnswSearchParamsCreate.ADDR; - } + private static final int _FEATURES_H = (int) 1L; - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) - * } - */ - public static int cuvsHnswSearchParamsCreate(MemorySegment params) { - var mh$ = cuvsHnswSearchParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswSearchParamsCreate", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + /** + * {@snippet lang = c : * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } - private static class cuvsHnswSearchParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); + private static final int _DEFAULT_SOURCE = (int) 1L; - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsDestroy"); + /** + * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int __GLIBC_USE_ISOC2X = (int) 0L; - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) - * } - */ - public static FunctionDescriptor cuvsHnswSearchParamsDestroy$descriptor() { - return cuvsHnswSearchParamsDestroy.DESC; - } + /** + * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) - * } - */ - public static MethodHandle cuvsHnswSearchParamsDestroy$handle() { - return cuvsHnswSearchParamsDestroy.HANDLE; - } + private static final int __USE_ISOC11 = (int) 1L; - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) - * } - */ - public static MemorySegment cuvsHnswSearchParamsDestroy$address() { - return cuvsHnswSearchParamsDestroy.ADDR; - } + /** + * {@snippet lang = c : * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) - * } - */ - public static int cuvsHnswSearchParamsDestroy(MemorySegment params) { - var mh$ = cuvsHnswSearchParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswSearchParamsDestroy", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef cuvsHnswIndex *cuvsHnswIndex_t - * } - */ - public static final AddressLayout cuvsHnswIndex_t = hnsw_h.C_POINTER; - - private static class cuvsHnswIndexCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); - - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int __USE_ISOC99 = (int) 1L; - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) - * } - */ - public static FunctionDescriptor cuvsHnswIndexCreate$descriptor() { - return cuvsHnswIndexCreate.DESC; - } + /** + * {@snippet lang = c : * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) - * } - */ - public static MethodHandle cuvsHnswIndexCreate$handle() { - return cuvsHnswIndexCreate.HANDLE; - } + private static final int __USE_ISOC95 = (int) 1L; - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) - * } - */ - public static MemorySegment cuvsHnswIndexCreate$address() { - return cuvsHnswIndexCreate.ADDR; - } + /** + * {@snippet lang = c : * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) - * } - */ - public static int cuvsHnswIndexCreate(MemorySegment index) { - var mh$ = cuvsHnswIndexCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswIndexCreate", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + private static final int __USE_POSIX_IMPLICITLY = (int) 1L; - private static class cuvsHnswIndexDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); + /** + * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexDestroy"); + private static final int _POSIX_SOURCE = (int) 1L; - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + /** + * {@snippet lang = c : * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) - * } - */ - public static FunctionDescriptor cuvsHnswIndexDestroy$descriptor() { - return cuvsHnswIndexDestroy.DESC; - } + private static final int __USE_POSIX = (int) 1L; - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) - * } - */ - public static MethodHandle cuvsHnswIndexDestroy$handle() { - return cuvsHnswIndexDestroy.HANDLE; - } + /** + * {@snippet lang = c : * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) - * } - */ - public static MemorySegment cuvsHnswIndexDestroy$address() { - return cuvsHnswIndexDestroy.ADDR; - } + private static final int __USE_POSIX2 = (int) 1L; - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) - * } - */ - public static int cuvsHnswIndexDestroy(MemorySegment index) { - var mh$ = cuvsHnswIndexDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswIndexDestroy", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + /** + * {@snippet lang = c : * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } - private static class cuvsHnswSearch { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_LONG, - hnsw_h.C_POINTER, - hnsw_h.C_POINTER, - hnsw_h.C_POINTER, - hnsw_h.C_POINTER, - hnsw_h.C_POINTER - ); + private static final int __USE_POSIX199309 = (int) 1L; - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearch"); + /** + * {@snippet lang = c : * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int __USE_POSIX199506 = (int) 1L; - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static FunctionDescriptor cuvsHnswSearch$descriptor() { - return cuvsHnswSearch.DESC; - } + /** + * {@snippet lang = c : * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MethodHandle cuvsHnswSearch$handle() { - return cuvsHnswSearch.HANDLE; - } + private static final int __USE_XOPEN2K = (int) 1L; - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MemorySegment cuvsHnswSearch$address() { - return cuvsHnswSearch.ADDR; - } + /** + * {@snippet lang = c : * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static int cuvsHnswSearch(long res, MemorySegment params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { - var mh$ = cuvsHnswSearch.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswSearch", res, params, index, queries, neighbors, distances); - } - return (int)mh$.invokeExact(res, params, index, queries, neighbors, distances); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + private static final int __USE_XOPEN2K8 = (int) 1L; - private static class cuvsHnswDeserialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_LONG, - hnsw_h.C_POINTER, - hnsw_h.C_INT, - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); + /** + * {@snippet lang = c : * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswDeserialize"); + private static final int _ATFILE_SOURCE = (int) 1L; - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + /** + * {@snippet lang = c : * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) - * } - */ - public static FunctionDescriptor cuvsHnswDeserialize$descriptor() { - return cuvsHnswDeserialize.DESC; - } + private static final int __WORDSIZE = (int) 64L; - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) - * } - */ - public static MethodHandle cuvsHnswDeserialize$handle() { - return cuvsHnswDeserialize.HANDLE; - } + /** + * {@snippet lang = c : * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) - * } - */ - public static MemorySegment cuvsHnswDeserialize$address() { - return cuvsHnswDeserialize.ADDR; - } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) - * } - */ - public static int cuvsHnswDeserialize(long res, MemorySegment filename, int dim, int metric, MemorySegment index) { - var mh$ = cuvsHnswDeserialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswDeserialize", res, filename, dim, metric, index); - } - return (int)mh$.invokeExact(res, filename, dim, metric, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } -} + /** + * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + + private static final int __SYSCALL_WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + + private static final int __USE_MISC = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + + private static final int __USE_ATFILE = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + + private static final int __USE_FORTIFY_LEVEL = (int) 0L; + + /** + * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + + private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + + private static final int _STDC_PREDEF_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + + private static final int __STDC_IEC_559__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + + private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + + private static final int __GNU_LIBRARY__ = (int) 6L; + + /** + * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + + private static final int __GLIBC__ = (int) 2L; + + /** + * {@snippet lang = c : * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + + private static final int __GLIBC_MINOR__ = (int) 35L; + + /** + * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + + private static final int _SYS_CDEFS_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + + private static final int __glibc_c99_flexarr_available = (int) 1L; + + /** + * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; + + /** + * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + + private static final int __HAVE_GENERIC_SELECTION = (int) 1L; + + /** + * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + + private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + + private static final int _BITS_TYPES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + + private static final int _BITS_TYPESIZES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + + private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + + private static final int __INO_T_MATCHES_INO64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + + private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + + private static final int __FD_SETSIZE = (int) 1024L; + + /** + * {@snippet lang = c : * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + + private static final int _BITS_TIME64_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + + private static final int _BITS_WCHAR_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + + private static final int _BITS_STDINT_INTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + + private static final int _BITS_STDINT_UINTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + + private static final int DLPACK_MAJOR_VERSION = (int) 1L; + + /** + * {@snippet lang = c : * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + + private static final int DLPACK_MINOR_VERSION = (int) 0L; + + /** + * {@snippet lang = c : * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + + private static final int true_ = (int) 1L; + + /** + * {@snippet lang = c : * #define true 1 + * } + */ + public static int true_() { + return true_; + } + + private static final int false_ = (int) 0L; + + /** + * {@snippet lang = c : * #define false 0 + * } + */ + public static int false_() { + return false_; + } + + private static final int __bool_true_false_are_defined = (int) 1L; + + /** + * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + + /** + * {@snippet lang = c : * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off_t + * } + */ + public static final OfLong __off_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef long __time_t + * } + */ + public static final OfLong __time_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef int __key_t + * } + */ + public static final OfInt __key_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = hnsw_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = hnsw_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = hnsw_h.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 = hnsw_h.C_LONG; + private static final int L2Expanded = (int) 0L; + + /** + * {@snippet lang = c : * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + + private static final int L2SqrtExpanded = (int) 1L; + + /** + * {@snippet lang = c : * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + + private static final int CosineExpanded = (int) 2L; + + /** + * {@snippet lang = c : * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + + private static final int L1 = (int) 3L; + + /** + * {@snippet lang = c : * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + + private static final int L2Unexpanded = (int) 4L; + + /** + * {@snippet lang = c : * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + + private static final int L2SqrtUnexpanded = (int) 5L; + + /** + * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + + private static final int InnerProduct = (int) 6L; + + /** + * {@snippet lang = c : * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + + private static final int Linf = (int) 7L; + + /** + * {@snippet lang = c : * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + + private static final int Canberra = (int) 8L; + + /** + * {@snippet lang = c : * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + + private static final int LpUnexpanded = (int) 9L; + + /** + * {@snippet lang = c : * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + + private static final int CorrelationExpanded = (int) 10L; + + /** + * {@snippet lang = c : * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + + private static final int JaccardExpanded = (int) 11L; + + /** + * {@snippet lang = c : * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + + private static final int HellingerExpanded = (int) 12L; + + /** + * {@snippet lang = c : * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + + private static final int Haversine = (int) 13L; + + /** + * {@snippet lang = c : * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + + private static final int BrayCurtis = (int) 14L; + + /** + * {@snippet lang = c : * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + + private static final int JensenShannon = (int) 15L; + + /** + * {@snippet lang = c : * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + + private static final int HammingUnexpanded = (int) 16L; + + /** + * {@snippet lang = c : * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + + private static final int KLDivergence = (int) 17L; + + /** + * {@snippet lang = c : * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + + private static final int RusselRaoExpanded = (int) 18L; + + /** + * {@snippet lang = c : * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + + private static final int DiceExpanded = (int) 19L; + + /** + * {@snippet lang = c : * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + + private static final int Precomputed = (int) 100L; + + /** + * {@snippet lang = c : * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + + /** + * {@snippet lang = c : * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = hnsw_h.C_INT; + private static final int kDLCPU = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + + private static final int kDLCUDA = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + + private static final int kDLCUDAHost = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + + private static final int kDLOpenCL = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + + private static final int kDLVulkan = (int) 7L; + + /** + * {@snippet lang = c : * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + + private static final int kDLMetal = (int) 8L; + + /** + * {@snippet lang = c : * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + + private static final int kDLVPI = (int) 9L; + + /** + * {@snippet lang = c : * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + + private static final int kDLROCM = (int) 10L; + + /** + * {@snippet lang = c : * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + + private static final int kDLROCMHost = (int) 11L; + + /** + * {@snippet lang = c : * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + + private static final int kDLExtDev = (int) 12L; + + /** + * {@snippet lang = c : * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + + private static final int kDLCUDAManaged = (int) 13L; + + /** + * {@snippet lang = c : * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + + private static final int kDLOneAPI = (int) 14L; + + /** + * {@snippet lang = c : * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + + private static final int kDLWebGPU = (int) 15L; + + /** + * {@snippet lang = c : * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + + private static final int kDLHexagon = (int) 16L; + + /** + * {@snippet lang = c : * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + + private static final int kDLMAIA = (int) 17L; + + /** + * {@snippet lang = c : * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + + private static final int kDLInt = (int) 0L; + + /** + * {@snippet lang = c : * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + + private static final int kDLUInt = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + + private static final int kDLFloat = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + + private static final int kDLOpaqueHandle = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + + private static final int kDLBfloat = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + + private static final int kDLComplex = (int) 5L; + + /** + * {@snippet lang = c : * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + + private static final int kDLBool = (int) 6L; + + /** + * {@snippet lang = c : * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsHnswSearchParams { + * int32_t ef; + * int32_t numThreads; + * } *cuvsHnswSearchParams_t + * } + */ + public static final AddressLayout cuvsHnswSearchParams_t = hnsw_h.C_POINTER; + + private static class cuvsHnswSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsHnswSearchParamsCreate$descriptor() { + return cuvsHnswSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static MethodHandle cuvsHnswSearchParamsCreate$handle() { + return cuvsHnswSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static MemorySegment cuvsHnswSearchParamsCreate$address() { + return cuvsHnswSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static int cuvsHnswSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsHnswSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearchParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsHnswSearchParamsDestroy$descriptor() { + return cuvsHnswSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static MethodHandle cuvsHnswSearchParamsDestroy$handle() { + return cuvsHnswSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static MemorySegment cuvsHnswSearchParamsDestroy$address() { + return cuvsHnswSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static int cuvsHnswSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsHnswSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearchParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : * typedef cuvsHnswIndex *cuvsHnswIndex_t + * } + */ + public static final AddressLayout cuvsHnswIndex_t = hnsw_h.C_POINTER; + + private static class cuvsHnswIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsHnswIndexCreate$descriptor() { + return cuvsHnswIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static MethodHandle cuvsHnswIndexCreate$handle() { + return cuvsHnswIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static MemorySegment cuvsHnswIndexCreate$address() { + return cuvsHnswIndexCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static int cuvsHnswIndexCreate(MemorySegment index) { + var mh$ = cuvsHnswIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswIndexCreate", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static FunctionDescriptor cuvsHnswIndexDestroy$descriptor() { + return cuvsHnswIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static MethodHandle cuvsHnswIndexDestroy$handle() { + return cuvsHnswIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static MemorySegment cuvsHnswIndexDestroy$address() { + return cuvsHnswIndexDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static int cuvsHnswIndexDestroy(MemorySegment index) { + var mh$ = cuvsHnswIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswIndexDestroy", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_LONG, hnsw_h.C_POINTER, + hnsw_h.C_POINTER, hnsw_h.C_POINTER, hnsw_h.C_POINTER, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsHnswSearch$descriptor() { + return cuvsHnswSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsHnswSearch$handle() { + return cuvsHnswSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsHnswSearch$address() { + return cuvsHnswSearch.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsHnswSearch(long res, MemorySegment params, MemorySegment index, MemorySegment queries, + MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsHnswSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearch", res, params, index, queries, neighbors, distances); + } + return (int) mh$.invokeExact(res, params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_LONG, hnsw_h.C_POINTER, + hnsw_h.C_INT, hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static FunctionDescriptor cuvsHnswDeserialize$descriptor() { + return cuvsHnswDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static MethodHandle cuvsHnswDeserialize$handle() { + return cuvsHnswDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static MemorySegment cuvsHnswDeserialize$address() { + return cuvsHnswDeserialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static int cuvsHnswDeserialize(long res, MemorySegment filename, int dim, int metric, MemorySegment index) { + var mh$ = cuvsHnswDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswDeserialize", res, filename, dim, metric, index); + } + return (int) mh$.invokeExact(res, filename, dim, metric, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static final long _POSIX_C_SOURCE = 200809L; + + /** + * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + + private static final int __TIMESIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + + private static final long __STDC_IEC_60559_BFP__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + + private static final long __STDC_ISO_10646__ = 201706L; + + /** + * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + + private static final int __WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + + private static final int __WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + + private static final int INT8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + + private static final int INT16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + + private static final int INT32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + + private static final long INT64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + + private static final int INT8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + + private static final int INT16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + + private static final int INT32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + + private static final long INT64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + + private static final int UINT8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + + private static final int UINT16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + + private static final int UINT32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + + private static final long UINT64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + + private static final int INT_LEAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + + private static final int INT_LEAST16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + + private static final int INT_LEAST32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + + private static final long INT_LEAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + + private static final int INT_LEAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + + private static final int INT_LEAST16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + + private static final int INT_LEAST32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + + private static final long INT_LEAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + + private static final int UINT_LEAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + + private static final int UINT_LEAST16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + + private static final int UINT_LEAST32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + + private static final long UINT_LEAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + + private static final int INT_FAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + + private static final long INT_FAST16_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + + private static final long INT_FAST32_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + + private static final long INT_FAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + + private static final int INT_FAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + + private static final long INT_FAST16_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + + private static final long INT_FAST32_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + + private static final long INT_FAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + + private static final int UINT_FAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + + private static final long UINT_FAST16_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + + private static final long UINT_FAST32_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + + private static final long UINT_FAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + + private static final long INTPTR_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + + private static final long INTPTR_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + + private static final long UINTPTR_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + + private static final long INTMAX_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + + private static final long INTMAX_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + + private static final long UINTMAX_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + + private static final long PTRDIFF_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + + private static final long PTRDIFF_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + + private static final int SIG_ATOMIC_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + + private static final int SIG_ATOMIC_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + + private static final long SIZE_MAX = -1L; + + /** + * {@snippet lang = c : * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + + private static final int WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + + private static final int WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + + private static final int WINT_MIN = (int) 0L; + + /** + * {@snippet lang = c : * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + + private static final int WINT_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + + /** + * {@snippet lang = c : * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java index 0848589b6..5f74bf223 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java @@ -1,2792 +1,2845 @@ -package com.nvidia.cuvs.panama; +/* + * Copyright (c) 2023-2024, 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. + */ -import java.lang.invoke.*; -import java.lang.foreign.*; -import java.nio.ByteOrder; -import java.util.*; -import java.util.function.*; -import java.util.stream.*; +package com.nvidia.cuvs.panama; -import static java.lang.foreign.ValueLayout.*; -import static java.lang.foreign.MemoryLayout.PathElement.*; +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; public class ivf_flat_h { - ivf_flat_h() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args) - .map(Object::toString) - .collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol) - .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream() - .map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? - MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() - .or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int _STDINT_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - private static final int _FEATURES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - private static final int _DEFAULT_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - private static final int __GLIBC_USE_ISOC2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - private static final int __USE_ISOC11 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - private static final int __USE_ISOC99 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - private static final int __USE_ISOC95 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - private static final int __USE_POSIX_IMPLICITLY = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - private static final int _POSIX_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - private static final int __USE_POSIX = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - private static final int __USE_POSIX2 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - private static final int __USE_POSIX199309 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - private static final int __USE_POSIX199506 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - private static final int __USE_XOPEN2K = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - private static final int __USE_XOPEN2K8 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - private static final int _ATFILE_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - private static final int __WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; - /** - * {@snippet lang=c : - * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - private static final int __SYSCALL_WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - private static final int __USE_MISC = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - private static final int __USE_ATFILE = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - private static final int __USE_FORTIFY_LEVEL = (int)0L; - /** - * {@snippet lang=c : - * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - private static final int _STDC_PREDEF_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - private static final int __STDC_IEC_559__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - private static final int __GNU_LIBRARY__ = (int)6L; - /** - * {@snippet lang=c : - * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - private static final int __GLIBC__ = (int)2L; - /** - * {@snippet lang=c : - * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - private static final int __GLIBC_MINOR__ = (int)35L; - /** - * {@snippet lang=c : - * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - private static final int _SYS_CDEFS_H = (int)1L; - /** - * {@snippet lang=c : - * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - private static final int __glibc_c99_flexarr_available = (int)1L; - /** - * {@snippet lang=c : - * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; - /** - * {@snippet lang=c : - * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - private static final int __HAVE_GENERIC_SELECTION = (int)1L; - /** - * {@snippet lang=c : - * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - private static final int _BITS_TYPES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - private static final int _BITS_TYPESIZES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - private static final int __INO_T_MATCHES_INO64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - private static final int __STATFS_MATCHES_STATFS64 = (int)1L; - /** - * {@snippet lang=c : - * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; - /** - * {@snippet lang=c : - * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - private static final int __FD_SETSIZE = (int)1024L; - /** - * {@snippet lang=c : - * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - private static final int _BITS_TIME64_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - private static final int _BITS_WCHAR_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - private static final int _BITS_STDINT_INTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - private static final int _BITS_STDINT_UINTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - private static final int DLPACK_MAJOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - private static final int DLPACK_MINOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - private static final int true_ = (int)1L; - /** - * {@snippet lang=c : - * #define true 1 - * } - */ - public static int true_() { - return true_; - } - private static final int false_ = (int)0L; - /** - * {@snippet lang=c : - * #define false 0 - * } - */ - public static int false_() { - return false_; - } - private static final int __bool_true_false_are_defined = (int)1L; - /** - * {@snippet lang=c : - * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = ivf_flat_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = ivf_flat_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = ivf_flat_h.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 = ivf_flat_h.C_LONG; - private static final int L2Expanded = (int)0L; - /** - * {@snippet lang=c : - * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - private static final int L2SqrtExpanded = (int)1L; - /** - * {@snippet lang=c : - * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - private static final int CosineExpanded = (int)2L; - /** - * {@snippet lang=c : - * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - private static final int L1 = (int)3L; - /** - * {@snippet lang=c : - * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - private static final int L2Unexpanded = (int)4L; - /** - * {@snippet lang=c : - * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - private static final int L2SqrtUnexpanded = (int)5L; - /** - * {@snippet lang=c : - * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - private static final int InnerProduct = (int)6L; - /** - * {@snippet lang=c : - * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - private static final int Linf = (int)7L; - /** - * {@snippet lang=c : - * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - private static final int Canberra = (int)8L; - /** - * {@snippet lang=c : - * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - private static final int LpUnexpanded = (int)9L; - /** - * {@snippet lang=c : - * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - private static final int CorrelationExpanded = (int)10L; - /** - * {@snippet lang=c : - * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - private static final int JaccardExpanded = (int)11L; - /** - * {@snippet lang=c : - * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - private static final int HellingerExpanded = (int)12L; - /** - * {@snippet lang=c : - * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - private static final int Haversine = (int)13L; - /** - * {@snippet lang=c : - * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - private static final int BrayCurtis = (int)14L; - /** - * {@snippet lang=c : - * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - private static final int JensenShannon = (int)15L; - /** - * {@snippet lang=c : - * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - private static final int HammingUnexpanded = (int)16L; - /** - * {@snippet lang=c : - * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - private static final int KLDivergence = (int)17L; - /** - * {@snippet lang=c : - * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - private static final int RusselRaoExpanded = (int)18L; - /** - * {@snippet lang=c : - * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - private static final int DiceExpanded = (int)19L; - /** - * {@snippet lang=c : - * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - private static final int Precomputed = (int)100L; - /** - * {@snippet lang=c : - * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = ivf_flat_h.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - /** - * {@snippet lang=c : - * typedef struct cuvsIvfFlatIndexParams { - * cuvsDistanceType metric; - * float metric_arg; - * _Bool add_data_on_build; - * uint32_t n_lists; - * uint32_t kmeans_n_iters; - * double kmeans_trainset_fraction; - * _Bool adaptive_centers; - * _Bool conservative_memory_allocation; - * } *cuvsIvfFlatIndexParams_t - * } - */ - public static final AddressLayout cuvsIvfFlatIndexParams_t = ivf_flat_h.C_POINTER; - - private static class cuvsIvfFlatIndexParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexParamsCreate$descriptor() { - return cuvsIvfFlatIndexParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static MethodHandle cuvsIvfFlatIndexParamsCreate$handle() { - return cuvsIvfFlatIndexParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static MemorySegment cuvsIvfFlatIndexParamsCreate$address() { - return cuvsIvfFlatIndexParamsCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static int cuvsIvfFlatIndexParamsCreate(MemorySegment index_params) { - var mh$ = cuvsIvfFlatIndexParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexParamsCreate", index_params); - } - return (int)mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatIndexParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexParamsDestroy$descriptor() { - return cuvsIvfFlatIndexParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static MethodHandle cuvsIvfFlatIndexParamsDestroy$handle() { - return cuvsIvfFlatIndexParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static MemorySegment cuvsIvfFlatIndexParamsDestroy$address() { - return cuvsIvfFlatIndexParamsDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static int cuvsIvfFlatIndexParamsDestroy(MemorySegment index_params) { - var mh$ = cuvsIvfFlatIndexParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexParamsDestroy", index_params); - } - return (int)mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef struct cuvsIvfFlatSearchParams { - * uint32_t n_probes; - * } *cuvsIvfFlatSearchParams_t - * } - */ - public static final AddressLayout cuvsIvfFlatSearchParams_t = ivf_flat_h.C_POINTER; - - private static class cuvsIvfFlatSearchParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSearchParamsCreate$descriptor() { - return cuvsIvfFlatSearchParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static MethodHandle cuvsIvfFlatSearchParamsCreate$handle() { - return cuvsIvfFlatSearchParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static MemorySegment cuvsIvfFlatSearchParamsCreate$address() { - return cuvsIvfFlatSearchParamsCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static int cuvsIvfFlatSearchParamsCreate(MemorySegment params) { - var mh$ = cuvsIvfFlatSearchParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSearchParamsCreate", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatSearchParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSearchParamsDestroy$descriptor() { - return cuvsIvfFlatSearchParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static MethodHandle cuvsIvfFlatSearchParamsDestroy$handle() { - return cuvsIvfFlatSearchParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static MemorySegment cuvsIvfFlatSearchParamsDestroy$address() { - return cuvsIvfFlatSearchParamsDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static int cuvsIvfFlatSearchParamsDestroy(MemorySegment params) { - var mh$ = cuvsIvfFlatSearchParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSearchParamsDestroy", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef cuvsIvfFlatIndex *cuvsIvfFlatIndex_t - * } - */ - public static final AddressLayout cuvsIvfFlatIndex_t = ivf_flat_h.C_POINTER; - - private static class cuvsIvfFlatIndexCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexCreate$descriptor() { - return cuvsIvfFlatIndexCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static MethodHandle cuvsIvfFlatIndexCreate$handle() { - return cuvsIvfFlatIndexCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static MemorySegment cuvsIvfFlatIndexCreate$address() { - return cuvsIvfFlatIndexCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static int cuvsIvfFlatIndexCreate(MemorySegment index) { - var mh$ = cuvsIvfFlatIndexCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexCreate", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatIndexDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexDestroy$descriptor() { - return cuvsIvfFlatIndexDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatIndexDestroy$handle() { - return cuvsIvfFlatIndexDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatIndexDestroy$address() { - return cuvsIvfFlatIndexDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatIndexDestroy(MemorySegment index) { - var mh$ = cuvsIvfFlatIndexDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexDestroy", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatBuild { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatBuild"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatBuild$descriptor() { - return cuvsIvfFlatBuild.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatBuild$handle() { - return cuvsIvfFlatBuild.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatBuild$address() { - return cuvsIvfFlatBuild.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatBuild(long res, MemorySegment index_params, MemorySegment dataset, MemorySegment index) { - var mh$ = cuvsIvfFlatBuild.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatBuild", res, index_params, dataset, index); - } - return (int)mh$.invokeExact(res, index_params, dataset, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatSearch { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearch"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSearch$descriptor() { - return cuvsIvfFlatSearch.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MethodHandle cuvsIvfFlatSearch$handle() { - return cuvsIvfFlatSearch.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MemorySegment cuvsIvfFlatSearch$address() { - return cuvsIvfFlatSearch.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static int cuvsIvfFlatSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { - var mh$ = cuvsIvfFlatSearch.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSearch", res, search_params, index, queries, neighbors, distances); - } - return (int)mh$.invokeExact(res, search_params, index, queries, neighbors, distances); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatSerialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSerialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSerialize$descriptor() { - return cuvsIvfFlatSerialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatSerialize$handle() { - return cuvsIvfFlatSerialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatSerialize$address() { - return cuvsIvfFlatSerialize.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatSerialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfFlatSerialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSerialize", res, filename, index); - } - return (int)mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatDeserialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatDeserialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatDeserialize$descriptor() { - return cuvsIvfFlatDeserialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatDeserialize$handle() { - return cuvsIvfFlatDeserialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatDeserialize$address() { - return cuvsIvfFlatDeserialize.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatDeserialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfFlatDeserialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatDeserialize", res, filename, index); - } - return (int)mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatExtend { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatExtend"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatExtend$descriptor() { - return cuvsIvfFlatExtend.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatExtend$handle() { - return cuvsIvfFlatExtend.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatExtend$address() { - return cuvsIvfFlatExtend.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, MemorySegment index) { - var mh$ = cuvsIvfFlatExtend.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatExtend", res, new_vectors, new_indices, index); - } - return (int)mh$.invokeExact(res, new_vectors, new_indices, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } + ivf_flat_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) + : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + + private static final int _FEATURES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + + private static final int _DEFAULT_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + + private static final int __GLIBC_USE_ISOC2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + + private static final int __USE_ISOC11 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + + private static final int __USE_ISOC99 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + + private static final int __USE_ISOC95 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + + private static final int __USE_POSIX_IMPLICITLY = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + + private static final int _POSIX_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + + private static final int __USE_POSIX = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + + private static final int __USE_POSIX2 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + + private static final int __USE_POSIX199309 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + + private static final int __USE_POSIX199506 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + + private static final int __USE_XOPEN2K = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + + private static final int __USE_XOPEN2K8 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + + private static final int _ATFILE_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + + private static final int __WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + + private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; + + /** + * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + + private static final int __SYSCALL_WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + + private static final int __USE_MISC = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + + private static final int __USE_ATFILE = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + + private static final int __USE_FORTIFY_LEVEL = (int) 0L; + + /** + * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + + private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + + private static final int _STDC_PREDEF_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + + private static final int __STDC_IEC_559__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + + private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + + private static final int __GNU_LIBRARY__ = (int) 6L; + + /** + * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + + private static final int __GLIBC__ = (int) 2L; + + /** + * {@snippet lang = c : * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + + private static final int __GLIBC_MINOR__ = (int) 35L; + + /** + * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + + private static final int _SYS_CDEFS_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + + private static final int __glibc_c99_flexarr_available = (int) 1L; + + /** + * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; + + /** + * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + + private static final int __HAVE_GENERIC_SELECTION = (int) 1L; + + /** + * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + + private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + + private static final int _BITS_TYPES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + + private static final int _BITS_TYPESIZES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + + private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + + private static final int __INO_T_MATCHES_INO64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + + private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + + private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + + private static final int __FD_SETSIZE = (int) 1024L; + + /** + * {@snippet lang = c : * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + + private static final int _BITS_TIME64_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + + private static final int _BITS_WCHAR_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + + private static final int _BITS_STDINT_INTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + + private static final int _BITS_STDINT_UINTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + + private static final int DLPACK_MAJOR_VERSION = (int) 1L; + + /** + * {@snippet lang = c : * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + + private static final int DLPACK_MINOR_VERSION = (int) 0L; + + /** + * {@snippet lang = c : * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + + private static final int true_ = (int) 1L; + + /** + * {@snippet lang = c : * #define true 1 + * } + */ + public static int true_() { + return true_; + } + + private static final int false_ = (int) 0L; + + /** + * {@snippet lang = c : * #define false 0 + * } + */ + public static int false_() { + return false_; + } + + private static final int __bool_true_false_are_defined = (int) 1L; + + /** + * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + + /** + * {@snippet lang = c : * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off_t + * } + */ + public static final OfLong __off_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef long __time_t + * } + */ + public static final OfLong __time_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef int __key_t + * } + */ + public static final OfInt __key_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = ivf_flat_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = ivf_flat_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = ivf_flat_h.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 = ivf_flat_h.C_LONG; + private static final int L2Expanded = (int) 0L; + + /** + * {@snippet lang = c : * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + + private static final int L2SqrtExpanded = (int) 1L; + + /** + * {@snippet lang = c : * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + + private static final int CosineExpanded = (int) 2L; + + /** + * {@snippet lang = c : * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + + private static final int L1 = (int) 3L; + + /** + * {@snippet lang = c : * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + + private static final int L2Unexpanded = (int) 4L; + + /** + * {@snippet lang = c : * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + + private static final int L2SqrtUnexpanded = (int) 5L; + + /** + * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + + private static final int InnerProduct = (int) 6L; + + /** + * {@snippet lang = c : * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + + private static final int Linf = (int) 7L; + + /** + * {@snippet lang = c : * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + + private static final int Canberra = (int) 8L; + + /** + * {@snippet lang = c : * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + + private static final int LpUnexpanded = (int) 9L; + + /** + * {@snippet lang = c : * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + + private static final int CorrelationExpanded = (int) 10L; + + /** + * {@snippet lang = c : * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + + private static final int JaccardExpanded = (int) 11L; + + /** + * {@snippet lang = c : * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + + private static final int HellingerExpanded = (int) 12L; + + /** + * {@snippet lang = c : * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + + private static final int Haversine = (int) 13L; + + /** + * {@snippet lang = c : * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + + private static final int BrayCurtis = (int) 14L; + + /** + * {@snippet lang = c : * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + + private static final int JensenShannon = (int) 15L; + + /** + * {@snippet lang = c : * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + + private static final int HammingUnexpanded = (int) 16L; + + /** + * {@snippet lang = c : * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + + private static final int KLDivergence = (int) 17L; + + /** + * {@snippet lang = c : * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + + private static final int RusselRaoExpanded = (int) 18L; + + /** + * {@snippet lang = c : * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + + private static final int DiceExpanded = (int) 19L; + + /** + * {@snippet lang = c : * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + + private static final int Precomputed = (int) 100L; + + /** + * {@snippet lang = c : * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + + /** + * {@snippet lang = c : * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = ivf_flat_h.C_INT; + private static final int kDLCPU = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + + private static final int kDLCUDA = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + + private static final int kDLCUDAHost = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + + private static final int kDLOpenCL = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + + private static final int kDLVulkan = (int) 7L; + + /** + * {@snippet lang = c : * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + + private static final int kDLMetal = (int) 8L; + + /** + * {@snippet lang = c : * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + + private static final int kDLVPI = (int) 9L; + + /** + * {@snippet lang = c : * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + + private static final int kDLROCM = (int) 10L; + + /** + * {@snippet lang = c : * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + + private static final int kDLROCMHost = (int) 11L; + + /** + * {@snippet lang = c : * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + + private static final int kDLExtDev = (int) 12L; + + /** + * {@snippet lang = c : * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + + private static final int kDLCUDAManaged = (int) 13L; + + /** + * {@snippet lang = c : * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + + private static final int kDLOneAPI = (int) 14L; + + /** + * {@snippet lang = c : * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + + private static final int kDLWebGPU = (int) 15L; + + /** + * {@snippet lang = c : * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + + private static final int kDLHexagon = (int) 16L; + + /** + * {@snippet lang = c : * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + + private static final int kDLMAIA = (int) 17L; + + /** + * {@snippet lang = c : * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + + private static final int kDLInt = (int) 0L; + + /** + * {@snippet lang = c : * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + + private static final int kDLUInt = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + + private static final int kDLFloat = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + + private static final int kDLOpaqueHandle = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + + private static final int kDLBfloat = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + + private static final int kDLComplex = (int) 5L; + + /** + * {@snippet lang = c : * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + + private static final int kDLBool = (int) 6L; + + /** + * {@snippet lang = c : * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsIvfFlatIndexParams { + * cuvsDistanceType metric; + * float metric_arg; + * _Bool add_data_on_build; + * uint32_t n_lists; + * uint32_t kmeans_n_iters; + * double kmeans_trainset_fraction; + * _Bool adaptive_centers; + * _Bool conservative_memory_allocation; + * } *cuvsIvfFlatIndexParams_t + * } + */ + public static final AddressLayout cuvsIvfFlatIndexParams_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexParamsCreate$descriptor() { + return cuvsIvfFlatIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static MethodHandle cuvsIvfFlatIndexParamsCreate$handle() { + return cuvsIvfFlatIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static MemorySegment cuvsIvfFlatIndexParamsCreate$address() { + return cuvsIvfFlatIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static int cuvsIvfFlatIndexParamsCreate(MemorySegment index_params) { + var mh$ = cuvsIvfFlatIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexParamsCreate", index_params); + } + return (int) mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexParamsDestroy$descriptor() { + return cuvsIvfFlatIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static MethodHandle cuvsIvfFlatIndexParamsDestroy$handle() { + return cuvsIvfFlatIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static MemorySegment cuvsIvfFlatIndexParamsDestroy$address() { + return cuvsIvfFlatIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static int cuvsIvfFlatIndexParamsDestroy(MemorySegment index_params) { + var mh$ = cuvsIvfFlatIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexParamsDestroy", index_params); + } + return (int) mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : + * typedef struct cuvsIvfFlatSearchParams { + * uint32_t n_probes; + * } *cuvsIvfFlatSearchParams_t + * } + */ + public static final AddressLayout cuvsIvfFlatSearchParams_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearchParamsCreate$descriptor() { + return cuvsIvfFlatSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static MethodHandle cuvsIvfFlatSearchParamsCreate$handle() { + return cuvsIvfFlatSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static MemorySegment cuvsIvfFlatSearchParamsCreate$address() { + return cuvsIvfFlatSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static int cuvsIvfFlatSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsIvfFlatSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearchParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearchParamsDestroy$descriptor() { + return cuvsIvfFlatSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static MethodHandle cuvsIvfFlatSearchParamsDestroy$handle() { + return cuvsIvfFlatSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static MemorySegment cuvsIvfFlatSearchParamsDestroy$address() { + return cuvsIvfFlatSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static int cuvsIvfFlatSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsIvfFlatSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearchParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : * typedef cuvsIvfFlatIndex *cuvsIvfFlatIndex_t + * } + */ + public static final AddressLayout cuvsIvfFlatIndex_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexCreate$descriptor() { + return cuvsIvfFlatIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static MethodHandle cuvsIvfFlatIndexCreate$handle() { + return cuvsIvfFlatIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static MemorySegment cuvsIvfFlatIndexCreate$address() { + return cuvsIvfFlatIndexCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static int cuvsIvfFlatIndexCreate(MemorySegment index) { + var mh$ = cuvsIvfFlatIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexCreate", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexDestroy$descriptor() { + return cuvsIvfFlatIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatIndexDestroy$handle() { + return cuvsIvfFlatIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatIndexDestroy$address() { + return cuvsIvfFlatIndexDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatIndexDestroy(MemorySegment index) { + var mh$ = cuvsIvfFlatIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexDestroy", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatBuild$descriptor() { + return cuvsIvfFlatBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatBuild$handle() { + return cuvsIvfFlatBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatBuild$address() { + return cuvsIvfFlatBuild.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatBuild(long res, MemorySegment index_params, MemorySegment dataset, MemorySegment index) { + var mh$ = cuvsIvfFlatBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatBuild", res, index_params, dataset, index); + } + return (int) mh$.invokeExact(res, index_params, dataset, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearch$descriptor() { + return cuvsIvfFlatSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsIvfFlatSearch$handle() { + return cuvsIvfFlatSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsIvfFlatSearch$address() { + return cuvsIvfFlatSearch.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsIvfFlatSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, + MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsIvfFlatSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearch", res, search_params, index, queries, neighbors, distances); + } + return (int) mh$.invokeExact(res, search_params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSerialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSerialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSerialize$descriptor() { + return cuvsIvfFlatSerialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatSerialize$handle() { + return cuvsIvfFlatSerialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatSerialize$address() { + return cuvsIvfFlatSerialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatSerialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfFlatSerialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSerialize", res, filename, index); + } + return (int) mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatDeserialize$descriptor() { + return cuvsIvfFlatDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatDeserialize$handle() { + return cuvsIvfFlatDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatDeserialize$address() { + return cuvsIvfFlatDeserialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatDeserialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfFlatDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatDeserialize", res, filename, index); + } + return (int) mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatExtend { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatExtend"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatExtend$descriptor() { + return cuvsIvfFlatExtend.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatExtend$handle() { + return cuvsIvfFlatExtend.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatExtend$address() { + return cuvsIvfFlatExtend.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, + MemorySegment index) { + var mh$ = cuvsIvfFlatExtend.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatExtend", res, new_vectors, new_indices, index); + } + return (int) mh$.invokeExact(res, new_vectors, new_indices, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static final long _POSIX_C_SOURCE = 200809L; + + /** + * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + + private static final int __TIMESIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + + private static final long __STDC_IEC_60559_BFP__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + + private static final long __STDC_ISO_10646__ = 201706L; + + /** + * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + + private static final int __WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + + private static final int __WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + + private static final int INT8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + + private static final int INT16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + + private static final int INT32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + + private static final long INT64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + + private static final int INT8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + + private static final int INT16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + + private static final int INT32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + + private static final long INT64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + + private static final int UINT8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + + private static final int UINT16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + + private static final int UINT32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + + private static final long UINT64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + + private static final int INT_LEAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + + private static final int INT_LEAST16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + + private static final int INT_LEAST32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + + private static final long INT_LEAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + + private static final int INT_LEAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + + private static final int INT_LEAST16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + + private static final int INT_LEAST32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + + private static final long INT_LEAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + + private static final int UINT_LEAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + + private static final int UINT_LEAST16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + + private static final int UINT_LEAST32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + + private static final long UINT_LEAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + + private static final int INT_FAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + + private static final long INT_FAST16_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + + private static final long INT_FAST32_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + + private static final long INT_FAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + + private static final int INT_FAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + + private static final long INT_FAST16_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + + private static final long INT_FAST32_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + + private static final long INT_FAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + + private static final int UINT_FAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + + private static final long UINT_FAST16_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + + private static final long UINT_FAST32_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + + private static final long UINT_FAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + + private static final long INTPTR_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + + private static final long INTPTR_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + + private static final long UINTPTR_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + + private static final long INTMAX_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + + private static final long INTMAX_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + + private static final long UINTMAX_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + + private static final long PTRDIFF_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + + private static final long PTRDIFF_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + + private static final int SIG_ATOMIC_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + + private static final int SIG_ATOMIC_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + + private static final long SIZE_MAX = -1L; + + /** + * {@snippet lang = c : * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + + private static final int WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + + private static final int WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + + private static final int WINT_MIN = (int) 0L; + + /** + * {@snippet lang = c : * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + + private static final int WINT_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + + /** + * {@snippet lang = c : * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } } - diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java index fd57078b6..0d97fabe1 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java @@ -1,3096 +1,3182 @@ -package com.nvidia.cuvs.panama; +/* + * Copyright (c) 2023-2024, 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. + */ -import java.lang.invoke.*; -import java.lang.foreign.*; -import java.nio.ByteOrder; -import java.util.*; -import java.util.function.*; -import java.util.stream.*; +package com.nvidia.cuvs.panama; -import static java.lang.foreign.ValueLayout.*; -import static java.lang.foreign.MemoryLayout.PathElement.*; +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; public class ivf_pq_h { - ivf_pq_h() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args) - .map(Object::toString) - .collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol) - .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream() - .map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? - MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() - .or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int _STDINT_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - private static final int _FEATURES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - private static final int _DEFAULT_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - private static final int __GLIBC_USE_ISOC2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - private static final int __USE_ISOC11 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - private static final int __USE_ISOC99 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - private static final int __USE_ISOC95 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - private static final int __USE_POSIX_IMPLICITLY = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - private static final int _POSIX_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - private static final int __USE_POSIX = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - private static final int __USE_POSIX2 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - private static final int __USE_POSIX199309 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - private static final int __USE_POSIX199506 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - private static final int __USE_XOPEN2K = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - private static final int __USE_XOPEN2K8 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - private static final int _ATFILE_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - private static final int __WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; - /** - * {@snippet lang=c : - * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - private static final int __SYSCALL_WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - private static final int __USE_MISC = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - private static final int __USE_ATFILE = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - private static final int __USE_FORTIFY_LEVEL = (int)0L; - /** - * {@snippet lang=c : - * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - private static final int _STDC_PREDEF_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - private static final int __STDC_IEC_559__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - private static final int __GNU_LIBRARY__ = (int)6L; - /** - * {@snippet lang=c : - * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - private static final int __GLIBC__ = (int)2L; - /** - * {@snippet lang=c : - * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - private static final int __GLIBC_MINOR__ = (int)35L; - /** - * {@snippet lang=c : - * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - private static final int _SYS_CDEFS_H = (int)1L; - /** - * {@snippet lang=c : - * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - private static final int __glibc_c99_flexarr_available = (int)1L; - /** - * {@snippet lang=c : - * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; - /** - * {@snippet lang=c : - * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - private static final int __HAVE_GENERIC_SELECTION = (int)1L; - /** - * {@snippet lang=c : - * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - private static final int _BITS_TYPES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - private static final int _BITS_TYPESIZES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - private static final int __INO_T_MATCHES_INO64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - private static final int __STATFS_MATCHES_STATFS64 = (int)1L; - /** - * {@snippet lang=c : - * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; - /** - * {@snippet lang=c : - * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - private static final int __FD_SETSIZE = (int)1024L; - /** - * {@snippet lang=c : - * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - private static final int _BITS_TIME64_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - private static final int _BITS_WCHAR_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - private static final int _BITS_STDINT_INTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - private static final int _BITS_STDINT_UINTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - private static final int DLPACK_MAJOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - private static final int DLPACK_MINOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - private static final int true_ = (int)1L; - /** - * {@snippet lang=c : - * #define true 1 - * } - */ - public static int true_() { - return true_; - } - private static final int false_ = (int)0L; - /** - * {@snippet lang=c : - * #define false 0 - * } - */ - public static int false_() { - return false_; - } - private static final int __bool_true_false_are_defined = (int)1L; - /** - * {@snippet lang=c : - * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = ivf_pq_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = ivf_pq_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = ivf_pq_h.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 = ivf_pq_h.C_LONG; - private static final int L2Expanded = (int)0L; - /** - * {@snippet lang=c : - * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - private static final int L2SqrtExpanded = (int)1L; - /** - * {@snippet lang=c : - * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - private static final int CosineExpanded = (int)2L; - /** - * {@snippet lang=c : - * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - private static final int L1 = (int)3L; - /** - * {@snippet lang=c : - * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - private static final int L2Unexpanded = (int)4L; - /** - * {@snippet lang=c : - * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - private static final int L2SqrtUnexpanded = (int)5L; - /** - * {@snippet lang=c : - * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - private static final int InnerProduct = (int)6L; - /** - * {@snippet lang=c : - * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - private static final int Linf = (int)7L; - /** - * {@snippet lang=c : - * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - private static final int Canberra = (int)8L; - /** - * {@snippet lang=c : - * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - private static final int LpUnexpanded = (int)9L; - /** - * {@snippet lang=c : - * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - private static final int CorrelationExpanded = (int)10L; - /** - * {@snippet lang=c : - * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - private static final int JaccardExpanded = (int)11L; - /** - * {@snippet lang=c : - * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - private static final int HellingerExpanded = (int)12L; - /** - * {@snippet lang=c : - * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - private static final int Haversine = (int)13L; - /** - * {@snippet lang=c : - * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - private static final int BrayCurtis = (int)14L; - /** - * {@snippet lang=c : - * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - private static final int JensenShannon = (int)15L; - /** - * {@snippet lang=c : - * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - private static final int HammingUnexpanded = (int)16L; - /** - * {@snippet lang=c : - * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - private static final int KLDivergence = (int)17L; - /** - * {@snippet lang=c : - * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - private static final int RusselRaoExpanded = (int)18L; - /** - * {@snippet lang=c : - * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - private static final int DiceExpanded = (int)19L; - /** - * {@snippet lang=c : - * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - private static final int Precomputed = (int)100L; - /** - * {@snippet lang=c : - * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = ivf_pq_h.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - private static final int CUDA_R_16F = (int)2L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_16F = 2 - * } - */ - public static int CUDA_R_16F() { - return CUDA_R_16F; - } - private static final int CUDA_C_16F = (int)6L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_16F = 6 - * } - */ - public static int CUDA_C_16F() { - return CUDA_C_16F; - } - private static final int CUDA_R_16BF = (int)14L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_16BF = 14 - * } - */ - public static int CUDA_R_16BF() { - return CUDA_R_16BF; - } - private static final int CUDA_C_16BF = (int)15L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_16BF = 15 - * } - */ - public static int CUDA_C_16BF() { - return CUDA_C_16BF; - } - private static final int CUDA_R_32F = (int)0L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_32F = 0 - * } - */ - public static int CUDA_R_32F() { - return CUDA_R_32F; - } - private static final int CUDA_C_32F = (int)4L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_32F = 4 - * } - */ - public static int CUDA_C_32F() { - return CUDA_C_32F; - } - private static final int CUDA_R_64F = (int)1L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_64F = 1 - * } - */ - public static int CUDA_R_64F() { - return CUDA_R_64F; - } - private static final int CUDA_C_64F = (int)5L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_64F = 5 - * } - */ - public static int CUDA_C_64F() { - return CUDA_C_64F; - } - private static final int CUDA_R_4I = (int)16L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_4I = 16 - * } - */ - public static int CUDA_R_4I() { - return CUDA_R_4I; - } - private static final int CUDA_C_4I = (int)17L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_4I = 17 - * } - */ - public static int CUDA_C_4I() { - return CUDA_C_4I; - } - private static final int CUDA_R_4U = (int)18L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_4U = 18 - * } - */ - public static int CUDA_R_4U() { - return CUDA_R_4U; - } - private static final int CUDA_C_4U = (int)19L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_4U = 19 - * } - */ - public static int CUDA_C_4U() { - return CUDA_C_4U; - } - private static final int CUDA_R_8I = (int)3L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_8I = 3 - * } - */ - public static int CUDA_R_8I() { - return CUDA_R_8I; - } - private static final int CUDA_C_8I = (int)7L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_8I = 7 - * } - */ - public static int CUDA_C_8I() { - return CUDA_C_8I; - } - private static final int CUDA_R_8U = (int)8L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_8U = 8 - * } - */ - public static int CUDA_R_8U() { - return CUDA_R_8U; - } - private static final int CUDA_C_8U = (int)9L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_8U = 9 - * } - */ - public static int CUDA_C_8U() { - return CUDA_C_8U; - } - private static final int CUDA_R_16I = (int)20L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_16I = 20 - * } - */ - public static int CUDA_R_16I() { - return CUDA_R_16I; - } - private static final int CUDA_C_16I = (int)21L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_16I = 21 - * } - */ - public static int CUDA_C_16I() { - return CUDA_C_16I; - } - private static final int CUDA_R_16U = (int)22L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_16U = 22 - * } - */ - public static int CUDA_R_16U() { - return CUDA_R_16U; - } - private static final int CUDA_C_16U = (int)23L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_16U = 23 - * } - */ - public static int CUDA_C_16U() { - return CUDA_C_16U; - } - private static final int CUDA_R_32I = (int)10L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_32I = 10 - * } - */ - public static int CUDA_R_32I() { - return CUDA_R_32I; - } - private static final int CUDA_C_32I = (int)11L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_32I = 11 - * } - */ - public static int CUDA_C_32I() { - return CUDA_C_32I; - } - private static final int CUDA_R_32U = (int)12L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_32U = 12 - * } - */ - public static int CUDA_R_32U() { - return CUDA_R_32U; - } - private static final int CUDA_C_32U = (int)13L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_32U = 13 - * } - */ - public static int CUDA_C_32U() { - return CUDA_C_32U; - } - private static final int CUDA_R_64I = (int)24L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_64I = 24 - * } - */ - public static int CUDA_R_64I() { - return CUDA_R_64I; - } - private static final int CUDA_C_64I = (int)25L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_64I = 25 - * } - */ - public static int CUDA_C_64I() { - return CUDA_C_64I; - } - private static final int CUDA_R_64U = (int)26L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_64U = 26 - * } - */ - public static int CUDA_R_64U() { - return CUDA_R_64U; - } - private static final int CUDA_C_64U = (int)27L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_64U = 27 - * } - */ - public static int CUDA_C_64U() { - return CUDA_C_64U; - } - private static final int MAJOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * enum libraryPropertyType_t.MAJOR_VERSION = 0 - * } - */ - public static int MAJOR_VERSION() { - return MAJOR_VERSION; - } - private static final int MINOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * enum libraryPropertyType_t.MINOR_VERSION = 1 - * } - */ - public static int MINOR_VERSION() { - return MINOR_VERSION; - } - private static final int PATCH_LEVEL = (int)2L; - /** - * {@snippet lang=c : - * enum libraryPropertyType_t.PATCH_LEVEL = 2 - * } - */ - public static int PATCH_LEVEL() { - return PATCH_LEVEL; - } - private static final int PER_SUBSPACE = (int)0L; - /** - * {@snippet lang=c : - * enum codebook_gen.PER_SUBSPACE = 0 - * } - */ - public static int PER_SUBSPACE() { - return PER_SUBSPACE; - } - private static final int PER_CLUSTER = (int)1L; - /** - * {@snippet lang=c : - * enum codebook_gen.PER_CLUSTER = 1 - * } - */ - public static int PER_CLUSTER() { - return PER_CLUSTER; - } - /** - * {@snippet lang=c : - * typedef struct cuvsIvfPqIndexParams { - * cuvsDistanceType metric; - * float metric_arg; - * _Bool add_data_on_build; - * uint32_t n_lists; - * uint32_t kmeans_n_iters; - * double kmeans_trainset_fraction; - * uint32_t pq_bits; - * uint32_t pq_dim; - * enum codebook_gen codebook_kind; - * _Bool force_random_rotation; - * _Bool conservative_memory_allocation; - * uint32_t max_train_points_per_pq_code; - * } *cuvsIvfPqIndexParams_t - * } - */ - public static final AddressLayout cuvsIvfPqIndexParams_t = ivf_pq_h.C_POINTER; - - private static class cuvsIvfPqIndexParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexParamsCreate$descriptor() { - return cuvsIvfPqIndexParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static MethodHandle cuvsIvfPqIndexParamsCreate$handle() { - return cuvsIvfPqIndexParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static MemorySegment cuvsIvfPqIndexParamsCreate$address() { - return cuvsIvfPqIndexParamsCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static int cuvsIvfPqIndexParamsCreate(MemorySegment index_params) { - var mh$ = cuvsIvfPqIndexParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexParamsCreate", index_params); - } - return (int)mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqIndexParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexParamsDestroy$descriptor() { - return cuvsIvfPqIndexParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static MethodHandle cuvsIvfPqIndexParamsDestroy$handle() { - return cuvsIvfPqIndexParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static MemorySegment cuvsIvfPqIndexParamsDestroy$address() { - return cuvsIvfPqIndexParamsDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static int cuvsIvfPqIndexParamsDestroy(MemorySegment index_params) { - var mh$ = cuvsIvfPqIndexParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexParamsDestroy", index_params); - } - return (int)mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef struct cuvsIvfPqSearchParams { - * uint32_t n_probes; - * cudaDataType_t lut_dtype; - * cudaDataType_t internal_distance_dtype; - * double preferred_shmem_carveout; - * } *cuvsIvfPqSearchParams_t - * } - */ - public static final AddressLayout cuvsIvfPqSearchParams_t = ivf_pq_h.C_POINTER; - - private static class cuvsIvfPqSearchParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static FunctionDescriptor cuvsIvfPqSearchParamsCreate$descriptor() { - return cuvsIvfPqSearchParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static MethodHandle cuvsIvfPqSearchParamsCreate$handle() { - return cuvsIvfPqSearchParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static MemorySegment cuvsIvfPqSearchParamsCreate$address() { - return cuvsIvfPqSearchParamsCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static int cuvsIvfPqSearchParamsCreate(MemorySegment params) { - var mh$ = cuvsIvfPqSearchParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSearchParamsCreate", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqSearchParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static FunctionDescriptor cuvsIvfPqSearchParamsDestroy$descriptor() { - return cuvsIvfPqSearchParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static MethodHandle cuvsIvfPqSearchParamsDestroy$handle() { - return cuvsIvfPqSearchParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static MemorySegment cuvsIvfPqSearchParamsDestroy$address() { - return cuvsIvfPqSearchParamsDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static int cuvsIvfPqSearchParamsDestroy(MemorySegment params) { - var mh$ = cuvsIvfPqSearchParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSearchParamsDestroy", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef cuvsIvfPq *cuvsIvfPqIndex_t - * } - */ - public static final AddressLayout cuvsIvfPqIndex_t = ivf_pq_h.C_POINTER; - - private static class cuvsIvfPqIndexCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexCreate$descriptor() { - return cuvsIvfPqIndexCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static MethodHandle cuvsIvfPqIndexCreate$handle() { - return cuvsIvfPqIndexCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static MemorySegment cuvsIvfPqIndexCreate$address() { - return cuvsIvfPqIndexCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static int cuvsIvfPqIndexCreate(MemorySegment index) { - var mh$ = cuvsIvfPqIndexCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexCreate", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqIndexDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexDestroy$descriptor() { - return cuvsIvfPqIndexDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqIndexDestroy$handle() { - return cuvsIvfPqIndexDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqIndexDestroy$address() { - return cuvsIvfPqIndexDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqIndexDestroy(MemorySegment index) { - var mh$ = cuvsIvfPqIndexDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexDestroy", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqBuild { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqBuild"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqBuild$descriptor() { - return cuvsIvfPqBuild.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqBuild$handle() { - return cuvsIvfPqBuild.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqBuild$address() { - return cuvsIvfPqBuild.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqBuild(long res, MemorySegment params, MemorySegment dataset, MemorySegment index) { - var mh$ = cuvsIvfPqBuild.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqBuild", res, params, dataset, index); - } - return (int)mh$.invokeExact(res, params, dataset, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqSearch { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearch"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static FunctionDescriptor cuvsIvfPqSearch$descriptor() { - return cuvsIvfPqSearch.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MethodHandle cuvsIvfPqSearch$handle() { - return cuvsIvfPqSearch.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MemorySegment cuvsIvfPqSearch$address() { - return cuvsIvfPqSearch.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static int cuvsIvfPqSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { - var mh$ = cuvsIvfPqSearch.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSearch", res, search_params, index, queries, neighbors, distances); - } - return (int)mh$.invokeExact(res, search_params, index, queries, neighbors, distances); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqSerialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSerialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqSerialize$descriptor() { - return cuvsIvfPqSerialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqSerialize$handle() { - return cuvsIvfPqSerialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqSerialize$address() { - return cuvsIvfPqSerialize.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqSerialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfPqSerialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSerialize", res, filename, index); - } - return (int)mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqDeserialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqDeserialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqDeserialize$descriptor() { - return cuvsIvfPqDeserialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqDeserialize$handle() { - return cuvsIvfPqDeserialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqDeserialize$address() { - return cuvsIvfPqDeserialize.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqDeserialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfPqDeserialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqDeserialize", res, filename, index); - } - return (int)mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqExtend { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqExtend"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqExtend$descriptor() { - return cuvsIvfPqExtend.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqExtend$handle() { - return cuvsIvfPqExtend.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqExtend$address() { - return cuvsIvfPqExtend.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, MemorySegment index) { - var mh$ = cuvsIvfPqExtend.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqExtend", res, new_vectors, new_indices, index); - } - return (int)mh$.invokeExact(res, new_vectors, new_indices, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } + ivf_pq_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) + : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + + private static final int _FEATURES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + + private static final int _DEFAULT_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + + private static final int __GLIBC_USE_ISOC2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + + private static final int __USE_ISOC11 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + + private static final int __USE_ISOC99 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + + private static final int __USE_ISOC95 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + + private static final int __USE_POSIX_IMPLICITLY = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + + private static final int _POSIX_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + + private static final int __USE_POSIX = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + + private static final int __USE_POSIX2 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + + private static final int __USE_POSIX199309 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + + private static final int __USE_POSIX199506 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + + private static final int __USE_XOPEN2K = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + + private static final int __USE_XOPEN2K8 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + + private static final int _ATFILE_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + + private static final int __WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + + private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; + + /** + * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + + private static final int __SYSCALL_WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + + private static final int __USE_MISC = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + + private static final int __USE_ATFILE = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + + private static final int __USE_FORTIFY_LEVEL = (int) 0L; + + /** + * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + + private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + + private static final int _STDC_PREDEF_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + + private static final int __STDC_IEC_559__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + + private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + + private static final int __GNU_LIBRARY__ = (int) 6L; + + /** + * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + + private static final int __GLIBC__ = (int) 2L; + + /** + * {@snippet lang = c : * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + + private static final int __GLIBC_MINOR__ = (int) 35L; + + /** + * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + + private static final int _SYS_CDEFS_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + + private static final int __glibc_c99_flexarr_available = (int) 1L; + + /** + * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; + + /** + * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + + private static final int __HAVE_GENERIC_SELECTION = (int) 1L; + + /** + * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + + private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + + private static final int _BITS_TYPES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + + private static final int _BITS_TYPESIZES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + + private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + + private static final int __INO_T_MATCHES_INO64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + + private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + + private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + + private static final int __FD_SETSIZE = (int) 1024L; + + /** + * {@snippet lang = c : * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + + private static final int _BITS_TIME64_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + + private static final int _BITS_WCHAR_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + + private static final int _BITS_STDINT_INTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + + private static final int _BITS_STDINT_UINTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + + private static final int DLPACK_MAJOR_VERSION = (int) 1L; + + /** + * {@snippet lang = c : * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + + private static final int DLPACK_MINOR_VERSION = (int) 0L; + + /** + * {@snippet lang = c : * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + + private static final int true_ = (int) 1L; + + /** + * {@snippet lang = c : * #define true 1 + * } + */ + public static int true_() { + return true_; + } + + private static final int false_ = (int) 0L; + + /** + * {@snippet lang = c : * #define false 0 + * } + */ + public static int false_() { + return false_; + } + + private static final int __bool_true_false_are_defined = (int) 1L; + + /** + * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + + /** + * {@snippet lang = c : * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off_t + * } + */ + public static final OfLong __off_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef long __time_t + * } + */ + public static final OfLong __time_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef int __key_t + * } + */ + public static final OfInt __key_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = ivf_pq_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = ivf_pq_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = ivf_pq_h.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 = ivf_pq_h.C_LONG; + private static final int L2Expanded = (int) 0L; + + /** + * {@snippet lang = c : * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + + private static final int L2SqrtExpanded = (int) 1L; + + /** + * {@snippet lang = c : * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + + private static final int CosineExpanded = (int) 2L; + + /** + * {@snippet lang = c : * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + + private static final int L1 = (int) 3L; + + /** + * {@snippet lang = c : * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + + private static final int L2Unexpanded = (int) 4L; + + /** + * {@snippet lang = c : * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + + private static final int L2SqrtUnexpanded = (int) 5L; + + /** + * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + + private static final int InnerProduct = (int) 6L; + + /** + * {@snippet lang = c : * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + + private static final int Linf = (int) 7L; + + /** + * {@snippet lang = c : * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + + private static final int Canberra = (int) 8L; + + /** + * {@snippet lang = c : * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + + private static final int LpUnexpanded = (int) 9L; + + /** + * {@snippet lang = c : * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + + private static final int CorrelationExpanded = (int) 10L; + + /** + * {@snippet lang = c : * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + + private static final int JaccardExpanded = (int) 11L; + + /** + * {@snippet lang = c : * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + + private static final int HellingerExpanded = (int) 12L; + + /** + * {@snippet lang = c : * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + + private static final int Haversine = (int) 13L; + + /** + * {@snippet lang = c : * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + + private static final int BrayCurtis = (int) 14L; + + /** + * {@snippet lang = c : * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + + private static final int JensenShannon = (int) 15L; + + /** + * {@snippet lang = c : * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + + private static final int HammingUnexpanded = (int) 16L; + + /** + * {@snippet lang = c : * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + + private static final int KLDivergence = (int) 17L; + + /** + * {@snippet lang = c : * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + + private static final int RusselRaoExpanded = (int) 18L; + + /** + * {@snippet lang = c : * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + + private static final int DiceExpanded = (int) 19L; + + /** + * {@snippet lang = c : * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + + private static final int Precomputed = (int) 100L; + + /** + * {@snippet lang = c : * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + + /** + * {@snippet lang = c : * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = ivf_pq_h.C_INT; + private static final int kDLCPU = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + + private static final int kDLCUDA = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + + private static final int kDLCUDAHost = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + + private static final int kDLOpenCL = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + + private static final int kDLVulkan = (int) 7L; + + /** + * {@snippet lang = c : * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + + private static final int kDLMetal = (int) 8L; + + /** + * {@snippet lang = c : * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + + private static final int kDLVPI = (int) 9L; + + /** + * {@snippet lang = c : * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + + private static final int kDLROCM = (int) 10L; + + /** + * {@snippet lang = c : * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + + private static final int kDLROCMHost = (int) 11L; + + /** + * {@snippet lang = c : * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + + private static final int kDLExtDev = (int) 12L; + + /** + * {@snippet lang = c : * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + + private static final int kDLCUDAManaged = (int) 13L; + + /** + * {@snippet lang = c : * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + + private static final int kDLOneAPI = (int) 14L; + + /** + * {@snippet lang = c : * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + + private static final int kDLWebGPU = (int) 15L; + + /** + * {@snippet lang = c : * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + + private static final int kDLHexagon = (int) 16L; + + /** + * {@snippet lang = c : * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + + private static final int kDLMAIA = (int) 17L; + + /** + * {@snippet lang = c : * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + + private static final int kDLInt = (int) 0L; + + /** + * {@snippet lang = c : * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + + private static final int kDLUInt = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + + private static final int kDLFloat = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + + private static final int kDLOpaqueHandle = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + + private static final int kDLBfloat = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + + private static final int kDLComplex = (int) 5L; + + /** + * {@snippet lang = c : * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + + private static final int kDLBool = (int) 6L; + + /** + * {@snippet lang = c : * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + + private static final int CUDA_R_16F = (int) 2L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16F = 2 + * } + */ + public static int CUDA_R_16F() { + return CUDA_R_16F; + } + + private static final int CUDA_C_16F = (int) 6L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16F = 6 + * } + */ + public static int CUDA_C_16F() { + return CUDA_C_16F; + } + + private static final int CUDA_R_16BF = (int) 14L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16BF = 14 + * } + */ + public static int CUDA_R_16BF() { + return CUDA_R_16BF; + } + + private static final int CUDA_C_16BF = (int) 15L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16BF = 15 + * } + */ + public static int CUDA_C_16BF() { + return CUDA_C_16BF; + } + + private static final int CUDA_R_32F = (int) 0L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_32F = 0 + * } + */ + public static int CUDA_R_32F() { + return CUDA_R_32F; + } + + private static final int CUDA_C_32F = (int) 4L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_32F = 4 + * } + */ + public static int CUDA_C_32F() { + return CUDA_C_32F; + } + + private static final int CUDA_R_64F = (int) 1L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_64F = 1 + * } + */ + public static int CUDA_R_64F() { + return CUDA_R_64F; + } + + private static final int CUDA_C_64F = (int) 5L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_64F = 5 + * } + */ + public static int CUDA_C_64F() { + return CUDA_C_64F; + } + + private static final int CUDA_R_4I = (int) 16L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_4I = 16 + * } + */ + public static int CUDA_R_4I() { + return CUDA_R_4I; + } + + private static final int CUDA_C_4I = (int) 17L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_4I = 17 + * } + */ + public static int CUDA_C_4I() { + return CUDA_C_4I; + } + + private static final int CUDA_R_4U = (int) 18L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_4U = 18 + * } + */ + public static int CUDA_R_4U() { + return CUDA_R_4U; + } + + private static final int CUDA_C_4U = (int) 19L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_4U = 19 + * } + */ + public static int CUDA_C_4U() { + return CUDA_C_4U; + } + + private static final int CUDA_R_8I = (int) 3L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_8I = 3 + * } + */ + public static int CUDA_R_8I() { + return CUDA_R_8I; + } + + private static final int CUDA_C_8I = (int) 7L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_8I = 7 + * } + */ + public static int CUDA_C_8I() { + return CUDA_C_8I; + } + + private static final int CUDA_R_8U = (int) 8L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_8U = 8 + * } + */ + public static int CUDA_R_8U() { + return CUDA_R_8U; + } + + private static final int CUDA_C_8U = (int) 9L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_8U = 9 + * } + */ + public static int CUDA_C_8U() { + return CUDA_C_8U; + } + + private static final int CUDA_R_16I = (int) 20L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16I = 20 + * } + */ + public static int CUDA_R_16I() { + return CUDA_R_16I; + } + + private static final int CUDA_C_16I = (int) 21L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16I = 21 + * } + */ + public static int CUDA_C_16I() { + return CUDA_C_16I; + } + + private static final int CUDA_R_16U = (int) 22L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16U = 22 + * } + */ + public static int CUDA_R_16U() { + return CUDA_R_16U; + } + + private static final int CUDA_C_16U = (int) 23L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16U = 23 + * } + */ + public static int CUDA_C_16U() { + return CUDA_C_16U; + } + + private static final int CUDA_R_32I = (int) 10L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_32I = 10 + * } + */ + public static int CUDA_R_32I() { + return CUDA_R_32I; + } + + private static final int CUDA_C_32I = (int) 11L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_32I = 11 + * } + */ + public static int CUDA_C_32I() { + return CUDA_C_32I; + } + + private static final int CUDA_R_32U = (int) 12L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_32U = 12 + * } + */ + public static int CUDA_R_32U() { + return CUDA_R_32U; + } + + private static final int CUDA_C_32U = (int) 13L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_32U = 13 + * } + */ + public static int CUDA_C_32U() { + return CUDA_C_32U; + } + + private static final int CUDA_R_64I = (int) 24L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_64I = 24 + * } + */ + public static int CUDA_R_64I() { + return CUDA_R_64I; + } + + private static final int CUDA_C_64I = (int) 25L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_64I = 25 + * } + */ + public static int CUDA_C_64I() { + return CUDA_C_64I; + } + + private static final int CUDA_R_64U = (int) 26L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_64U = 26 + * } + */ + public static int CUDA_R_64U() { + return CUDA_R_64U; + } + + private static final int CUDA_C_64U = (int) 27L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_64U = 27 + * } + */ + public static int CUDA_C_64U() { + return CUDA_C_64U; + } + + private static final int MAJOR_VERSION = (int) 0L; + + /** + * {@snippet lang = c : * enum libraryPropertyType_t.MAJOR_VERSION = 0 + * } + */ + public static int MAJOR_VERSION() { + return MAJOR_VERSION; + } + + private static final int MINOR_VERSION = (int) 1L; + + /** + * {@snippet lang = c : * enum libraryPropertyType_t.MINOR_VERSION = 1 + * } + */ + public static int MINOR_VERSION() { + return MINOR_VERSION; + } + + private static final int PATCH_LEVEL = (int) 2L; + + /** + * {@snippet lang = c : * enum libraryPropertyType_t.PATCH_LEVEL = 2 + * } + */ + public static int PATCH_LEVEL() { + return PATCH_LEVEL; + } + + private static final int PER_SUBSPACE = (int) 0L; + + /** + * {@snippet lang = c : * enum codebook_gen.PER_SUBSPACE = 0 + * } + */ + public static int PER_SUBSPACE() { + return PER_SUBSPACE; + } + + private static final int PER_CLUSTER = (int) 1L; + + /** + * {@snippet lang = c : * enum codebook_gen.PER_CLUSTER = 1 + * } + */ + public static int PER_CLUSTER() { + return PER_CLUSTER; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsIvfPqIndexParams { + * cuvsDistanceType metric; + * float metric_arg; + * _Bool add_data_on_build; + * uint32_t n_lists; + * uint32_t kmeans_n_iters; + * double kmeans_trainset_fraction; + * uint32_t pq_bits; + * uint32_t pq_dim; + * enum codebook_gen codebook_kind; + * _Bool force_random_rotation; + * _Bool conservative_memory_allocation; + * uint32_t max_train_points_per_pq_code; + * } *cuvsIvfPqIndexParams_t + * } + */ + public static final AddressLayout cuvsIvfPqIndexParams_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexParamsCreate$descriptor() { + return cuvsIvfPqIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static MethodHandle cuvsIvfPqIndexParamsCreate$handle() { + return cuvsIvfPqIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static MemorySegment cuvsIvfPqIndexParamsCreate$address() { + return cuvsIvfPqIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static int cuvsIvfPqIndexParamsCreate(MemorySegment index_params) { + var mh$ = cuvsIvfPqIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexParamsCreate", index_params); + } + return (int) mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexParamsDestroy$descriptor() { + return cuvsIvfPqIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static MethodHandle cuvsIvfPqIndexParamsDestroy$handle() { + return cuvsIvfPqIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static MemorySegment cuvsIvfPqIndexParamsDestroy$address() { + return cuvsIvfPqIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static int cuvsIvfPqIndexParamsDestroy(MemorySegment index_params) { + var mh$ = cuvsIvfPqIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexParamsDestroy", index_params); + } + return (int) mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : + * typedef struct cuvsIvfPqSearchParams { + * uint32_t n_probes; + * cudaDataType_t lut_dtype; + * cudaDataType_t internal_distance_dtype; + * double preferred_shmem_carveout; + * } *cuvsIvfPqSearchParams_t + * } + */ + public static final AddressLayout cuvsIvfPqSearchParams_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearchParamsCreate$descriptor() { + return cuvsIvfPqSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static MethodHandle cuvsIvfPqSearchParamsCreate$handle() { + return cuvsIvfPqSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static MemorySegment cuvsIvfPqSearchParamsCreate$address() { + return cuvsIvfPqSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static int cuvsIvfPqSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsIvfPqSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearchParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearchParamsDestroy$descriptor() { + return cuvsIvfPqSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static MethodHandle cuvsIvfPqSearchParamsDestroy$handle() { + return cuvsIvfPqSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static MemorySegment cuvsIvfPqSearchParamsDestroy$address() { + return cuvsIvfPqSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static int cuvsIvfPqSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsIvfPqSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearchParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : * typedef cuvsIvfPq *cuvsIvfPqIndex_t + * } + */ + public static final AddressLayout cuvsIvfPqIndex_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexCreate$descriptor() { + return cuvsIvfPqIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static MethodHandle cuvsIvfPqIndexCreate$handle() { + return cuvsIvfPqIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static MemorySegment cuvsIvfPqIndexCreate$address() { + return cuvsIvfPqIndexCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static int cuvsIvfPqIndexCreate(MemorySegment index) { + var mh$ = cuvsIvfPqIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexCreate", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexDestroy$descriptor() { + return cuvsIvfPqIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqIndexDestroy$handle() { + return cuvsIvfPqIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqIndexDestroy$address() { + return cuvsIvfPqIndexDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqIndexDestroy(MemorySegment index) { + var mh$ = cuvsIvfPqIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexDestroy", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqBuild$descriptor() { + return cuvsIvfPqBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqBuild$handle() { + return cuvsIvfPqBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqBuild$address() { + return cuvsIvfPqBuild.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqBuild(long res, MemorySegment params, MemorySegment dataset, MemorySegment index) { + var mh$ = cuvsIvfPqBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqBuild", res, params, dataset, index); + } + return (int) mh$.invokeExact(res, params, dataset, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearch$descriptor() { + return cuvsIvfPqSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsIvfPqSearch$handle() { + return cuvsIvfPqSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsIvfPqSearch$address() { + return cuvsIvfPqSearch.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsIvfPqSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, + MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsIvfPqSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearch", res, search_params, index, queries, neighbors, distances); + } + return (int) mh$.invokeExact(res, search_params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSerialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSerialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqSerialize$descriptor() { + return cuvsIvfPqSerialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqSerialize$handle() { + return cuvsIvfPqSerialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqSerialize$address() { + return cuvsIvfPqSerialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqSerialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfPqSerialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSerialize", res, filename, index); + } + return (int) mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqDeserialize$descriptor() { + return cuvsIvfPqDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqDeserialize$handle() { + return cuvsIvfPqDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqDeserialize$address() { + return cuvsIvfPqDeserialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqDeserialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfPqDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqDeserialize", res, filename, index); + } + return (int) mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqExtend { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqExtend"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqExtend$descriptor() { + return cuvsIvfPqExtend.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqExtend$handle() { + return cuvsIvfPqExtend.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqExtend$address() { + return cuvsIvfPqExtend.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, + MemorySegment index) { + var mh$ = cuvsIvfPqExtend.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqExtend", res, new_vectors, new_indices, index); + } + return (int) mh$.invokeExact(res, new_vectors, new_indices, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static final long _POSIX_C_SOURCE = 200809L; + + /** + * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + + private static final int __TIMESIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + + private static final long __STDC_IEC_60559_BFP__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + + private static final long __STDC_ISO_10646__ = 201706L; + + /** + * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + + private static final int __WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + + private static final int __WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + + private static final int INT8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + + private static final int INT16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + + private static final int INT32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + + private static final long INT64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + + private static final int INT8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + + private static final int INT16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + + private static final int INT32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + + private static final long INT64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + + private static final int UINT8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + + private static final int UINT16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + + private static final int UINT32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + + private static final long UINT64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + + private static final int INT_LEAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + + private static final int INT_LEAST16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + + private static final int INT_LEAST32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + + private static final long INT_LEAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + + private static final int INT_LEAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + + private static final int INT_LEAST16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + + private static final int INT_LEAST32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + + private static final long INT_LEAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + + private static final int UINT_LEAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + + private static final int UINT_LEAST16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + + private static final int UINT_LEAST32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + + private static final long UINT_LEAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + + private static final int INT_FAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + + private static final long INT_FAST16_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + + private static final long INT_FAST32_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + + private static final long INT_FAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + + private static final int INT_FAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + + private static final long INT_FAST16_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + + private static final long INT_FAST32_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + + private static final long INT_FAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + + private static final int UINT_FAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + + private static final long UINT_FAST16_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + + private static final long UINT_FAST32_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + + private static final long UINT_FAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + + private static final long INTPTR_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + + private static final long INTPTR_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + + private static final long UINTPTR_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + + private static final long INTMAX_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + + private static final long INTMAX_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + + private static final long UINTMAX_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + + private static final long PTRDIFF_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + + private static final long PTRDIFF_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + + private static final int SIG_ATOMIC_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + + private static final int SIG_ATOMIC_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + + private static final long SIZE_MAX = -1L; + + /** + * {@snippet lang = c : * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + + private static final int WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + + private static final int WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + + private static final int WINT_MIN = (int) 0L; + + /** + * {@snippet lang = c : * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + + private static final int WINT_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + + /** + * {@snippet lang = c : * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } } - diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java index 555a4316e..21076f75f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java index 6f4b031bb..78b81f44b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java index aabd8b41b..de4a42082 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.ValueLayout.JAVA_BYTE; diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index b5f553108..e4d9df120 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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 static org.junit.jupiter.api.Assertions.assertEquals; @@ -24,7 +40,7 @@ public class CagraBuildAndSearchTest { - private static Logger LOGGER = LoggerFactory.getLogger(CagraBuildAndSearchTest.class); + private static Logger logger = LoggerFactory.getLogger(CagraBuildAndSearchTest.class); /** * A basic test that checks the whole flow - from indexing to search. @@ -47,59 +63,60 @@ public void testIndexingAndSearchingFlow() throws Throwable { Map.of(1, 0.15224178f, 0, 0.59063464f, 3, 0.5986642f)); // Create resource - CuVSResources res = new CuVSResources(); + CuVSResources cuvsResources = new CuVSResources(); // Configure index parameters - CagraIndexParams cagraIndexParams = new CagraIndexParams + CagraIndexParams cagraIndexParameters = new CagraIndexParams .Builder() - .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.NN_DESCENT) + .withCuvsCagraGraphBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.NN_DESCENT) .build(); // Create the index with the dataset - CagraIndex index = new CagraIndex - .Builder(res) + CagraIndex cagraIndex = new CagraIndex + .Builder(cuvsResources) .withDataset(dataset) - .withIndexParams(cagraIndexParams) + .withIndexParams(cagraIndexParameters) .build(); // Saving the index on to the disk. - String fileName = UUID.randomUUID().toString() + ".cag"; - index.serialize(new FileOutputStream(fileName)); + String indexFileName = UUID.randomUUID().toString() + ".cag"; + cagraIndex.serialize(new FileOutputStream(indexFileName)); // Loading a CAGRA index from disk. - File testSerializedIndexFile = new File(fileName); - InputStream fin = new FileInputStream(testSerializedIndexFile); - CagraIndex index2 = new CagraIndex.Builder(res) - .from(fin) + File testSerializedIndexFile = new File(indexFileName); + InputStream inputStream = new FileInputStream(testSerializedIndexFile); + CagraIndex deserializedCagraIndex = new CagraIndex + .Builder(cuvsResources) + .from(inputStream) .build(); // Configure search parameters - CagraSearchParams cagraSearchParams = new CagraSearchParams + CagraSearchParams cagraSearchParameters = new CagraSearchParams .Builder() .build(); // Create a query object with the query vectors - CuVSQuery query = new CuVSQuery + CuVSQuery cuvsQuery = new CuVSQuery .Builder() .withTopK(3) - .withSearchParams(cagraSearchParams) + .withSearchParams(cagraSearchParameters) .withQueryVectors(queries) .withMapping(map) .build(); // Perform the search - SearchResult searchResults = index.search(query); + SearchResult searchResults = cagraIndex.search(cuvsQuery); // Check results - LOGGER.info(searchResults.getResults().toString()); + logger.info(searchResults.getResults().toString()); assertEquals(expectedQueryResults, searchResults.getResults(), "Results different than expected"); - // Search from de-serialized index - SearchResult searchResults2 = index2.search(query); + // Search from deserialized index + SearchResult searchResultsFromDeserializedCagraIndex = deserializedCagraIndex.search(cuvsQuery); // Check results - LOGGER.info(searchResults.getResults().toString()); - assertEquals(expectedQueryResults, searchResults2.getResults(), "Results different than expected"); + logger.info(searchResults.getResults().toString()); + assertEquals(expectedQueryResults, searchResultsFromDeserializedCagraIndex.getResults(), "Results different than expected"); // Cleanup if (testSerializedIndexFile.exists()) { diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index db8177e6e..0352e24e3 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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. + */ + #include #include #include @@ -5,10 +21,10 @@ #include #include -cuvsResources_t create_resource(int *rv) { - cuvsResources_t res; - *rv = cuvsResourcesCreate(&res); - return res; +cuvsResources_t create_resource(int *returnValue) { + cuvsResources_t cuvsResources; + *returnValue = cuvsResourcesCreate(&cuvsResources); + return cuvsResources; } DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, long dimensions) { @@ -26,35 +42,35 @@ DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, return tensor; } -cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsResources_t res, int *rv, +cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvsResources, int *returnValue, cuvsCagraIndexParams_t index_params) { - + int64_t dataset_shape[2] = {rows, dimensions}; DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat, dimensions); cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); - *rv = cuvsCagraBuild(res, index_params, &dataset_tensor, index); + *returnValue = cuvsCagraBuild(cuvsResources, index_params, &dataset_tensor, index); return index; } -void serialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, char* filename) { - *rv = cuvsCagraSerialize(res, filename, index, true); +void serialize_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { + *returnValue = cuvsCagraSerialize(cuvsResources, filename, index, true); } -void deserialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, char* filename) { - *rv = cuvsCagraDeserialize(res, filename, index); +void deserialize_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *rv, char* filename) { + *rv = cuvsCagraDeserialize(cuvsResources, filename, index); } void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, - cuvsResources_t res, int *neighbors_h, float *distances_h, int *rv, cuvsCagraSearchParams_t search_params) { - + cuvsResources_t cuvsResources, int *neighbors_h, float *distances_h, int *returnValue, cuvsCagraSearchParams_t search_params) { + uint32_t *neighbors; float *distances, *queries_d; - cuvsRMMAlloc(res, (void**) &queries_d, sizeof(float) * n_queries * dimensions); - cuvsRMMAlloc(res, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); - cuvsRMMAlloc(res, (void**) &distances, sizeof(float) * n_queries * topk); + cuvsRMMAlloc(cuvsResources, (void**) &queries_d, sizeof(float) * n_queries * dimensions); + cuvsRMMAlloc(cuvsResources, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); + cuvsRMMAlloc(cuvsResources, (void**) &distances, sizeof(float) * n_queries * topk); cudaMemcpy(queries_d, queries, sizeof(float) * n_queries * dimensions, cudaMemcpyDefault); @@ -69,7 +85,7 @@ void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queri cuvsCagraSearchParamsCreate(&search_params); - *rv = cuvsCagraSearch(res, search_params, index, &queries_tensor, &neighbors_tensor, + *returnValue = cuvsCagraSearch(cuvsResources, search_params, index, &queries_tensor, &neighbors_tensor, &distances_tensor); cudaMemcpy(neighbors_h, neighbors, sizeof(uint32_t) * n_queries * topk, cudaMemcpyDefault); From 322253626392eed188ea6643d09ccd353a7dac05 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Sat, 16 Nov 2024 13:58:17 -0500 Subject: [PATCH 10/53] Javadoc draft 1 --- .../com/nvidia/cuvs/cagra/CagraIndex.java | 191 ++++++++-- .../nvidia/cuvs/cagra/CagraIndexParams.java | 127 ++++++- .../cuvs/cagra/CagraIndexReference.java | 20 + .../nvidia/cuvs/cagra/CagraSearchParams.java | 350 +++++++++++++++--- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 91 ++++- .../com/nvidia/cuvs/cagra/CuVSResources.java | 25 +- .../java/com/nvidia/cuvs/cagra/PreFilter.java | 10 +- .../com/nvidia/cuvs/cagra/SearchResult.java | 45 ++- java/internal/src/cuvs_java.c | 8 +- 9 files changed, 761 insertions(+), 106 deletions(-) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 75d12736e..cb617de2b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -40,75 +40,123 @@ *

* CAGRA is a graph-based nearest neighbors algorithm that was built from the * ground up for GPU acceleration. CAGRA demonstrates state-of-the art index - * build and query performance for both small- and large-batch sized search. + * build and query performance for both small and large-batch sized search. Know + * more about this algorithm + * here + * + * @since 24.12 */ public class CagraIndex { private final float[][] dataset; private final CuVSResources cuvsResources; private Arena arena; - private CagraIndexParams cagraIndexParameters; - private CagraIndexReference cagraIndesReference; private Linker linker; private MethodHandle indexMethodHandle; private MethodHandle searchMethodHandle; private MethodHandle serializeMethodHandle; private MethodHandle deserializeMethodHandle; private SymbolLookup symbolLookup; + private CagraIndexParams cagraIndexParameters; + private CagraIndexReference cagraIndesReference; + /** + * Constructor that initializes CagraIndex with an instance of CagraIndexParams, + * dataset, and an instance of CuVSResources + * + * @param indexParameters index parameters + * @param dataset 2D float dataset array + * @param cuvsResources cuVS resources instance + * @throws Throwable exception thrown when native function is invoked + * @see CagraIndexParams + * @see CuVSResources + */ private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources cuvsResources) throws Throwable { this.cagraIndexParameters = indexParameters; this.dataset = dataset; - this.init(); + this.initializeMethodHandles(); this.cuvsResources = cuvsResources; this.cagraIndesReference = build(); } + /** + * Constructs an instance of CagraIndex with an instance of InputStream and + * CuVSResources + * + * @param inputStream an instance of InputStream (eg. FileInputStream) to read + * a persisted CAGRA index. + * @param cuvsResources an instance of CuVSResources. + * @throws Throwable exception thrown when native function is invoked + */ private CagraIndex(InputStream inputStream, CuVSResources cuvsResources) throws Throwable { this.cagraIndexParameters = null; this.dataset = null; this.cuvsResources = cuvsResources; - this.init(); + this.initializeMethodHandles(); this.cagraIndesReference = deserialize(inputStream); } - private void init() throws Throwable { + /** + * Initializes the MethodHandles for invoking native methods. + * + * @see MethodHandle + */ + private void initializeMethodHandles() { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); File workingDirectory = new File(System.getProperty("user.dir")); symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - indexMethodHandle = linker.downcallHandle(symbolLookup.find("build_index").get(), + indexMethodHandle = linker.downcallHandle(symbolLookup.find("build_cagra_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - searchMethodHandle = linker.downcallHandle(symbolLookup.find("search_index").get(), + searchMethodHandle = linker.downcallHandle(symbolLookup.find("search_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMethodHandle = linker.downcallHandle(symbolLookup.find("serialize_index").get(), + serializeMethodHandle = linker.downcallHandle(symbolLookup.find("serialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMethodHandle = linker.downcallHandle(symbolLookup.find("deserialize_index").get(), + deserializeMethodHandle = linker.downcallHandle(symbolLookup.find("deserialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } - public MemorySegment getStringSegment(StringBuilder string) { + /** + * A utility method for getting an instance of MemorySegment for a String. + * + * @param string the string for the expected MemorySegment + * @return an instance of MemorySegment + * @see MemoryLayout + * @see MemorySegment + * @see StringBuilder + */ + public MemorySegment getStringMemorySegment(StringBuilder string) { string.append('\0'); - MemoryLayout sq = MemoryLayout.sequenceLayout(string.length(), linker.canonicalLayouts().get("char")); - MemorySegment fln = arena.allocate(sq); + MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(string.length(), + linker.canonicalLayouts().get("char")); + MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); for (int i = 0; i < string.length(); i++) { - VarHandle flnVH = sq.varHandle(PathElement.sequenceElement(i)); - flnVH.set(fln, 0L, (byte) string.charAt(i)); + VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); + varHandle.set(stringMemorySegment, 0L, (byte) string.charAt(i)); } - return fln; + return stringMemorySegment; } + /** + * A utility method for getting an instance of MemorySegment for a 2D float + * array. + * + * @param data The 2D float array for which the MemorySegment is needed + * @return an instance of MemorySegment + * @see MemoryLayout + * @see MemorySegment + */ private MemorySegment getMemorySegment(float[][] data) { long rows = data.length; long cols = data[0].length; @@ -128,6 +176,15 @@ private MemorySegment getMemorySegment(float[][] data) { return dataMemorySegment; } + /** + * Invokes the native build_index function via the Panama API to build the CAGRA + * index. + * + * @return an instance of CagraIndexReference that holds the pointer to the + * index + * @throws Throwable exception thrown when native function is invoked + * @see CagraIndexReference + */ private CagraIndexReference build() throws Throwable { long rows = dataset.length; long cols = dataset[0].length; @@ -141,6 +198,17 @@ private CagraIndexReference build() throws Throwable { return cagraIndesReference; } + /** + * Invokes the native search_index via the Panama API for searching a CAGRA + * index. + * + * @param cuvsQuery an instance of CuVSQuery holding the query and its + * parameters + * @return an instance of SearchResult containing the results + * @throws Throwable exception thrown when native function is invoked + * @see CuVSQuery + * @see SearchResult + */ public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); @@ -153,19 +221,27 @@ public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { searchMethodHandle.invokeExact(cagraIndesReference.getIndexMemorySegment(), getMemorySegment(cuvsQuery.getQueryVectors()), cuvsQuery.getTopK(), 4L, 2L, cuvsResources.getCuvsResourcesMemorySegment(), neighborsMemorySegment, distancesMemorySegment, - returnValueMemorySegment, cuvsQuery.getCagraSearchParameters().getCagraSearchParamsMS()); + returnValueMemorySegment, cuvsQuery.getCagraSearchParameters().getCagraSearchParamsMemorySegment()); return new SearchResult(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, distancesMemorySegment, cuvsQuery.getTopK(), cuvsQuery.getMapping(), cuvsQuery.getQueryVectors().length); } + /** + * A method to persist a CAGRA index using an instance of OutputStream for + * writing index bytes. + * + * @param outputStream an instance of OutputStream to write the index bytes into + * @throws Throwable exception thrown when native function is invoked + * @see OutputStream + */ public void serialize(OutputStream outputStream) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringSegment(new StringBuilder(tmpIndexFile))); + getStringMemorySegment(new StringBuilder(tmpIndexFile))); File tempFile = new File(tmpIndexFile); FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; @@ -177,12 +253,21 @@ public void serialize(OutputStream outputStream) throws Throwable { tempFile.delete(); } + /** + * A method to persist a CAGRA index using an instance of OutputStream and path + * to the intermediate temporary file. + * + * @param outputStream an instance of OutputStream to write the index bytes to + * @param tmpFilePath path to a temporary file where CAGRA index is written + * @throws Throwable exception thrown when native function is invoked + * @see OutputStream + */ public void serialize(OutputStream outputStream, String tmpFilePath) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringSegment(new StringBuilder(tmpFilePath))); + getStringMemorySegment(new StringBuilder(tmpFilePath))); File tempFile = new File(tmpFilePath); FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; @@ -194,6 +279,17 @@ public void serialize(OutputStream outputStream, String tmpFilePath) throws Thro tempFile.delete(); } + /** + * Gets an instance of CagraIndexReference by deserializing a CAGRA index using + * an input stream. + * + * @param inputStream an instance of InputStream (eg. FileInputStream when + * reading an index file). + * @return an instance of CagraIndexReference. + * @throws Throwable exception thrown when native function is invoked + * @see CagraIndexReference + * @see InputStream + */ private CagraIndexReference deserialize(InputStream inputStream) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); @@ -209,7 +305,7 @@ private CagraIndexReference deserialize(InputStream inputStream) throws Throwabl } deserializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), cagraIndexReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringSegment(new StringBuilder(tmpIndexFile))); + getStringMemorySegment(new StringBuilder(tmpIndexFile))); inputStream.close(); fileOutputStream.close(); @@ -218,40 +314,88 @@ private CagraIndexReference deserialize(InputStream inputStream) throws Throwabl return cagraIndexReference; } - public CagraIndexParams getParams() { + /** + * Gets an instance of CagraIndexParams. + * + * @return an instance of CagraIndexParams + * @see CagraIndexParams + */ + public CagraIndexParams getCagraIndexParameters() { return cagraIndexParameters; } - public CuVSResources getResources() { + /** + * Gets an instance of CuVSResources. + * + * @return an instance of CuVSResources + * @see CuVSResources + */ + public CuVSResources getCuVSResources() { return cuvsResources; } + /** + * Builder helps configure and create an instance of CagraIndex. + */ public static class Builder { - private CagraIndexParams cagraIndexParams; private float[][] dataset; + private CagraIndexParams cagraIndexParams; private CuVSResources cuvsResources; private InputStream inputStream; + /** + * Constructs this Builder with an instance of CuVSResources. + * + * @param cuvsResources an instance of CuVSResources + * @see CuVSResources + */ public Builder(CuVSResources cuvsResources) { this.cuvsResources = cuvsResources; } + /** + * Sets an instance of InputStream typically used when index deserialization is + * needed. + * + * @param inputStream an instance of InputStream + * @return an instance of this Builder + * @see InputStream + */ public Builder from(InputStream inputStream) { this.inputStream = inputStream; return this; } + /** + * Sets the dataset for building the CAGRA index. + * + * @param dataset a two-dimensional float array + * @return an instance of this Builder + */ public Builder withDataset(float[][] dataset) { this.dataset = dataset; return this; } + /** + * Registers an instance of configured CagraIndexParams with this Builder. + * + * @param cagraIndexParameters An instance of CagraIndexParams. + * @return An instance of this Builder. + * @see CagraIndexParams + */ public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { this.cagraIndexParams = cagraIndexParameters; return this; } + /** + * Builds and returns an instance of CagraIndex. + * + * @return an instance of CagraIndex + * @throws Throwable exception thrown when native function is invoked + */ public CagraIndex build() throws Throwable { if (inputStream != null) { return new CagraIndex(inputStream, cuvsResources); @@ -260,5 +404,4 @@ public CagraIndex build() throws Throwable { } } } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index 3030e458f..9a65ca167 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -21,21 +21,40 @@ import com.nvidia.cuvs.panama.cuvsCagraIndexParams; -/* -* Supplemental parameters to build CAGRA Index. -*/ +/** + * Supplemental parameters to build CAGRA Index. + * + * @since 24.12 + */ public class CagraIndexParams { + private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; + private MemorySegment cagraIndexParamsMemorySegment; private Arena arena; private int intermediateGraphDegree; private int graphDegree; - private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; private int nnDescentNiter; - private MemorySegment cagraIndexParamsMemorySegment; + /** + * Enum that denotes which ANN algorithm is used to build CAGRA graph. + */ public enum CuvsCagraGraphBuildAlgo { - AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); - + /** + * AUTO_SELECT + */ + AUTO_SELECT(0), + /** + * IVF_PQ + */ + IVF_PQ(1), + /** + * NN_DESCENT + */ + NN_DESCENT(2); + + /** + * The value for the enum choice. + */ public final int label; private CuvsCagraGraphBuildAlgo(int label) { @@ -43,6 +62,18 @@ private CuvsCagraGraphBuildAlgo(int label) { } } + /** + * Constructor that initializes CagraIndexParams with an instance of Arena, + * intermediateGraphDegree, graphDegree, CuvsCagraGraphBuildAlgo, and + * nnDescentNiter. + * + * @param arena the Arena instance to use + * @param intermediateGraphDegree the degree of input graph for pruning + * @param graphDegree the degree of output graph + * @param CuvsCagraGraphBuildAlgo the CuvsCagraGraphBuildAlgo + * @param nnDescentNiter the number of Iterations to run if building + * with NN_DESCENT + */ public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, CuvsCagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter) { this.arena = arena; @@ -50,10 +81,15 @@ public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegre this.graphDegree = graphDegree; this.cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo; this.nnDescentNiter = nnDescentNiter; - this.set(); + this.setCagraIndexParamsStubValues(); } - private void set() { + /** + * Sets the parameter values in the stub's MemorySegment. + * + * @see MemorySegment + */ + private void setCagraIndexParamsStubValues() { cagraIndexParamsMemorySegment = cuvsCagraIndexParams.allocate(arena); cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMemorySegment, intermediateGraphDegree); cuvsCagraIndexParams.graph_degree(cagraIndexParamsMemorySegment, graphDegree); @@ -61,22 +97,47 @@ private void set() { cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMemorySegment, nnDescentNiter); } + /** + * Gets the degree of input graph for pruning. + * + * @return the degree of input graph + */ public int getIntermediateGraphDegree() { return intermediateGraphDegree; } + /** + * Gets the degree of output graph. + * + * @return the degree of output graph + */ public int getGraphDegree() { return graphDegree; } + /** + * Gets the CuvsCagraGraphBuildAlgo. + * + * @return CuvsCagraGraphBuildAlgo selected + */ public CuvsCagraGraphBuildAlgo getCuvsCagraGraphBuildAlgo() { return cuvsCagraGraphBuildAlgo; } + /** + * Gets the number of Iterations to run if building with NN_DESCENT. + * + * @return the number of Iterations + */ public int getNNDescentNiter() { return nnDescentNiter; } + /** + * Gets the cagraIndexParams MemorySegment. + * + * @return an instance of MemorySegment + */ public MemorySegment getCagraIndexParamsMemorySegment() { return cagraIndexParamsMemorySegment; } @@ -88,45 +149,89 @@ public String toString() { + nnDescentNiter + ", cagraIndexParamsMemorySegment=" + cagraIndexParamsMemorySegment + "]"; } + /** + * Builder configures and creates an instance of CagraIndexParams. + */ public static class Builder { + private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo.NN_DESCENT; private Arena arena; private int intermediateGraphDegree = 128; private int graphDegree = 64; - private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo.NN_DESCENT; private int nnDescentNiter = 20; private int writerThreads = 1; + /** + * Constructor for builder for initializing and instance of Arena. + * + * @see Arena + */ public Builder() { this.arena = Arena.ofConfined(); } + /** + * Sets the degree of input graph for pruning. + * + * @param intermediateGraphDegree degree of input graph for pruning + * @return an instance of Builder + */ public Builder withIntermediateGraphDegree(int intermediateGraphDegree) { this.intermediateGraphDegree = intermediateGraphDegree; return this; } + /** + * Sets the degree of output graph. + * + * @param graphDegree degree of output graph + * @return an instance to Builder + */ public Builder withGraphDegree(int graphDegree) { this.graphDegree = graphDegree; return this; } + /** + * Sets the CuvsCagraGraphBuildAlgo to use. + * + * @param cuvsCagraGraphBuildAlgo the CuvsCagraGraphBuildAlgo to use + * @return an instance of Builder + */ public Builder withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo) { this.cuvsCagraGraphBuildAlgo = cuvsCagraGraphBuildAlgo; return this; } + /** + * Sets the Number of Iterations to run if building with NN_DESCENT. + * + * @param nnDescentNiter number of Iterations to run if building with NN_DESCENT + * @return an instance of Builder + */ public Builder withNNDescentNiter(int nnDescentNiter) { this.nnDescentNiter = nnDescentNiter; return this; } + /** + * Registers the number of writer threads to use for indexing. + * + * @param writerThreads number of writer threads to use + * @return an instance of Builder + */ public Builder withWriterThreads(int writerThreads) { this.writerThreads = writerThreads; return this; } - public CagraIndexParams build() throws Throwable { + /** + * Builds an instance of CagraIndexParams. + * + * @return an instance of CagraIndexParams + * @see CagraIndexParams + */ + public CagraIndexParams build() { return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, nnDescentNiter); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java index 2eab62147..a675ebd76 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -21,19 +21,39 @@ import com.nvidia.cuvs.panama.cuvsCagraIndex; +/** + * Holds the reference to the index using MemorySegment. + * + * @since 24.12 + */ public class CagraIndexReference { private MemorySegment indexMemorySegment; + /** + * Constructs CagraIndexReference and allocate the MemorySegment. + */ public CagraIndexReference() { Arena arena = Arena.ofConfined(); indexMemorySegment = cuvsCagraIndex.allocate(arena); } + /** + * Constructs CagraIndexReference with an instance of MemorySegment passed as a + * parameter. + * + * @param indexMemorySegment the MemorySegment instance to use for containing + * index reference + */ public CagraIndexReference(MemorySegment indexMemorySegment) { this.indexMemorySegment = indexMemorySegment; } + /** + * Gets the instance of index MemorySegment. + * + * @return index MemorySegment + */ public MemorySegment getIndexMemorySegment() { return indexMemorySegment; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index df4398fd2..1d2cf6ae4 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -21,47 +21,115 @@ import com.nvidia.cuvs.panama.cuvsCagraSearchParams; +/** + * CagraSearchParams encapsulates the logic for configuring and holding search + * parameters. + * + * @since 24.12 + */ public class CagraSearchParams { - private Arena arena; private int maxQueries; private int itopkSize; private int maxIterations; - private CuvsCagraSearchAlgo cuvsCagraSearchAlgo; private int teamSize; private int searchWidth; private int minIterations; private int threadBlockSize; - private CuvsCagraHashMode cuvsCagraHashMode; private int hashmapMinBitlen; - private float hashmapMaxFillRate; private int numRandomSamplings; + private float hashmapMaxFillRate; private long randXorMask; + private Arena arena; private MemorySegment cagraSearchParamsMemorySegment; - - enum CuvsCagraSearchAlgo { - SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); - - public final int label; - - private CuvsCagraSearchAlgo(int label) { - this.label = label; + private CuvsCagraSearchAlgo cuvsCagraSearchAlgo; + private CuvsCagraHashMapMode cuvsCagraHashMapMode; + + /** + * Enum to denote algorithm used to search CAGRA Index. + */ + public enum CuvsCagraSearchAlgo { + /** + * for large batch sizes + */ + SINGLE_CTA(0), + /** + * for small batch sizes + */ + MULTI_CTA(1), + /** + * MULTI_KERNEL + */ + MULTI_KERNEL(2), + /** + * AUTO + */ + AUTO(3); + + /** + * The value for the enum choice. + */ + public final int value; + + private CuvsCagraSearchAlgo(int value) { + this.value = value; } } - enum CuvsCagraHashMode { - HASH(0), SMALL(1), AUTO_HASH(2); - - public final int label; - - private CuvsCagraHashMode(int label) { - this.label = label; + /** + * Enum to denote Hash Mode used while searching CAGRA index. + */ + public enum CuvsCagraHashMapMode { + /** + * HASH + */ + HASH(0), + /** + * SMALL + */ + SMALL(1), + /** + * AUTO_HASH + */ + AUTO_HASH(2); + + /** + * The value for the enum choice. + */ + public final int value; + + private CuvsCagraHashMapMode(int value) { + this.value = value; } } + /** + * Constructs an instance of CagraSearchParams with passed search parameters. + * + * @param arena the Arena instance to use + * @param maxQueries the maximum number of queries to search at the + * same time (batch size) + * @param itopkSize the number of intermediate search results retained + * during the search + * @param maxIterations the upper limit of search iterations + * @param cuvsCagraSearchAlgo the search implementation is configured + * @param teamSize the number of threads used to calculate a single + * distance + * @param searchWidth the number of graph nodes to select as the + * starting point for the search in each iteration + * @param minIterations the lower limit of search iterations + * @param threadBlockSize the thread block size + * @param hashmapMode the hashmap type configured + * @param hashmapMinBitlen the lower limit of hashmap bit length + * @param hashmapMaxFillRate the upper limit of hashmap fill rate + * @param numRandomSamplings the number of iterations of initial random seed + * node selection + * @param randXorMask the bit mask used for initial random seed node + * selection + */ public CagraSearchParams(Arena arena, int maxQueries, int itopkSize, int maxIterations, CuvsCagraSearchAlgo cuvsCagraSearchAlgo, int teamSize, int searchWidth, int minIterations, int threadBlockSize, - CuvsCagraHashMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, + CuvsCagraHashMapMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, long randXorMask) { super(); this.arena = arena; @@ -73,188 +141,362 @@ public CagraSearchParams(Arena arena, int maxQueries, int itopkSize, int maxIter this.searchWidth = searchWidth; this.minIterations = minIterations; this.threadBlockSize = threadBlockSize; - this.cuvsCagraHashMode = hashmapMode; + this.cuvsCagraHashMapMode = hashmapMode; this.hashmapMinBitlen = hashmapMinBitlen; this.hashmapMaxFillRate = hashmapMaxFillRate; this.numRandomSamplings = numRandomSamplings; this.randXorMask = randXorMask; - this.set(); + this.setSearchParametersInTheStubMemorySegment(); } - public void set() { + /** + * Sets the configured search parameters in the MemorySegment. + */ + public void setSearchParametersInTheStubMemorySegment() { cagraSearchParamsMemorySegment = cuvsCagraSearchParams.allocate(arena); cuvsCagraSearchParams.max_queries(cagraSearchParamsMemorySegment, maxQueries); cuvsCagraSearchParams.itopk_size(cagraSearchParamsMemorySegment, itopkSize); cuvsCagraSearchParams.max_iterations(cagraSearchParamsMemorySegment, maxIterations); - cuvsCagraSearchParams.algo(cagraSearchParamsMemorySegment, cuvsCagraSearchAlgo.label); + cuvsCagraSearchParams.algo(cagraSearchParamsMemorySegment, cuvsCagraSearchAlgo.value); cuvsCagraSearchParams.team_size(cagraSearchParamsMemorySegment, teamSize); cuvsCagraSearchParams.search_width(cagraSearchParamsMemorySegment, searchWidth); cuvsCagraSearchParams.min_iterations(cagraSearchParamsMemorySegment, minIterations); cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMemorySegment, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMemorySegment, cuvsCagraHashMode.label); + cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMemorySegment, cuvsCagraHashMapMode.value); cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMemorySegment, hashmapMinBitlen); cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMemorySegment, hashmapMaxFillRate); cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMemorySegment, numRandomSamplings); cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMemorySegment, randXorMask); } - public int getMax_queries() { + /** + * Gets the maximum number of queries to search at the same time (batch size). + * + * @return the maximum number of queries + */ + public int getMaxQueries() { return maxQueries; } - public int getItopk_size() { + /** + * Gets the number of intermediate search results retained during the search. + * + * @return the number of intermediate search results + */ + public int getItopkSize() { return itopkSize; } - public int getMax_iterations() { + /** + * Gets the upper limit of search iterations. + * + * @return the upper limit value + */ + public int getMaxIterations() { return maxIterations; } - public CuvsCagraSearchAlgo getAlgo() { - return cuvsCagraSearchAlgo; - } - - public int getTeam_size() { + /** + * Gets the number of threads used to calculate a single distance. + * + * @return the number of threads configured + */ + public int getTeamSize() { return teamSize; } - public int getSearch_width() { + /** + * Gets the number of graph nodes to select as the starting point for the search + * in each iteration. + * + * @return the number of graph nodes + */ + public int getSearchWidth() { return searchWidth; } - public int getMin_iterations() { + /** + * Gets the lower limit of search iterations. + * + * @return the lower limit value + */ + public int getMinIterations() { return minIterations; } - public int getThread_block_size() { + /** + * Gets the thread block size. + * + * @return the thread block size + */ + public int getThreadBlockSize() { return threadBlockSize; } - public CuvsCagraHashMode getHashmap_mode() { - return cuvsCagraHashMode; - } - - public int getHashmap_min_bitlen() { + /** + * Gets the lower limit of hashmap bit length. + * + * @return the lower limit value + */ + public int getHashmapMinBitlen() { return hashmapMinBitlen; } - public float getHashmap_max_fill_rate() { - return hashmapMaxFillRate; + /** + * Gets the number of iterations of initial random seed node selection. + * + * @return the number of iterations + */ + public int getNumRandomSamplings() { + return numRandomSamplings; } - public int getNum_random_samplings() { - return numRandomSamplings; + /** + * Gets the upper limit of hashmap fill rate. + * + * @return the upper limit of hashmap fill rate + */ + public float getHashmapMaxFillRate() { + return hashmapMaxFillRate; } - public long getRand_xor_mask() { + /** + * Gets the bit mask used for initial random seed node selection. + * + * @return the bit mask value + */ + public long getRandXorMask() { return randXorMask; } - public MemorySegment getCagraSearchParamsMS() { + /** + * Gets the MemorySegment holding CagraSearchParams. + * + * @return the MemorySegment holding CagraSearchParams + */ + public MemorySegment getCagraSearchParamsMemorySegment() { return cagraSearchParamsMemorySegment; } + /** + * Gets which search implementation is configured. + * + * @return the search implementation configured + * @see CuvsCagraSearchAlgo + */ + public CuvsCagraSearchAlgo getCuvsCagraSearchAlgo() { + return cuvsCagraSearchAlgo; + } + + /** + * Gets the hashmap type configured. + * + * @return the hashmap type configured + * @see CuvsCagraHashMapMode + */ + public CuvsCagraHashMapMode getCuvsCagraHashMapMode() { + return cuvsCagraHashMapMode; + } + @Override public String toString() { return "CagraSearchParams [arena=" + arena + ", maxQueries=" + maxQueries + ", itopkSize=" + itopkSize + ", maxIterations=" + maxIterations + ", cuvsCagraSearchAlgo=" + cuvsCagraSearchAlgo + ", teamSize=" + teamSize + ", searchWidth=" + searchWidth + ", minIterations=" + minIterations + ", threadBlockSize=" + threadBlockSize - + ", cuvsCagraHashMode=" + cuvsCagraHashMode + ", hashmapMinBitlen=" + hashmapMinBitlen + + ", cuvsCagraHashMapMode=" + cuvsCagraHashMapMode + ", hashmapMinBitlen=" + hashmapMinBitlen + ", hashmapMaxFillRate=" + hashmapMaxFillRate + ", numRandomSamplings=" + numRandomSamplings + ", randXorMask=" + randXorMask + ", cagraSearchParamsMemorySegment=" + cagraSearchParamsMemorySegment + "]"; } + /** + * Builder configures and creates an instance of CagraSearchParams. + */ public static class Builder { private Arena arena; private int maxQueries = 1; private int itopkSize = 2; private int maxIterations = 3; - private CuvsCagraSearchAlgo cuvsCagraSearchAlgo = CuvsCagraSearchAlgo.MULTI_KERNEL; private int teamSize = 4; private int searchWidth = 5; private int minIterations = 6; private int threadBlockSize = 7; - private CuvsCagraHashMode cuvsCagraHashMode = CuvsCagraHashMode.AUTO_HASH; private int hashmapMinBitlen = 8; - private float hashmapMaxFillRate = 9.0f; private int numRandomSamplings = 10; + private float hashmapMaxFillRate = 9.0f; private long randXorMask = 11L; + private CuvsCagraSearchAlgo cuvsCagraSearchAlgo = CuvsCagraSearchAlgo.MULTI_KERNEL; + private CuvsCagraHashMapMode cuvsCagraHashMode = CuvsCagraHashMapMode.AUTO_HASH; + /** + * Constructs this Builder with an instance of Arena. + */ public Builder() { this.arena = Arena.ofConfined(); } + /** + * Sets the maximum number of queries to search at the same time (batch size). + * Auto select when 0. + * + * @param maxQueries the maximum number of queries + * @return an instance of this Builder + */ public Builder withMaxQueries(int maxQueries) { this.maxQueries = maxQueries; return this; } + /** + * Sets the number of intermediate search results retained during the search. + * This is the main knob to adjust trade off between accuracy and search speed. + * Higher values improve the search accuracy. + * + * @param itopkSize the number of intermediate search results + * @return an instance of this Builder + */ public Builder withItopkSize(int itopkSize) { this.itopkSize = itopkSize; return this; } + /** + * Sets the upper limit of search iterations. Auto select when 0. + * + * @param maxIterations the upper limit of search iterations + * @return an instance of this Builder + */ public Builder withMaxIterations(int maxIterations) { this.maxIterations = maxIterations; return this; } + /** + * Sets which search implementation to use. + * + * @param cuvsCagraSearchAlgo the search implementation to use + * @return an instance of this Builder + * @see CuvsCagraSearchAlgo + */ public Builder withAlgo(CuvsCagraSearchAlgo cuvsCagraSearchAlgo) { this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; return this; } + /** + * Sets the number of threads used to calculate a single distance. 4, 8, 16, or + * 32. + * + * @param teamSize the number of threads used to calculate a single distance + * @return an instance of this Builder + */ public Builder withTeamSize(int teamSize) { this.teamSize = teamSize; return this; } + /** + * Sets the number of graph nodes to select as the starting point for the search + * in each iteration. + * + * @param searchWidth the number of graph nodes to select + * @return an instance of this Builder + */ public Builder withSearchWidth(int searchWidth) { this.searchWidth = searchWidth; return this; } + /** + * Sets the lower limit of search iterations. + * + * @param minIterations the lower limit of search iterations + * @return an instance of this Builder + */ public Builder withMinIterations(int minIterations) { this.minIterations = minIterations; return this; } + /** + * Sets the thread block size. 0, 64, 128, 256, 512, 1024. Auto selection when + * 0. + * + * @param threadBlockSize the thread block size + * @return an instance of this Builder + */ public Builder withThreadBlockSize(int threadBlockSize) { this.threadBlockSize = threadBlockSize; return this; } - public Builder withHashmapMode(CuvsCagraHashMode cuvsCagraHashMode) { + /** + * Sets the hashmap type. Auto selection when AUTO. + * + * @param cuvsCagraHashMode the hashmap type + * @return an instance of this Builder + * @see CuvsCagraHashMapMode + */ + public Builder withHashmapMode(CuvsCagraHashMapMode cuvsCagraHashMode) { this.cuvsCagraHashMode = cuvsCagraHashMode; return this; } + /** + * Sets the lower limit of hashmap bit length. More than 8. + * + * @param hashmapMinBitlen the lower limit of hashmap bit length + * @return an instance of this Builder + */ public Builder withHashmapMinBitlen(int hashmapMinBitlen) { this.hashmapMinBitlen = hashmapMinBitlen; return this; } + /** + * Sets the upper limit of hashmap fill rate. More than 0.1, less than 0.9. + * + * @param hashmapMaxFillRate the upper limit of hashmap fill rate + * @return an instance of this Builder + */ public Builder withHashmapMaxFillRate(float hashmapMaxFillRate) { this.hashmapMaxFillRate = hashmapMaxFillRate; return this; } + /** + * Sets the number of iterations of initial random seed node selection. 1 or + * more. + * + * @param numRandomSamplings the number of iterations of initial random seed + * node selection + * @return an instance of this Builder + */ public Builder withNumRandomSamplings(int numRandomSamplings) { this.numRandomSamplings = numRandomSamplings; return this; } + /** + * Sets the bit mask used for initial random seed node selection. + * + * @param randXorMask the bit mask used for initial random seed node selection + * @return an instance of this Builder + */ public Builder withRandXorMask(long randXorMask) { this.randXorMask = randXorMask; return this; } - public CagraSearchParams build() throws Throwable { + /** + * Builds an instance of CagraSearchParams with passed search parameters. + * + * @return an instance of CagraSearchParams + */ + public CagraSearchParams build() { return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, cuvsCagraSearchAlgo, teamSize, searchWidth, minIterations, threadBlockSize, cuvsCagraHashMode, hashmapMinBitlen, hashmapMaxFillRate, numRandomSamplings, randXorMask); } - } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index 1fc3321de..b3260be83 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -19,14 +19,31 @@ import java.util.Arrays; import java.util.Map; +/** + * CuVSQuery holds the CagraSearchParams and the query vectors to be used while + * invoking search. + * + * @since 24.12 + */ public class CuVSQuery { private CagraSearchParams cagraSearchParameters; private PreFilter preFilter; - private float[][] queryVectors; private Map mapping; + private float[][] queryVectors; private int topK; + /** + * Constructs an instance of CuVSQuery using cagraSearchParameters, preFilter, + * queryVectors, mapping, and topK. + * + * @param cagraSearchParameters an instance of CagraSearchParams holding the + * search parameters + * @param preFilter an instance of PreFilter + * @param queryVectors 2D float query vector array + * @param mapping an instance of ID mapping + * @param topK the top k results to return + */ public CuVSQuery(CagraSearchParams cagraSearchParameters, PreFilter preFilter, float[][] queryVectors, Map mapping, int topK) { super(); @@ -37,22 +54,47 @@ public CuVSQuery(CagraSearchParams cagraSearchParameters, PreFilter preFilter, f this.topK = topK; } + /** + * Gets the instance of CagraSearchParams initially set. + * + * @return an instance CagraSearchParams + */ public CagraSearchParams getCagraSearchParameters() { return cagraSearchParameters; } + /** + * Gets the instance of PreFilter initially set. + * + * @return an instance of PreFilter + */ public PreFilter getPreFilter() { return preFilter; } + /** + * Gets the query vector 2D float array. + * + * @return 2D float array + */ public float[][] getQueryVectors() { return queryVectors; } + /** + * Gets the passed map instance. + * + * @return a map of ID mappings + */ public Map getMapping() { return mapping; } + /** + * Gets the topK value. + * + * @return an integer + */ public int getTopK() { return topK; } @@ -63,6 +105,9 @@ public String toString() { + Arrays.toString(queryVectors) + ", mapping=" + mapping + ", topK=" + topK + "]"; } + /** + * Builder helps configure and create an instance of CuVSQuery. + */ public static class Builder { private CagraSearchParams cagraSearchParams; @@ -71,32 +116,74 @@ public static class Builder { private Map mapping; private int topK = 2; + /** + * Default constructor. + */ + public Builder() { + } + + /** + * Sets the instance of configured CagraSearchParams to be passed for search. + * + * @param cagraSearchParams an instance of the configured CagraSearchParams to + * be used for this query + * @return an instance of this Builder + */ public Builder withSearchParams(CagraSearchParams cagraSearchParams) { this.cagraSearchParams = cagraSearchParams; return this; } + /** + * Registers the query vectors to be passed in the search call. + * + * @param queryVectors 2D float query vector array + * @return an instance of this Builder + */ public Builder withQueryVectors(float[][] queryVectors) { this.queryVectors = queryVectors; return this; } + /** + * Sets the PreFilter to be used with CuVSQuery. + * + * @param preFilter the PreFilter instance to be configured + * @return an instance of this Builder + */ public Builder withPreFilter(PreFilter preFilter) { this.preFilter = preFilter; return this; } + /** + * Sets the instance of mapping to be used for ID mapping. + * + * @param mapping the ID mapping instance + * @return an instance of this Builder + */ public Builder withMapping(Map mapping) { this.mapping = mapping; return this; } + /** + * Registers the topK value. + * + * @param topK the topK value used to retrieve the topK results + * @return an instance of this Builder + */ public Builder withTopK(int topK) { this.topK = topK; return this; } - public CuVSQuery build() throws Throwable { + /** + * Builds an instance of CuVSQuery. + * + * @return an instance of CuVSQuery + */ + public CuVSQuery build() { return new CuVSQuery(cagraSearchParams, preFilter, queryVectors, mapping, topK); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java index 6ab5b7554..42ed42a1a 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -26,14 +26,26 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; +/** + * CuVSResources has the logic to initialize and hold the reference to CuVS + * Resources instance. + * + * @since 24.12 + */ public class CuVSResources { private Arena arena; private Linker linker; - private MethodHandle createResourcesMemoryHandler; - private MemorySegment cuvsResourcesMemorySegment; private SymbolLookup symbolLookup; + private MethodHandle createResourcesMethodHandle; + private MemorySegment cuvsResourcesMemorySegment; + /** + * Constructor for CuVSResources that initializes MethodHandle and invokes the + * native create_resource function via Panama API. + * + * @throws Throwable exception thrown when native function is invoked + */ public CuVSResources() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); @@ -41,15 +53,20 @@ public CuVSResources() throws Throwable { File workingDirectory = new File(System.getProperty("user.dir")); symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - createResourcesMemoryHandler = linker.downcallHandle(symbolLookup.find("create_resource").get(), + createResourcesMethodHandle = linker.downcallHandle(symbolLookup.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - cuvsResourcesMemorySegment = (MemorySegment) createResourcesMemoryHandler.invokeExact(returnValueMemorySegment); + cuvsResourcesMemorySegment = (MemorySegment) createResourcesMethodHandle.invokeExact(returnValueMemorySegment); } + /** + * Gets the reference to the cuvsResources MemorySegment. + * + * @return cuvsResources MemorySegment + */ public MemorySegment getCuvsResourcesMemorySegment() { return cuvsResourcesMemorySegment; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java index 5034d2e45..4d985c9d0 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java @@ -17,8 +17,16 @@ package com.nvidia.cuvs.cagra; /** - * TODO: Pending implementation + * Pending Implementation + * + * @since 24.12 */ public class PreFilter { + /** + * Default constructor + */ + public PreFilter() { + } + } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index 0eea21c9a..911c9f09a 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -25,6 +25,11 @@ import java.util.List; import java.util.Map; +/** + * SearchResult encapsulates the logic for reading and holding search results. + * + * @since 24.12 + */ public class SearchResult { private List> results; @@ -36,6 +41,22 @@ public class SearchResult { private int topK; private int numberOfQueries; + /** + * Constructor that initializes SearchResult with neighboursSequenceLayout, + * distancesSequenceLayout, neighboursMemorySegment, distancesMemorySegment, + * topK, mapping, and numberOfQueries. + * + * @param neighboursSequenceLayout neighbor SequenceLayout instance + * @param distancesSequenceLayout distance SequenceLayout instance + * @param neighboursMemorySegment neighbor MemorySegment instance + * @param distancesMemorySegment distance MemorySegment instance + * @param topK an integer denoting the topK value + * @param mapping id mapping + * @param numberOfQueries number of queries that were initially + * submitted + * @see SequenceLayout + * @see MemorySegment + */ public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, MemorySegment neighboursMemorySegment, MemorySegment distancesMemorySegment, int topK, Map mapping, int numberOfQueries) { @@ -48,18 +69,25 @@ public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout dist this.distancesMemorySegment = distancesMemorySegment; this.mapping = mapping; results = new LinkedList>(); - this.load(); + this.readResultMemorySegments(); } - private void load() { - VarHandle neighboursVH = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); - VarHandle distancesVH = distancesSequenceLayout.varHandle(PathElement.sequenceElement()); + /** + * Reads neighbors and distances MemorySegments and load values in a List of + * Maps. + * + * @see MemorySegment + * @see VarHandle + */ + private void readResultMemorySegments() { + VarHandle neighboursVarHandle = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); + VarHandle distancesVarHandle = distancesSequenceLayout.varHandle(PathElement.sequenceElement()); Map intermediateResultMap = new LinkedHashMap(); int count = 0; for (long i = 0; i < topK * numberOfQueries; i++) { - int id = (int) neighboursVH.get(neighboursMemorySegment, 0L, i); - float dst = (float) distancesVH.get(distancesMemorySegment, 0L, i); + int id = (int) neighboursVarHandle.get(neighboursMemorySegment, 0L, i); + float dst = (float) distancesVarHandle.get(distancesMemorySegment, 0L, i); intermediateResultMap.put(mapping != null ? mapping.get(id) : id, dst); count += 1; if (count == topK) { @@ -70,6 +98,11 @@ private void load() { } } + /** + * Gets a list of maps containing topK ID and distances. + * + * @return a list of maps + */ public List> getResults() { return results; } diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index 0352e24e3..06fcac6ed 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -42,7 +42,7 @@ DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, return tensor; } -cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvsResources, int *returnValue, +cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvsResources, int *returnValue, cuvsCagraIndexParams_t index_params) { int64_t dataset_shape[2] = {rows, dimensions}; @@ -55,15 +55,15 @@ cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsRes return index; } -void serialize_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { +void serialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { *returnValue = cuvsCagraSerialize(cuvsResources, filename, index, true); } -void deserialize_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *rv, char* filename) { +void deserialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *rv, char* filename) { *rv = cuvsCagraDeserialize(cuvsResources, filename, index); } -void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, +void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, cuvsResources_t cuvsResources, int *neighbors_h, float *distances_h, int *returnValue, cuvsCagraSearchParams_t search_params) { uint32_t *neighbors; From c5536b6110c2f5277505ade21bf545c8695e8a34 Mon Sep 17 00:00:00 2001 From: Ishan Chattopadhyaya Date: Sun, 17 Nov 2024 20:51:27 +0530 Subject: [PATCH 11/53] Fixes for Javadocs, reducing visibility of internals, other refactorings --- java/README.md | 6 +- java/build.sh | 13 +- .../{ExampleApp.java => CagraExample.java} | 67 ++--- .../com/nvidia/cuvs/cagra/CagraIndex.java | 259 +++++++----------- .../nvidia/cuvs/cagra/CagraIndexParams.java | 128 ++++----- .../cuvs/cagra/CagraIndexReference.java | 60 ---- .../cagra/{CuVSQuery.java => CagraQuery.java} | 37 +-- .../nvidia/cuvs/cagra/CagraSearchParams.java | 199 +++++++------- ...rchResult.java => CagraSearchResults.java} | 52 ++-- .../java/com/nvidia/cuvs/cagra/PreFilter.java | 32 --- .../main/java/com/nvidia/cuvs/cagra/Util.java | 72 +++++ .../cuvs/{cagra => common}/CuVSResources.java | 28 +- .../com/nvidia/cuvs/common/SearchResults.java | 14 + ...xParams.java => CuVSCagraIndexParams.java} | 4 +- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 40 ++- 15 files changed, 431 insertions(+), 580 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{ExampleApp.java => CagraExample.java} (52%) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java rename java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/{CuVSQuery.java => CagraQuery.java} (80%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/{SearchResult.java => CagraSearchResults.java} (62%) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => common}/CuVSResources.java (69%) create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java rename java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/{cuvsCagraIndexParams.java => CuVSCagraIndexParams.java} (99%) diff --git a/java/README.md b/java/README.md index 4919578b1..a734273d6 100644 --- a/java/README.md +++ b/java/README.md @@ -1,12 +1,12 @@ Prerequisites ------------- -* JDK 24 +* JDK 22 * Maven 3.9.6 or later -Please build libcuvs (`./build.sh libcuvs` from top level directory) before building the Java API. +Please build libcuvs (`./build.sh libcuvs` from top level directory) before building the Java API with `./build.sh` from this directory. Building -------- -./build.sh will generate the libcuvs_java.so file in internal/ directory, and then build the final jar file for the cuVS Java API in cuvs-java/ directory. +`./build.sh` will generate the libcuvs_java.so file in internal/ directory, and then build the final jar file for the cuVS Java API in cuvs-java/ directory. diff --git a/java/build.sh b/java/build.sh index b06cf2fac..162c9e83f 100755 --- a/java/build.sh +++ b/java/build.sh @@ -1,9 +1,6 @@ export CMAKE_PREFIX_PATH=`pwd`/../cpp/build -cd internal -cmake . -cmake --build . -cd .. -mvn install:install-file -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java-internal -Dversion=0.1 -Dpackaging=so -Dfile=./internal/libcuvs_java.so - -cd cuvs-java -mvn package +cd internal && cmake . && cmake --build . \ + && cd .. \ + && mvn install:install-file -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java-internal -Dversion=0.1 -Dpackaging=so -Dfile=./internal/libcuvs_java.so \ + && cd cuvs-java \ + && mvn package diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java similarity index 52% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java index 592720827..bb8e1d978 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java @@ -20,78 +20,67 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; -import java.util.Map; +import java.lang.invoke.MethodHandles; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; -import com.nvidia.cuvs.cagra.CagraIndexParams.CuvsCagraGraphBuildAlgo; +import com.nvidia.cuvs.cagra.CagraIndexParams.CagraGraphBuildAlgo; +import com.nvidia.cuvs.common.CuVSResources; +import com.nvidia.cuvs.common.SearchResults; import com.nvidia.cuvs.cagra.CagraSearchParams; -import com.nvidia.cuvs.cagra.CuVSQuery; -import com.nvidia.cuvs.cagra.CuVSResources; -import com.nvidia.cuvs.cagra.SearchResult; +import com.nvidia.cuvs.cagra.CagraQuery; -public class ExampleApp { +public class CagraExample { - private static Logger logger = LoggerFactory.getLogger(ExampleApp.class); + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); public static void main(String[] args) throws Throwable { // Sample data and query float[][] dataset = { { 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, { 0.6673192f, 0.10993068f } }; - Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); float[][] queries = { { 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f } }; - CuVSResources cuvsResources = new CuVSResources(); + // Allocate the resources + CuVSResources resources = new CuVSResources(); - CagraIndexParams cagraIndexParameters = new CagraIndexParams - .Builder() + // Building a new CAGRA index + CagraIndexParams indexParams = new CagraIndexParams.Builder() .withIntermediateGraphDegree(10) - .withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo.NN_DESCENT) + .withCagraGraphBuildAlgo(CagraGraphBuildAlgo.NN_DESCENT) .build(); - - // Creating a new CAGRA index - CagraIndex cagraIndex = new CagraIndex - .Builder(cuvsResources) + CagraIndex index = new CagraIndex.Builder(resources) .withDataset(dataset) - .withIndexParams(cagraIndexParameters) + .withIndexParams(indexParams) .build(); - // Saving the CAGRA index on to the disk. - File indexFile = new File("sample_index.cag"); - cagraIndex.serialize(new FileOutputStream(indexFile)); + // Serializing the index to a file + File indexFile = new File("cagra_index.cag"); + index.serialize(new FileOutputStream(indexFile)); - // Loading a CAGRA index from disk. + // Loading a CAGRA index from the file. InputStream fileInputStream = new FileInputStream(indexFile); - CagraIndex deserializedIndex = new CagraIndex - .Builder(cuvsResources) + CagraIndex loadedIndex = new CagraIndex.Builder(resources) .from(fileInputStream) .build(); - CagraSearchParams cagraSearchParameters = new CagraSearchParams - .Builder() - .build(); - - // Query - CuVSQuery cuvsQuery = new CuVSQuery - .Builder() + // Search + CagraSearchParams searchParams = new CagraSearchParams.Builder().build(); + CagraQuery query = new CagraQuery.Builder() .withTopK(3) - .withSearchParams(cagraSearchParameters) + .withSearchParams(searchParams) .withQueryVectors(queries) - .withMapping(map) .build(); + SearchResults results = index.search(query); + log.info(results.getResults().toString()); - // Search - SearchResult searchResult = cagraIndex.search(cuvsQuery); - logger.info(searchResult.getResults().toString()); - - // Search from deserialized index - SearchResult searchResultFromDeserializedIndex = deserializedIndex.search(cuvsQuery); - logger.info(searchResultFromDeserializedIndex.getResults().toString()); + // Search from loaded index + results = loadedIndex.search(query); + log.info(results.getResults().toString()); // Cleanup if (indexFile.exists()) { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index cb617de2b..45cfd86da 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -25,18 +25,18 @@ import java.lang.foreign.FunctionDescriptor; import java.lang.foreign.Linker; import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemoryLayout.PathElement; import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.foreign.SymbolLookup; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; -import java.lang.invoke.VarHandle; import java.util.UUID; +import com.nvidia.cuvs.common.CuVSResources; +import com.nvidia.cuvs.panama.cuvsCagraIndex; + /** - * CagraIndex encapsulates the implementation of crucial methods for interacting - * with the CAGRA index. + * {@link CagraIndex} encapsulates a CAGRA index, along with methods to interact with it. *

* CAGRA is a graph-based nearest neighbors algorithm that was built from the * ground up for GPU acceleration. CAGRA demonstrates state-of-the art index @@ -58,18 +58,10 @@ public class CagraIndex { private MethodHandle deserializeMethodHandle; private SymbolLookup symbolLookup; private CagraIndexParams cagraIndexParameters; - private CagraIndexReference cagraIndesReference; + private IndexReference cagraIndexReference; - /** - * Constructor that initializes CagraIndex with an instance of CagraIndexParams, - * dataset, and an instance of CuVSResources - * - * @param indexParameters index parameters - * @param dataset 2D float dataset array - * @param cuvsResources cuVS resources instance - * @throws Throwable exception thrown when native function is invoked - * @see CagraIndexParams - * @see CuVSResources + /* + * Constructor for building the index using specified dataset */ private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources cuvsResources) throws Throwable { @@ -77,30 +69,22 @@ private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSReso this.dataset = dataset; this.initializeMethodHandles(); this.cuvsResources = cuvsResources; - this.cagraIndesReference = build(); + this.cagraIndexReference = build(); } /** - * Constructs an instance of CagraIndex with an instance of InputStream and - * CuVSResources - * - * @param inputStream an instance of InputStream (eg. FileInputStream) to read - * a persisted CAGRA index. - * @param cuvsResources an instance of CuVSResources. - * @throws Throwable exception thrown when native function is invoked + * Constructor for loading the index from an {@link InputStream} */ private CagraIndex(InputStream inputStream, CuVSResources cuvsResources) throws Throwable { this.cagraIndexParameters = null; this.dataset = null; this.cuvsResources = cuvsResources; this.initializeMethodHandles(); - this.cagraIndesReference = deserialize(inputStream); + this.cagraIndexReference = deserialize(inputStream); } /** - * Initializes the MethodHandles for invoking native methods. - * - * @see MethodHandle + * Initializes the {@link MethodHandles} for invoking native methods. */ private void initializeMethodHandles() { linker = Linker.nativeLinker(); @@ -127,90 +111,33 @@ private void initializeMethodHandles() { } /** - * A utility method for getting an instance of MemorySegment for a String. - * - * @param string the string for the expected MemorySegment - * @return an instance of MemorySegment - * @see MemoryLayout - * @see MemorySegment - * @see StringBuilder - */ - public MemorySegment getStringMemorySegment(StringBuilder string) { - string.append('\0'); - MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(string.length(), - linker.canonicalLayouts().get("char")); - MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); - - for (int i = 0; i < string.length(); i++) { - VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); - varHandle.set(stringMemorySegment, 0L, (byte) string.charAt(i)); - } - return stringMemorySegment; - } - - /** - * A utility method for getting an instance of MemorySegment for a 2D float - * array. - * - * @param data The 2D float array for which the MemorySegment is needed - * @return an instance of MemorySegment - * @see MemoryLayout - * @see MemorySegment - */ - private MemorySegment getMemorySegment(float[][] data) { - long rows = data.length; - long cols = data[0].length; - - MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, - MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); - MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); - - for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), - PathElement.sequenceElement(c)); - element.set(dataMemorySegment, 0, 0, data[r][c]); - } - } - - return dataMemorySegment; - } - - /** - * Invokes the native build_index function via the Panama API to build the CAGRA - * index. + * Invokes the native build_index function via the Panama API to build the {@link CagraIndex} * - * @return an instance of CagraIndexReference that holds the pointer to the + * @return an instance of {@link IndexReference} that holds the pointer to the * index - * @throws Throwable exception thrown when native function is invoked - * @see CagraIndexReference */ - private CagraIndexReference build() throws Throwable { + private IndexReference build() throws Throwable { long rows = dataset.length; long cols = dataset[0].length; - MemoryLayout returnvalueMemoryLayout = linker.canonicalLayouts().get("int"); - MemorySegment returnvalueMemorySegment = arena.allocate(returnvalueMemoryLayout); + MemoryLayout layout = linker.canonicalLayouts().get("int"); + MemorySegment segment = arena.allocate(layout); - cagraIndesReference = new CagraIndexReference((MemorySegment) indexMethodHandle.invokeExact( - getMemorySegment(dataset), rows, cols, cuvsResources.getCuvsResourcesMemorySegment(), returnvalueMemorySegment, - cagraIndexParameters.getCagraIndexParamsMemorySegment())); + cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( + Util.buildMemorySegment(linker, arena, dataset), rows, cols, cuvsResources.getMemorySegment(), segment, + cagraIndexParameters.getMemorySegment())); - return cagraIndesReference; + return cagraIndexReference; } /** * Invokes the native search_index via the Panama API for searching a CAGRA * index. * - * @param cuvsQuery an instance of CuVSQuery holding the query and its + * @param query an instance of {@link CagraQuery} holding the query vectors and other * parameters - * @return an instance of SearchResult containing the results - * @throws Throwable exception thrown when native function is invoked - * @see CuVSQuery - * @see SearchResult + * @return an instance of {@link CagraSearchResults} containing the results */ - public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { - + public CagraSearchResults search(CagraQuery query) throws Throwable { SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); MemorySegment neighborsMemorySegment = arena.allocate(neighborsSequenceLayout); @@ -218,59 +145,40 @@ public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - searchMethodHandle.invokeExact(cagraIndesReference.getIndexMemorySegment(), - getMemorySegment(cuvsQuery.getQueryVectors()), cuvsQuery.getTopK(), 4L, 2L, - cuvsResources.getCuvsResourcesMemorySegment(), neighborsMemorySegment, distancesMemorySegment, - returnValueMemorySegment, cuvsQuery.getCagraSearchParameters().getCagraSearchParamsMemorySegment()); + searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), + Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), 4L, 2L, + cuvsResources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, + returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); - return new SearchResult(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, - distancesMemorySegment, cuvsQuery.getTopK(), cuvsQuery.getMapping(), cuvsQuery.getQueryVectors().length); + return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, + distancesMemorySegment, query.getTopK(), query.getMapping(), query.getQueryVectors().length); } /** - * A method to persist a CAGRA index using an instance of OutputStream for + * A method to persist a CAGRA index using an instance of {@link OutputStream} for * writing index bytes. * - * @param outputStream an instance of OutputStream to write the index bytes into - * @throws Throwable exception thrown when native function is invoked - * @see OutputStream + * @param outputStream an instance of {@link OutputStream} to write the index bytes into */ public void serialize(OutputStream outputStream) throws Throwable { - MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); - MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), - cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringMemorySegment(new StringBuilder(tmpIndexFile))); - File tempFile = new File(tmpIndexFile); - FileInputStream fileInputStream = new FileInputStream(tempFile); - byte[] chunk = new byte[1024]; - int chunkLength = 0; - while ((chunkLength = fileInputStream.read(chunk)) != -1) { - outputStream.write(chunk, 0, chunkLength); - } - fileInputStream.close(); - tempFile.delete(); + serialize(outputStream, File.createTempFile(UUID.randomUUID().toString(), ".cag")); } /** - * A method to persist a CAGRA index using an instance of OutputStream and path + * A method to persist a CAGRA index using an instance of {@link OutputStream} and path * to the intermediate temporary file. * - * @param outputStream an instance of OutputStream to write the index bytes to - * @param tmpFilePath path to a temporary file where CAGRA index is written - * @throws Throwable exception thrown when native function is invoked - * @see OutputStream + * @param outputStream an instance of {@link OutputStream} to write the index bytes to + * @param tmpFilePath an intermediate {@link File} where CAGRA index is written temporarily */ - public void serialize(OutputStream outputStream, String tmpFilePath) throws Throwable { + public void serialize(OutputStream outputStream, File tempFile) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), - cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringMemorySegment(new StringBuilder(tmpFilePath))); - File tempFile = new File(tmpFilePath); + serializeMethodHandle.invokeExact(cuvsResources.getMemorySegment(), + cagraIndexReference.getMemorySegment(), returnValueMemorySegment, + Util.buildMemorySegment(linker, arena, tempFile.getAbsolutePath())); FileInputStream fileInputStream = new FileInputStream(tempFile); - byte[] chunk = new byte[1024]; + byte[] chunk = new byte[1024]; // TODO: Make this configurable int chunkLength = 0; while ((chunkLength = fileInputStream.read(chunk)) != -1) { outputStream.write(chunk, 0, chunkLength); @@ -280,21 +188,17 @@ public void serialize(OutputStream outputStream, String tmpFilePath) throws Thro } /** - * Gets an instance of CagraIndexReference by deserializing a CAGRA index using - * an input stream. + * Gets an instance of {@link IndexReference} by deserializing a CAGRA index using + * an {@link InputStream}. * - * @param inputStream an instance of InputStream (eg. FileInputStream when - * reading an index file). - * @return an instance of CagraIndexReference. - * @throws Throwable exception thrown when native function is invoked - * @see CagraIndexReference - * @see InputStream + * @param inputStream an instance of {@link InputStream} + * @return an instance of {@link IndexReference}. */ - private CagraIndexReference deserialize(InputStream inputStream) throws Throwable { + private IndexReference deserialize(InputStream inputStream) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - CagraIndexReference cagraIndexReference = new CagraIndexReference(); + IndexReference indexReference = new IndexReference(); File tempFile = new File(tmpIndexFile); FileOutputStream fileOutputStream = new FileOutputStream(tempFile); @@ -303,39 +207,37 @@ private CagraIndexReference deserialize(InputStream inputStream) throws Throwabl while ((chunkLength = inputStream.read(chunk)) != -1) { fileOutputStream.write(chunk, 0, chunkLength); } - deserializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), - cagraIndexReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringMemorySegment(new StringBuilder(tmpIndexFile))); + deserializeMethodHandle.invokeExact(cuvsResources.getMemorySegment(), + indexReference.getMemorySegment(), returnValueMemorySegment, + Util.buildMemorySegment(linker, arena, tmpIndexFile)); inputStream.close(); fileOutputStream.close(); tempFile.delete(); - return cagraIndexReference; + return indexReference; } /** - * Gets an instance of CagraIndexParams. + * Gets an instance of {@link CagraIndexParams} * - * @return an instance of CagraIndexParams - * @see CagraIndexParams + * @return an instance of {@link CagraIndexParams} */ public CagraIndexParams getCagraIndexParameters() { return cagraIndexParameters; } /** - * Gets an instance of CuVSResources. + * Gets an instance of {@link CuVSResources} * - * @return an instance of CuVSResources - * @see CuVSResources + * @return an instance of {@link CuVSResources} */ public CuVSResources getCuVSResources() { return cuvsResources; } /** - * Builder helps configure and create an instance of CagraIndex. + * Builder helps configure and create an instance of {@link CagraIndex}. */ public static class Builder { @@ -345,10 +247,9 @@ public static class Builder { private InputStream inputStream; /** - * Constructs this Builder with an instance of CuVSResources. + * Constructs this Builder with an instance of {@link CuVSResources}. * - * @param cuvsResources an instance of CuVSResources - * @see CuVSResources + * @param cuvsResources an instance of {@link CuVSResources} */ public Builder(CuVSResources cuvsResources) { this.cuvsResources = cuvsResources; @@ -358,9 +259,8 @@ public Builder(CuVSResources cuvsResources) { * Sets an instance of InputStream typically used when index deserialization is * needed. * - * @param inputStream an instance of InputStream + * @param inputStream an instance of {@link InputStream} * @return an instance of this Builder - * @see InputStream */ public Builder from(InputStream inputStream) { this.inputStream = inputStream; @@ -368,7 +268,7 @@ public Builder from(InputStream inputStream) { } /** - * Sets the dataset for building the CAGRA index. + * Sets the dataset for building the {@link CagraIndex}. * * @param dataset a two-dimensional float array * @return an instance of this Builder @@ -379,11 +279,10 @@ public Builder withDataset(float[][] dataset) { } /** - * Registers an instance of configured CagraIndexParams with this Builder. + * Registers an instance of configured {@link CagraIndexParams} with this Builder. * * @param cagraIndexParameters An instance of CagraIndexParams. * @return An instance of this Builder. - * @see CagraIndexParams */ public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { this.cagraIndexParams = cagraIndexParameters; @@ -394,7 +293,6 @@ public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { * Builds and returns an instance of CagraIndex. * * @return an instance of CagraIndex - * @throws Throwable exception thrown when native function is invoked */ public CagraIndex build() throws Throwable { if (inputStream != null) { @@ -404,4 +302,41 @@ public CagraIndex build() throws Throwable { } } } + + /** + * Holds the memory reference to an index. + */ + protected static class IndexReference { + + private MemorySegment memorySegment; + + /** + * Constructs CagraIndexReference and allocate the MemorySegment. + */ + protected IndexReference() { + Arena arena = Arena.ofConfined(); + memorySegment = cuvsCagraIndex.allocate(arena); + } + + /** + * Constructs CagraIndexReference with an instance of MemorySegment passed as a + * parameter. + * + * @param indexMemorySegment the MemorySegment instance to use for containing + * index reference + */ + protected IndexReference(MemorySegment indexMemorySegment) { + this.memorySegment = indexMemorySegment; + } + + /** + * Gets the instance of index MemorySegment. + * + * @return index MemorySegment + */ + protected MemorySegment getMemorySegment() { + return memorySegment; + } + } + } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index 9a65ca167..118f1e387 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -19,7 +19,7 @@ import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; -import com.nvidia.cuvs.panama.cuvsCagraIndexParams; +import com.nvidia.cuvs.panama.CuVSCagraIndexParams; /** * Supplemental parameters to build CAGRA Index. @@ -28,17 +28,18 @@ */ public class CagraIndexParams { - private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; - private MemorySegment cagraIndexParamsMemorySegment; - private Arena arena; - private int intermediateGraphDegree; - private int graphDegree; - private int nnDescentNiter; + private final CagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; + private final MemorySegment memorySegment; + private final Arena arena; + private final int intermediateGraphDegree; + private final int graphDegree; + private final int nnDescentNiter; + private final int numWriterThreads; /** * Enum that denotes which ANN algorithm is used to build CAGRA graph. */ - public enum CuvsCagraGraphBuildAlgo { + public enum CagraGraphBuildAlgo { /** * AUTO_SELECT */ @@ -57,44 +58,30 @@ public enum CuvsCagraGraphBuildAlgo { */ public final int label; - private CuvsCagraGraphBuildAlgo(int label) { + private CagraGraphBuildAlgo(int label) { this.label = label; } } - /** - * Constructor that initializes CagraIndexParams with an instance of Arena, - * intermediateGraphDegree, graphDegree, CuvsCagraGraphBuildAlgo, and - * nnDescentNiter. - * - * @param arena the Arena instance to use - * @param intermediateGraphDegree the degree of input graph for pruning - * @param graphDegree the degree of output graph - * @param CuvsCagraGraphBuildAlgo the CuvsCagraGraphBuildAlgo - * @param nnDescentNiter the number of Iterations to run if building - * with NN_DESCENT - */ - public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, - CuvsCagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter) { + private CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, + CagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter, int writerThreads) { this.arena = arena; this.intermediateGraphDegree = intermediateGraphDegree; this.graphDegree = graphDegree; this.cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo; this.nnDescentNiter = nnDescentNiter; - this.setCagraIndexParamsStubValues(); + this.numWriterThreads = writerThreads; + + this.memorySegment = initMemorySegment(); } - /** - * Sets the parameter values in the stub's MemorySegment. - * - * @see MemorySegment - */ - private void setCagraIndexParamsStubValues() { - cagraIndexParamsMemorySegment = cuvsCagraIndexParams.allocate(arena); - cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMemorySegment, intermediateGraphDegree); - cuvsCagraIndexParams.graph_degree(cagraIndexParamsMemorySegment, graphDegree); - cuvsCagraIndexParams.build_algo(cagraIndexParamsMemorySegment, cuvsCagraGraphBuildAlgo.label); - cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMemorySegment, nnDescentNiter); + private MemorySegment initMemorySegment() { + MemorySegment memorySegment = CuVSCagraIndexParams.allocate(arena); + CuVSCagraIndexParams.intermediate_graph_degree(memorySegment, intermediateGraphDegree); + CuVSCagraIndexParams.graph_degree(memorySegment, graphDegree); + CuVSCagraIndexParams.build_algo(memorySegment, cuvsCagraGraphBuildAlgo.label); + CuVSCagraIndexParams.nn_descent_niter(memorySegment, nnDescentNiter); + return memorySegment; } /** @@ -116,58 +103,51 @@ public int getGraphDegree() { } /** - * Gets the CuvsCagraGraphBuildAlgo. - * - * @return CuvsCagraGraphBuildAlgo selected + * Gets the {@link CagraGraphBuildAlgo} used to build the index. */ - public CuvsCagraGraphBuildAlgo getCuvsCagraGraphBuildAlgo() { + public CagraGraphBuildAlgo getCagraGraphBuildAlgo() { return cuvsCagraGraphBuildAlgo; } /** - * Gets the number of Iterations to run if building with NN_DESCENT. - * - * @return the number of Iterations + * Gets the number of iterations to run if building with {@link CagraGraphBuildAlgo#NN_DESCENT} */ - public int getNNDescentNiter() { + public int getNNDescentNumIterations() { return nnDescentNiter; } - /** - * Gets the cagraIndexParams MemorySegment. - * - * @return an instance of MemorySegment - */ - public MemorySegment getCagraIndexParamsMemorySegment() { - return cagraIndexParamsMemorySegment; + protected MemorySegment getMemorySegment() { + return memorySegment; } @Override public String toString() { return "CagraIndexParams [arena=" + arena + ", intermediateGraphDegree=" + intermediateGraphDegree + ", graphDegree=" + graphDegree + ", cuvsCagraGraphBuildAlgo=" + cuvsCagraGraphBuildAlgo + ", nnDescentNiter=" - + nnDescentNiter + ", cagraIndexParamsMemorySegment=" + cagraIndexParamsMemorySegment + "]"; + + nnDescentNiter + ", cagraIndexParamsMemorySegment=" + memorySegment + "]"; } /** - * Builder configures and creates an instance of CagraIndexParams. + * Gets the number of threads used to build the index. + */ + public int getNumWriterThreads() { + return numWriterThreads; +} + + /** + * Builder configures and creates an instance of {@link CagraIndexParams}. */ public static class Builder { - private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo.NN_DESCENT; + private CagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CagraGraphBuildAlgo.NN_DESCENT; private Arena arena; private int intermediateGraphDegree = 128; private int graphDegree = 64; - private int nnDescentNiter = 20; - private int writerThreads = 1; + private int nnDescentNumIterations = 20; + private int numWriterThreads = 1; - /** - * Constructor for builder for initializing and instance of Arena. - * - * @see Arena - */ public Builder() { - this.arena = Arena.ofConfined(); + } /** @@ -198,41 +178,41 @@ public Builder withGraphDegree(int graphDegree) { * @param cuvsCagraGraphBuildAlgo the CuvsCagraGraphBuildAlgo to use * @return an instance of Builder */ - public Builder withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo) { + public Builder withCagraGraphBuildAlgo(CagraGraphBuildAlgo cuvsCagraGraphBuildAlgo) { this.cuvsCagraGraphBuildAlgo = cuvsCagraGraphBuildAlgo; return this; } /** - * Sets the Number of Iterations to run if building with NN_DESCENT. + * Sets the Number of Iterations to run if building with {@link CagraGraphBuildAlgo#NN_DESCENT}. * - * @param nnDescentNiter number of Iterations to run if building with NN_DESCENT + * @param nnDescentNiter number of Iterations to run if building with {@link CagraGraphBuildAlgo#NN_DESCENT} * @return an instance of Builder */ - public Builder withNNDescentNiter(int nnDescentNiter) { - this.nnDescentNiter = nnDescentNiter; + public Builder withNNDescentNumIterations(int nnDescentNiter) { + this.nnDescentNumIterations = nnDescentNiter; return this; } /** - * Registers the number of writer threads to use for indexing. + * Sets the number of writer threads to use for indexing. * - * @param writerThreads number of writer threads to use + * @param numWriterThreads number of writer threads to use * @return an instance of Builder */ - public Builder withWriterThreads(int writerThreads) { - this.writerThreads = writerThreads; + public Builder withNumWriterThreads(int numWriterThreads) { + this.numWriterThreads = numWriterThreads; return this; } /** - * Builds an instance of CagraIndexParams. + * Builds an instance of {@link CagraIndexParams}. * - * @return an instance of CagraIndexParams - * @see CagraIndexParams + * @return an instance of {@link CagraIndexParams} */ public CagraIndexParams build() { - return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, nnDescentNiter); + this.arena = Arena.ofConfined(); + return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, nnDescentNumIterations, numWriterThreads); } } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java deleted file mode 100644 index a675ebd76..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023-2024, 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.cagra; - -import java.lang.foreign.Arena; -import java.lang.foreign.MemorySegment; - -import com.nvidia.cuvs.panama.cuvsCagraIndex; - -/** - * Holds the reference to the index using MemorySegment. - * - * @since 24.12 - */ -public class CagraIndexReference { - - private MemorySegment indexMemorySegment; - - /** - * Constructs CagraIndexReference and allocate the MemorySegment. - */ - public CagraIndexReference() { - Arena arena = Arena.ofConfined(); - indexMemorySegment = cuvsCagraIndex.allocate(arena); - } - - /** - * Constructs CagraIndexReference with an instance of MemorySegment passed as a - * parameter. - * - * @param indexMemorySegment the MemorySegment instance to use for containing - * index reference - */ - public CagraIndexReference(MemorySegment indexMemorySegment) { - this.indexMemorySegment = indexMemorySegment; - } - - /** - * Gets the instance of index MemorySegment. - * - * @return index MemorySegment - */ - public MemorySegment getIndexMemorySegment() { - return indexMemorySegment; - } -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java similarity index 80% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java index b3260be83..e5b9d7cff 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java @@ -25,30 +25,28 @@ * * @since 24.12 */ -public class CuVSQuery { +public class CagraQuery { private CagraSearchParams cagraSearchParameters; - private PreFilter preFilter; private Map mapping; private float[][] queryVectors; private int topK; /** - * Constructs an instance of CuVSQuery using cagraSearchParameters, preFilter, + * Constructs an instance of {@link CagraQuery} using cagraSearchParameters, preFilter, * queryVectors, mapping, and topK. * - * @param cagraSearchParameters an instance of CagraSearchParams holding the + * @param cagraSearchParameters an instance of {@link CagraSearchParams} holding the * search parameters * @param preFilter an instance of PreFilter * @param queryVectors 2D float query vector array * @param mapping an instance of ID mapping * @param topK the top k results to return */ - public CuVSQuery(CagraSearchParams cagraSearchParameters, PreFilter preFilter, float[][] queryVectors, + public CagraQuery(CagraSearchParams cagraSearchParameters, float[][] queryVectors, Map mapping, int topK) { super(); this.cagraSearchParameters = cagraSearchParameters; - this.preFilter = preFilter; this.queryVectors = queryVectors; this.mapping = mapping; this.topK = topK; @@ -63,15 +61,6 @@ public CagraSearchParams getCagraSearchParameters() { return cagraSearchParameters; } - /** - * Gets the instance of PreFilter initially set. - * - * @return an instance of PreFilter - */ - public PreFilter getPreFilter() { - return preFilter; - } - /** * Gets the query vector 2D float array. * @@ -101,7 +90,7 @@ public int getTopK() { @Override public String toString() { - return "CuVSQuery [cagraSearchParameters=" + cagraSearchParameters + ", preFilter=" + preFilter + ", queryVectors=" + return "CuVSQuery [cagraSearchParameters=" + cagraSearchParameters + ", queryVectors=" + Arrays.toString(queryVectors) + ", mapping=" + mapping + ", topK=" + topK + "]"; } @@ -111,7 +100,6 @@ public String toString() { public static class Builder { private CagraSearchParams cagraSearchParams; - private PreFilter preFilter; private float[][] queryVectors; private Map mapping; private int topK = 2; @@ -145,17 +133,6 @@ public Builder withQueryVectors(float[][] queryVectors) { return this; } - /** - * Sets the PreFilter to be used with CuVSQuery. - * - * @param preFilter the PreFilter instance to be configured - * @return an instance of this Builder - */ - public Builder withPreFilter(PreFilter preFilter) { - this.preFilter = preFilter; - return this; - } - /** * Sets the instance of mapping to be used for ID mapping. * @@ -183,8 +160,8 @@ public Builder withTopK(int topK) { * * @return an instance of CuVSQuery */ - public CuVSQuery build() { - return new CuVSQuery(cagraSearchParams, preFilter, queryVectors, mapping, topK); + public CagraQuery build() { + return new CagraQuery(cagraSearchParams, queryVectors, mapping, topK); } } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index 1d2cf6ae4..51ad1b8b2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -30,7 +30,7 @@ public class CagraSearchParams { private int maxQueries; - private int itopkSize; + private int iTopKSize; private int maxIterations; private int teamSize; private int searchWidth; @@ -38,17 +38,17 @@ public class CagraSearchParams { private int threadBlockSize; private int hashmapMinBitlen; private int numRandomSamplings; - private float hashmapMaxFillRate; - private long randXorMask; + private float hashMapMaxFillRate; + private long randXORMask; private Arena arena; - private MemorySegment cagraSearchParamsMemorySegment; - private CuvsCagraSearchAlgo cuvsCagraSearchAlgo; - private CuvsCagraHashMapMode cuvsCagraHashMapMode; + private MemorySegment memorySegment; + private SearchAlgo searchAlgo; + private HashMapMode hashMapMode; /** * Enum to denote algorithm used to search CAGRA Index. */ - public enum CuvsCagraSearchAlgo { + public enum SearchAlgo { /** * for large batch sizes */ @@ -71,7 +71,7 @@ public enum CuvsCagraSearchAlgo { */ public final int value; - private CuvsCagraSearchAlgo(int value) { + private SearchAlgo(int value) { this.value = value; } } @@ -79,7 +79,7 @@ private CuvsCagraSearchAlgo(int value) { /** * Enum to denote Hash Mode used while searching CAGRA index. */ - public enum CuvsCagraHashMapMode { + public enum HashMapMode { /** * HASH */ @@ -98,7 +98,7 @@ public enum CuvsCagraHashMapMode { */ public final int value; - private CuvsCagraHashMapMode(int value) { + private HashMapMode(int value) { this.value = value; } } @@ -109,64 +109,65 @@ private CuvsCagraHashMapMode(int value) { * @param arena the Arena instance to use * @param maxQueries the maximum number of queries to search at the * same time (batch size) - * @param itopkSize the number of intermediate search results retained + * @param iTopKSize the number of intermediate search results retained * during the search * @param maxIterations the upper limit of search iterations - * @param cuvsCagraSearchAlgo the search implementation is configured + * @param searchAlgo the search implementation is configured * @param teamSize the number of threads used to calculate a single * distance * @param searchWidth the number of graph nodes to select as the * starting point for the search in each iteration * @param minIterations the lower limit of search iterations * @param threadBlockSize the thread block size - * @param hashmapMode the hashmap type configured - * @param hashmapMinBitlen the lower limit of hashmap bit length - * @param hashmapMaxFillRate the upper limit of hashmap fill rate + * @param hashmapMode the hash map type configured + * @param hashmapMinBitlen the lower limit of hash map bit length + * @param hashmapMaxFillRate the upper limit of hash map fill rate * @param numRandomSamplings the number of iterations of initial random seed * node selection - * @param randXorMask the bit mask used for initial random seed node + * @param randXORMask the bit mask used for initial random seed node * selection */ - public CagraSearchParams(Arena arena, int maxQueries, int itopkSize, int maxIterations, - CuvsCagraSearchAlgo cuvsCagraSearchAlgo, int teamSize, int searchWidth, int minIterations, int threadBlockSize, - CuvsCagraHashMapMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, - long randXorMask) { - super(); + private CagraSearchParams(Arena arena, int maxQueries, int iTopKSize, int maxIterations, + SearchAlgo searchAlgo, int teamSize, int searchWidth, int minIterations, int threadBlockSize, + HashMapMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, + long randXORMask) { this.arena = arena; this.maxQueries = maxQueries; - this.itopkSize = itopkSize; + this.iTopKSize = iTopKSize; this.maxIterations = maxIterations; - this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; + this.searchAlgo = searchAlgo; this.teamSize = teamSize; this.searchWidth = searchWidth; this.minIterations = minIterations; this.threadBlockSize = threadBlockSize; - this.cuvsCagraHashMapMode = hashmapMode; + this.hashMapMode = hashmapMode; this.hashmapMinBitlen = hashmapMinBitlen; - this.hashmapMaxFillRate = hashmapMaxFillRate; + this.hashMapMaxFillRate = hashmapMaxFillRate; this.numRandomSamplings = numRandomSamplings; - this.randXorMask = randXorMask; - this.setSearchParametersInTheStubMemorySegment(); + this.randXORMask = randXORMask; + + this.memorySegment = allocateMemorySegment(); } /** - * Sets the configured search parameters in the MemorySegment. + * Allocates the configured search parameters in the MemorySegment. */ - public void setSearchParametersInTheStubMemorySegment() { - cagraSearchParamsMemorySegment = cuvsCagraSearchParams.allocate(arena); - cuvsCagraSearchParams.max_queries(cagraSearchParamsMemorySegment, maxQueries); - cuvsCagraSearchParams.itopk_size(cagraSearchParamsMemorySegment, itopkSize); - cuvsCagraSearchParams.max_iterations(cagraSearchParamsMemorySegment, maxIterations); - cuvsCagraSearchParams.algo(cagraSearchParamsMemorySegment, cuvsCagraSearchAlgo.value); - cuvsCagraSearchParams.team_size(cagraSearchParamsMemorySegment, teamSize); - cuvsCagraSearchParams.search_width(cagraSearchParamsMemorySegment, searchWidth); - cuvsCagraSearchParams.min_iterations(cagraSearchParamsMemorySegment, minIterations); - cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMemorySegment, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMemorySegment, cuvsCagraHashMapMode.value); - cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMemorySegment, hashmapMinBitlen); - cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMemorySegment, hashmapMaxFillRate); - cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMemorySegment, numRandomSamplings); - cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMemorySegment, randXorMask); + private MemorySegment allocateMemorySegment() { + MemorySegment memorySegment = cuvsCagraSearchParams.allocate(arena); + cuvsCagraSearchParams.max_queries(memorySegment, maxQueries); + cuvsCagraSearchParams.itopk_size(memorySegment, iTopKSize); + cuvsCagraSearchParams.max_iterations(memorySegment, maxIterations); + cuvsCagraSearchParams.algo(memorySegment, searchAlgo.value); + cuvsCagraSearchParams.team_size(memorySegment, teamSize); + cuvsCagraSearchParams.search_width(memorySegment, searchWidth); + cuvsCagraSearchParams.min_iterations(memorySegment, minIterations); + cuvsCagraSearchParams.thread_block_size(memorySegment, threadBlockSize); + cuvsCagraSearchParams.hashmap_mode(memorySegment, hashMapMode.value); + cuvsCagraSearchParams.hashmap_min_bitlen(memorySegment, hashmapMinBitlen); + cuvsCagraSearchParams.hashmap_max_fill_rate(memorySegment, hashMapMaxFillRate); + cuvsCagraSearchParams.num_random_samplings(memorySegment, numRandomSamplings); + cuvsCagraSearchParams.rand_xor_mask(memorySegment, randXORMask); + return memorySegment; } /** @@ -183,8 +184,8 @@ public int getMaxQueries() { * * @return the number of intermediate search results */ - public int getItopkSize() { - return itopkSize; + public int getITopKSize() { + return iTopKSize; } /** @@ -234,7 +235,7 @@ public int getThreadBlockSize() { } /** - * Gets the lower limit of hashmap bit length. + * Gets the lower limit of hash map bit length. * * @return the lower limit value */ @@ -252,12 +253,12 @@ public int getNumRandomSamplings() { } /** - * Gets the upper limit of hashmap fill rate. + * Gets the upper limit of hash map fill rate. * - * @return the upper limit of hashmap fill rate + * @return the upper limit of hash map fill rate */ - public float getHashmapMaxFillRate() { - return hashmapMaxFillRate; + public float getHashMapMaxFillRate() { + return hashMapMaxFillRate; } /** @@ -265,8 +266,8 @@ public float getHashmapMaxFillRate() { * * @return the bit mask value */ - public long getRandXorMask() { - return randXorMask; + public long getRandXORMask() { + return randXORMask; } /** @@ -274,38 +275,36 @@ public long getRandXorMask() { * * @return the MemorySegment holding CagraSearchParams */ - public MemorySegment getCagraSearchParamsMemorySegment() { - return cagraSearchParamsMemorySegment; + protected MemorySegment getMemorySegment() { + return memorySegment; } /** * Gets which search implementation is configured. * - * @return the search implementation configured - * @see CuvsCagraSearchAlgo + * @return the configured {@link SearchAlgo} */ - public CuvsCagraSearchAlgo getCuvsCagraSearchAlgo() { - return cuvsCagraSearchAlgo; + public SearchAlgo getCagraSearchAlgo() { + return searchAlgo; } /** - * Gets the hashmap type configured. + * Gets the hash map mode configured. * - * @return the hashmap type configured - * @see CuvsCagraHashMapMode + * @return the configured {@link HashMapMode} */ - public CuvsCagraHashMapMode getCuvsCagraHashMapMode() { - return cuvsCagraHashMapMode; + public HashMapMode getHashMapMode() { + return hashMapMode; } @Override public String toString() { - return "CagraSearchParams [arena=" + arena + ", maxQueries=" + maxQueries + ", itopkSize=" + itopkSize - + ", maxIterations=" + maxIterations + ", cuvsCagraSearchAlgo=" + cuvsCagraSearchAlgo + ", teamSize=" + teamSize + return "CagraSearchParams [arena=" + arena + ", maxQueries=" + maxQueries + ", itopkSize=" + iTopKSize + + ", maxIterations=" + maxIterations + ", cuvsCagraSearchAlgo=" + searchAlgo + ", teamSize=" + teamSize + ", searchWidth=" + searchWidth + ", minIterations=" + minIterations + ", threadBlockSize=" + threadBlockSize - + ", cuvsCagraHashMapMode=" + cuvsCagraHashMapMode + ", hashmapMinBitlen=" + hashmapMinBitlen - + ", hashmapMaxFillRate=" + hashmapMaxFillRate + ", numRandomSamplings=" + numRandomSamplings + ", randXorMask=" - + randXorMask + ", cagraSearchParamsMemorySegment=" + cagraSearchParamsMemorySegment + "]"; + + ", hashMapMode=" + hashMapMode + ", hashMapMinBitlen=" + hashmapMinBitlen + + ", hashMapMaxFillRate=" + hashMapMaxFillRate + ", numRandomSamplings=" + numRandomSamplings + ", randXORMask=" + + randXORMask + ", memorySegment=" + memorySegment + "]"; } /** @@ -315,18 +314,18 @@ public static class Builder { private Arena arena; private int maxQueries = 1; - private int itopkSize = 2; + private int iTopKSize = 2; private int maxIterations = 3; private int teamSize = 4; private int searchWidth = 5; private int minIterations = 6; private int threadBlockSize = 7; - private int hashmapMinBitlen = 8; + private int hashMapMinBitlen = 8; private int numRandomSamplings = 10; - private float hashmapMaxFillRate = 9.0f; - private long randXorMask = 11L; - private CuvsCagraSearchAlgo cuvsCagraSearchAlgo = CuvsCagraSearchAlgo.MULTI_KERNEL; - private CuvsCagraHashMapMode cuvsCagraHashMode = CuvsCagraHashMapMode.AUTO_HASH; + private float hashMapMaxFillRate = 9.0f; + private long randXORMask = 11L; + private SearchAlgo searchAlgo = SearchAlgo.MULTI_KERNEL; + private HashMapMode hashMapMode = HashMapMode.AUTO_HASH; /** * Constructs this Builder with an instance of Arena. @@ -352,11 +351,11 @@ public Builder withMaxQueries(int maxQueries) { * This is the main knob to adjust trade off between accuracy and search speed. * Higher values improve the search accuracy. * - * @param itopkSize the number of intermediate search results + * @param iTopKSize the number of intermediate search results * @return an instance of this Builder */ - public Builder withItopkSize(int itopkSize) { - this.itopkSize = itopkSize; + public Builder withItopkSize(int iTopKSize) { + this.iTopKSize = iTopKSize; return this; } @@ -374,12 +373,11 @@ public Builder withMaxIterations(int maxIterations) { /** * Sets which search implementation to use. * - * @param cuvsCagraSearchAlgo the search implementation to use + * @param cuvsCagraSearchAlgo the {@link SearchAlgo} to use * @return an instance of this Builder - * @see CuvsCagraSearchAlgo */ - public Builder withAlgo(CuvsCagraSearchAlgo cuvsCagraSearchAlgo) { - this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; + public Builder withAlgo(SearchAlgo cuvsCagraSearchAlgo) { + this.searchAlgo = cuvsCagraSearchAlgo; return this; } @@ -431,36 +429,35 @@ public Builder withThreadBlockSize(int threadBlockSize) { } /** - * Sets the hashmap type. Auto selection when AUTO. + * Sets the hash map type. Auto selection when AUTO. * - * @param cuvsCagraHashMode the hashmap type + * @param hashMapMode the {@link HashMapMode} * @return an instance of this Builder - * @see CuvsCagraHashMapMode */ - public Builder withHashmapMode(CuvsCagraHashMapMode cuvsCagraHashMode) { - this.cuvsCagraHashMode = cuvsCagraHashMode; + public Builder withHashMapMode(HashMapMode hashMapMode) { + this.hashMapMode = hashMapMode; return this; } /** - * Sets the lower limit of hashmap bit length. More than 8. + * Sets the lower limit of hash map bit length. More than 8. * - * @param hashmapMinBitlen the lower limit of hashmap bit length + * @param hashMapMinBitlen the lower limit of hash map bit length * @return an instance of this Builder */ - public Builder withHashmapMinBitlen(int hashmapMinBitlen) { - this.hashmapMinBitlen = hashmapMinBitlen; + public Builder withHashMapMinBitlen(int hashMapMinBitlen) { + this.hashMapMinBitlen = hashMapMinBitlen; return this; } /** - * Sets the upper limit of hashmap fill rate. More than 0.1, less than 0.9. + * Sets the upper limit of hash map fill rate. More than 0.1, less than 0.9. * - * @param hashmapMaxFillRate the upper limit of hashmap fill rate + * @param hashMapMaxFillRate the upper limit of hash map fill rate * @return an instance of this Builder */ - public Builder withHashmapMaxFillRate(float hashmapMaxFillRate) { - this.hashmapMaxFillRate = hashmapMaxFillRate; + public Builder withHashMapMaxFillRate(float hashMapMaxFillRate) { + this.hashMapMaxFillRate = hashMapMaxFillRate; return this; } @@ -480,23 +477,23 @@ public Builder withNumRandomSamplings(int numRandomSamplings) { /** * Sets the bit mask used for initial random seed node selection. * - * @param randXorMask the bit mask used for initial random seed node selection + * @param randXORMask the bit mask used for initial random seed node selection * @return an instance of this Builder */ - public Builder withRandXorMask(long randXorMask) { - this.randXorMask = randXorMask; + public Builder withRandXorMask(long randXORMask) { + this.randXORMask = randXORMask; return this; } /** - * Builds an instance of CagraSearchParams with passed search parameters. + * Builds an instance of {@link CagraSearchParams} with passed search parameters. * * @return an instance of CagraSearchParams */ public CagraSearchParams build() { - return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, cuvsCagraSearchAlgo, teamSize, - searchWidth, minIterations, threadBlockSize, cuvsCagraHashMode, hashmapMinBitlen, hashmapMaxFillRate, - numRandomSamplings, randXorMask); + return new CagraSearchParams(arena, maxQueries, iTopKSize, maxIterations, searchAlgo, teamSize, + searchWidth, minIterations, threadBlockSize, hashMapMode, hashMapMinBitlen, hashMapMaxFillRate, + numRandomSamplings, randXORMask); } } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java similarity index 62% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java index 911c9f09a..78b74d3eb 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java @@ -25,39 +25,25 @@ import java.util.List; import java.util.Map; +import com.nvidia.cuvs.common.SearchResults; + /** * SearchResult encapsulates the logic for reading and holding search results. * * @since 24.12 */ -public class SearchResult { +public class CagraSearchResults implements SearchResults { - private List> results; - private Map mapping; - private SequenceLayout neighboursSequenceLayout; - private SequenceLayout distancesSequenceLayout; - private MemorySegment neighboursMemorySegment; - private MemorySegment distancesMemorySegment; - private int topK; - private int numberOfQueries; + private final List> results; + private final Map mapping; // TODO: Is this performant in a user application? + private final SequenceLayout neighboursSequenceLayout; + private final SequenceLayout distancesSequenceLayout; + private final MemorySegment neighboursMemorySegment; + private final MemorySegment distancesMemorySegment; + private final int topK; + private final int numberOfQueries; - /** - * Constructor that initializes SearchResult with neighboursSequenceLayout, - * distancesSequenceLayout, neighboursMemorySegment, distancesMemorySegment, - * topK, mapping, and numberOfQueries. - * - * @param neighboursSequenceLayout neighbor SequenceLayout instance - * @param distancesSequenceLayout distance SequenceLayout instance - * @param neighboursMemorySegment neighbor MemorySegment instance - * @param distancesMemorySegment distance MemorySegment instance - * @param topK an integer denoting the topK value - * @param mapping id mapping - * @param numberOfQueries number of queries that were initially - * submitted - * @see SequenceLayout - * @see MemorySegment - */ - public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, + protected CagraSearchResults(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, MemorySegment neighboursMemorySegment, MemorySegment distancesMemorySegment, int topK, Map mapping, int numberOfQueries) { super(); @@ -69,15 +55,12 @@ public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout dist this.distancesMemorySegment = distancesMemorySegment; this.mapping = mapping; results = new LinkedList>(); - this.readResultMemorySegments(); + + readResultMemorySegments(); } /** - * Reads neighbors and distances MemorySegments and load values in a List of - * Maps. - * - * @see MemorySegment - * @see VarHandle + * Reads neighbors and distances {@link MemorySegment} and loads the values internally */ private void readResultMemorySegments() { VarHandle neighboursVarHandle = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); @@ -99,10 +82,11 @@ private void readResultMemorySegments() { } /** - * Gets a list of maps containing topK ID and distances. + * Gets a list results as a map of neighbor IDs to distances. * - * @return a list of maps + * @return a list of results for each query as a map of neighbor IDs to distance */ + @Override public List> getResults() { return results; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java deleted file mode 100644 index 4d985c9d0..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023-2024, 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.cagra; - -/** - * Pending Implementation - * - * @since 24.12 - */ -public class PreFilter { - - /** - * Default constructor - */ - public PreFilter() { - } - -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java new file mode 100644 index 000000000..c2d00091a --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; + +import java.lang.foreign.Arena; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.MemoryLayout.PathElement; +import java.lang.invoke.VarHandle; + +public class Util { + /** + * A utility method for getting an instance of {@link MemorySegment} for a {@link String}. + * + * @param str the string for the expected {@link MemorySegment} + * @return an instance of {@link MemorySegment} + */ + protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { + StringBuilder sb = new StringBuilder(str).append('\0'); + MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), + linker.canonicalLayouts().get("char")); + MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); + + for (int i = 0; i < sb.length(); i++) { + VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); + varHandle.set(stringMemorySegment, 0L, (byte) sb.charAt(i)); + } + return stringMemorySegment; + } + + /** + * A utility method for building a {@link MemorySegment} for a 2D float array. + * + * @param data The 2D float array for which the {@link MemorySegment} is needed + * @return an instance of {@link MemorySegment} + */ + protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { + long rows = data.length; + long cols = data[0].length; + + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, + MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); + MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); + + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), + PathElement.sequenceElement(c)); + element.set(dataMemorySegment, 0, 0, data[r][c]); + } + } + + return dataMemorySegment; + } + + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java similarity index 69% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java index 42ed42a1a..59f7f942e 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs.common; import java.io.File; import java.lang.foreign.Arena; @@ -27,22 +27,20 @@ import java.lang.invoke.MethodHandle; /** - * CuVSResources has the logic to initialize and hold the reference to CuVS - * Resources instance. + * Used for allocating resources for cuVS * * @since 24.12 */ public class CuVSResources { - private Arena arena; - private Linker linker; - private SymbolLookup symbolLookup; - private MethodHandle createResourcesMethodHandle; - private MemorySegment cuvsResourcesMemorySegment; + private final Arena arena; + private final Linker linker; + private final SymbolLookup symbolLookup; + private final MethodHandle createResourceMethodHandle; + private final MemorySegment memorySegment; /** - * Constructor for CuVSResources that initializes MethodHandle and invokes the - * native create_resource function via Panama API. + * Constructor that allocates the resources needed for cuVS * * @throws Throwable exception thrown when native function is invoked */ @@ -51,15 +49,16 @@ public CuVSResources() throws Throwable { arena = Arena.ofConfined(); File workingDirectory = new File(System.getProperty("user.dir")); + // TODO Remove hardcoding, also load from .jar symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - createResourcesMethodHandle = linker.downcallHandle(symbolLookup.find("create_resource").get(), + createResourceMethodHandle = linker.downcallHandle(symbolLookup.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - cuvsResourcesMemorySegment = (MemorySegment) createResourcesMethodHandle.invokeExact(returnValueMemorySegment); + memorySegment = (MemorySegment) createResourceMethodHandle.invokeExact(returnValueMemorySegment); } /** @@ -67,7 +66,8 @@ public CuVSResources() throws Throwable { * * @return cuvsResources MemorySegment */ - public MemorySegment getCuvsResourcesMemorySegment() { - return cuvsResourcesMemorySegment; + public MemorySegment getMemorySegment() { + // TODO: Is there a way to not letting a memory segment leak into the public API? + return memorySegment; } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java new file mode 100644 index 000000000..ae8fa6a23 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java @@ -0,0 +1,14 @@ +package com.nvidia.cuvs.common; + +import java.util.List; +import java.util.Map; + +public interface SearchResults { + + /** + * Gets a list results as a map of neighbor IDs to distances. + * + * @return a list of results for each query as a map of neighbor IDs to distance + */ + public List> getResults(); +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java similarity index 99% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java index 022793289..73b02f40d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java @@ -37,9 +37,9 @@ * } * } */ -public class cuvsCagraIndexParams { +public class CuVSCagraIndexParams { - cuvsCagraIndexParams() { + CuVSCagraIndexParams() { // Should not be called directly } diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index e4d9df120..cdc34c255 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -22,6 +22,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; +import java.lang.invoke.MethodHandles; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -33,14 +34,14 @@ import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; +import com.nvidia.cuvs.cagra.CagraQuery; import com.nvidia.cuvs.cagra.CagraSearchParams; -import com.nvidia.cuvs.cagra.CuVSQuery; -import com.nvidia.cuvs.cagra.CuVSResources; -import com.nvidia.cuvs.cagra.SearchResult; +import com.nvidia.cuvs.common.CuVSResources; +import com.nvidia.cuvs.common.SearchResults; public class CagraBuildAndSearchTest { - private static Logger logger = LoggerFactory.getLogger(CagraBuildAndSearchTest.class); + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); /** * A basic test that checks the whole flow - from indexing to search. @@ -63,30 +64,27 @@ public void testIndexingAndSearchingFlow() throws Throwable { Map.of(1, 0.15224178f, 0, 0.59063464f, 3, 0.5986642f)); // Create resource - CuVSResources cuvsResources = new CuVSResources(); + CuVSResources resources = new CuVSResources(); // Configure index parameters - CagraIndexParams cagraIndexParameters = new CagraIndexParams - .Builder() - .withCuvsCagraGraphBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.NN_DESCENT) + CagraIndexParams indexParams = new CagraIndexParams.Builder() + .withCagraGraphBuildAlgo(CagraIndexParams.CagraGraphBuildAlgo.NN_DESCENT) .build(); // Create the index with the dataset - CagraIndex cagraIndex = new CagraIndex - .Builder(cuvsResources) + CagraIndex index = new CagraIndex.Builder(resources) .withDataset(dataset) - .withIndexParams(cagraIndexParameters) + .withIndexParams(indexParams) .build(); // Saving the index on to the disk. String indexFileName = UUID.randomUUID().toString() + ".cag"; - cagraIndex.serialize(new FileOutputStream(indexFileName)); + index.serialize(new FileOutputStream(indexFileName)); // Loading a CAGRA index from disk. File testSerializedIndexFile = new File(indexFileName); InputStream inputStream = new FileInputStream(testSerializedIndexFile); - CagraIndex deserializedCagraIndex = new CagraIndex - .Builder(cuvsResources) + CagraIndex loadedIndex = new CagraIndex.Builder(resources) .from(inputStream) .build(); @@ -96,7 +94,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { .build(); // Create a query object with the query vectors - CuVSQuery cuvsQuery = new CuVSQuery + CagraQuery cuvsQuery = new CagraQuery .Builder() .withTopK(3) .withSearchParams(cagraSearchParameters) @@ -105,18 +103,18 @@ public void testIndexingAndSearchingFlow() throws Throwable { .build(); // Perform the search - SearchResult searchResults = cagraIndex.search(cuvsQuery); + SearchResults results = index.search(cuvsQuery); // Check results - logger.info(searchResults.getResults().toString()); - assertEquals(expectedQueryResults, searchResults.getResults(), "Results different than expected"); + log.info(results.getResults().toString()); + assertEquals(expectedQueryResults, results.getResults(), "Results different than expected"); // Search from deserialized index - SearchResult searchResultsFromDeserializedCagraIndex = deserializedCagraIndex.search(cuvsQuery); + results = loadedIndex.search(cuvsQuery); // Check results - logger.info(searchResults.getResults().toString()); - assertEquals(expectedQueryResults, searchResultsFromDeserializedCagraIndex.getResults(), "Results different than expected"); + log.info(results.getResults().toString()); + assertEquals(expectedQueryResults, results.getResults(), "Results different than expected"); // Cleanup if (testSerializedIndexFile.exists()) { From 2d79580acc5adca176f58436e3c39658cb501e96 Mon Sep 17 00:00:00 2001 From: ishan Date: Sun, 17 Nov 2024 21:30:19 +0530 Subject: [PATCH 12/53] Loading the .so file from the jar instead of a hardcoded path --- .../com/nvidia/cuvs/cagra/CagraIndex.java | 46 +++++++++---------- .../com/nvidia/cuvs/common/CuVSResources.java | 16 +++++-- .../nvidia/cuvs/{cagra => common}/Util.java | 43 +++++++++++++++-- 3 files changed, 74 insertions(+), 31 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => common}/Util.java (62%) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 45cfd86da..7ff7fc8d2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.foreign.Arena; @@ -33,6 +34,7 @@ import java.util.UUID; import com.nvidia.cuvs.common.CuVSResources; +import com.nvidia.cuvs.common.Util; import com.nvidia.cuvs.panama.cuvsCagraIndex; /** @@ -49,65 +51,63 @@ public class CagraIndex { private final float[][] dataset; - private final CuVSResources cuvsResources; + private final CuVSResources resources; private Arena arena; private Linker linker; private MethodHandle indexMethodHandle; private MethodHandle searchMethodHandle; private MethodHandle serializeMethodHandle; private MethodHandle deserializeMethodHandle; - private SymbolLookup symbolLookup; private CagraIndexParams cagraIndexParameters; private IndexReference cagraIndexReference; /* * Constructor for building the index using specified dataset */ - private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources cuvsResources) + private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources resources) throws Throwable { this.cagraIndexParameters = indexParameters; this.dataset = dataset; - this.initializeMethodHandles(); - this.cuvsResources = cuvsResources; + this.resources = resources; + + initializeMethodHandles(); this.cagraIndexReference = build(); } /** * Constructor for loading the index from an {@link InputStream} */ - private CagraIndex(InputStream inputStream, CuVSResources cuvsResources) throws Throwable { + private CagraIndex(InputStream inputStream, CuVSResources resources) throws Throwable { this.cagraIndexParameters = null; this.dataset = null; - this.cuvsResources = cuvsResources; - this.initializeMethodHandles(); + this.resources = resources; + + initializeMethodHandles(); this.cagraIndexReference = deserialize(inputStream); } /** * Initializes the {@link MethodHandles} for invoking native methods. + * @throws IOException @{@link IOException} is unable to load the native library */ - private void initializeMethodHandles() { + private void initializeMethodHandles() throws IOException { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); - File workingDirectory = new File(System.getProperty("user.dir")); - symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - - indexMethodHandle = linker.downcallHandle(symbolLookup.find("build_cagra_index").get(), + indexMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("build_cagra_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - searchMethodHandle = linker.downcallHandle(symbolLookup.find("search_cagra_index").get(), + searchMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMethodHandle = linker.downcallHandle(symbolLookup.find("serialize_cagra_index").get(), + serializeMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("serialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMethodHandle = linker.downcallHandle(symbolLookup.find("deserialize_cagra_index").get(), + deserializeMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("deserialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } /** @@ -123,7 +123,7 @@ private IndexReference build() throws Throwable { MemorySegment segment = arena.allocate(layout); cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( - Util.buildMemorySegment(linker, arena, dataset), rows, cols, cuvsResources.getMemorySegment(), segment, + Util.buildMemorySegment(linker, arena, dataset), rows, cols, resources.getMemorySegment(), segment, cagraIndexParameters.getMemorySegment())); return cagraIndexReference; @@ -147,7 +147,7 @@ public CagraSearchResults search(CagraQuery query) throws Throwable { searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), 4L, 2L, - cuvsResources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, + resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, @@ -174,7 +174,7 @@ public void serialize(OutputStream outputStream) throws Throwable { public void serialize(OutputStream outputStream, File tempFile) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - serializeMethodHandle.invokeExact(cuvsResources.getMemorySegment(), + serializeMethodHandle.invokeExact(resources.getMemorySegment(), cagraIndexReference.getMemorySegment(), returnValueMemorySegment, Util.buildMemorySegment(linker, arena, tempFile.getAbsolutePath())); FileInputStream fileInputStream = new FileInputStream(tempFile); @@ -207,7 +207,7 @@ private IndexReference deserialize(InputStream inputStream) throws Throwable { while ((chunkLength = inputStream.read(chunk)) != -1) { fileOutputStream.write(chunk, 0, chunkLength); } - deserializeMethodHandle.invokeExact(cuvsResources.getMemorySegment(), + deserializeMethodHandle.invokeExact(resources.getMemorySegment(), indexReference.getMemorySegment(), returnValueMemorySegment, Util.buildMemorySegment(linker, arena, tmpIndexFile)); @@ -233,7 +233,7 @@ public CagraIndexParams getCagraIndexParameters() { * @return an instance of {@link CuVSResources} */ public CuVSResources getCuVSResources() { - return cuvsResources; + return resources; } /** @@ -308,7 +308,7 @@ public CagraIndex build() throws Throwable { */ protected static class IndexReference { - private MemorySegment memorySegment; + private final MemorySegment memorySegment; /** * Constructs CagraIndexReference and allocate the MemorySegment. diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java index 59f7f942e..b63bac8e0 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java @@ -35,7 +35,7 @@ public class CuVSResources { private final Arena arena; private final Linker linker; - private final SymbolLookup symbolLookup; + private final SymbolLookup libcuvsNativeLibrary; private final MethodHandle createResourceMethodHandle; private final MemorySegment memorySegment; @@ -48,11 +48,10 @@ public CuVSResources() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); - File workingDirectory = new File(System.getProperty("user.dir")); - // TODO Remove hardcoding, also load from .jar - symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); + File nativeLibrary = Util.loadLibraryFromJar("/libcuvs_java.so"); + libcuvsNativeLibrary = SymbolLookup.libraryLookup(nativeLibrary.getAbsolutePath(), arena); - createResourceMethodHandle = linker.downcallHandle(symbolLookup.find("create_resource").get(), + createResourceMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); @@ -70,4 +69,11 @@ public MemorySegment getMemorySegment() { // TODO: Is there a way to not letting a memory segment leak into the public API? return memorySegment; } + + /** + * Returns the loaded libcuvs_java.so as a {@link SymbolLookup} + */ + public SymbolLookup getLibcuvsNativeLibrary() { + return libcuvsNativeLibrary; + } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java similarity index 62% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java index c2d00091a..23b490abd 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java @@ -14,14 +14,25 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs.common; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.lang.foreign.Arena; import java.lang.foreign.Linker; import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemorySegment; import java.lang.foreign.MemoryLayout.PathElement; import java.lang.invoke.VarHandle; +import java.nio.file.FileSystemNotFoundException; +import java.nio.file.FileSystems; +import java.nio.file.ProviderNotFoundException; + +import org.apache.commons.io.IOUtils; public class Util { /** @@ -30,7 +41,7 @@ public class Util { * @param str the string for the expected {@link MemorySegment} * @return an instance of {@link MemorySegment} */ - protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { + public static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { StringBuilder sb = new StringBuilder(str).append('\0'); MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), linker.canonicalLayouts().get("char")); @@ -49,7 +60,7 @@ protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, St * @param data The 2D float array for which the {@link MemorySegment} is needed * @return an instance of {@link MemorySegment} */ - protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { + public static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { long rows = data.length; long cols = data[0].length; @@ -68,5 +79,31 @@ protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, fl return dataMemorySegment; } + /** + * Load a file from the classpath to a temporary file. Suitable for loading .so files from the jar. + */ + public static File loadLibraryFromJar(String path) throws IOException { + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path has to be absolute (start with '/')."); + } + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + + // Split filename to prefix and suffix (extension) + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = (parts.length > 1) ? "." + parts[parts.length - 1] : null; + } + // Prepare temporary file + File temp = File.createTempFile(prefix, suffix); + IOUtils.copy(Util.class.getResourceAsStream(path), new FileOutputStream(temp)); + + return temp; + } + } From 84c6121c915af6106fed99521e1ac0e1bd11d777 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Sun, 17 Nov 2024 15:24:17 -0500 Subject: [PATCH 13/53] package renaming and formatting --- .../nvidia/cuvs/{cagra => }/CagraIndex.java | 78 ++++++----- .../cuvs/{cagra => }/CagraIndexParams.java | 2 +- .../nvidia/cuvs/{cagra => }/CagraQuery.java | 14 +- .../cuvs/{cagra => }/CagraSearchParams.java | 2 +- .../cuvs/{cagra => }/CagraSearchResults.java | 7 +- .../com/nvidia/cuvs/common/CuVSResources.java | 5 +- .../com/nvidia/cuvs/common/SearchResults.java | 12 +- .../java/com/nvidia/cuvs/common/Util.java | 132 +++++++++--------- .../cuvs/{ => examples}/CagraExample.java | 12 +- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 26 ++-- 10 files changed, 143 insertions(+), 147 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraIndex.java (86%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraIndexParams.java (99%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraQuery.java (94%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraSearchParams.java (99%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraSearchResults.java (98%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{ => examples}/CagraExample.java (91%) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java similarity index 86% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java index 7ff7fc8d2..0bac413cb 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.io.File; import java.io.FileInputStream; @@ -28,9 +28,9 @@ import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; -import java.lang.foreign.SymbolLookup; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; import java.util.UUID; import com.nvidia.cuvs.common.CuVSResources; @@ -38,7 +38,8 @@ import com.nvidia.cuvs.panama.cuvsCagraIndex; /** - * {@link CagraIndex} encapsulates a CAGRA index, along with methods to interact with it. + * {@link CagraIndex} encapsulates a CAGRA index, along with methods to interact + * with it. *

* CAGRA is a graph-based nearest neighbors algorithm that was built from the * ground up for GPU acceleration. CAGRA demonstrates state-of-the art index @@ -62,10 +63,9 @@ public class CagraIndex { private IndexReference cagraIndexReference; /* - * Constructor for building the index using specified dataset + * Constructor for building the index using specified dataset */ - private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources resources) - throws Throwable { + private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources resources) throws Throwable { this.cagraIndexParameters = indexParameters; this.dataset = dataset; this.resources = resources; @@ -81,14 +81,15 @@ private CagraIndex(InputStream inputStream, CuVSResources resources) throws Thro this.cagraIndexParameters = null; this.dataset = null; this.resources = resources; - + initializeMethodHandles(); this.cagraIndexReference = deserialize(inputStream); } /** * Initializes the {@link MethodHandles} for invoking native methods. - * @throws IOException @{@link IOException} is unable to load the native library + * + * @throws IOException @{@link IOException} is unable to load the native library */ private void initializeMethodHandles() throws IOException { linker = Linker.nativeLinker(); @@ -103,15 +104,18 @@ private void initializeMethodHandles() throws IOException { linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("serialize_cagra_index").get(), + serializeMethodHandle = linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("serialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("deserialize_cagra_index").get(), + deserializeMethodHandle = linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("deserialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } /** - * Invokes the native build_index function via the Panama API to build the {@link CagraIndex} + * Invokes the native build_index function via the Panama API to build the + * {@link CagraIndex} * * @return an instance of {@link IndexReference} that holds the pointer to the * index @@ -122,9 +126,9 @@ private IndexReference build() throws Throwable { MemoryLayout layout = linker.canonicalLayouts().get("int"); MemorySegment segment = arena.allocate(layout); - cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( - Util.buildMemorySegment(linker, arena, dataset), rows, cols, resources.getMemorySegment(), segment, - cagraIndexParameters.getMemorySegment())); + cagraIndexReference = new IndexReference( + (MemorySegment) indexMethodHandle.invokeExact(Util.buildMemorySegment(linker, arena, dataset), rows, cols, + resources.getMemorySegment(), segment, cagraIndexParameters.getMemorySegment())); return cagraIndexReference; } @@ -133,8 +137,8 @@ private IndexReference build() throws Throwable { * Invokes the native search_index via the Panama API for searching a CAGRA * index. * - * @param query an instance of {@link CagraQuery} holding the query vectors and other - * parameters + * @param query an instance of {@link CagraQuery} holding the query vectors and + * other parameters * @return an instance of {@link CagraSearchResults} containing the results */ public CagraSearchResults search(CagraQuery query) throws Throwable { @@ -147,36 +151,38 @@ public CagraSearchResults search(CagraQuery query) throws Throwable { searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), 4L, 2L, - resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, - returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); + resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, returnValueMemorySegment, + query.getCagraSearchParameters().getMemorySegment()); return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, distancesMemorySegment, query.getTopK(), query.getMapping(), query.getQueryVectors().length); } /** - * A method to persist a CAGRA index using an instance of {@link OutputStream} for - * writing index bytes. + * A method to persist a CAGRA index using an instance of {@link OutputStream} + * for writing index bytes. * - * @param outputStream an instance of {@link OutputStream} to write the index bytes into + * @param outputStream an instance of {@link OutputStream} to write the index + * bytes into */ public void serialize(OutputStream outputStream) throws Throwable { - serialize(outputStream, File.createTempFile(UUID.randomUUID().toString(), ".cag")); + serialize(outputStream, File.createTempFile(UUID.randomUUID().toString(), ".cag")); } /** - * A method to persist a CAGRA index using an instance of {@link OutputStream} and path - * to the intermediate temporary file. + * A method to persist a CAGRA index using an instance of {@link OutputStream} + * and path to the intermediate temporary file. * - * @param outputStream an instance of {@link OutputStream} to write the index bytes to - * @param tmpFilePath an intermediate {@link File} where CAGRA index is written temporarily + * @param outputStream an instance of {@link OutputStream} to write the index + * bytes to + * @param tmpFilePath an intermediate {@link File} where CAGRA index is written + * temporarily */ public void serialize(OutputStream outputStream, File tempFile) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - serializeMethodHandle.invokeExact(resources.getMemorySegment(), - cagraIndexReference.getMemorySegment(), returnValueMemorySegment, - Util.buildMemorySegment(linker, arena, tempFile.getAbsolutePath())); + serializeMethodHandle.invokeExact(resources.getMemorySegment(), cagraIndexReference.getMemorySegment(), + returnValueMemorySegment, Util.buildMemorySegment(linker, arena, tempFile.getAbsolutePath())); FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; // TODO: Make this configurable int chunkLength = 0; @@ -188,8 +194,8 @@ public void serialize(OutputStream outputStream, File tempFile) throws Throwable } /** - * Gets an instance of {@link IndexReference} by deserializing a CAGRA index using - * an {@link InputStream}. + * Gets an instance of {@link IndexReference} by deserializing a CAGRA index + * using an {@link InputStream}. * * @param inputStream an instance of {@link InputStream} * @return an instance of {@link IndexReference}. @@ -207,9 +213,8 @@ private IndexReference deserialize(InputStream inputStream) throws Throwable { while ((chunkLength = inputStream.read(chunk)) != -1) { fileOutputStream.write(chunk, 0, chunkLength); } - deserializeMethodHandle.invokeExact(resources.getMemorySegment(), - indexReference.getMemorySegment(), returnValueMemorySegment, - Util.buildMemorySegment(linker, arena, tmpIndexFile)); + deserializeMethodHandle.invokeExact(resources.getMemorySegment(), indexReference.getMemorySegment(), + returnValueMemorySegment, Util.buildMemorySegment(linker, arena, tmpIndexFile)); inputStream.close(); fileOutputStream.close(); @@ -279,7 +284,8 @@ public Builder withDataset(float[][] dataset) { } /** - * Registers an instance of configured {@link CagraIndexParams} with this Builder. + * Registers an instance of configured {@link CagraIndexParams} with this + * Builder. * * @param cagraIndexParameters An instance of CagraIndexParams. * @return An instance of this Builder. @@ -302,7 +308,7 @@ public CagraIndex build() throws Throwable { } } } - + /** * Holds the memory reference to an index. */ diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java similarity index 99% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java index 118f1e387..dd8fa6329 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java similarity index 94% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java index e5b9d7cff..ac42a4559 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.util.Arrays; import java.util.Map; @@ -33,18 +33,18 @@ public class CagraQuery { private int topK; /** - * Constructs an instance of {@link CagraQuery} using cagraSearchParameters, preFilter, - * queryVectors, mapping, and topK. + * Constructs an instance of {@link CagraQuery} using cagraSearchParameters, + * preFilter, queryVectors, mapping, and topK. * - * @param cagraSearchParameters an instance of {@link CagraSearchParams} holding the - * search parameters + * @param cagraSearchParameters an instance of {@link CagraSearchParams} holding + * the search parameters * @param preFilter an instance of PreFilter * @param queryVectors 2D float query vector array * @param mapping an instance of ID mapping * @param topK the top k results to return */ - public CagraQuery(CagraSearchParams cagraSearchParameters, float[][] queryVectors, - Map mapping, int topK) { + public CagraQuery(CagraSearchParams cagraSearchParameters, float[][] queryVectors, Map mapping, + int topK) { super(); this.cagraSearchParameters = cagraSearchParameters; this.queryVectors = queryVectors; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java similarity index 99% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java index 51ad1b8b2..14abd08dd 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java similarity index 98% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java index 78b74d3eb..6fe581964 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.lang.foreign.MemoryLayout.PathElement; import java.lang.foreign.MemorySegment; @@ -55,12 +55,13 @@ protected CagraSearchResults(SequenceLayout neighboursSequenceLayout, SequenceLa this.distancesMemorySegment = distancesMemorySegment; this.mapping = mapping; results = new LinkedList>(); - + readResultMemorySegments(); } /** - * Reads neighbors and distances {@link MemorySegment} and loads the values internally + * Reads neighbors and distances {@link MemorySegment} and loads the values + * internally */ private void readResultMemorySegments() { VarHandle neighboursVarHandle = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java index b63bac8e0..026aa4146 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java @@ -66,7 +66,8 @@ public CuVSResources() throws Throwable { * @return cuvsResources MemorySegment */ public MemorySegment getMemorySegment() { - // TODO: Is there a way to not letting a memory segment leak into the public API? + // TODO: Is there a way to not letting a memory segment leak into the public + // API? return memorySegment; } @@ -74,6 +75,6 @@ public MemorySegment getMemorySegment() { * Returns the loaded libcuvs_java.so as a {@link SymbolLookup} */ public SymbolLookup getLibcuvsNativeLibrary() { - return libcuvsNativeLibrary; + return libcuvsNativeLibrary; } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java index ae8fa6a23..9561e304b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java @@ -5,10 +5,10 @@ public interface SearchResults { - /** - * Gets a list results as a map of neighbor IDs to distances. - * - * @return a list of results for each query as a map of neighbor IDs to distance - */ - public List> getResults(); + /** + * Gets a list results as a map of neighbor IDs to distances. + * + * @return a list of results for each query as a map of neighbor IDs to distance + */ + public List> getResults(); } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java index 23b490abd..0c47436a0 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java @@ -17,93 +17,87 @@ package com.nvidia.cuvs.common; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.lang.foreign.Arena; import java.lang.foreign.Linker; import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; import java.lang.foreign.MemoryLayout.PathElement; +import java.lang.foreign.MemorySegment; import java.lang.invoke.VarHandle; -import java.nio.file.FileSystemNotFoundException; -import java.nio.file.FileSystems; -import java.nio.file.ProviderNotFoundException; import org.apache.commons.io.IOUtils; public class Util { - /** - * A utility method for getting an instance of {@link MemorySegment} for a {@link String}. - * - * @param str the string for the expected {@link MemorySegment} - * @return an instance of {@link MemorySegment} - */ - public static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { - StringBuilder sb = new StringBuilder(str).append('\0'); - MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), - linker.canonicalLayouts().get("char")); - MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); - - for (int i = 0; i < sb.length(); i++) { - VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); - varHandle.set(stringMemorySegment, 0L, (byte) sb.charAt(i)); - } - return stringMemorySegment; - } + /** + * A utility method for getting an instance of {@link MemorySegment} for a + * {@link String}. + * + * @param str the string for the expected {@link MemorySegment} + * @return an instance of {@link MemorySegment} + */ + public static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { + StringBuilder sb = new StringBuilder(str).append('\0'); + MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), linker.canonicalLayouts().get("char")); + MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); - /** - * A utility method for building a {@link MemorySegment} for a 2D float array. - * - * @param data The 2D float array for which the {@link MemorySegment} is needed - * @return an instance of {@link MemorySegment} - */ - public static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { - long rows = data.length; - long cols = data[0].length; + for (int i = 0; i < sb.length(); i++) { + VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); + varHandle.set(stringMemorySegment, 0L, (byte) sb.charAt(i)); + } + return stringMemorySegment; + } - MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, - MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); - MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); + /** + * A utility method for building a {@link MemorySegment} for a 2D float array. + * + * @param data The 2D float array for which the {@link MemorySegment} is needed + * @return an instance of {@link MemorySegment} + */ + public static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { + long rows = data.length; + long cols = data[0].length; - for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), - PathElement.sequenceElement(c)); - element.set(dataMemorySegment, 0, 0, data[r][c]); - } - } + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, + MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); + MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); - return dataMemorySegment; - } + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), + PathElement.sequenceElement(c)); + element.set(dataMemorySegment, 0, 0, data[r][c]); + } + } - /** - * Load a file from the classpath to a temporary file. Suitable for loading .so files from the jar. - */ - public static File loadLibraryFromJar(String path) throws IOException { - if (!path.startsWith("/")) { - throw new IllegalArgumentException("The path has to be absolute (start with '/')."); - } - // Obtain filename from path - String[] parts = path.split("/"); - String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + return dataMemorySegment; + } - // Split filename to prefix and suffix (extension) - String prefix = ""; - String suffix = null; - if (filename != null) { - parts = filename.split("\\.", 2); - prefix = parts[0]; - suffix = (parts.length > 1) ? "." + parts[parts.length - 1] : null; - } - // Prepare temporary file - File temp = File.createTempFile(prefix, suffix); - IOUtils.copy(Util.class.getResourceAsStream(path), new FileOutputStream(temp)); + /** + * Load a file from the classpath to a temporary file. Suitable for loading .so + * files from the jar. + */ + public static File loadLibraryFromJar(String path) throws IOException { + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path has to be absolute (start with '/')."); + } + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; - return temp; - } + // Split filename to prefix and suffix (extension) + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = (parts.length > 1) ? "." + parts[parts.length - 1] : null; + } + // Prepare temporary file + File temp = File.createTempFile(prefix, suffix); + IOUtils.copy(Util.class.getResourceAsStream(path), new FileOutputStream(temp)); + return temp; + } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java similarity index 91% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java index bb8e1d978..8fd03777b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs; +package com.nvidia.cuvs.examples; import java.io.File; import java.io.FileInputStream; @@ -25,13 +25,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.nvidia.cuvs.cagra.CagraIndex; -import com.nvidia.cuvs.cagra.CagraIndexParams; -import com.nvidia.cuvs.cagra.CagraIndexParams.CagraGraphBuildAlgo; +import com.nvidia.cuvs.CagraIndex; +import com.nvidia.cuvs.CagraIndexParams; +import com.nvidia.cuvs.CagraQuery; +import com.nvidia.cuvs.CagraSearchParams; +import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.SearchResults; -import com.nvidia.cuvs.cagra.CagraSearchParams; -import com.nvidia.cuvs.cagra.CagraQuery; public class CagraExample { diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index cdc34c255..e41f68026 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -32,10 +32,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.nvidia.cuvs.cagra.CagraIndex; -import com.nvidia.cuvs.cagra.CagraIndexParams; -import com.nvidia.cuvs.cagra.CagraQuery; -import com.nvidia.cuvs.cagra.CagraSearchParams; import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.SearchResults; @@ -57,7 +53,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { float[][] queries = {{ 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f }}; // Expected search results - List> expectedQueryResults = Arrays.asList( + List> expectedResults = Arrays.asList( Map.of(3, 0.038782578f, 2, 0.3590463f, 0, 0.83774555f), Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), Map.of(3, 0.047766715f, 2, 0.20332818f, 0, 0.48305473f), @@ -82,22 +78,20 @@ public void testIndexingAndSearchingFlow() throws Throwable { index.serialize(new FileOutputStream(indexFileName)); // Loading a CAGRA index from disk. - File testSerializedIndexFile = new File(indexFileName); - InputStream inputStream = new FileInputStream(testSerializedIndexFile); + File indexFile = new File(indexFileName); + InputStream inputStream = new FileInputStream(indexFile); CagraIndex loadedIndex = new CagraIndex.Builder(resources) .from(inputStream) .build(); // Configure search parameters - CagraSearchParams cagraSearchParameters = new CagraSearchParams - .Builder() + CagraSearchParams searchParams = new CagraSearchParams.Builder() .build(); // Create a query object with the query vectors - CagraQuery cuvsQuery = new CagraQuery - .Builder() + CagraQuery cuvsQuery = new CagraQuery.Builder() .withTopK(3) - .withSearchParams(cagraSearchParameters) + .withSearchParams(searchParams) .withQueryVectors(queries) .withMapping(map) .build(); @@ -107,18 +101,18 @@ public void testIndexingAndSearchingFlow() throws Throwable { // Check results log.info(results.getResults().toString()); - assertEquals(expectedQueryResults, results.getResults(), "Results different than expected"); + assertEquals(expectedResults, results.getResults(), "Results different than expected"); // Search from deserialized index results = loadedIndex.search(cuvsQuery); // Check results log.info(results.getResults().toString()); - assertEquals(expectedQueryResults, results.getResults(), "Results different than expected"); + assertEquals(expectedResults, results.getResults(), "Results different than expected"); // Cleanup - if (testSerializedIndexFile.exists()) { - testSerializedIndexFile.delete(); + if (indexFile.exists()) { + indexFile.delete(); } } } \ No newline at end of file From 20562ee7b24c021c3fdc8dd9129cc43b63b92193 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Mon, 18 Nov 2024 00:14:57 -0500 Subject: [PATCH 14/53] moving CuVSResources + other updates --- .../main/java/com/nvidia/cuvs/CagraIndex.java | 1 - .../com/nvidia/cuvs/CagraIndexParams.java | 14 +- .../main/java/com/nvidia/cuvs/CagraQuery.java | 2 +- .../cuvs/{common => }/CuVSResources.java | 8 +- .../nvidia/cuvs/examples/CagraExample.java | 2 +- .../java/com/nvidia/cuvs/panama/results.java | 227 ------------------ .../com/nvidia/cuvs/panama/results_h.java | 99 -------- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 1 - 8 files changed, 14 insertions(+), 340 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{common => }/CuVSResources.java (93%) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java 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 0bac413cb..636771b21 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 @@ -33,7 +33,6 @@ import java.lang.invoke.MethodHandles; import java.util.UUID; -import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.Util; import com.nvidia.cuvs.panama.cuvsCagraIndex; 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 dd8fa6329..ab42b2c9c 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 @@ -41,25 +41,25 @@ public class CagraIndexParams { */ public enum CagraGraphBuildAlgo { /** - * AUTO_SELECT + * Select build algorithm automatically */ AUTO_SELECT(0), /** - * IVF_PQ + * Use IVF-PQ to build all-neighbors knn graph */ IVF_PQ(1), /** - * NN_DESCENT + * Experimental, use NN-Descent to build all-neighbors knn graph */ NN_DESCENT(2); /** * The value for the enum choice. */ - public final int label; + public final int value; - private CagraGraphBuildAlgo(int label) { - this.label = label; + private CagraGraphBuildAlgo(int value) { + this.value = value; } } @@ -79,7 +79,7 @@ private MemorySegment initMemorySegment() { MemorySegment memorySegment = CuVSCagraIndexParams.allocate(arena); CuVSCagraIndexParams.intermediate_graph_degree(memorySegment, intermediateGraphDegree); CuVSCagraIndexParams.graph_degree(memorySegment, graphDegree); - CuVSCagraIndexParams.build_algo(memorySegment, cuvsCagraGraphBuildAlgo.label); + CuVSCagraIndexParams.build_algo(memorySegment, cuvsCagraGraphBuildAlgo.value); CuVSCagraIndexParams.nn_descent_niter(memorySegment, nnDescentNiter); return memorySegment; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java index ac42a4559..f9a8e5884 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java @@ -20,7 +20,7 @@ import java.util.Map; /** - * CuVSQuery holds the CagraSearchParams and the query vectors to be used while + * CagraQuery holds the CagraSearchParams and the query vectors to be used while * invoking search. * * @since 24.12 diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java similarity index 93% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java index 026aa4146..822f1959d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.common; +package com.nvidia.cuvs; import java.io.File; import java.lang.foreign.Arena; @@ -26,6 +26,8 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; +import com.nvidia.cuvs.common.Util; + /** * Used for allocating resources for cuVS * @@ -65,7 +67,7 @@ public CuVSResources() throws Throwable { * * @return cuvsResources MemorySegment */ - public MemorySegment getMemorySegment() { + protected MemorySegment getMemorySegment() { // TODO: Is there a way to not letting a memory segment leak into the public // API? return memorySegment; @@ -74,7 +76,7 @@ public MemorySegment getMemorySegment() { /** * Returns the loaded libcuvs_java.so as a {@link SymbolLookup} */ - public SymbolLookup getLibcuvsNativeLibrary() { + protected SymbolLookup getLibcuvsNativeLibrary() { return libcuvsNativeLibrary; } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java index 8fd03777b..bfb9713a4 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java @@ -29,8 +29,8 @@ import com.nvidia.cuvs.CagraIndexParams; import com.nvidia.cuvs.CagraQuery; import com.nvidia.cuvs.CagraSearchParams; +import com.nvidia.cuvs.CuVSResources; import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; -import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.SearchResults; public class CagraExample { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java deleted file mode 100644 index 78b81f44b..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2023-2024, 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.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct results { - * int test; - * int *neighbors_h; - * float *distances_h; - * } - * } - */ -public class results { - - results() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout - .structLayout(results_h.C_INT.withName("test"), MemoryLayout.paddingLayout(4), - results_h.C_POINTER.withName("neighbors_h"), results_h.C_POINTER.withName("distances_h")) - .withName("results"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt test$LAYOUT = (OfInt) $LAYOUT.select(groupElement("test")); - - /** - * Layout for field: - * {@snippet lang = c : * int test - * } - */ - public static final OfInt test$layout() { - return test$LAYOUT; - } - - private static final long test$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * int test - * } - */ - public static final long test$offset() { - return test$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int test - * } - */ - public static int test(MemorySegment struct) { - return struct.get(test$LAYOUT, test$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int test - * } - */ - public static void test(MemorySegment struct, int fieldValue) { - struct.set(test$LAYOUT, test$OFFSET, fieldValue); - } - - private static final AddressLayout neighbors_h$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("neighbors_h")); - - /** - * Layout for field: - * {@snippet lang = c : * int *neighbors_h - * } - */ - public static final AddressLayout neighbors_h$layout() { - return neighbors_h$LAYOUT; - } - - private static final long neighbors_h$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang = c : * int *neighbors_h - * } - */ - public static final long neighbors_h$offset() { - return neighbors_h$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int *neighbors_h - * } - */ - public static MemorySegment neighbors_h(MemorySegment struct) { - return struct.get(neighbors_h$LAYOUT, neighbors_h$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int *neighbors_h - * } - */ - public static void neighbors_h(MemorySegment struct, MemorySegment fieldValue) { - struct.set(neighbors_h$LAYOUT, neighbors_h$OFFSET, fieldValue); - } - - private static final AddressLayout distances_h$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("distances_h")); - - /** - * Layout for field: - * {@snippet lang = c : * float *distances_h - * } - */ - public static final AddressLayout distances_h$layout() { - return distances_h$LAYOUT; - } - - private static final long distances_h$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang = c : * float *distances_h - * } - */ - public static final long distances_h$offset() { - return distances_h$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * float *distances_h - * } - */ - public static MemorySegment distances_h(MemorySegment struct) { - return struct.get(distances_h$LAYOUT, distances_h$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * float *distances_h - * } - */ - public static void distances_h(MemorySegment struct, MemorySegment fieldValue) { - struct.set(distances_h$LAYOUT, distances_h$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/java/com/nvidia/cuvs/panama/results_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java deleted file mode 100644 index de4a42082..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2023-2024, 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.panama; - -import static java.lang.foreign.ValueLayout.JAVA_BYTE; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.PaddingLayout; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.StructLayout; -import java.lang.foreign.SymbolLookup; -import java.lang.foreign.ValueLayout; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class results_h { - - results_h() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) - : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - /** - * {@snippet lang = c : - * typedef struct results { - * int test; - * int *neighbors_h; - * float *distances_h; - * } *rsltp - * } - */ - public static final AddressLayout rsltp = results_h.C_POINTER; -} diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index e41f68026..29b12df1f 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -32,7 +32,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.SearchResults; public class CagraBuildAndSearchTest { From ad11369668e39af896527a51a3519f07f08a3b9b Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Mon, 18 Nov 2024 01:19:09 -0500 Subject: [PATCH 15/53] code refactoring --- .../main/java/com/nvidia/cuvs/CagraIndex.java | 17 +++++++++++------ .../com/nvidia/cuvs/CagraSearchResults.java | 4 ++-- .../java/com/nvidia/cuvs/CuVSResources.java | 2 -- .../main/java/com/nvidia/cuvs/common/Util.java | 1 - java/internal/src/cuvs_java.c | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) 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 636771b21..09d969e59 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 @@ -100,7 +100,7 @@ private void initializeMethodHandles() throws IOException { searchMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), - linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, + linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("int"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); serializeMethodHandle = linker.downcallHandle( @@ -141,20 +141,26 @@ private IndexReference build() throws Throwable { * @return an instance of {@link CagraSearchResults} containing the results */ public CagraSearchResults search(CagraQuery query) throws Throwable { - SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); - SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); + long numQueries = query.getQueryVectors().length; + long numBlocks = query.getTopK() * numQueries; + int vectorDimension = numQueries > 0 ? query.getQueryVectors()[0].length : 0; + + SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, + linker.canonicalLayouts().get("int")); + SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, + linker.canonicalLayouts().get("float")); MemorySegment neighborsMemorySegment = arena.allocate(neighborsSequenceLayout); MemorySegment distancesMemorySegment = arena.allocate(distancesSequenceLayout); MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), - Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), 4L, 2L, + Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), numQueries, vectorDimension, resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, - distancesMemorySegment, query.getTopK(), query.getMapping(), query.getQueryVectors().length); + distancesMemorySegment, query.getTopK(), query.getMapping(), numQueries); } /** @@ -343,5 +349,4 @@ protected MemorySegment getMemorySegment() { return memorySegment; } } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java index 6fe581964..372c1965c 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java @@ -41,11 +41,11 @@ public class CagraSearchResults implements SearchResults { private final MemorySegment neighboursMemorySegment; private final MemorySegment distancesMemorySegment; private final int topK; - private final int numberOfQueries; + private final long numberOfQueries; protected CagraSearchResults(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, MemorySegment neighboursMemorySegment, MemorySegment distancesMemorySegment, int topK, - Map mapping, int numberOfQueries) { + Map mapping, long numberOfQueries) { super(); this.topK = topK; this.numberOfQueries = numberOfQueries; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java index 822f1959d..b9fc4ba9b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java @@ -68,8 +68,6 @@ public CuVSResources() throws Throwable { * @return cuvsResources MemorySegment */ protected MemorySegment getMemorySegment() { - // TODO: Is there a way to not letting a memory segment leak into the public - // API? return memorySegment; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java index 0c47436a0..896253dd7 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java @@ -99,5 +99,4 @@ public static File loadLibraryFromJar(String path) throws IOException { return temp; } - } diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index 06fcac6ed..aac773c1b 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -63,7 +63,7 @@ void deserialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t ind *rv = cuvsCagraDeserialize(cuvsResources, filename, index); } -void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, +void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, int dimensions, cuvsResources_t cuvsResources, int *neighbors_h, float *distances_h, int *returnValue, cuvsCagraSearchParams_t search_params) { uint32_t *neighbors; From 6a851ef18bf96f6f564ca57b2737905c026a4378 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Mon, 18 Nov 2024 02:35:13 -0500 Subject: [PATCH 16/53] javadoc maven config update and bug fixes --- java/cuvs-java/pom.xml | 2 +- java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java | 2 +- java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 41ea18ca9..644cd8bb8 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -154,7 +154,7 @@ maven-javadoc-plugin 3.6.2 - com.nvidia.cuvs,com.nvidia.cuvs.panama + com.nvidia.cuvs.examples,com.nvidia.cuvs.panama ${project.build.directory} 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 09d969e59..f9c8b0161 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 @@ -180,7 +180,7 @@ public void serialize(OutputStream outputStream) throws Throwable { * * @param outputStream an instance of {@link OutputStream} to write the index * bytes to - * @param tmpFilePath an intermediate {@link File} where CAGRA index is written + * @param tempFile an intermediate {@link File} where CAGRA index is written * temporarily */ public void serialize(OutputStream outputStream, File tempFile) throws Throwable { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java index f9a8e5884..480f598ee 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java @@ -38,7 +38,6 @@ public class CagraQuery { * * @param cagraSearchParameters an instance of {@link CagraSearchParams} holding * the search parameters - * @param preFilter an instance of PreFilter * @param queryVectors 2D float query vector array * @param mapping an instance of ID mapping * @param topK the top k results to return From 68e8b94551b8a494df95a0a4300c27c0a126bef5 Mon Sep 17 00:00:00 2001 From: Ishan Chattopadhyaya Date: Tue, 26 Nov 2024 19:03:14 +0530 Subject: [PATCH 17/53] Consolidating all Arenas and Linkers to CuVSResources, fixing copyright notices --- java/cuvs-java/pom.xml | 6 +- .../main/java/com/nvidia/cuvs/CagraIndex.java | 65 +++++++--------- .../com/nvidia/cuvs/CagraIndexParams.java | 36 +++++---- .../main/java/com/nvidia/cuvs/CagraQuery.java | 2 +- .../com/nvidia/cuvs/CagraSearchParams.java | 77 ++++++++++--------- .../com/nvidia/cuvs/CagraSearchResults.java | 2 +- .../java/com/nvidia/cuvs/CuVSResources.java | 11 +-- .../java/com/nvidia/cuvs/common/Util.java | 2 +- .../nvidia/cuvs/examples/CagraExample.java | 20 ++--- .../cuvs/panama/CuVSCagraIndexParams.java | 2 +- .../com/nvidia/cuvs/panama/DLDataType.java | 2 +- .../java/com/nvidia/cuvs/panama/DLDevice.java | 2 +- .../nvidia/cuvs/panama/DLManagedTensor.java | 2 +- .../cuvs/panama/DLManagedTensorVersioned.java | 2 +- .../com/nvidia/cuvs/panama/DLPackVersion.java | 2 +- .../java/com/nvidia/cuvs/panama/DLTensor.java | 2 +- .../java/com/nvidia/cuvs/panama/__fsid_t.java | 2 +- .../com/nvidia/cuvs/panama/brute_force_h.java | 2 +- .../java/com/nvidia/cuvs/panama/cagra_h.java | 2 +- .../panama/cuvsCagraCompressionParams.java | 2 +- .../nvidia/cuvs/panama/cuvsCagraIndex.java | 2 +- .../cuvs/panama/cuvsCagraSearchParams.java | 2 +- .../com/nvidia/cuvs/panama/cuvsFilter.java | 2 +- .../java/com/nvidia/cuvs/panama/dlpack_h.java | 2 +- .../java/com/nvidia/cuvs/panama/hnsw_h.java | 2 +- .../com/nvidia/cuvs/panama/ivf_flat_h.java | 2 +- .../java/com/nvidia/cuvs/panama/ivf_pq_h.java | 2 +- .../com/nvidia/cuvs/panama/max_align_t.java | 2 +- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 6 +- java/internal/src/cuvs_java.c | 4 +- 30 files changed, 134 insertions(+), 135 deletions(-) diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 644cd8bb8..0f0c4dcb5 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -1,6 +1,6 @@ + + + + maven-clean-plugin + 3.4.0 + + + + maven-resources-plugin + 3.3.1 + + + maven-compiler-plugin + 3.13.0 + + + maven-surefire-plugin + 3.3.0 + + + maven-jar-plugin + 3.4.2 + + + maven-install-plugin + 3.1.2 + + + maven-deploy-plugin + 3.1.2 + + + + maven-site-plugin + 3.12.1 + + + maven-project-info-reports-plugin + 3.6.1 + + + maven-assembly-plugin + + + make-jar-with-dependencies + + package + + + single + + + + + + + com.nvidia.cuvs.examples.CagraExample + + + + jar-with-dependencies + + + + + + + diff --git a/java/examples/cagra-example/src/main/java/com/nvidia/cuvs/examples/CagraExample.java b/java/examples/cagra-example/src/main/java/com/nvidia/cuvs/examples/CagraExample.java new file mode 100644 index 000000000..86c405606 --- /dev/null +++ b/java/examples/cagra-example/src/main/java/com/nvidia/cuvs/examples/CagraExample.java @@ -0,0 +1,58 @@ +package com.nvidia.cuvs.examples; + +import java.lang.invoke.MethodHandles; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.nvidia.cuvs.CagraIndex; +import com.nvidia.cuvs.CagraIndexParams; +import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; +import com.nvidia.cuvs.CagraQuery; +import com.nvidia.cuvs.CagraSearchParams; +import com.nvidia.cuvs.CuVSResources; +import com.nvidia.cuvs.common.SearchResults; + +public class CagraExample { + + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + public static void main(String[] args) throws Throwable { + // Sample dataset and queries + float[][] dataset = { { 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, + { 0.6673192f, 0.10993068f } }; + float[][] queries = { { 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, + { 0.05198065f, 0.5789965f } }; + + // Allocate the resources + CuVSResources resources = new CuVSResources(); + + // Create an index and a searcher + CagraIndexParams indexParams = new CagraIndexParams.Builder(resources) + .withIntermediateGraphDegree(10) + .withCagraGraphBuildAlgo(CagraGraphBuildAlgo.NN_DESCENT) + .build(); + CagraIndex index = new CagraIndex.Builder(resources) + .withDataset(dataset) + .withIndexParams(indexParams) + .build(); + log.info("Indexing done!"); + + // Search + CagraSearchParams searchParams = new CagraSearchParams.Builder(resources).build(); + CagraQuery query = new CagraQuery.Builder() + .withTopK(2) // get only the top 2 items + .withSearchParams(searchParams) + .withQueryVectors(queries) + .build(); + SearchResults results = index.search(query); + + // Print the results + for (int i=0; i + + + + + + + + + + + + + \ No newline at end of file From 479e4881fd80659f28028189eb6083950ec02f5c Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Wed, 27 Nov 2024 14:14:29 -0500 Subject: [PATCH 19/53] major performance improvement - reduced creation time for memory segment for data array --- .../main/java/com/nvidia/cuvs/CagraIndex.java | 36 ++++++++++--------- .../com/nvidia/cuvs/CagraSearchParams.java | 1 + .../java/com/nvidia/cuvs/common/Util.java | 14 ++++---- java/internal/src/cuvs_java.c | 14 ++++---- 4 files changed, 34 insertions(+), 31 deletions(-) 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 90b542947..8ad64d7d6 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 @@ -87,15 +87,18 @@ private CagraIndex(InputStream inputStream, CuVSResources resources) throws Thro * @throws IOException @{@link IOException} is unable to load the native library */ private void initializeMethodHandles() throws IOException { - - indexMethodHandle = resources.linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("build_cagra_index").get(), + indexMethodHandle = resources.linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("build_cagra_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("long"), - resources.linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + resources.linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, + ValueLayout.ADDRESS)); - searchMethodHandle = resources.linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("int"), - resources.linker.canonicalLayouts().get("long"), resources.linker.canonicalLayouts().get("int"), ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + searchMethodHandle = resources.linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, + resources.linker.canonicalLayouts().get("int"), resources.linker.canonicalLayouts().get("long"), + resources.linker.canonicalLayouts().get("int"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, + ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); serializeMethodHandle = resources.linker.downcallHandle( resources.getLibcuvsNativeLibrary().find("serialize_cagra_index").get(), @@ -119,9 +122,9 @@ private IndexReference build() throws Throwable { MemoryLayout layout = resources.linker.canonicalLayouts().get("int"); MemorySegment segment = resources.arena.allocate(layout); - cagraIndexReference = new IndexReference( - (MemorySegment) indexMethodHandle.invokeExact(Util.buildMemorySegment(resources.linker, resources.arena, dataset), rows, cols, - resources.getMemorySegment(), segment, cagraIndexParameters.getMemorySegment())); + cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( + Util.buildMemorySegment(resources.linker, resources.arena, dataset), rows, cols, resources.getMemorySegment(), + segment, cagraIndexParameters.getMemorySegment())); return cagraIndexReference; } @@ -147,11 +150,11 @@ public CagraSearchResults search(CagraQuery query) throws Throwable { MemorySegment distancesMemorySegment = resources.arena.allocate(distancesSequenceLayout); MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); - + searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), - Util.buildMemorySegment(resources.linker, resources.arena, query.getQueryVectors()), query.getTopK(), numQueries, vectorDimension, - resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, returnValueMemorySegment, - query.getCagraSearchParameters().getMemorySegment()); + Util.buildMemorySegment(resources.linker, resources.arena, query.getQueryVectors()), query.getTopK(), + numQueries, vectorDimension, resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, + returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, distancesMemorySegment, query.getTopK(), query.getMapping(), numQueries); @@ -174,14 +177,15 @@ public void serialize(OutputStream outputStream) throws Throwable { * * @param outputStream an instance of {@link OutputStream} to write the index * bytes to - * @param tempFile an intermediate {@link File} where CAGRA index is written + * @param tempFile an intermediate {@link File} where CAGRA index is written * temporarily */ public void serialize(OutputStream outputStream, File tempFile) throws Throwable { MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); serializeMethodHandle.invokeExact(resources.getMemorySegment(), cagraIndexReference.getMemorySegment(), - returnValueMemorySegment, Util.buildMemorySegment(resources.linker, resources.arena, tempFile.getAbsolutePath())); + returnValueMemorySegment, + Util.buildMemorySegment(resources.linker, resources.arena, tempFile.getAbsolutePath())); FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; // TODO: Make this configurable int chunkLength = 0; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java index 07f887697..8ea4287b6 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java @@ -328,6 +328,7 @@ public static class Builder { /** * Constructs this Builder with an instance of Arena. + * * @param resources the {@link CuVSResources} instance to use */ public Builder(CuVSResources resources) { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java index 740e8d371..750e49d64 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java @@ -24,6 +24,7 @@ import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemoryLayout.PathElement; import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; import java.lang.invoke.VarHandle; import org.apache.commons.io.IOUtils; @@ -56,18 +57,15 @@ public static MemorySegment buildMemorySegment(Linker linker, Arena arena, Strin */ public static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { long rows = data.length; - long cols = data[0].length; + long cols = rows > 0 ? data[0].length : 0; - MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, - MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows * cols, linker.canonicalLayouts().get("float")); MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); + long floatByteSize = linker.canonicalLayouts().get("float").byteSize(); for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), - PathElement.sequenceElement(c)); - element.set(dataMemorySegment, 0, 0, data[r][c]); - } + MemorySegment.copy(data[r], 0, dataMemorySegment, (ValueLayout) linker.canonicalLayouts().get("float"), + (r * cols * floatByteSize), (int) cols); } return dataMemorySegment; diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index 14c8a0112..ec9ecb6af 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -27,7 +27,7 @@ cuvsResources_t create_resource(int *returnValue) { return cuvsResources; } -DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, long dimensions) { +DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) { DLManagedTensor tensor; tensor.dl_tensor.data = data; @@ -46,7 +46,7 @@ cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, c cuvsCagraIndexParams_t index_params) { int64_t dataset_shape[2] = {rows, dimensions}; - DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat, dimensions); + DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat); cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); @@ -59,8 +59,8 @@ void serialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index *returnValue = cuvsCagraSerialize(cuvsResources, filename, index, true); } -void deserialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *rv, char* filename) { - *rv = cuvsCagraDeserialize(cuvsResources, filename, index); +void deserialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { + *returnValue = cuvsCagraDeserialize(cuvsResources, filename, index); } void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, int dimensions, @@ -75,13 +75,13 @@ void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n cudaMemcpy(queries_d, queries, sizeof(float) * n_queries * dimensions, cudaMemcpyDefault); int64_t queries_shape[2] = {n_queries, dimensions}; - DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat, dimensions); + DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat); int64_t neighbors_shape[2] = {n_queries, topk}; - DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt, dimensions); + DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt); int64_t distances_shape[2] = {n_queries, topk}; - DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat, dimensions); + DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat); cuvsCagraSearchParamsCreate(&search_params); From 43f5e154c6687c58b06e3273a3f10d4230b136d2 Mon Sep 17 00:00:00 2001 From: Vivek Narang <123010842+narangvivek10@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:06:17 -0500 Subject: [PATCH 20/53] Adding randomized test, fixes for memory allocation and deallocation, etc. (#6) * Ability to configure CAGRA compression parameters * Enabling indexing threads * Enabling RMM pool resource configuration * Bug fixes for wrong values passed in index and search parameters * Deallocation of resources using Autoclosable * Including a randomized test Co-authored-by: Vivek Narang Co-authored-by: Ishan Chattopadhyaya Co-authored-by: Puneet Ahuja --- java/cuvs-java/pom.xml | 14 +- .../nvidia/cuvs/CagraCompressionParams.java | 266 ++ .../main/java/com/nvidia/cuvs/CagraIndex.java | 54 +- .../com/nvidia/cuvs/CagraIndexParams.java | 14 +- .../main/java/com/nvidia/cuvs/CagraQuery.java | 2 +- .../com/nvidia/cuvs/CagraSearchParams.java | 62 +- .../com/nvidia/cuvs/CagraSearchResults.java | 2 +- .../java/com/nvidia/cuvs/CuVSResources.java | 41 +- .../cuvs/panama/CuVSCagraIndexParams.java | 517 ++- .../panama/CuvsCagraCompressionParams.java | 352 ++ .../cuvs/panama/CuvsCagraSearchParams.java | 644 +++ .../java/com/nvidia/cuvs/panama/__fsid_t.java | 2 +- .../java/com/nvidia/cuvs/panama/cagra_h.java | 4033 +++++++++-------- .../panama/cuvsCagraCompressionParams.java | 372 -- .../cuvs/panama/cuvsCagraSearchParams.java | 697 --- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 142 +- .../com/nvidia/cuvs/CagraRandomizedTest.java | 163 + .../java/com/nvidia/cuvs/CuVSTestCase.java | 19 + java/internal/CMakeLists.txt | 5 +- java/internal/src/cuvs_java.c | 30 +- 20 files changed, 3977 insertions(+), 3454 deletions(-) create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraCompressionParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraCompressionParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraSearchParams.java delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java create mode 100644 java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraRandomizedTest.java create mode 100644 java/cuvs-java/src/test/java/com/nvidia/cuvs/CuVSTestCase.java diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index aacbad2ca..95d0afb24 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -59,9 +59,17 @@ - org.junit.jupiter - junit-jupiter-api - 5.10.0 + com.carrotsearch.randomizedtesting + randomizedtesting-runner + 2.8.2 + test + + + + junit + junit + 4.13.1 + test diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraCompressionParams.java new file mode 100644 index 000000000..50df0c64b --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraCompressionParams.java @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2024, 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 java.lang.foreign.MemorySegment; + +import com.nvidia.cuvs.panama.CuvsCagraCompressionParams; + +/** + * Supplemental compression parameters to build CAGRA Index. + * + * @since 25.02 + */ +public class CagraCompressionParams { + + private final MemorySegment memorySegment; + private CuVSResources resources; + private final int pqBits; + private final int pqDim; + private final int vqNCenters; + private final int kmeansNIters; + private final double vqKmeansTrainsetFraction; + private final double pqKmeansTrainsetFraction; + + /** + * Constructs an instance of CagraCompressionParams with passed search + * parameters. + * + * @param resources the resources instance to use + * @param pqBits the bit length of the vector element after + * compression by PQ + * @param pqDim the dimensionality of the vector after + * compression by PQ + * @param vqNCenters the vector quantization (VQ) codebook size - + * number of “coarse cluster centers” + * @param kmeansNIters the number of iterations searching for kmeans + * centers (both VQ and PQ phases) + * @param vqKmeansTrainsetFraction the fraction of data to use during iterative + * kmeans building (VQ phase) + * @param pqKmeansTrainsetFraction the fraction of data to use during iterative + * kmeans building (PQ phase) + */ + private CagraCompressionParams(CuVSResources resources, int pqBits, int pqDim, int vqNCenters, int kmeansNIters, + double vqKmeansTrainsetFraction, double pqKmeansTrainsetFraction) { + this.resources = resources; + this.pqBits = pqBits; + this.pqDim = pqDim; + this.vqNCenters = vqNCenters; + this.kmeansNIters = kmeansNIters; + this.vqKmeansTrainsetFraction = vqKmeansTrainsetFraction; + this.pqKmeansTrainsetFraction = pqKmeansTrainsetFraction; + this.memorySegment = initMemorySegment(); + } + + /** + * Allocates the configured compression parameters in the MemorySegment. + */ + private MemorySegment initMemorySegment() { + MemorySegment compressionParamsMemorySegment = CuvsCagraCompressionParams.allocate(resources.arena); + CuvsCagraCompressionParams.pq_bits(compressionParamsMemorySegment, pqBits); + CuvsCagraCompressionParams.pq_dim(compressionParamsMemorySegment, pqDim); + CuvsCagraCompressionParams.vq_n_centers(compressionParamsMemorySegment, vqNCenters); + CuvsCagraCompressionParams.kmeans_n_iters(compressionParamsMemorySegment, kmeansNIters); + CuvsCagraCompressionParams.vq_kmeans_trainset_fraction(compressionParamsMemorySegment, vqKmeansTrainsetFraction); + CuvsCagraCompressionParams.pq_kmeans_trainset_fraction(compressionParamsMemorySegment, pqKmeansTrainsetFraction); + return compressionParamsMemorySegment; + } + + /** + * Gets the memory segment instance containing the compression parameters. + * + * @return the memory segment instance containing the compression parameters. + */ + protected MemorySegment getMemorySegment() { + return memorySegment; + } + + /** + * 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 the vector quantization (VQ) codebook size - number of “coarse cluster + * centers”. + * + * @return the vector quantization (VQ) codebook size - number of “coarse + * cluster centers”. + */ + public int getVqNCenters() { + return vqNCenters; + } + + /** + * Gets the number of iterations searching for kmeans centers (both VQ and PQ + * phases). + * + * @return the number of iterations searching for kmeans centers (both VQ and PQ + * phases). + */ + public int getKmeansNIters() { + return kmeansNIters; + } + + /** + * Gets the fraction of data to use during iterative kmeans building (VQ phase). + * + * @return the fraction of data to use during iterative kmeans building (VQ + * phase). + */ + public double getVqKmeansTrainsetFraction() { + return vqKmeansTrainsetFraction; + } + + /** + * Gets the fraction of data to use during iterative kmeans building (PQ phase). + * + * @return the fraction of data to use during iterative kmeans building (PQ + * phase). + */ + public double getPqKmeansTrainsetFraction() { + return pqKmeansTrainsetFraction; + } + + @Override + public String toString() { + return "CagraCompressionParams [pqBits=" + pqBits + ", pqDim=" + pqDim + ", vqNCenters=" + vqNCenters + + ", kmeansNIters=" + kmeansNIters + ", vqKmeansTrainsetFraction=" + vqKmeansTrainsetFraction + + ", pqKmeansTrainsetFraction=" + pqKmeansTrainsetFraction + "]"; + } + + /** + * Builder configures and creates an instance of {@link CagraCompressionParams}. + */ + public static class Builder { + + private CuVSResources resources; + private int pqBits = 8; + private int pqDim = 0; + private int vqNCenters = 0; + private int kmeansNIters = 25; + private double vqKmeansTrainsetFraction = 0; + private double pqKmeansTrainsetFraction = 0; + + public Builder(CuVSResources resources) { + this.resources = resources; + } + + /** + * Sets 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. + * + * @param pqBits + * @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. + * + * When zero, an optimal value is selected using a heuristic. + * + * @param pqDim + * @return an instance of Builder + */ + public Builder withPqDim(int pqDim) { + this.pqDim = pqDim; + return this; + } + + /** + * Sets the vector quantization (VQ) codebook size - number of “coarse cluster + * centers”. + * + * When zero, an optimal value is selected using a heuristic. + * + * @param vqNCenters + * @return an instance of Builder + */ + public Builder withVqNCenters(int vqNCenters) { + this.vqNCenters = vqNCenters; + return this; + } + + /** + * Sets the number of iterations searching for kmeans centers (both VQ and PQ + * phases). + * + * @param kmeansNIters + * @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 (VQ phase). + * + * When zero, an optimal value is selected using a heuristic. + * + * @param vqKmeansTrainsetFraction + * @return an instance of Builder + */ + public Builder withVqKmeansTrainsetFraction(double vqKmeansTrainsetFraction) { + this.vqKmeansTrainsetFraction = vqKmeansTrainsetFraction; + return this; + } + + /** + * Sets the fraction of data to use during iterative kmeans building (PQ phase). + * + * When zero, an optimal value is selected using a heuristic. + * + * @param pqKmeansTrainsetFraction + * @return an instance of Builder + */ + public Builder withPqKmeansTrainsetFraction(double pqKmeansTrainsetFraction) { + this.pqKmeansTrainsetFraction = pqKmeansTrainsetFraction; + return this; + } + + /** + * Builds an instance of {@link CagraCompressionParams}. + * + * @return an instance of {@link CagraCompressionParams} + */ + public CagraCompressionParams build() { + return new CagraCompressionParams(resources, pqBits, pqDim, vqNCenters, kmeansNIters, vqKmeansTrainsetFraction, + pqKmeansTrainsetFraction); + } + } +} \ No newline at end of file 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 8ad64d7d6..67394b53b 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 @@ -44,7 +44,7 @@ * more about this algorithm * here * - * @since 24.12 + * @since 25.02 */ public class CagraIndex { @@ -54,14 +54,18 @@ public class CagraIndex { private MethodHandle searchMethodHandle; private MethodHandle serializeMethodHandle; private MethodHandle deserializeMethodHandle; + private MethodHandle destroyIndexMethodHandle; private CagraIndexParams cagraIndexParameters; + private CagraCompressionParams cagraCompressionParams; private IndexReference cagraIndexReference; /* * Constructor for building the index using specified dataset */ - private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources resources) throws Throwable { + private CagraIndex(CagraIndexParams indexParameters, CagraCompressionParams cagraCompressionParams, float[][] dataset, + CuVSResources resources) throws Throwable { this.cagraIndexParameters = indexParameters; + this.cagraCompressionParams = cagraCompressionParams; this.dataset = dataset; this.resources = resources; @@ -74,6 +78,7 @@ private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSReso */ private CagraIndex(InputStream inputStream, CuVSResources resources) throws Throwable { this.cagraIndexParameters = null; + this.cagraCompressionParams = null; this.dataset = null; this.resources = resources; @@ -91,7 +96,7 @@ private void initializeMethodHandles() throws IOException { resources.getLibcuvsNativeLibrary().find("build_cagra_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("long"), resources.linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS)); + ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("int"))); searchMethodHandle = resources.linker.downcallHandle( resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), @@ -107,6 +112,16 @@ private void initializeMethodHandles() throws IOException { deserializeMethodHandle = resources.linker.downcallHandle( resources.getLibcuvsNativeLibrary().find("deserialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + destroyIndexMethodHandle = resources.linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("destroy_cagra_index").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + } + + public void destroyIndex() throws Throwable { + MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); + destroyIndexMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), returnValueMemorySegment); } /** @@ -118,15 +133,25 @@ private void initializeMethodHandles() throws IOException { */ private IndexReference build() throws Throwable { long rows = dataset.length; - long cols = dataset[0].length; + long cols = rows > 0 ? dataset[0].length : 0; + MemoryLayout layout = resources.linker.canonicalLayouts().get("int"); MemorySegment segment = resources.arena.allocate(layout); - cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( + MemorySegment indexParamsMemorySegment = cagraIndexParameters != null ? cagraIndexParameters.getMemorySegment() + : MemorySegment.NULL; + + int numWriterThreads = cagraIndexParameters != null ? cagraIndexParameters.getNumWriterThreads() : 1; + + MemorySegment compressionParamsMemorySegment = cagraCompressionParams != null + ? cagraCompressionParams.getMemorySegment() + : MemorySegment.NULL; + + IndexReference indexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( Util.buildMemorySegment(resources.linker, resources.arena, dataset), rows, cols, resources.getMemorySegment(), - segment, cagraIndexParameters.getMemorySegment())); + segment, indexParamsMemorySegment, compressionParamsMemorySegment, numWriterThreads)); - return cagraIndexReference; + return indexReference; } /** @@ -251,6 +276,7 @@ public static class Builder { private float[][] dataset; private CagraIndexParams cagraIndexParams; + private CagraCompressionParams cagraCompressionParams; private CuVSResources cuvsResources; private InputStream inputStream; @@ -298,6 +324,18 @@ public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { return this; } + /** + * Registers an instance of configured {@link CagraCompressionParams} with this + * Builder. + * + * @param cagraCompressionParams An instance of CagraCompressionParams. + * @return An instance of this Builder. + */ + public Builder withCompressionParams(CagraCompressionParams cagraCompressionParams) { + this.cagraCompressionParams = cagraCompressionParams; + return this; + } + /** * Builds and returns an instance of CagraIndex. * @@ -307,7 +345,7 @@ public CagraIndex build() throws Throwable { if (inputStream != null) { return new CagraIndex(inputStream, cuvsResources); } else { - return new CagraIndex(cagraIndexParams, dataset, cuvsResources); + return new CagraIndex(cagraIndexParams, cagraCompressionParams, dataset, cuvsResources); } } } 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 e2ecf513e..66eb235e2 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 @@ -23,7 +23,7 @@ /** * Supplemental parameters to build CAGRA Index. * - * @since 24.12 + * @since 25.02 */ public class CagraIndexParams { @@ -75,12 +75,12 @@ private CagraIndexParams(CuVSResources resources, int intermediateGraphDegree, i } private MemorySegment initMemorySegment() { - MemorySegment memorySegment = CuVSCagraIndexParams.allocate(resources.arena); - CuVSCagraIndexParams.intermediate_graph_degree(memorySegment, intermediateGraphDegree); - CuVSCagraIndexParams.graph_degree(memorySegment, graphDegree); - CuVSCagraIndexParams.build_algo(memorySegment, cuvsCagraGraphBuildAlgo.value); - CuVSCagraIndexParams.nn_descent_niter(memorySegment, nnDescentNiter); - return memorySegment; + MemorySegment indexParamsMemorySegment = CuVSCagraIndexParams.allocate(resources.arena); + CuVSCagraIndexParams.intermediate_graph_degree(indexParamsMemorySegment, intermediateGraphDegree); + CuVSCagraIndexParams.graph_degree(indexParamsMemorySegment, graphDegree); + CuVSCagraIndexParams.build_algo(indexParamsMemorySegment, cuvsCagraGraphBuildAlgo.value); + CuVSCagraIndexParams.nn_descent_niter(indexParamsMemorySegment, nnDescentNiter); + return indexParamsMemorySegment; } /** diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java index 85e31f08a..77cbf33f3 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java @@ -23,7 +23,7 @@ * CagraQuery holds the CagraSearchParams and the query vectors to be used while * invoking search. * - * @since 24.12 + * @since 25.02 */ public class CagraQuery { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java index 8ea4287b6..d7de498c9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java @@ -18,13 +18,13 @@ import java.lang.foreign.MemorySegment; -import com.nvidia.cuvs.panama.cuvsCagraSearchParams; +import com.nvidia.cuvs.panama.CuvsCagraSearchParams; /** * CagraSearchParams encapsulates the logic for configuring and holding search * parameters. * - * @since 24.12 + * @since 25.02 */ public class CagraSearchParams { @@ -152,20 +152,24 @@ private CagraSearchParams(CuVSResources resources, int maxQueries, int iTopKSize * Allocates the configured search parameters in the MemorySegment. */ private MemorySegment allocateMemorySegment() { - MemorySegment memorySegment = cuvsCagraSearchParams.allocate(resources.arena); - cuvsCagraSearchParams.max_queries(memorySegment, maxQueries); - cuvsCagraSearchParams.itopk_size(memorySegment, iTopKSize); - cuvsCagraSearchParams.max_iterations(memorySegment, maxIterations); - cuvsCagraSearchParams.algo(memorySegment, searchAlgo.value); - cuvsCagraSearchParams.team_size(memorySegment, teamSize); - cuvsCagraSearchParams.search_width(memorySegment, searchWidth); - cuvsCagraSearchParams.min_iterations(memorySegment, minIterations); - cuvsCagraSearchParams.thread_block_size(memorySegment, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(memorySegment, hashMapMode.value); - cuvsCagraSearchParams.hashmap_min_bitlen(memorySegment, hashmapMinBitlen); - cuvsCagraSearchParams.hashmap_max_fill_rate(memorySegment, hashMapMaxFillRate); - cuvsCagraSearchParams.num_random_samplings(memorySegment, numRandomSamplings); - cuvsCagraSearchParams.rand_xor_mask(memorySegment, randXORMask); + MemorySegment memorySegment = CuvsCagraSearchParams.allocate(resources.arena); + CuvsCagraSearchParams.max_queries(memorySegment, maxQueries); + CuvsCagraSearchParams.itopk_size(memorySegment, iTopKSize); + CuvsCagraSearchParams.max_iterations(memorySegment, maxIterations); + if (searchAlgo != null) { + CuvsCagraSearchParams.algo(memorySegment, searchAlgo.value); + } + CuvsCagraSearchParams.team_size(memorySegment, teamSize); + CuvsCagraSearchParams.search_width(memorySegment, searchWidth); + CuvsCagraSearchParams.min_iterations(memorySegment, minIterations); + CuvsCagraSearchParams.thread_block_size(memorySegment, threadBlockSize); + if (hashMapMode != null) { + CuvsCagraSearchParams.hashmap_mode(memorySegment, hashMapMode.value); + } + CuvsCagraSearchParams.hashmap_min_bitlen(memorySegment, hashmapMinBitlen); + CuvsCagraSearchParams.hashmap_max_fill_rate(memorySegment, hashMapMaxFillRate); + CuvsCagraSearchParams.num_random_samplings(memorySegment, numRandomSamplings); + CuvsCagraSearchParams.rand_xor_mask(memorySegment, randXORMask); return memorySegment; } @@ -312,19 +316,19 @@ public String toString() { public static class Builder { private CuVSResources resources; - private int maxQueries = 1; - private int iTopKSize = 2; - private int maxIterations = 3; - private int teamSize = 4; - private int searchWidth = 5; - private int minIterations = 6; - private int threadBlockSize = 7; - private int hashMapMinBitlen = 8; - private int numRandomSamplings = 10; - private float hashMapMaxFillRate = 9.0f; - private long randXORMask = 11L; - private SearchAlgo searchAlgo = SearchAlgo.MULTI_KERNEL; - private HashMapMode hashMapMode = HashMapMode.AUTO_HASH; + private int maxQueries; + private int iTopKSize = 64; + private int maxIterations; + private int teamSize; + private int searchWidth = 1; + private int minIterations; + private int threadBlockSize; + private int hashMapMinBitlen; + private int numRandomSamplings = 1; + private float hashMapMaxFillRate = 0.5f; + private long randXORMask = 0x128394; + private SearchAlgo searchAlgo; + private HashMapMode hashMapMode; /** * Constructs this Builder with an instance of Arena. diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java index c601a8539..f4326fde3 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java @@ -30,7 +30,7 @@ /** * SearchResult encapsulates the logic for reading and holding search results. * - * @since 24.12 + * @since 25.02 */ public class CagraSearchResults implements SearchResults { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java index 5020c0b6d..60f68981b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java @@ -31,16 +31,18 @@ /** * Used for allocating resources for cuVS * - * @since 24.12 + * @since 25.02 */ -public class CuVSResources { +public class CuVSResources implements AutoCloseable { public final Arena arena; public final Linker linker; public final SymbolLookup libcuvsNativeLibrary; + protected File nativeLibrary; - private final MethodHandle createResourceMethodHandle; - private final MemorySegment memorySegment; + private final MethodHandle createResourcesMethodHandle; + private final MethodHandle destroyResourcesMethodHandle; + private MemorySegment resourcesMemorySegment; /** * Constructor that allocates the resources needed for cuVS @@ -50,17 +52,38 @@ public class CuVSResources { public CuVSResources() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofShared(); - - File nativeLibrary = Util.loadLibraryFromJar("/libcuvs_java.so"); + nativeLibrary = Util.loadLibraryFromJar("/libcuvs_java.so"); libcuvsNativeLibrary = SymbolLookup.libraryLookup(nativeLibrary.getAbsolutePath(), arena); - createResourceMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("create_resource").get(), + createResourcesMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("create_resources").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + destroyResourcesMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("destroy_resources").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + createResources(); + } + + /** + * Creates the resources used internally and returns its reference. + * + * @throws Throwable exception thrown when native function is invoked + */ + public void createResources() throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); + resourcesMemorySegment = (MemorySegment) createResourcesMethodHandle.invokeExact(returnValueMemorySegment); + } - memorySegment = (MemorySegment) createResourceMethodHandle.invokeExact(returnValueMemorySegment); + @Override + public void close() { + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); + try { + destroyResourcesMethodHandle.invokeExact(resourcesMemorySegment, returnValueMemorySegment); + } catch (Throwable e) { + e.printStackTrace(); + } + nativeLibrary.delete(); } /** @@ -69,7 +92,7 @@ public CuVSResources() throws Throwable { * @return cuvsResources MemorySegment */ protected MemorySegment getMemorySegment() { - return memorySegment; + return resourcesMemorySegment; } /** diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java index f24be1fd5..72d30e9bb 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java @@ -18,6 +18,7 @@ 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; @@ -28,254 +29,284 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct cuvsCagraIndexParams { - * size_t intermediate_graph_degree; - * size_t graph_degree; + * long intermediate_graph_degree; + * long graph_degree; * enum cuvsCagraGraphBuildAlgo build_algo; - * size_t nn_descent_niter; + * long nn_descent_niter; + * cuvsCagraCompressionParams_t compression; * } * } */ public class CuVSCagraIndexParams { - CuVSCagraIndexParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - cagra_h.C_LONG.withName("intermediate_graph_degree"), - cagra_h.C_LONG.withName("graph_degree"), - cagra_h.C_INT.withName("build_algo"), - MemoryLayout.paddingLayout(4), - cagra_h.C_LONG.withName("nn_descent_niter") - ).withName("cuvsCagraIndexParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong intermediate_graph_degree$LAYOUT = (OfLong)$LAYOUT.select(groupElement("intermediate_graph_degree")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t intermediate_graph_degree - * } - */ - public static final OfLong intermediate_graph_degree$layout() { - return intermediate_graph_degree$LAYOUT; - } - - private static final long intermediate_graph_degree$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t intermediate_graph_degree - * } - */ - public static final long intermediate_graph_degree$offset() { - return intermediate_graph_degree$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t intermediate_graph_degree - * } - */ - public static long intermediate_graph_degree(MemorySegment struct) { - return struct.get(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t intermediate_graph_degree - * } - */ - public static void intermediate_graph_degree(MemorySegment struct, long fieldValue) { - struct.set(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET, fieldValue); - } - - private static final OfLong graph_degree$LAYOUT = (OfLong)$LAYOUT.select(groupElement("graph_degree")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t graph_degree - * } - */ - public static final OfLong graph_degree$layout() { - return graph_degree$LAYOUT; - } - - private static final long graph_degree$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t graph_degree - * } - */ - public static final long graph_degree$offset() { - return graph_degree$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t graph_degree - * } - */ - public static long graph_degree(MemorySegment struct) { - return struct.get(graph_degree$LAYOUT, graph_degree$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t graph_degree - * } - */ - public static void graph_degree(MemorySegment struct, long fieldValue) { - struct.set(graph_degree$LAYOUT, graph_degree$OFFSET, fieldValue); - } - - private static final OfInt build_algo$LAYOUT = (OfInt)$LAYOUT.select(groupElement("build_algo")); - - /** - * Layout for field: - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static final OfInt build_algo$layout() { - return build_algo$LAYOUT; - } - - private static final long build_algo$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static final long build_algo$offset() { - return build_algo$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static int build_algo(MemorySegment struct) { - return struct.get(build_algo$LAYOUT, build_algo$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static void build_algo(MemorySegment struct, int fieldValue) { - struct.set(build_algo$LAYOUT, build_algo$OFFSET, fieldValue); - } - - private static final OfLong nn_descent_niter$LAYOUT = (OfLong)$LAYOUT.select(groupElement("nn_descent_niter")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t nn_descent_niter - * } - */ - public static final OfLong nn_descent_niter$layout() { - return nn_descent_niter$LAYOUT; - } - - private static final long nn_descent_niter$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t nn_descent_niter - * } - */ - public static final long nn_descent_niter$offset() { - return nn_descent_niter$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t nn_descent_niter - * } - */ - public static long nn_descent_niter(MemorySegment struct) { - return struct.get(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t nn_descent_niter - * } - */ - public static void nn_descent_niter(MemorySegment struct, long fieldValue) { - struct.set(nn_descent_niter$LAYOUT, nn_descent_niter$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); - } + CuVSCagraIndexParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(cagra_h.C_LONG.withName("intermediate_graph_degree"), cagra_h.C_LONG.withName("graph_degree"), + cagra_h.C_INT.withName("build_algo"), MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("nn_descent_niter"), cagra_h.C_POINTER.withName("compression")) + .withName("cuvsCagraIndexParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong intermediate_graph_degree$LAYOUT = (OfLong) $LAYOUT + .select(groupElement("intermediate_graph_degree")); + + /** + * Layout for field: + * {@snippet lang = c : * long intermediate_graph_degree + * } + */ + public static final OfLong intermediate_graph_degree$layout() { + return intermediate_graph_degree$LAYOUT; + } + + private static final long intermediate_graph_degree$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * long intermediate_graph_degree + * } + */ + public static final long intermediate_graph_degree$offset() { + return intermediate_graph_degree$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long intermediate_graph_degree + * } + */ + public static long intermediate_graph_degree(MemorySegment struct) { + return struct.get(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long intermediate_graph_degree + * } + */ + public static void intermediate_graph_degree(MemorySegment struct, long fieldValue) { + struct.set(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET, fieldValue); + } + + private static final OfLong graph_degree$LAYOUT = (OfLong) $LAYOUT.select(groupElement("graph_degree")); + + /** + * Layout for field: + * {@snippet lang = c : * long graph_degree + * } + */ + public static final OfLong graph_degree$layout() { + return graph_degree$LAYOUT; + } + + private static final long graph_degree$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * long graph_degree + * } + */ + public static final long graph_degree$offset() { + return graph_degree$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long graph_degree + * } + */ + public static long graph_degree(MemorySegment struct) { + return struct.get(graph_degree$LAYOUT, graph_degree$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long graph_degree + * } + */ + public static void graph_degree(MemorySegment struct, long fieldValue) { + struct.set(graph_degree$LAYOUT, graph_degree$OFFSET, fieldValue); + } + + private static final OfInt build_algo$LAYOUT = (OfInt) $LAYOUT.select(groupElement("build_algo")); + + /** + * Layout for field: + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static final OfInt build_algo$layout() { + return build_algo$LAYOUT; + } + + private static final long build_algo$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static final long build_algo$offset() { + return build_algo$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static int build_algo(MemorySegment struct) { + return struct.get(build_algo$LAYOUT, build_algo$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static void build_algo(MemorySegment struct, int fieldValue) { + struct.set(build_algo$LAYOUT, build_algo$OFFSET, fieldValue); + } + + private static final OfLong nn_descent_niter$LAYOUT = (OfLong) $LAYOUT.select(groupElement("nn_descent_niter")); + + /** + * Layout for field: + * {@snippet lang = c : * long nn_descent_niter + * } + */ + public static final OfLong nn_descent_niter$layout() { + return nn_descent_niter$LAYOUT; + } + + private static final long nn_descent_niter$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang = c : * long nn_descent_niter + * } + */ + public static final long nn_descent_niter$offset() { + return nn_descent_niter$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long nn_descent_niter + * } + */ + public static long nn_descent_niter(MemorySegment struct) { + return struct.get(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long nn_descent_niter + * } + */ + public static void nn_descent_niter(MemorySegment struct, long fieldValue) { + struct.set(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET, fieldValue); + } + + private static final AddressLayout compression$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("compression")); + + /** + * Layout for field: + * {@snippet lang = c : * cuvsCagraCompressionParams_t compression + * } + */ + public static final AddressLayout compression$layout() { + return compression$LAYOUT; + } + + private static final long compression$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang = c : * cuvsCagraCompressionParams_t compression + * } + */ + public static final long compression$offset() { + return compression$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * cuvsCagraCompressionParams_t compression + * } + */ + public static MemorySegment compression(MemorySegment struct) { + return struct.get(compression$LAYOUT, compression$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * cuvsCagraCompressionParams_t compression + * } + */ + public static void compression(MemorySegment struct, MemorySegment fieldValue) { + struct.set(compression$LAYOUT, compression$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } } - diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraCompressionParams.java new file mode 100644 index 000000000..8ee3e7568 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraCompressionParams.java @@ -0,0 +1,352 @@ +/* + * Copyright (c) 2024, 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.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfDouble; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct cuvsCagraCompressionParams { + * uint32_t pq_bits; + * uint32_t pq_dim; + * uint32_t vq_n_centers; + * uint32_t kmeans_n_iters; + * double vq_kmeans_trainset_fraction; + * double pq_kmeans_trainset_fraction; + * } + * } + */ +public class CuvsCagraCompressionParams { + + CuvsCagraCompressionParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(cagra_h.C_INT.withName("pq_bits"), + cagra_h.C_INT.withName("pq_dim"), cagra_h.C_INT.withName("vq_n_centers"), + cagra_h.C_INT.withName("kmeans_n_iters"), cagra_h.C_DOUBLE.withName("vq_kmeans_trainset_fraction"), + cagra_h.C_DOUBLE.withName("pq_kmeans_trainset_fraction")).withName("cuvsCagraCompressionParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt pq_bits$LAYOUT = (OfInt) $LAYOUT.select(groupElement("pq_bits")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t pq_bits + * } + */ + public static final OfInt pq_bits$layout() { + return pq_bits$LAYOUT; + } + + private static final long pq_bits$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t pq_bits + * } + */ + public static final long pq_bits$offset() { + return pq_bits$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t pq_bits + * } + */ + public static int pq_bits(MemorySegment struct) { + return struct.get(pq_bits$LAYOUT, pq_bits$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t pq_bits + * } + */ + public static void pq_bits(MemorySegment struct, int fieldValue) { + struct.set(pq_bits$LAYOUT, pq_bits$OFFSET, fieldValue); + } + + private static final OfInt pq_dim$LAYOUT = (OfInt) $LAYOUT.select(groupElement("pq_dim")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t pq_dim + * } + */ + public static final OfInt pq_dim$layout() { + return pq_dim$LAYOUT; + } + + private static final long pq_dim$OFFSET = 4; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t pq_dim + * } + */ + public static final long pq_dim$offset() { + return pq_dim$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t pq_dim + * } + */ + public static int pq_dim(MemorySegment struct) { + return struct.get(pq_dim$LAYOUT, pq_dim$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t pq_dim + * } + */ + public static void pq_dim(MemorySegment struct, int fieldValue) { + struct.set(pq_dim$LAYOUT, pq_dim$OFFSET, fieldValue); + } + + private static final OfInt vq_n_centers$LAYOUT = (OfInt) $LAYOUT.select(groupElement("vq_n_centers")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t vq_n_centers + * } + */ + public static final OfInt vq_n_centers$layout() { + return vq_n_centers$LAYOUT; + } + + private static final long vq_n_centers$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t vq_n_centers + * } + */ + public static final long vq_n_centers$offset() { + return vq_n_centers$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t vq_n_centers + * } + */ + public static int vq_n_centers(MemorySegment struct) { + return struct.get(vq_n_centers$LAYOUT, vq_n_centers$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t vq_n_centers + * } + */ + public static void vq_n_centers(MemorySegment struct, int fieldValue) { + struct.set(vq_n_centers$LAYOUT, vq_n_centers$OFFSET, fieldValue); + } + + private static final OfInt kmeans_n_iters$LAYOUT = (OfInt) $LAYOUT.select(groupElement("kmeans_n_iters")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t kmeans_n_iters + * } + */ + public static final OfInt kmeans_n_iters$layout() { + return kmeans_n_iters$LAYOUT; + } + + private static final long kmeans_n_iters$OFFSET = 12; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t kmeans_n_iters + * } + */ + public static final long kmeans_n_iters$offset() { + return kmeans_n_iters$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t kmeans_n_iters + * } + */ + public static int kmeans_n_iters(MemorySegment struct) { + return struct.get(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t kmeans_n_iters + * } + */ + public static void kmeans_n_iters(MemorySegment struct, int fieldValue) { + struct.set(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET, fieldValue); + } + + private static final OfDouble vq_kmeans_trainset_fraction$LAYOUT = (OfDouble) $LAYOUT + .select(groupElement("vq_kmeans_trainset_fraction")); + + /** + * Layout for field: + * {@snippet lang = c : * double vq_kmeans_trainset_fraction + * } + */ + public static final OfDouble vq_kmeans_trainset_fraction$layout() { + return vq_kmeans_trainset_fraction$LAYOUT; + } + + private static final long vq_kmeans_trainset_fraction$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * double vq_kmeans_trainset_fraction + * } + */ + public static final long vq_kmeans_trainset_fraction$offset() { + return vq_kmeans_trainset_fraction$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * double vq_kmeans_trainset_fraction + * } + */ + public static double vq_kmeans_trainset_fraction(MemorySegment struct) { + return struct.get(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * double vq_kmeans_trainset_fraction + * } + */ + public static void vq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { + struct.set(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET, fieldValue); + } + + private static final OfDouble pq_kmeans_trainset_fraction$LAYOUT = (OfDouble) $LAYOUT + .select(groupElement("pq_kmeans_trainset_fraction")); + + /** + * Layout for field: + * {@snippet lang = c : * double pq_kmeans_trainset_fraction + * } + */ + public static final OfDouble pq_kmeans_trainset_fraction$layout() { + return pq_kmeans_trainset_fraction$LAYOUT; + } + + private static final long pq_kmeans_trainset_fraction$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang = c : * double pq_kmeans_trainset_fraction + * } + */ + public static final long pq_kmeans_trainset_fraction$offset() { + return pq_kmeans_trainset_fraction$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * double pq_kmeans_trainset_fraction + * } + */ + public static double pq_kmeans_trainset_fraction(MemorySegment struct) { + return struct.get(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * double pq_kmeans_trainset_fraction + * } + */ + public static void pq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { + struct.set(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraSearchParams.java new file mode 100644 index 000000000..b54b91b5b --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraSearchParams.java @@ -0,0 +1,644 @@ +/* + * Copyright (c) 2024, 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.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfFloat; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct cuvsCagraSearchParams { + * long max_queries; + * long itopk_size; + * long max_iterations; + * enum cuvsCagraSearchAlgo algo; + * long team_size; + * long search_width; + * long min_iterations; + * long thread_block_size; + * enum cuvsCagraHashMode hashmap_mode; + * long hashmap_min_bitlen; + * float hashmap_max_fill_rate; + * uint32_t num_random_samplings; + * uint64_t rand_xor_mask; + * } + * } + */ +public class CuvsCagraSearchParams { + + CuvsCagraSearchParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(cagra_h.C_LONG.withName("max_queries"), cagra_h.C_LONG.withName("itopk_size"), + cagra_h.C_LONG.withName("max_iterations"), cagra_h.C_INT.withName("algo"), MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("team_size"), cagra_h.C_LONG.withName("search_width"), + cagra_h.C_LONG.withName("min_iterations"), cagra_h.C_LONG.withName("thread_block_size"), + cagra_h.C_INT.withName("hashmap_mode"), MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("hashmap_min_bitlen"), cagra_h.C_FLOAT.withName("hashmap_max_fill_rate"), + cagra_h.C_INT.withName("num_random_samplings"), cagra_h.C_LONG.withName("rand_xor_mask")) + .withName("cuvsCagraSearchParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong max_queries$LAYOUT = (OfLong) $LAYOUT.select(groupElement("max_queries")); + + /** + * Layout for field: + * {@snippet lang = c : * long max_queries + * } + */ + public static final OfLong max_queries$layout() { + return max_queries$LAYOUT; + } + + private static final long max_queries$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * long max_queries + * } + */ + public static final long max_queries$offset() { + return max_queries$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long max_queries + * } + */ + public static long max_queries(MemorySegment struct) { + return struct.get(max_queries$LAYOUT, max_queries$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long max_queries + * } + */ + public static void max_queries(MemorySegment struct, long fieldValue) { + struct.set(max_queries$LAYOUT, max_queries$OFFSET, fieldValue); + } + + private static final OfLong itopk_size$LAYOUT = (OfLong) $LAYOUT.select(groupElement("itopk_size")); + + /** + * Layout for field: + * {@snippet lang = c : * long itopk_size + * } + */ + public static final OfLong itopk_size$layout() { + return itopk_size$LAYOUT; + } + + private static final long itopk_size$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * long itopk_size + * } + */ + public static final long itopk_size$offset() { + return itopk_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long itopk_size + * } + */ + public static long itopk_size(MemorySegment struct) { + return struct.get(itopk_size$LAYOUT, itopk_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long itopk_size + * } + */ + public static void itopk_size(MemorySegment struct, long fieldValue) { + struct.set(itopk_size$LAYOUT, itopk_size$OFFSET, fieldValue); + } + + private static final OfLong max_iterations$LAYOUT = (OfLong) $LAYOUT.select(groupElement("max_iterations")); + + /** + * Layout for field: + * {@snippet lang = c : * long max_iterations + * } + */ + public static final OfLong max_iterations$layout() { + return max_iterations$LAYOUT; + } + + private static final long max_iterations$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * long max_iterations + * } + */ + public static final long max_iterations$offset() { + return max_iterations$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long max_iterations + * } + */ + public static long max_iterations(MemorySegment struct) { + return struct.get(max_iterations$LAYOUT, max_iterations$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long max_iterations + * } + */ + public static void max_iterations(MemorySegment struct, long fieldValue) { + struct.set(max_iterations$LAYOUT, max_iterations$OFFSET, fieldValue); + } + + private static final OfInt algo$LAYOUT = (OfInt) $LAYOUT.select(groupElement("algo")); + + /** + * Layout for field: + * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo + * } + */ + public static final OfInt algo$layout() { + return algo$LAYOUT; + } + + private static final long algo$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo + * } + */ + public static final long algo$offset() { + return algo$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo + * } + */ + public static int algo(MemorySegment struct) { + return struct.get(algo$LAYOUT, algo$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo + * } + */ + public static void algo(MemorySegment struct, int fieldValue) { + struct.set(algo$LAYOUT, algo$OFFSET, fieldValue); + } + + private static final OfLong team_size$LAYOUT = (OfLong) $LAYOUT.select(groupElement("team_size")); + + /** + * Layout for field: + * {@snippet lang = c : * long team_size + * } + */ + public static final OfLong team_size$layout() { + return team_size$LAYOUT; + } + + private static final long team_size$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang = c : * long team_size + * } + */ + public static final long team_size$offset() { + return team_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long team_size + * } + */ + public static long team_size(MemorySegment struct) { + return struct.get(team_size$LAYOUT, team_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long team_size + * } + */ + public static void team_size(MemorySegment struct, long fieldValue) { + struct.set(team_size$LAYOUT, team_size$OFFSET, fieldValue); + } + + private static final OfLong search_width$LAYOUT = (OfLong) $LAYOUT.select(groupElement("search_width")); + + /** + * Layout for field: + * {@snippet lang = c : * long search_width + * } + */ + public static final OfLong search_width$layout() { + return search_width$LAYOUT; + } + + private static final long search_width$OFFSET = 40; + + /** + * Offset for field: + * {@snippet lang = c : * long search_width + * } + */ + public static final long search_width$offset() { + return search_width$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long search_width + * } + */ + public static long search_width(MemorySegment struct) { + return struct.get(search_width$LAYOUT, search_width$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long search_width + * } + */ + public static void search_width(MemorySegment struct, long fieldValue) { + struct.set(search_width$LAYOUT, search_width$OFFSET, fieldValue); + } + + private static final OfLong min_iterations$LAYOUT = (OfLong) $LAYOUT.select(groupElement("min_iterations")); + + /** + * Layout for field: + * {@snippet lang = c : * long min_iterations + * } + */ + public static final OfLong min_iterations$layout() { + return min_iterations$LAYOUT; + } + + private static final long min_iterations$OFFSET = 48; + + /** + * Offset for field: + * {@snippet lang = c : * long min_iterations + * } + */ + public static final long min_iterations$offset() { + return min_iterations$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long min_iterations + * } + */ + public static long min_iterations(MemorySegment struct) { + return struct.get(min_iterations$LAYOUT, min_iterations$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long min_iterations + * } + */ + public static void min_iterations(MemorySegment struct, long fieldValue) { + struct.set(min_iterations$LAYOUT, min_iterations$OFFSET, fieldValue); + } + + private static final OfLong thread_block_size$LAYOUT = (OfLong) $LAYOUT.select(groupElement("thread_block_size")); + + /** + * Layout for field: + * {@snippet lang = c : * long thread_block_size + * } + */ + public static final OfLong thread_block_size$layout() { + return thread_block_size$LAYOUT; + } + + private static final long thread_block_size$OFFSET = 56; + + /** + * Offset for field: + * {@snippet lang = c : * long thread_block_size + * } + */ + public static final long thread_block_size$offset() { + return thread_block_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long thread_block_size + * } + */ + public static long thread_block_size(MemorySegment struct) { + return struct.get(thread_block_size$LAYOUT, thread_block_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long thread_block_size + * } + */ + public static void thread_block_size(MemorySegment struct, long fieldValue) { + struct.set(thread_block_size$LAYOUT, thread_block_size$OFFSET, fieldValue); + } + + private static final OfInt hashmap_mode$LAYOUT = (OfInt) $LAYOUT.select(groupElement("hashmap_mode")); + + /** + * Layout for field: + * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static final OfInt hashmap_mode$layout() { + return hashmap_mode$LAYOUT; + } + + private static final long hashmap_mode$OFFSET = 64; + + /** + * Offset for field: + * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static final long hashmap_mode$offset() { + return hashmap_mode$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static int hashmap_mode(MemorySegment struct) { + return struct.get(hashmap_mode$LAYOUT, hashmap_mode$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static void hashmap_mode(MemorySegment struct, int fieldValue) { + struct.set(hashmap_mode$LAYOUT, hashmap_mode$OFFSET, fieldValue); + } + + private static final OfLong hashmap_min_bitlen$LAYOUT = (OfLong) $LAYOUT.select(groupElement("hashmap_min_bitlen")); + + /** + * Layout for field: + * {@snippet lang = c : * long hashmap_min_bitlen + * } + */ + public static final OfLong hashmap_min_bitlen$layout() { + return hashmap_min_bitlen$LAYOUT; + } + + private static final long hashmap_min_bitlen$OFFSET = 72; + + /** + * Offset for field: + * {@snippet lang = c : * long hashmap_min_bitlen + * } + */ + public static final long hashmap_min_bitlen$offset() { + return hashmap_min_bitlen$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long hashmap_min_bitlen + * } + */ + public static long hashmap_min_bitlen(MemorySegment struct) { + return struct.get(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long hashmap_min_bitlen + * } + */ + public static void hashmap_min_bitlen(MemorySegment struct, long fieldValue) { + struct.set(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET, fieldValue); + } + + private static final OfFloat hashmap_max_fill_rate$LAYOUT = (OfFloat) $LAYOUT + .select(groupElement("hashmap_max_fill_rate")); + + /** + * Layout for field: + * {@snippet lang = c : * float hashmap_max_fill_rate + * } + */ + public static final OfFloat hashmap_max_fill_rate$layout() { + return hashmap_max_fill_rate$LAYOUT; + } + + private static final long hashmap_max_fill_rate$OFFSET = 80; + + /** + * Offset for field: + * {@snippet lang = c : * float hashmap_max_fill_rate + * } + */ + public static final long hashmap_max_fill_rate$offset() { + return hashmap_max_fill_rate$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * float hashmap_max_fill_rate + * } + */ + public static float hashmap_max_fill_rate(MemorySegment struct) { + return struct.get(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * float hashmap_max_fill_rate + * } + */ + public static void hashmap_max_fill_rate(MemorySegment struct, float fieldValue) { + struct.set(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET, fieldValue); + } + + private static final OfInt num_random_samplings$LAYOUT = (OfInt) $LAYOUT.select(groupElement("num_random_samplings")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t num_random_samplings + * } + */ + public static final OfInt num_random_samplings$layout() { + return num_random_samplings$LAYOUT; + } + + private static final long num_random_samplings$OFFSET = 84; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t num_random_samplings + * } + */ + public static final long num_random_samplings$offset() { + return num_random_samplings$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t num_random_samplings + * } + */ + public static int num_random_samplings(MemorySegment struct) { + return struct.get(num_random_samplings$LAYOUT, num_random_samplings$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t num_random_samplings + * } + */ + public static void num_random_samplings(MemorySegment struct, int fieldValue) { + struct.set(num_random_samplings$LAYOUT, num_random_samplings$OFFSET, fieldValue); + } + + private static final OfLong rand_xor_mask$LAYOUT = (OfLong) $LAYOUT.select(groupElement("rand_xor_mask")); + + /** + * Layout for field: + * {@snippet lang = c : * uint64_t rand_xor_mask + * } + */ + public static final OfLong rand_xor_mask$layout() { + return rand_xor_mask$LAYOUT; + } + + private static final long rand_xor_mask$OFFSET = 88; + + /** + * Offset for field: + * {@snippet lang = c : * uint64_t rand_xor_mask + * } + */ + public static final long rand_xor_mask$offset() { + return rand_xor_mask$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint64_t rand_xor_mask + * } + */ + public static long rand_xor_mask(MemorySegment struct) { + return struct.get(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint64_t rand_xor_mask + * } + */ + public static void rand_xor_mask(MemorySegment struct, long fieldValue) { + struct.set(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java index 52ebe83ec..66e8dd760 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java @@ -42,7 +42,7 @@ public class __fsid_t { } private static final GroupLayout $LAYOUT = MemoryLayout - .structLayout(MemoryLayout.sequenceLayout(2, dlpack_h.C_INT).withName("__val")).withName("$anon$155:12"); + .structLayout(MemoryLayout.sequenceLayout(2, cagra_h.C_INT).withName("__val")).withName("$anon$155:12"); /** * The layout of this struct diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java index a037e2c17..f01afbfbd 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java @@ -41,2027 +41,2028 @@ public class cagra_h { - cagra_h() { - // Should not be called directly - } + cagra_h() { + // 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; - } - private static final int true_ = (int)1L; - /** - * {@snippet lang=c : - * #define true 1 - * } - */ - public static int true_() { - return true_; - } - private static final int false_ = (int)0L; - /** - * {@snippet lang=c : - * #define false 0 - * } - */ - public static int false_() { - return false_; - } - private static final int __bool_true_false_are_defined = (int)1L; - /** - * {@snippet lang=c : - * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = cagra_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = cagra_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = cagra_h.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - private static final int AUTO_SELECT = (int)0L; - /** - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 - * } - */ - public static int AUTO_SELECT() { - return AUTO_SELECT; - } - private static final int IVF_PQ = (int)1L; - /** - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 - * } - */ - public static int IVF_PQ() { - return IVF_PQ; - } - private static final int NN_DESCENT = (int)2L; - /** - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 - * } - */ - public static int NN_DESCENT() { - return NN_DESCENT; - } - /** - * {@snippet lang=c : - * typedef struct cuvsCagraCompressionParams { - * uint32_t pq_bits; - * uint32_t pq_dim; - * uint32_t vq_n_centers; - * uint32_t kmeans_n_iters; - * double vq_kmeans_trainset_fraction; - * double pq_kmeans_trainset_fraction; - * } *cuvsCagraCompressionParams_t - * } - */ - public static final AddressLayout cuvsCagraCompressionParams_t = cagra_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef struct cuvsCagraIndexParams { - * size_t intermediate_graph_degree; - * size_t graph_degree; - * enum cuvsCagraGraphBuildAlgo build_algo; - * size_t nn_descent_niter; - * cuvsCagraCompressionParams_t compression; - * } *cuvsCagraIndexParams_t - * } - */ - public static final AddressLayout cuvsCagraIndexParams_t = cagra_h.C_POINTER; - private static final int SINGLE_CTA = (int)0L; - /** - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo.SINGLE_CTA = 0 - * } - */ - public static int SINGLE_CTA() { - return SINGLE_CTA; - } - private static final int MULTI_CTA = (int)1L; - /** - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo.MULTI_CTA = 1 - * } - */ - public static int MULTI_CTA() { - return MULTI_CTA; - } - private static final int MULTI_KERNEL = (int)2L; - /** - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo.MULTI_KERNEL = 2 - * } - */ - public static int MULTI_KERNEL() { - return MULTI_KERNEL; - } - private static final int AUTO = (int)3L; - /** - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo.AUTO = 3 - * } - */ - public static int AUTO() { - return AUTO; - } - private static final int HASH = (int)0L; - /** - * {@snippet lang=c : - * enum cuvsCagraHashMode.HASH = 0 - * } - */ - public static int HASH() { - return HASH; - } - private static final int SMALL = (int)1L; - /** - * {@snippet lang=c : - * enum cuvsCagraHashMode.SMALL = 1 - * } - */ - public static int SMALL() { - return SMALL; - } - private static final int AUTO_HASH = (int)2L; - /** - * {@snippet lang=c : - * enum cuvsCagraHashMode.AUTO_HASH = 2 - * } - */ - public static int AUTO_HASH() { - return AUTO_HASH; - } - /** - * {@snippet lang=c : - * typedef struct cuvsCagraSearchParams { - * size_t max_queries; - * size_t itopk_size; - * size_t max_iterations; - * enum cuvsCagraSearchAlgo algo; - * size_t team_size; - * size_t search_width; - * size_t min_iterations; - * size_t thread_block_size; - * enum cuvsCagraHashMode hashmap_mode; - * size_t hashmap_min_bitlen; - * float hashmap_max_fill_rate; - * uint32_t num_random_samplings; - * uint64_t rand_xor_mask; - * } *cuvsCagraSearchParams_t - * } - */ - public static final AddressLayout cuvsCagraSearchParams_t = cagra_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef cuvsCagraIndex *cuvsCagraIndex_t - * } - */ - public static final AddressLayout cuvsCagraIndex_t = cagra_h.C_POINTER; - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - 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 true_ = (int) 1L; + + /** + * {@snippet lang = c : * #define true 1 + * } + */ + public static int true_() { + return true_; + } + + private static final int false_ = (int) 0L; + + /** + * {@snippet lang = c : * #define false 0 + * } + */ + public static int false_() { + return false_; + } + + private static final int __bool_true_false_are_defined = (int) 1L; + + /** + * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + + private static final int _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 = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off_t + * } + */ + public static final OfLong __off_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef long __time_t + * } + */ + public static final OfLong __time_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef int __key_t + * } + */ + public static final OfInt __key_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = cagra_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = cagra_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = cagra_h.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; + } + + private static final int AUTO_SELECT = (int) 0L; + + /** + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 + * } + */ + public static int AUTO_SELECT() { + return AUTO_SELECT; + } + + private static final int IVF_PQ = (int) 1L; + + /** + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 + * } + */ + public static int IVF_PQ() { + return IVF_PQ; + } + + private static final int NN_DESCENT = (int) 2L; + + /** + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 + * } + */ + public static int NN_DESCENT() { + return NN_DESCENT; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsCagraCompressionParams { + * uint32_t pq_bits; + * uint32_t pq_dim; + * uint32_t vq_n_centers; + * uint32_t kmeans_n_iters; + * double vq_kmeans_trainset_fraction; + * double pq_kmeans_trainset_fraction; + * } *cuvsCagraCompressionParams_t + * } + */ + public static final AddressLayout cuvsCagraCompressionParams_t = cagra_h.C_POINTER; + /** + * {@snippet lang = c : + * typedef struct cuvsCagraIndexParams { + * unsigned int intermediate_graph_degree; + * unsigned int graph_degree; + * enum cuvsCagraGraphBuildAlgo build_algo; + * unsigned int nn_descent_niter; + * cuvsCagraCompressionParams_t compression; + * } *cuvsCagraIndexParams_t + * } + */ + public static final AddressLayout cuvsCagraIndexParams_t = cagra_h.C_POINTER; + + private static class cuvsCagraIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); + + public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * } + */ + public static FunctionDescriptor cuvsCagraIndexParamsCreate$descriptor() { + return cuvsCagraIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * } + */ + public static MethodHandle cuvsCagraIndexParamsCreate$handle() { + return cuvsCagraIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * } + */ + public static MemorySegment cuvsCagraIndexParamsCreate$address() { + return cuvsCagraIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * } + */ + public static int cuvsCagraIndexParamsCreate(MemorySegment params) { + var mh$ = cuvsCagraIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsCagraIndexParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsCagraIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); + + public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * } + */ + public static FunctionDescriptor cuvsCagraIndexParamsDestroy$descriptor() { + return cuvsCagraIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * } + */ + public static MethodHandle cuvsCagraIndexParamsDestroy$handle() { + return cuvsCagraIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * } + */ + public static MemorySegment cuvsCagraIndexParamsDestroy$address() { + return cuvsCagraIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * } + */ + public static int cuvsCagraIndexParamsDestroy(MemorySegment params) { + var mh$ = cuvsCagraIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsCagraIndexParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsCagraCompressionParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); + + public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraCompressionParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * } + */ + public static FunctionDescriptor cuvsCagraCompressionParamsCreate$descriptor() { + return cuvsCagraCompressionParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * } + */ + public static MethodHandle cuvsCagraCompressionParamsCreate$handle() { + return cuvsCagraCompressionParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * } + */ + public static MemorySegment cuvsCagraCompressionParamsCreate$address() { + return cuvsCagraCompressionParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * } + */ + public static int cuvsCagraCompressionParamsCreate(MemorySegment params) { + var mh$ = cuvsCagraCompressionParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsCagraCompressionParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsCagraCompressionParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); + + public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraCompressionParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * } + */ + public static FunctionDescriptor cuvsCagraCompressionParamsDestroy$descriptor() { + return cuvsCagraCompressionParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * } + */ + public static MethodHandle cuvsCagraCompressionParamsDestroy$handle() { + return cuvsCagraCompressionParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * } + */ + public static MemorySegment cuvsCagraCompressionParamsDestroy$address() { + return cuvsCagraCompressionParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * } + */ + public static int cuvsCagraCompressionParamsDestroy(MemorySegment params) { + var mh$ = cuvsCagraCompressionParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsCagraCompressionParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static final int SINGLE_CTA = (int) 0L; + + /** + * {@snippet lang = c : * enum cuvsCagraSearchAlgo.SINGLE_CTA = 0 + * } + */ + public static int SINGLE_CTA() { + return SINGLE_CTA; + } + + private static final int MULTI_CTA = (int) 1L; + + /** + * {@snippet lang = c : * enum cuvsCagraSearchAlgo.MULTI_CTA = 1 + * } + */ + public static int MULTI_CTA() { + return MULTI_CTA; + } + + private static final int MULTI_KERNEL = (int) 2L; + + /** + * {@snippet lang = c : * enum cuvsCagraSearchAlgo.MULTI_KERNEL = 2 + * } + */ + public static int MULTI_KERNEL() { + return MULTI_KERNEL; + } + + private static final int AUTO = (int) 3L; + + /** + * {@snippet lang = c : * enum cuvsCagraSearchAlgo.AUTO = 3 + * } + */ + public static int AUTO() { + return AUTO; + } + + private static final int HASH = (int) 0L; + + /** + * {@snippet lang = c : * enum cuvsCagraHashMode.HASH = 0 + * } + */ + public static int HASH() { + return HASH; + } + + private static final int SMALL = (int) 1L; + + /** + * {@snippet lang = c : * enum cuvsCagraHashMode.SMALL = 1 + * } + */ + public static int SMALL() { + return SMALL; + } + + private static final int AUTO_HASH = (int) 2L; + + /** + * {@snippet lang = c : * enum cuvsCagraHashMode.AUTO_HASH = 2 + * } + */ + public static int AUTO_HASH() { + return AUTO_HASH; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsCagraSearchParams { + * unsigned int max_queries; + * unsigned int itopk_size; + * unsigned int max_iterations; + * enum cuvsCagraSearchAlgo algo; + * unsigned int team_size; + * unsigned int search_width; + * unsigned int min_iterations; + * unsigned int thread_block_size; + * enum cuvsCagraHashMode hashmap_mode; + * unsigned int hashmap_min_bitlen; + * float hashmap_max_fill_rate; + * uint32_t num_random_samplings; + * uint64_t rand_xor_mask; + * } *cuvsCagraSearchParams_t + * } + */ + public static final AddressLayout cuvsCagraSearchParams_t = cagra_h.C_POINTER; + private static final long _POSIX_C_SOURCE = 200809L; + + /** + * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + + private static final int __TIMESIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + + private static final long __STDC_IEC_60559_BFP__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + + private static final long __STDC_ISO_10646__ = 201706L; + + /** + * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + + private static final int __WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + + private static final int __WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + + private static final int INT8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + + private static final int INT16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + + private static final int INT32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + + private static final long INT64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + + private static final int INT8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + + private static final int INT16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + + private static final int INT32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + + private static final long INT64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + + private static final int UINT8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + + private static final int UINT16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + + private static final int UINT32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + + private static final long UINT64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + + private static final int INT_LEAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + + private static final int INT_LEAST16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + + private static final int INT_LEAST32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + + private static final long INT_LEAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + + private static final int INT_LEAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + + private static final int INT_LEAST16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + + private static final int INT_LEAST32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + + private static final long INT_LEAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + + private static final int UINT_LEAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + + private static final int UINT_LEAST16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + + private static final int UINT_LEAST32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + + private static final long UINT_LEAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + + private static final int INT_FAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + + private static final long INT_FAST16_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + + private static final long INT_FAST32_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + + private static final long INT_FAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + + private static final int INT_FAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + + private static final long INT_FAST16_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + + private static final long INT_FAST32_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + + private static final long INT_FAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + + private static final int UINT_FAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + + private static final long UINT_FAST16_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + + private static final long UINT_FAST32_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + + private static final long UINT_FAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + + private static final long INTPTR_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + + private static final long INTPTR_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + + private static final long UINTPTR_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + + private static final long INTMAX_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + + private static final long INTMAX_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + + private static final long UINTMAX_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + + private static final long PTRDIFF_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + + private static final long PTRDIFF_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + + private static final int SIG_ATOMIC_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + + private static final int SIG_ATOMIC_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + + private static final long SIZE_MAX = -1L; + + /** + * {@snippet lang = c : * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + + private static final int WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + + private static final int WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + + private static final int WINT_MIN = (int) 0L; + + /** + * {@snippet lang = c : * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + + private static final int WINT_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java deleted file mode 100644 index 4bf6f639b..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright (c) 2024, 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.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfDouble; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct cuvsCagraCompressionParams { - * uint32_t pq_bits; - * uint32_t pq_dim; - * uint32_t vq_n_centers; - * uint32_t kmeans_n_iters; - * double vq_kmeans_trainset_fraction; - * double pq_kmeans_trainset_fraction; - * } - * } - */ -public class cuvsCagraCompressionParams { - - cuvsCagraCompressionParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - cagra_h.C_INT.withName("pq_bits"), - cagra_h.C_INT.withName("pq_dim"), - cagra_h.C_INT.withName("vq_n_centers"), - cagra_h.C_INT.withName("kmeans_n_iters"), - cagra_h.C_DOUBLE.withName("vq_kmeans_trainset_fraction"), - cagra_h.C_DOUBLE.withName("pq_kmeans_trainset_fraction") - ).withName("cuvsCagraCompressionParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt pq_bits$LAYOUT = (OfInt)$LAYOUT.select(groupElement("pq_bits")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t pq_bits - * } - */ - public static final OfInt pq_bits$layout() { - return pq_bits$LAYOUT; - } - - private static final long pq_bits$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t pq_bits - * } - */ - public static final long pq_bits$offset() { - return pq_bits$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t pq_bits - * } - */ - public static int pq_bits(MemorySegment struct) { - return struct.get(pq_bits$LAYOUT, pq_bits$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t pq_bits - * } - */ - public static void pq_bits(MemorySegment struct, int fieldValue) { - struct.set(pq_bits$LAYOUT, pq_bits$OFFSET, fieldValue); - } - - private static final OfInt pq_dim$LAYOUT = (OfInt)$LAYOUT.select(groupElement("pq_dim")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t pq_dim - * } - */ - public static final OfInt pq_dim$layout() { - return pq_dim$LAYOUT; - } - - private static final long pq_dim$OFFSET = 4; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t pq_dim - * } - */ - public static final long pq_dim$offset() { - return pq_dim$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t pq_dim - * } - */ - public static int pq_dim(MemorySegment struct) { - return struct.get(pq_dim$LAYOUT, pq_dim$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t pq_dim - * } - */ - public static void pq_dim(MemorySegment struct, int fieldValue) { - struct.set(pq_dim$LAYOUT, pq_dim$OFFSET, fieldValue); - } - - private static final OfInt vq_n_centers$LAYOUT = (OfInt)$LAYOUT.select(groupElement("vq_n_centers")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t vq_n_centers - * } - */ - public static final OfInt vq_n_centers$layout() { - return vq_n_centers$LAYOUT; - } - - private static final long vq_n_centers$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t vq_n_centers - * } - */ - public static final long vq_n_centers$offset() { - return vq_n_centers$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t vq_n_centers - * } - */ - public static int vq_n_centers(MemorySegment struct) { - return struct.get(vq_n_centers$LAYOUT, vq_n_centers$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t vq_n_centers - * } - */ - public static void vq_n_centers(MemorySegment struct, int fieldValue) { - struct.set(vq_n_centers$LAYOUT, vq_n_centers$OFFSET, fieldValue); - } - - private static final OfInt kmeans_n_iters$LAYOUT = (OfInt)$LAYOUT.select(groupElement("kmeans_n_iters")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t kmeans_n_iters - * } - */ - public static final OfInt kmeans_n_iters$layout() { - return kmeans_n_iters$LAYOUT; - } - - private static final long kmeans_n_iters$OFFSET = 12; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t kmeans_n_iters - * } - */ - public static final long kmeans_n_iters$offset() { - return kmeans_n_iters$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t kmeans_n_iters - * } - */ - public static int kmeans_n_iters(MemorySegment struct) { - return struct.get(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t kmeans_n_iters - * } - */ - public static void kmeans_n_iters(MemorySegment struct, int fieldValue) { - struct.set(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET, fieldValue); - } - - private static final OfDouble vq_kmeans_trainset_fraction$LAYOUT = (OfDouble)$LAYOUT.select(groupElement("vq_kmeans_trainset_fraction")); - - /** - * Layout for field: - * {@snippet lang=c : - * double vq_kmeans_trainset_fraction - * } - */ - public static final OfDouble vq_kmeans_trainset_fraction$layout() { - return vq_kmeans_trainset_fraction$LAYOUT; - } - - private static final long vq_kmeans_trainset_fraction$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang=c : - * double vq_kmeans_trainset_fraction - * } - */ - public static final long vq_kmeans_trainset_fraction$offset() { - return vq_kmeans_trainset_fraction$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * double vq_kmeans_trainset_fraction - * } - */ - public static double vq_kmeans_trainset_fraction(MemorySegment struct) { - return struct.get(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * double vq_kmeans_trainset_fraction - * } - */ - public static void vq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { - struct.set(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET, fieldValue); - } - - private static final OfDouble pq_kmeans_trainset_fraction$LAYOUT = (OfDouble)$LAYOUT.select(groupElement("pq_kmeans_trainset_fraction")); - - /** - * Layout for field: - * {@snippet lang=c : - * double pq_kmeans_trainset_fraction - * } - */ - public static final OfDouble pq_kmeans_trainset_fraction$layout() { - return pq_kmeans_trainset_fraction$LAYOUT; - } - - private static final long pq_kmeans_trainset_fraction$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang=c : - * double pq_kmeans_trainset_fraction - * } - */ - public static final long pq_kmeans_trainset_fraction$offset() { - return pq_kmeans_trainset_fraction$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * double pq_kmeans_trainset_fraction - * } - */ - public static double pq_kmeans_trainset_fraction(MemorySegment struct) { - return struct.get(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * double pq_kmeans_trainset_fraction - * } - */ - public static void pq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { - struct.set(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} - diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java deleted file mode 100644 index 9384f587e..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Copyright (c) 2024, 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.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfFloat; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct cuvsCagraSearchParams { - * size_t max_queries; - * size_t itopk_size; - * size_t max_iterations; - * enum cuvsCagraSearchAlgo algo; - * size_t team_size; - * size_t search_width; - * size_t min_iterations; - * size_t thread_block_size; - * enum cuvsCagraHashMode hashmap_mode; - * size_t hashmap_min_bitlen; - * float hashmap_max_fill_rate; - * uint32_t num_random_samplings; - * uint64_t rand_xor_mask; - * } - * } - */ -public class cuvsCagraSearchParams { - - cuvsCagraSearchParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - cagra_h.C_LONG.withName("max_queries"), - cagra_h.C_LONG.withName("itopk_size"), - cagra_h.C_LONG.withName("max_iterations"), - cagra_h.C_INT.withName("algo"), - MemoryLayout.paddingLayout(4), - cagra_h.C_LONG.withName("team_size"), - cagra_h.C_LONG.withName("search_width"), - cagra_h.C_LONG.withName("min_iterations"), - cagra_h.C_LONG.withName("thread_block_size"), - cagra_h.C_INT.withName("hashmap_mode"), - MemoryLayout.paddingLayout(4), - cagra_h.C_LONG.withName("hashmap_min_bitlen"), - cagra_h.C_FLOAT.withName("hashmap_max_fill_rate"), - cagra_h.C_INT.withName("num_random_samplings"), - cagra_h.C_LONG.withName("rand_xor_mask") - ).withName("cuvsCagraSearchParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong max_queries$LAYOUT = (OfLong)$LAYOUT.select(groupElement("max_queries")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t max_queries - * } - */ - public static final OfLong max_queries$layout() { - return max_queries$LAYOUT; - } - - private static final long max_queries$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t max_queries - * } - */ - public static final long max_queries$offset() { - return max_queries$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t max_queries - * } - */ - public static long max_queries(MemorySegment struct) { - return struct.get(max_queries$LAYOUT, max_queries$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t max_queries - * } - */ - public static void max_queries(MemorySegment struct, long fieldValue) { - struct.set(max_queries$LAYOUT, max_queries$OFFSET, fieldValue); - } - - private static final OfLong itopk_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("itopk_size")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t itopk_size - * } - */ - public static final OfLong itopk_size$layout() { - return itopk_size$LAYOUT; - } - - private static final long itopk_size$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t itopk_size - * } - */ - public static final long itopk_size$offset() { - return itopk_size$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t itopk_size - * } - */ - public static long itopk_size(MemorySegment struct) { - return struct.get(itopk_size$LAYOUT, itopk_size$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t itopk_size - * } - */ - public static void itopk_size(MemorySegment struct, long fieldValue) { - struct.set(itopk_size$LAYOUT, itopk_size$OFFSET, fieldValue); - } - - private static final OfLong max_iterations$LAYOUT = (OfLong)$LAYOUT.select(groupElement("max_iterations")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t max_iterations - * } - */ - public static final OfLong max_iterations$layout() { - return max_iterations$LAYOUT; - } - - private static final long max_iterations$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t max_iterations - * } - */ - public static final long max_iterations$offset() { - return max_iterations$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t max_iterations - * } - */ - public static long max_iterations(MemorySegment struct) { - return struct.get(max_iterations$LAYOUT, max_iterations$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t max_iterations - * } - */ - public static void max_iterations(MemorySegment struct, long fieldValue) { - struct.set(max_iterations$LAYOUT, max_iterations$OFFSET, fieldValue); - } - - private static final OfInt algo$LAYOUT = (OfInt)$LAYOUT.select(groupElement("algo")); - - /** - * Layout for field: - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo algo - * } - */ - public static final OfInt algo$layout() { - return algo$LAYOUT; - } - - private static final long algo$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo algo - * } - */ - public static final long algo$offset() { - return algo$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo algo - * } - */ - public static int algo(MemorySegment struct) { - return struct.get(algo$LAYOUT, algo$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo algo - * } - */ - public static void algo(MemorySegment struct, int fieldValue) { - struct.set(algo$LAYOUT, algo$OFFSET, fieldValue); - } - - private static final OfLong team_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("team_size")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t team_size - * } - */ - public static final OfLong team_size$layout() { - return team_size$LAYOUT; - } - - private static final long team_size$OFFSET = 32; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t team_size - * } - */ - public static final long team_size$offset() { - return team_size$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t team_size - * } - */ - public static long team_size(MemorySegment struct) { - return struct.get(team_size$LAYOUT, team_size$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t team_size - * } - */ - public static void team_size(MemorySegment struct, long fieldValue) { - struct.set(team_size$LAYOUT, team_size$OFFSET, fieldValue); - } - - private static final OfLong search_width$LAYOUT = (OfLong)$LAYOUT.select(groupElement("search_width")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t search_width - * } - */ - public static final OfLong search_width$layout() { - return search_width$LAYOUT; - } - - private static final long search_width$OFFSET = 40; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t search_width - * } - */ - public static final long search_width$offset() { - return search_width$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t search_width - * } - */ - public static long search_width(MemorySegment struct) { - return struct.get(search_width$LAYOUT, search_width$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t search_width - * } - */ - public static void search_width(MemorySegment struct, long fieldValue) { - struct.set(search_width$LAYOUT, search_width$OFFSET, fieldValue); - } - - private static final OfLong min_iterations$LAYOUT = (OfLong)$LAYOUT.select(groupElement("min_iterations")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t min_iterations - * } - */ - public static final OfLong min_iterations$layout() { - return min_iterations$LAYOUT; - } - - private static final long min_iterations$OFFSET = 48; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t min_iterations - * } - */ - public static final long min_iterations$offset() { - return min_iterations$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t min_iterations - * } - */ - public static long min_iterations(MemorySegment struct) { - return struct.get(min_iterations$LAYOUT, min_iterations$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t min_iterations - * } - */ - public static void min_iterations(MemorySegment struct, long fieldValue) { - struct.set(min_iterations$LAYOUT, min_iterations$OFFSET, fieldValue); - } - - private static final OfLong thread_block_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("thread_block_size")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t thread_block_size - * } - */ - public static final OfLong thread_block_size$layout() { - return thread_block_size$LAYOUT; - } - - private static final long thread_block_size$OFFSET = 56; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t thread_block_size - * } - */ - public static final long thread_block_size$offset() { - return thread_block_size$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t thread_block_size - * } - */ - public static long thread_block_size(MemorySegment struct) { - return struct.get(thread_block_size$LAYOUT, thread_block_size$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t thread_block_size - * } - */ - public static void thread_block_size(MemorySegment struct, long fieldValue) { - struct.set(thread_block_size$LAYOUT, thread_block_size$OFFSET, fieldValue); - } - - private static final OfInt hashmap_mode$LAYOUT = (OfInt)$LAYOUT.select(groupElement("hashmap_mode")); - - /** - * Layout for field: - * {@snippet lang=c : - * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static final OfInt hashmap_mode$layout() { - return hashmap_mode$LAYOUT; - } - - private static final long hashmap_mode$OFFSET = 64; - - /** - * Offset for field: - * {@snippet lang=c : - * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static final long hashmap_mode$offset() { - return hashmap_mode$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static int hashmap_mode(MemorySegment struct) { - return struct.get(hashmap_mode$LAYOUT, hashmap_mode$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static void hashmap_mode(MemorySegment struct, int fieldValue) { - struct.set(hashmap_mode$LAYOUT, hashmap_mode$OFFSET, fieldValue); - } - - private static final OfLong hashmap_min_bitlen$LAYOUT = (OfLong)$LAYOUT.select(groupElement("hashmap_min_bitlen")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t hashmap_min_bitlen - * } - */ - public static final OfLong hashmap_min_bitlen$layout() { - return hashmap_min_bitlen$LAYOUT; - } - - private static final long hashmap_min_bitlen$OFFSET = 72; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t hashmap_min_bitlen - * } - */ - public static final long hashmap_min_bitlen$offset() { - return hashmap_min_bitlen$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t hashmap_min_bitlen - * } - */ - public static long hashmap_min_bitlen(MemorySegment struct) { - return struct.get(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t hashmap_min_bitlen - * } - */ - public static void hashmap_min_bitlen(MemorySegment struct, long fieldValue) { - struct.set(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET, fieldValue); - } - - private static final OfFloat hashmap_max_fill_rate$LAYOUT = (OfFloat)$LAYOUT.select(groupElement("hashmap_max_fill_rate")); - - /** - * Layout for field: - * {@snippet lang=c : - * float hashmap_max_fill_rate - * } - */ - public static final OfFloat hashmap_max_fill_rate$layout() { - return hashmap_max_fill_rate$LAYOUT; - } - - private static final long hashmap_max_fill_rate$OFFSET = 80; - - /** - * Offset for field: - * {@snippet lang=c : - * float hashmap_max_fill_rate - * } - */ - public static final long hashmap_max_fill_rate$offset() { - return hashmap_max_fill_rate$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * float hashmap_max_fill_rate - * } - */ - public static float hashmap_max_fill_rate(MemorySegment struct) { - return struct.get(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * float hashmap_max_fill_rate - * } - */ - public static void hashmap_max_fill_rate(MemorySegment struct, float fieldValue) { - struct.set(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET, fieldValue); - } - - private static final OfInt num_random_samplings$LAYOUT = (OfInt)$LAYOUT.select(groupElement("num_random_samplings")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t num_random_samplings - * } - */ - public static final OfInt num_random_samplings$layout() { - return num_random_samplings$LAYOUT; - } - - private static final long num_random_samplings$OFFSET = 84; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t num_random_samplings - * } - */ - public static final long num_random_samplings$offset() { - return num_random_samplings$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t num_random_samplings - * } - */ - public static int num_random_samplings(MemorySegment struct) { - return struct.get(num_random_samplings$LAYOUT, num_random_samplings$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t num_random_samplings - * } - */ - public static void num_random_samplings(MemorySegment struct, int fieldValue) { - struct.set(num_random_samplings$LAYOUT, num_random_samplings$OFFSET, fieldValue); - } - - private static final OfLong rand_xor_mask$LAYOUT = (OfLong)$LAYOUT.select(groupElement("rand_xor_mask")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint64_t rand_xor_mask - * } - */ - public static final OfLong rand_xor_mask$layout() { - return rand_xor_mask$LAYOUT; - } - - private static final long rand_xor_mask$OFFSET = 88; - - /** - * Offset for field: - * {@snippet lang=c : - * uint64_t rand_xor_mask - * } - */ - public static final long rand_xor_mask$offset() { - return rand_xor_mask$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint64_t rand_xor_mask - * } - */ - public static long rand_xor_mask(MemorySegment struct) { - return struct.get(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint64_t rand_xor_mask - * } - */ - public static void rand_xor_mask(MemorySegment struct, long fieldValue) { - struct.set(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} - diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index c5788d342..47e42f2a5 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -16,7 +16,7 @@ package com.nvidia.cuvs; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.Assert.assertEquals; import java.io.File; import java.io.FileInputStream; @@ -28,14 +28,15 @@ import java.util.Map; import java.util.UUID; -import org.junit.jupiter.api.Test; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; import com.nvidia.cuvs.common.SearchResults; public class CagraBuildAndSearchTest { - + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); /** @@ -47,71 +48,88 @@ public class CagraBuildAndSearchTest { public void testIndexingAndSearchingFlow() throws Throwable { // Sample data and query - float[][] dataset = {{ 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, { 0.6673192f, 0.10993068f }}; + float[][] dataset = { + { 0.74021935f, 0.9209938f }, + { 0.03902049f, 0.9689629f }, + { 0.92514056f, 0.4463501f }, + { 0.6673192f, 0.10993068f } + }; Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); - float[][] queries = {{ 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f }}; - + float[][] queries = { + { 0.48216683f, 0.0428398f }, + { 0.5084142f, 0.6545497f }, + { 0.51260436f, 0.2643005f }, + { 0.05198065f, 0.5789965f } + }; + // Expected search results List> expectedResults = Arrays.asList( Map.of(3, 0.038782578f, 2, 0.3590463f, 0, 0.83774555f), - Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), - Map.of(3, 0.047766715f, 2, 0.20332818f, 0, 0.48305473f), + Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), + Map.of(3, 0.047766715f, 2, 0.20332818f, 0, 0.48305473f), Map.of(1, 0.15224178f, 0, 0.59063464f, 3, 0.5986642f)); - // Create resource - CuVSResources resources = new CuVSResources(); - - // Configure index parameters - CagraIndexParams indexParams = new CagraIndexParams.Builder(resources) - .withCagraGraphBuildAlgo(CagraIndexParams.CagraGraphBuildAlgo.NN_DESCENT) - .build(); - - // Create the index with the dataset - CagraIndex index = new CagraIndex.Builder(resources) - .withDataset(dataset) - .withIndexParams(indexParams) - .build(); - - // Saving the index on to the disk. - String indexFileName = UUID.randomUUID().toString() + ".cag"; - index.serialize(new FileOutputStream(indexFileName)); - - // Loading a CAGRA index from disk. - File indexFile = new File(indexFileName); - InputStream inputStream = new FileInputStream(indexFile); - CagraIndex loadedIndex = new CagraIndex.Builder(resources) - .from(inputStream) - .build(); - - // Configure search parameters - CagraSearchParams searchParams = new CagraSearchParams.Builder(resources) - .build(); - - // Create a query object with the query vectors - CagraQuery cuvsQuery = new CagraQuery.Builder() - .withTopK(3) - .withSearchParams(searchParams) - .withQueryVectors(queries) - .withMapping(map) - .build(); - - // Perform the search - SearchResults results = index.search(cuvsQuery); - - // Check results - log.info(results.getResults().toString()); - assertEquals(expectedResults, results.getResults(), "Results different than expected"); - - // Search from deserialized index - results = loadedIndex.search(cuvsQuery); - - // Check results - log.info(results.getResults().toString()); - assertEquals(expectedResults, results.getResults(), "Results different than expected"); - - // Cleanup - if (indexFile.exists()) { - indexFile.delete(); + for (int j = 0; j < 10; j++) { + + try (CuVSResources resources = new CuVSResources()) { + + // Configure index parameters + CagraIndexParams indexParams = new CagraIndexParams.Builder(resources) + .withCagraGraphBuildAlgo(CagraGraphBuildAlgo.NN_DESCENT) + .withGraphDegree(1) + .withIntermediateGraphDegree(2) + .withNumWriterThreads(32) + .build(); + + // Create the index with the dataset + CagraIndex index = new CagraIndex.Builder(resources) + .withDataset(dataset) + .withIndexParams(indexParams) + .build(); + + // Saving the index on to the disk. + String indexFileName = UUID.randomUUID().toString() + ".cag"; + index.serialize(new FileOutputStream(indexFileName)); + + // Loading a CAGRA index from disk. + File indexFile = new File(indexFileName); + InputStream inputStream = new FileInputStream(indexFile); + CagraIndex loadedIndex = new CagraIndex.Builder(resources) + .from(inputStream) + .build(); + + // Configure search parameters + CagraSearchParams searchParams = new CagraSearchParams.Builder(resources) + .build(); + + // Create a query object with the query vectors + CagraQuery cuvsQuery = new CagraQuery.Builder() + .withTopK(3) + .withSearchParams(searchParams) + .withQueryVectors(queries) + .withMapping(map) + .build(); + + // Perform the search + SearchResults results = index.search(cuvsQuery); + + // Check results + log.info(results.getResults().toString()); + assertEquals(expectedResults, results.getResults()); + + // Search from deserialized index + results = loadedIndex.search(cuvsQuery); + + // Check results + log.info(results.getResults().toString()); + assertEquals(expectedResults, results.getResults()); + + // Cleanup + if (indexFile.exists()) { + indexFile.delete(); + } + index.destroyIndex(); + } } } } \ No newline at end of file diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraRandomizedTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraRandomizedTest.java new file mode 100644 index 000000000..0d5ba5c6d --- /dev/null +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraRandomizedTest.java @@ -0,0 +1,163 @@ +package com.nvidia.cuvs; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.carrotsearch.randomizedtesting.RandomizedRunner; +import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; + +@RunWith(RandomizedRunner.class) +public class CagraRandomizedTest extends CuVSTestCase { + + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + @Before + public void setup() { + initializeRandom(); + log.info("Random context initialized for test."); + } + + @Test + public void testResultsTopKWithRandomValues() throws Throwable { + for (int i=0; i<10; i++) { + tmpResultsTopKWithRandomValues(); + } + } + + public void tmpResultsTopKWithRandomValues() throws Throwable { + int DATASET_SIZE_LIMIT = 10_000; + int DIMENSIONS_LIMIT = 2048; + int NUM_QUERIES_LIMIT = 10; + int TOP_K_LIMIT = 64; // nocommit This fails beyond 64 + + int datasetSize = random.nextInt(DATASET_SIZE_LIMIT) + 1; + int dimensions = random.nextInt(DIMENSIONS_LIMIT) + 1; + int numQueries = random.nextInt(NUM_QUERIES_LIMIT) + 1; + int topK = Math.min(random.nextInt(TOP_K_LIMIT) + 1, datasetSize); + + if(datasetSize < topK) datasetSize = topK; + + // Generate a random dataset + float[][] dataset = new float[datasetSize][dimensions]; + for (int i = 0; i < datasetSize; i++) { + for (int j = 0; j < dimensions; j++) { + dataset[i][j] = random.nextFloat() * 100; + } + } + // Generate random query vectors + float[][] queries = new float[numQueries][dimensions]; + for (int i = 0; i < numQueries; i++) { + for (int j = 0; j < dimensions; j++) { + queries[i][j] = random.nextFloat() * 100; + } + } + log.info("Dataset size: {}x{}", datasetSize, dimensions); + log.info("Query size: {}x{}", numQueries, dimensions); + log.info("TopK: {}", topK); + + // Debugging: Log dataset and queries + if (log.isDebugEnabled()) { + log.debug("Dataset:"); + for (float[] row : dataset) { + log.debug(java.util.Arrays.toString(row)); + } + log.debug("Queries:"); + for (float[] query : queries) { + log.debug(java.util.Arrays.toString(query)); + } + } + // Sanity checks + assert dataset.length > 0 : "Dataset is empty."; + assert queries.length > 0 : "Queries are empty."; + assert dimensions > 0 : "Invalid dimensions."; + assert topK > 0 && topK <= datasetSize : "Invalid topK value."; + + // Generate expected results using brute force + List> expected = generateExpectedResults(topK, dataset, queries); + + // Create CuVS index and query + try (CuVSResources resources = new CuVSResources()) { + CagraIndexParams indexParams = new CagraIndexParams.Builder(resources).withCagraGraphBuildAlgo(CagraGraphBuildAlgo.NN_DESCENT).build(); + CagraIndex index = new CagraIndex.Builder(resources).withDataset(dataset).withIndexParams(indexParams).build(); + log.info("Index built successfully."); + + // Execute search and retrieve results + CagraQuery query = new CagraQuery.Builder() + .withQueryVectors(queries) + .withTopK(topK) + .withSearchParams(new CagraSearchParams.Builder(resources).build()) + .build(); + log.info("Query built successfully. Executing search..."); + CagraSearchResults results = index.search(query); + + for (int i=0; i result = results.getResults().get(i); + assertEquals("TopK mismatch for query.", Math.min(topK, datasetSize), result.size()); + + // Sort result by values (distances) and extract keys + List sortedResultKeys = result.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) // Sort by value (distance) + .map(Map.Entry::getKey) // Extract sorted keys + .toList(); + + // Compare using primitive int arrays + /*assertArrayEquals( + "Query " + i + " mismatched", + expected.get(i).stream().mapToInt(Integer::intValue).toArray(), + sortedResultKeys.stream().mapToInt(Integer::intValue).toArray() + );*/ + + // just make sure that the first 5 results are in the expected list (which comprises of 2*topK results) + for (int j = 0; j< Math.min(5, sortedResultKeys.size()); j++) { + assertTrue("Not found in expected list: " + sortedResultKeys.get(j), + expected.get(i).contains(sortedResultKeys.get(j))); + } + + } + } + } + + private List> generateExpectedResults(int topK, float[][] dataset, float[][] queries) { + List> neighborsResult = new ArrayList<>(); + int dimensions = dataset[0].length; + + for (float[] query : queries) { + Map distances = new TreeMap<>(); + for (int j = 0; j < dataset.length; j++) { + double distance = 0; + for (int k = 0; k < dimensions; k++) { + distance += (query[k] - dataset[j][k]) * (query[k] - dataset[j][k]); + } + distances.put(j, Math.sqrt(distance)); + } + + // Sort by distance and select the topK nearest neighbors + List neighbors = distances.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .map(Map.Entry::getKey) + .toList(); + neighborsResult.add(neighbors.subList(0, Math.min(topK * 2, dataset.length))); // generate double the topK results in the expected array + } + + log.info("Expected results generated successfully."); + return neighborsResult; + } +} diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CuVSTestCase.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CuVSTestCase.java new file mode 100644 index 000000000..a07cb4ebf --- /dev/null +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CuVSTestCase.java @@ -0,0 +1,19 @@ +package com.nvidia.cuvs; + +import java.lang.invoke.MethodHandles; +import java.util.Random; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.carrotsearch.randomizedtesting.RandomizedContext; + +public abstract class CuVSTestCase { + protected Random random; + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + protected void initializeRandom() { + random = RandomizedContext.current().getRandom(); + log.info("Test seed: " + RandomizedContext.current().getRunnerSeedAsString()); + } +} diff --git a/java/internal/CMakeLists.txt b/java/internal/CMakeLists.txt index d9a851872..7c1f882f5 100644 --- a/java/internal/CMakeLists.txt +++ b/java/internal/CMakeLists.txt @@ -27,6 +27,9 @@ project( LANGUAGES CXX C ) +find_package(OpenMP) +find_package(Threads) + option(FIND_CUVS_CPP "Search for existing CUVS C++ installations before defaulting to local files" ON ) @@ -53,4 +56,4 @@ include(get_dlpack.cmake) ADD_LIBRARY(cuvs_java SHARED src/cuvs_java.c) target_include_directories(cuvs_java PUBLIC "$") -target_link_libraries(cuvs_java PRIVATE cuvs::c_api $) +target_link_libraries(cuvs_java PRIVATE cuvs::c_api $ OpenMP::OpenMP_CXX Threads::Threads) diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index ec9ecb6af..b6a078e24 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -20,13 +20,22 @@ #include #include #include +#include -cuvsResources_t create_resource(int *returnValue) { +#define try bool __HadError=false; +#define catch(x) ExitJmp:if(__HadError) +#define throw(x) {__HadError=true;goto ExitJmp;} + +cuvsResources_t create_resources(int *returnValue) { cuvsResources_t cuvsResources; *returnValue = cuvsResourcesCreate(&cuvsResources); return cuvsResources; } +void destroy_resources(cuvsResources_t cuvsResources, int *returnValue) { + *returnValue = cuvsResourcesDestroy(cuvsResources); +} + DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) { DLManagedTensor tensor; @@ -43,7 +52,10 @@ DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) } cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvsResources, int *returnValue, - cuvsCagraIndexParams_t index_params) { + cuvsCagraIndexParams_t index_params, cuvsCagraCompressionParams_t compression_params, int numWriterThreads) { + + omp_set_num_threads(numWriterThreads); + cuvsRMMPoolMemoryResourceEnable(95, 95, true); int64_t dataset_shape[2] = {rows, dimensions}; DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat); @@ -51,10 +63,18 @@ cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, c cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); + index_params->compression = compression_params; *returnValue = cuvsCagraBuild(cuvsResources, index_params, &dataset_tensor, index); + + omp_set_num_threads(1); + return index; } +void destroy_cagra_index(cuvsCagraIndex_t index, int *returnValue) { + *returnValue = cuvsCagraIndexDestroy(index); +} + void serialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { *returnValue = cuvsCagraSerialize(cuvsResources, filename, index, true); } @@ -83,11 +103,13 @@ void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n int64_t distances_shape[2] = {n_queries, topk}; DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat); - cuvsCagraSearchParamsCreate(&search_params); - *returnValue = cuvsCagraSearch(cuvsResources, search_params, index, &queries_tensor, &neighbors_tensor, &distances_tensor); cudaMemcpy(neighbors_h, neighbors, sizeof(uint32_t) * n_queries * topk, cudaMemcpyDefault); cudaMemcpy(distances_h, distances, sizeof(float) * n_queries * topk, cudaMemcpyDefault); + + cuvsRMMFree(cuvsResources, distances, sizeof(float) * n_queries * topk); + cuvsRMMFree(cuvsResources, neighbors, sizeof(uint32_t) * n_queries * topk); + cuvsRMMFree(cuvsResources, queries_d, sizeof(float) * n_queries * dimensions); } From 3438dbf85cf3f57fb1bb9a43a1e5a746b0985fb6 Mon Sep 17 00:00:00 2001 From: Ishan Chattopadhyaya Date: Fri, 8 Nov 2024 19:20:12 +0530 Subject: [PATCH 21/53] Initial cut for a cuVS Java API Co-authored-by: Vivek Narang --- .gitignore | 6 + build.sh | 12 +- java/README.md | 12 + java/build.sh | 9 + java/cuvs-java/pom.xml | 135 + .../main/java/com/nvidia/cuvs/ExampleApp.java | 74 + .../nvidia/cuvs/cagra/CagraIndexParams.java | 118 + .../cuvs/cagra/CagraIndexReference.java | 28 + .../nvidia/cuvs/cagra/CagraSearchParams.java | 256 ++ .../java/com/nvidia/cuvs/cagra/CuVSIndex.java | 335 ++ .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 118 + .../com/nvidia/cuvs/cagra/CuVSResources.java | 43 + .../com/nvidia/cuvs/cagra/IndexParams.java | 9 + .../nvidia/cuvs/cagra/PointerToDataset.java | 5 + .../java/com/nvidia/cuvs/cagra/PreFilter.java | 5 + .../com/nvidia/cuvs/cagra/SearchParams.java | 9 + .../com/nvidia/cuvs/cagra/SearchResult.java | 49 + .../com/nvidia/cuvs/panama/DLDataType.java | 218 ++ .../java/com/nvidia/cuvs/panama/DLDevice.java | 171 + .../nvidia/cuvs/panama/DLManagedTensor.java | 273 ++ .../cuvs/panama/DLManagedTensorVersioned.java | 366 ++ .../com/nvidia/cuvs/panama/DLPackVersion.java | 171 + .../java/com/nvidia/cuvs/panama/DLTensor.java | 402 +++ .../java/com/nvidia/cuvs/panama/__fsid_t.java | 159 + .../com/nvidia/cuvs/panama/brute_force_h.java | 2357 +++++++++++++ .../java/com/nvidia/cuvs/panama/cagra_h.java | 2051 +++++++++++ .../panama/cuvsCagraCompressionParams.java | 356 ++ .../nvidia/cuvs/panama/cuvsCagraIndex.java | 172 + .../cuvs/panama/cuvsCagraIndexParams.java | 265 ++ .../cuvs/panama/cuvsCagraSearchParams.java | 681 ++++ .../com/nvidia/cuvs/panama/cuvsFilter.java | 172 + .../java/com/nvidia/cuvs/panama/dlpack_h.java | 1883 ++++++++++ .../java/com/nvidia/cuvs/panama/hnsw_h.java | 2482 +++++++++++++ .../com/nvidia/cuvs/panama/ivf_flat_h.java | 2792 +++++++++++++++ .../java/com/nvidia/cuvs/panama/ivf_pq_h.java | 3096 +++++++++++++++++ .../com/nvidia/cuvs/panama/max_align_t.java | 127 + .../java/com/nvidia/cuvs/panama/results.java | 211 ++ .../com/nvidia/cuvs/panama/results_h.java | 83 + .../src/test/java/ai/rapids/cuvs/AppTest.java | 19 + java/internal/CMakeLists.txt | 56 + java/internal/VERSION | 1 + java/internal/get_dlpack.cmake | 1 + java/internal/rapids_config.cmake | 1 + java/internal/src/cuvs_java.c | 78 + 44 files changed, 19865 insertions(+), 2 deletions(-) create mode 100644 java/README.md create mode 100755 java/build.sh create mode 100644 java/cuvs-java/pom.xml create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java create mode 100644 java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java create mode 100644 java/internal/CMakeLists.txt create mode 120000 java/internal/VERSION create mode 120000 java/internal/get_dlpack.cmake create mode 120000 java/internal/rapids_config.cmake create mode 100644 java/internal/src/cuvs_java.c diff --git a/.gitignore b/.gitignore index da6eb07f6..9b00a5faf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ ## common __pycache__ +.gitignore *.pyc *~ \#* @@ -83,3 +84,8 @@ ivf_pq_index # cuvs_bench datasets/ /*.json + +# java +.classpath + + diff --git a/build.sh b/build.sh index bd5fa649b..a92480ac1 100755 --- a/build.sh +++ b/build.sh @@ -18,7 +18,7 @@ ARGS=$* # scripts, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean libcuvs python rust docs tests bench-ann examples --uninstall -v -g -n --compile-static-lib --allgpuarch --no-mg --no-cpu --cpu-only --no-shared-libs --no-nvtx --show_depr_warn --incl-cache-stats --time -h" +VALIDARGS="clean libcuvs python rust java docs tests bench-ann examples --uninstall -v -g -n --compile-static-lib --allgpuarch --no-mg --no-cpu --cpu-only --no-shared-libs --no-nvtx --show_depr_warn --incl-cache-stats --time -h" HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool=] [--limit-tests=] [--limit-bench-ann=] [--build-metrics=] where is: clean - remove all existing build artifacts and configuration (start over) @@ -26,6 +26,7 @@ HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool= + 4.0.0 + com.nvidia.cuvs + cuvs-java + 0.1 + cuvs-java + jar + + + 21 + 21 + + + + + commons-io + commons-io + 2.15.1 + + + + com.github.fommil + jniloader + 1.1 + + + + org.slf4j + slf4j-api + 2.0.13 + + + + org.slf4j + slf4j-simple + 2.0.13 + runtime + + + + org.junit.jupiter + junit-jupiter-api + 5.10.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.7 + + + ${project.build.directory}/classes + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + + copy + compile + + copy + + + + + com.nvidia.cuvs + cuvs-java-internal + 0.1 + so + false + + ${project.build.directory}/classes + libcuvs_java.so + + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + + + jar-with-dependencies + + + add + + + + + com.nvidia.cuvs.ExampleApp + + + + + + assemble-all + package + + single + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + true + + com.nvidia.cuvs.ExampleApp + + + + + + + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java new file mode 100644 index 000000000..3497810bf --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -0,0 +1,74 @@ +package com.nvidia.cuvs; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.Map; + +import com.nvidia.cuvs.cagra.CuVSIndex; +import com.nvidia.cuvs.cagra.CuVSIndex.ANNAlgorithms; +import com.nvidia.cuvs.cagra.CagraIndexParams; +import com.nvidia.cuvs.cagra.CagraIndexParams.CuvsCagraGraphBuildAlgo; +import com.nvidia.cuvs.cagra.CagraSearchParams; +import com.nvidia.cuvs.cagra.CuVSQuery; +import com.nvidia.cuvs.cagra.CuVSResources; +import com.nvidia.cuvs.cagra.SearchResult; + +public class ExampleApp { + public static void main(String[] args) throws Throwable { + + // Sample data and query + float[][] dataset = { { 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, + { 0.6673192f, 0.10993068f } }; + Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); + float[][] queries = { { 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, + { 0.05198065f, 0.5789965f } }; + + CuVSResources res = new CuVSResources(); + + CagraIndexParams cagraIndexParams = new CagraIndexParams.Builder() + .withIntermediateGraphDegree(10) + .withBuildAlgo(CuvsCagraGraphBuildAlgo.IVF_PQ) + .withWriterThreads(1) + .build(); + + CagraSearchParams cagraSearchParams = new CagraSearchParams + .Builder() + .withMaxQueries(15) + .build(); + + // Creating a new index + CuVSIndex index = new CuVSIndex.Builder(res) + .withDataset(dataset) + .withANNAlgorithm(ANNAlgorithms.CAGRA) + .withIndexParams(cagraIndexParams) + .build(); + + // Saving the index on to the disk. + index.serialize(new FileOutputStream("abc.cag"), "/tmp/index.cag"); + + // Loading a cagra index from disk. + InputStream fin = new FileInputStream(new File("abc.cag")); + CuVSIndex index2 = new CuVSIndex.Builder(res) + .from(fin) + .build(); + + // Query + CuVSQuery query = new CuVSQuery.Builder() + .withANNAlgorithm(ANNAlgorithms.CAGRA) + .withSearchParams(cagraSearchParams) + .withQueryVectors(queries) + .withMapping(map) + .build(); + + // Search + SearchResult rslt = index.search(query); + System.out.println(rslt.results); + + // Search from de-serialized index + SearchResult rslt2 = index2.search(query); + System.out.println(rslt2.results); + + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java new file mode 100644 index 000000000..1c99bdfdf --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -0,0 +1,118 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; + +import com.nvidia.cuvs.panama.cuvsCagraIndexParams; + +/* +* struct cuvsCagraIndexParams { +* size_t intermediate_graph_degree; +* size_t graph_degree; +* enum cuvsCagraGraphBuildAlgo build_algo; +* size_t nn_descent_niter; +* } +*/ +public class CagraIndexParams extends IndexParams { + + Arena arena; + int intermediateGraphDegree; + int graphDegree; + CuvsCagraGraphBuildAlgo buildAlgo; + int nnDescentNiter; + + public enum CuvsCagraGraphBuildAlgo { + AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); + + public final int label; + + private CuvsCagraGraphBuildAlgo(int label) { + this.label = label; + } + } + + public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, + CuvsCagraGraphBuildAlgo buildAlgo, int nnDescentNiter) { + this.arena = arena; + this.intermediateGraphDegree = intermediateGraphDegree; + this.graphDegree = graphDegree; + this.buildAlgo = buildAlgo; + this.nnDescentNiter = nnDescentNiter; + this.set(); + } + + private void set() { + indexParamsMS = cuvsCagraIndexParams.allocate(arena); + cuvsCagraIndexParams.intermediate_graph_degree(indexParamsMS, intermediateGraphDegree); + cuvsCagraIndexParams.graph_degree(indexParamsMS, graphDegree); + cuvsCagraIndexParams.build_algo(indexParamsMS, buildAlgo.label); + cuvsCagraIndexParams.nn_descent_niter(indexParamsMS, nnDescentNiter); + } + + public int getIntermediate_graph_degree() { + return intermediateGraphDegree; + } + + public int getGraph_degree() { + return graphDegree; + } + + public CuvsCagraGraphBuildAlgo getBuild_algo() { + return buildAlgo; + } + + public int getNn_descent_niter() { + return nnDescentNiter; + } + + @Override + public String toString() { + return "CagraIndexParams [intermediate_graph_degree=" + intermediateGraphDegree + ", graph_degree=" + graphDegree + + ", build_algo=" + buildAlgo + ", nn_descent_niter=" + nnDescentNiter + "]"; + } + + public static class Builder { + + Arena arena; + int intermediateGraphDegree = 128; + int graphDegree = 64; + CuvsCagraGraphBuildAlgo buildAlgo = CuvsCagraGraphBuildAlgo.IVF_PQ; + int nnDescentNiter = 20; + int writerThreads = 1; + + public Builder() { + this.arena = Arena.ofConfined(); + } + + public Builder withIntermediateGraphDegree(int intermediateGraphDegree) { + this.intermediateGraphDegree = intermediateGraphDegree; + return this; + } + + public Builder withGraphDegree(int graphDegree) { + this.graphDegree = graphDegree; + return this; + } + + public Builder withBuildAlgo(CuvsCagraGraphBuildAlgo buildAlgo) { + this.buildAlgo = buildAlgo; + return this; + } + + public Builder withNNDescentNiter(int nnDescentNiter) { + this.nnDescentNiter = nnDescentNiter; + return this; + } + + public Builder withWriterThreads(int writerThreads) { + this.writerThreads = writerThreads; + return this; + } + + public CagraIndexParams build() throws Throwable { + return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, buildAlgo, nnDescentNiter); + } + + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java new file mode 100644 index 000000000..bbcca2407 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -0,0 +1,28 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; + +import com.nvidia.cuvs.panama.cuvsCagraIndex; + +public class CagraIndexReference { + + public MemorySegment indexMemorySegment; + + /** + * + */ + public CagraIndexReference() { + Arena arena = Arena.ofConfined(); + indexMemorySegment = cuvsCagraIndex.allocate(arena); + } + + /** + * + * @param indexMemorySegment + */ + public CagraIndexReference(MemorySegment indexMemorySegment) { + this.indexMemorySegment = indexMemorySegment; + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java new file mode 100644 index 000000000..3dd5aebd2 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -0,0 +1,256 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; + +import com.nvidia.cuvs.panama.cuvsCagraSearchParams; + +/* +* struct cuvsCagraSearchParams { +* size_t max_queries; +* size_t itopk_size; +* size_t max_iterations; +* enum cuvsCagraSearchAlgo algo; +* size_t team_size; +* size_t search_width; +* size_t min_iterations; +* size_t thread_block_size; +* enum cuvsCagraHashMode hashmap_mode; +* size_t hashmap_min_bitlen; +* float hashmap_max_fill_rate; +* uint32_t num_random_samplings; +* uint64_t rand_xor_mask; +* } +*/ +public class CagraSearchParams extends SearchParams { + + Arena arena; + int maxQueries; + int itopkSize; + int maxIterations; + CuvsCagraSearchAlgo algo; + int teamSize; + int searchWidth; + int minIterations; + int threadBlockSize; + CuvsCagraHashMode hashmapMode; + int hashmapMinBitlen; + float hashmapMaxFillRate; + int numRandomSamplings; + long randXorMask; + + enum CuvsCagraSearchAlgo { + SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); + + public final int label; + + private CuvsCagraSearchAlgo(int label) { + this.label = label; + } + + } + + enum CuvsCagraHashMode { + HASH(0), SMALL(1), AUTO_HASH(2); + + public final int label; + + private CuvsCagraHashMode(int label) { + this.label = label; + } + } + + public CagraSearchParams(Arena arena, int max_queries, int itopk_size, int max_iterations, CuvsCagraSearchAlgo algo, + int team_size, int search_width, int min_iterations, int thread_block_size, CuvsCagraHashMode hashmap_mode, + int hashmap_min_bitlen, float hashmap_max_fill_rate, int num_random_samplings, long rand_xor_mask) { + super(); + this.arena = arena; + this.maxQueries = max_queries; + this.itopkSize = itopk_size; + this.maxIterations = max_iterations; + this.algo = algo; + this.teamSize = team_size; + this.searchWidth = search_width; + this.minIterations = min_iterations; + this.threadBlockSize = thread_block_size; + this.hashmapMode = hashmap_mode; + this.hashmapMinBitlen = hashmap_min_bitlen; + this.hashmapMaxFillRate = hashmap_max_fill_rate; + this.numRandomSamplings = num_random_samplings; + this.randXorMask = rand_xor_mask; + this.set(); + } + + public void set() { + searchParamsMS = cuvsCagraSearchParams.allocate(arena); + cuvsCagraSearchParams.max_queries(searchParamsMS, maxQueries); + cuvsCagraSearchParams.itopk_size(searchParamsMS, itopkSize); + cuvsCagraSearchParams.max_iterations(searchParamsMS, maxIterations); + cuvsCagraSearchParams.algo(searchParamsMS, algo.label); + cuvsCagraSearchParams.team_size(searchParamsMS, teamSize); + cuvsCagraSearchParams.search_width(searchParamsMS, searchWidth); + cuvsCagraSearchParams.min_iterations(searchParamsMS, minIterations); + cuvsCagraSearchParams.thread_block_size(searchParamsMS, threadBlockSize); + cuvsCagraSearchParams.hashmap_mode(searchParamsMS, hashmapMode.label); + cuvsCagraSearchParams.hashmap_min_bitlen(searchParamsMS, hashmapMinBitlen); + cuvsCagraSearchParams.hashmap_max_fill_rate(searchParamsMS, hashmapMaxFillRate); + cuvsCagraSearchParams.num_random_samplings(searchParamsMS, numRandomSamplings); + cuvsCagraSearchParams.rand_xor_mask(searchParamsMS, randXorMask); + } + + public int getMax_queries() { + return maxQueries; + } + + public int getItopk_size() { + return itopkSize; + } + + public int getMax_iterations() { + return maxIterations; + } + + public CuvsCagraSearchAlgo getAlgo() { + return algo; + } + + public int getTeam_size() { + return teamSize; + } + + public int getSearch_width() { + return searchWidth; + } + + public int getMin_iterations() { + return minIterations; + } + + public int getThread_block_size() { + return threadBlockSize; + } + + public CuvsCagraHashMode getHashmap_mode() { + return hashmapMode; + } + + public int getHashmap_min_bitlen() { + return hashmapMinBitlen; + } + + public float getHashmap_max_fill_rate() { + return hashmapMaxFillRate; + } + + public int getNum_random_samplings() { + return numRandomSamplings; + } + + public long getRand_xor_mask() { + return randXorMask; + } + + @Override + public String toString() { + return "CagraSearchParams [max_queries=" + maxQueries + ", itopk_size=" + itopkSize + ", max_iterations=" + + maxIterations + ", algo=" + algo + ", team_size=" + teamSize + ", search_width=" + searchWidth + + ", min_iterations=" + minIterations + ", thread_block_size=" + threadBlockSize + ", hashmap_mode=" + + hashmapMode + ", hashmap_min_bitlen=" + hashmapMinBitlen + ", hashmap_max_fill_rate=" + + hashmapMaxFillRate + ", num_random_samplings=" + numRandomSamplings + ", rand_xor_mask=" + randXorMask + + "]"; + } + + public static class Builder { + + Arena arena; + int maxQueries = 1; + int itopkSize = 2; + int maxIterations = 3; + CuvsCagraSearchAlgo algo = CuvsCagraSearchAlgo.MULTI_KERNEL; + int teamSize = 4; + int searchWidth = 5; + int minIterations = 6; + int threadBlockSize = 7; + CuvsCagraHashMode hashmapMode = CuvsCagraHashMode.AUTO_HASH; + int hashmapMinBitlen = 8; + float hashmapMaxFillRate = 9.0f; + int numRandomSamplings = 10; + long randXorMask = 11L; + + public Builder() { + this.arena = Arena.ofConfined(); + } + + public Builder withMaxQueries(int max_queries) { + this.maxQueries = max_queries; + return this; + } + + public Builder withItopkSize(int itopk_size) { + this.itopkSize = itopk_size; + return this; + } + + public Builder withMaxIterations(int max_iterations) { + this.maxIterations = max_iterations; + return this; + } + + public Builder withAlgo(CuvsCagraSearchAlgo algo) { + this.algo = algo; + return this; + } + + public Builder withTeamSize(int team_size) { + this.teamSize = team_size; + return this; + } + + public Builder withSearchWidth(int search_width) { + this.searchWidth = search_width; + return this; + } + + public Builder withMinIterations(int min_iterations) { + this.minIterations = min_iterations; + return this; + } + + public Builder withThreadBlockSize(int thread_block_size) { + this.threadBlockSize = thread_block_size; + return this; + } + + public Builder withHashmapMode(CuvsCagraHashMode hashmap_mode) { + this.hashmapMode = hashmap_mode; + return this; + } + + public Builder withHashmapMinBitlen(int hashmap_min_bitlen) { + this.hashmapMinBitlen = hashmap_min_bitlen; + return this; + } + + public Builder withHashmapMaxFillRate(float hashmap_max_fill_rate) { + this.hashmapMaxFillRate = hashmap_max_fill_rate; + return this; + } + + public Builder withNumRandomSamplings(int num_random_samplings) { + this.numRandomSamplings = num_random_samplings; + return this; + } + + public Builder withRandXorMask(long rand_xor_mask) { + this.randXorMask = rand_xor_mask; + return this; + } + + public CagraSearchParams build() throws Throwable { + return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, algo, teamSize, searchWidth, + minIterations, threadBlockSize, hashmapMode, hashmapMinBitlen, hashmapMaxFillRate, + numRandomSamplings, randXorMask); + } + + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java new file mode 100644 index 000000000..df0cc3f2d --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java @@ -0,0 +1,335 @@ +package com.nvidia.cuvs.cagra; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemoryLayout.PathElement; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.VarHandle; +import java.util.UUID; + +public class CuVSIndex { + + private IndexParams indexParams; + private final float[][] dataset; + private final CuVSResources res; + private CagraIndexReference ref; + private ANNAlgorithms algo; + + public enum ANNAlgorithms { + BRUTEFORCE, CAGRA, IVF_PQ, IVF_FLAT + } + + Linker linker; + Arena arena; + MethodHandle cresMH; + MethodHandle indexMH; + MethodHandle searchMH; + MethodHandle serializeMH; + MethodHandle deserializeMH; + MemorySegment dataMS; + SymbolLookup bridge; + + /** + * + * @param indexParams + * @param dataset + * @param mapping + * @param res + * @throws Throwable + */ + private CuVSIndex(IndexParams indexParams, float[][] dataset, CuVSResources res, ANNAlgorithms algo) + throws Throwable { + this.indexParams = indexParams; + this.dataset = dataset; + this.init(); + this.res = res; + this.ref = build(); + this.algo = algo; + } + + /** + * + * @param in + * @param res + * @throws Throwable + */ + private CuVSIndex(InputStream in, CuVSResources res) throws Throwable { + this.indexParams = null; + this.dataset = null; + this.res = res; + this.init(); + this.ref = deserialize(in); + } + + /** + * + * @throws Throwable + */ + private void init() throws Throwable { + linker = Linker.nativeLinker(); + arena = Arena.ofConfined(); + + File wd = new File(System.getProperty("user.dir")); + bridge = SymbolLookup.libraryLookup(wd.getParent() + "/api-sys/build/libcuvs_wrapper.so", arena); + + indexMH = linker.downcallHandle(bridge.findOrThrow("build_index"), + FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), + linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + searchMH = linker.downcallHandle(bridge.findOrThrow("search_index"), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), + linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, + ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + serializeMH = linker.downcallHandle(bridge.findOrThrow("serialize_index"), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + deserializeMH = linker.downcallHandle(bridge.findOrThrow("deserialize_index"), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + } + + /** + * Java String -> C char* + * + * @param str + * @return MemorySegment + */ + public MemorySegment getStringSegment(StringBuilder str) { + str.append('\0'); + MemoryLayout sq = MemoryLayout.sequenceLayout(str.length(), linker.canonicalLayouts().get("char")); + MemorySegment fln = arena.allocate(sq); + + for (int i = 0; i < str.length(); i++) { + VarHandle flnVH = sq.varHandle(PathElement.sequenceElement(i)); + flnVH.set(fln, 0L, (byte) str.charAt(i)); + } + return fln; + } + + /** + * + * @param data + * @return + */ + private MemorySegment getMemorySegment(float[][] data) { + long rows = data.length; + long cols = data[0].length; + + MemoryLayout dataML = MemoryLayout.sequenceLayout(rows, + MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); + MemorySegment dataMS = arena.allocate(dataML); + + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + VarHandle element = dataML.arrayElementVarHandle(PathElement.sequenceElement(r), + PathElement.sequenceElement(c)); + element.set(dataMS, 0, 0, data[r][c]); + } + } + + return dataMS; + } + + /** + * + * @return + * @throws Throwable + */ + private CagraIndexReference build() throws Throwable { + long rows = dataset.length; + long cols = dataset[0].length; + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + + ref = new CagraIndexReference((MemorySegment) indexMH.invokeExact(getMemorySegment(dataset), rows, cols, + res.resource, rvMS, indexParams.indexParamsMS)); + + System.out.println("Build call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + + return ref; + } + + /** + * + * @param params + * @param queryVectors + * @return + * @throws Throwable + */ + public SearchResult search(CuVSQuery query) throws Throwable { + + SequenceLayout neighborsSL = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); + SequenceLayout distancesSL = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); + MemorySegment neighborsMS = arena.allocate(neighborsSL); + MemorySegment distancesMS = arena.allocate(distancesSL); + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + + searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.queryVectors), 2, 4L, 2L, res.resource, + neighborsMS, distancesMS, rvMS, query.searchParams.searchParamsMS); + + System.out.println("Search call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + + return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, 2, query.mapping); + } + + /** + * + * @param out + * @param tmpFilePath + * @throws Throwable + */ + public void serialize(OutputStream out, String tmpFilePath) throws Throwable { + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + serializeMH.invokeExact(res.resource, ref.indexMemorySegment, rvMS, + getStringSegment(new StringBuilder(tmpFilePath))); + System.out.println("Serialize call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + + File tempFile = new File(tmpFilePath); + FileInputStream is = new FileInputStream(tempFile); + byte[] chunk = new byte[1024]; + int chunkLen = 0; + while ((chunkLen = is.read(chunk)) != -1) { + out.write(chunk, 0, chunkLen); + } + is.close(); + tempFile.delete(); + } + + /** + * + * @param in + * @return + * @throws Throwable + */ + private CagraIndexReference deserialize(InputStream in) throws Throwable { + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; + CagraIndexReference ref = new CagraIndexReference(); + + File tempFile = new File(tmpIndexFile); + FileOutputStream out = new FileOutputStream(tempFile); + byte[] chunk = new byte[1024]; + int chunkLen = 0; + while ((chunkLen = in.read(chunk)) != -1) { + out.write(chunk, 0, chunkLen); + } + deserializeMH.invokeExact(res.resource, ref.indexMemorySegment, rvMS, + getStringSegment(new StringBuilder(tmpIndexFile))); + + in.close(); + out.close(); + tempFile.delete(); + + return ref; + } + + /** + * + * @return + */ + public IndexParams getParams() { + return indexParams; + } + + /** + * + * @return + */ + public PointerToDataset getDataset() { + return null; + } + + /** + * + * @return + */ + public CuVSResources getResources() { + return res; + } + + public static class Builder { + private IndexParams indexParams; + float[][] dataset; + CuVSResources res; + ANNAlgorithms algo = ANNAlgorithms.CAGRA; + + InputStream in; + + /** + * + * @param res + */ + public Builder(CuVSResources res) { + this.res = res; + } + + /** + * + * @param in + * @return + */ + public Builder from(InputStream in) { + this.in = in; + return this; + } + + /** + * + * @param dataset + * @return + */ + public Builder withDataset(float[][] dataset) { + this.dataset = dataset; + return this; + } + + /** + * + * @param params + * @return + */ + public Builder withIndexParams(IndexParams indexParams) { + this.indexParams = indexParams; + return this; + } + + /** + * + * @param params + * @return + */ + public Builder withANNAlgorithm(ANNAlgorithms algo) { + this.algo = algo; + return this; + } + + /** + * + * @return + * @throws Throwable + */ + public CuVSIndex build() throws Throwable { + if (in != null) { + return new CuVSIndex(in, res); + } else { + return new CuVSIndex(indexParams, dataset, res, algo); + } + } + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java new file mode 100644 index 000000000..96111b0eb --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -0,0 +1,118 @@ +package com.nvidia.cuvs.cagra; + +import java.util.Arrays; +import java.util.Map; + +import com.nvidia.cuvs.cagra.CuVSIndex.ANNAlgorithms; + +public class CuVSQuery { + + SearchParams searchParams; + PreFilter preFilter; + float[][] queryVectors; + public Map mapping; + ANNAlgorithms algo; + + public CuVSQuery(SearchParams searchParams, PreFilter preFilter, float[][] queryVectors, + Map mapping, ANNAlgorithms algo) { + super(); + this.searchParams = searchParams; + this.preFilter = preFilter; + this.queryVectors = queryVectors; + this.mapping = mapping; + this.algo = algo; + } + + @Override + public String toString() { + return "CuVSQuery [searchParams=" + searchParams + ", preFilter=" + preFilter + ", queries=" + + Arrays.toString(queryVectors) + "]"; + } + + public SearchParams getSearchParams() { + return searchParams; + } + + public PreFilter getPreFilter() { + return preFilter; + } + + public float[][] getQueries() { + return queryVectors; + } + + public static class Builder { + SearchParams searchParams; + PreFilter preFilter; + float[][] queryVectors; + Map mapping; + ANNAlgorithms algo = ANNAlgorithms.CAGRA; + + /** + * + * @param res + */ + public Builder() { + } + + /** + * + * @param dataset + * @return + */ + public Builder withSearchParams(SearchParams searchParams) { + this.searchParams = searchParams; + return this; + } + + /** + * + * @param queryVectors + * @return + */ + public Builder withQueryVectors(float[][] queryVectors) { + this.queryVectors = queryVectors; + return this; + } + + /** + * + * @param preFilter + * @return + */ + public Builder withPreFilter(PreFilter preFilter) { + this.preFilter = preFilter; + return this; + } + + /** + * + * @param mapping + * @return + */ + public Builder withMapping(Map mapping) { + this.mapping = mapping; + return this; + } + + /** + * + * @param params + * @return + */ + public Builder withANNAlgorithm(ANNAlgorithms algo) { + this.algo = algo; + return this; + } + + /** + * + * @return + * @throws Throwable + */ + public CuVSQuery build() throws Throwable { + return new CuVSQuery(searchParams, preFilter, queryVectors, mapping, algo); + } + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java new file mode 100644 index 000000000..14affd3b8 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -0,0 +1,43 @@ +package com.nvidia.cuvs.cagra; + +import java.io.File; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; + +public class CuVSResources { + + private Linker linker; + private Arena arena; + private MethodHandle cresMH; + private SymbolLookup bridge; + public MemorySegment resource; + + /** + * + * @throws Throwable + */ + public CuVSResources() throws Throwable { + linker = Linker.nativeLinker(); + arena = Arena.ofConfined(); + + File wd = new File(System.getProperty("user.dir")); + bridge = SymbolLookup.libraryLookup(wd.getParent() + "/api-sys/build/libcuvs_wrapper.so", arena); + + cresMH = linker.downcallHandle(bridge.findOrThrow("create_resource"), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + + resource = (MemorySegment) cresMH.invokeExact(rvMS); + + System.out.println("Create resource call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java new file mode 100644 index 000000000..df073f36e --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java @@ -0,0 +1,9 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.MemorySegment; + +public class IndexParams { + + public MemorySegment indexParamsMS; + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java new file mode 100644 index 000000000..c5fc4f074 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java @@ -0,0 +1,5 @@ +package com.nvidia.cuvs.cagra; + +public class PointerToDataset { + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java new file mode 100644 index 000000000..b8310af31 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java @@ -0,0 +1,5 @@ +package com.nvidia.cuvs.cagra; + +public class PreFilter { + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java new file mode 100644 index 000000000..6cca9bf49 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java @@ -0,0 +1,9 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.MemorySegment; + +public class SearchParams { + + public MemorySegment searchParamsMS; + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java new file mode 100644 index 000000000..ccc722267 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -0,0 +1,49 @@ +package com.nvidia.cuvs.cagra; + +import java.lang.foreign.MemoryLayout.PathElement; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SequenceLayout; +import java.lang.invoke.VarHandle; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SearchResult { + + public List neighbours; // TODO: Get clarity on these two. + public List distances; + public Map results; + public Map mapping; + SequenceLayout neighboursSL; + SequenceLayout distancesSL; + MemorySegment neighboursMS; + MemorySegment distancesMS; + int topK; + + public SearchResult(SequenceLayout neighboursSL, SequenceLayout distancesSL, MemorySegment neighboursMS, + MemorySegment distancesMS, int topK, Map mapping) { + super(); + this.topK = topK; + this.neighboursSL = neighboursSL; + this.distancesSL = distancesSL; + this.neighboursMS = neighboursMS; + this.distancesMS = distancesMS; + this.mapping = mapping; + neighbours = new ArrayList(); + distances = new ArrayList(); + results = new HashMap(); + this.load(); + } + + private void load() { + VarHandle neighboursVH = neighboursSL.varHandle(PathElement.sequenceElement()); + VarHandle distancesVH = distancesSL.varHandle(PathElement.sequenceElement()); + + for (long i = 0; i < topK; i++) { + int id = (int) neighboursVH.get(neighboursMS, 0L, i); + results.put(mapping != null ? mapping.get(id) : id, (float) distancesVH.get(distancesMS, 0L, i)); + } + } + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java new file mode 100644 index 000000000..0326aa8f4 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java @@ -0,0 +1,218 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfShort; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * uint8_t code; + * uint8_t bits; + * uint16_t lanes; + * } + * } + */ +public class DLDataType { + + DLDataType() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_CHAR.withName("code"), + dlpack_h.C_CHAR.withName("bits"), + dlpack_h.C_SHORT.withName("lanes") + ).withName("$anon$174:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfByte code$LAYOUT = (OfByte)$LAYOUT.select(groupElement("code")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint8_t code + * } + */ + public static final OfByte code$layout() { + return code$LAYOUT; + } + + private static final long code$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * uint8_t code + * } + */ + public static final long code$offset() { + return code$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint8_t code + * } + */ + public static byte code(MemorySegment struct) { + return struct.get(code$LAYOUT, code$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint8_t code + * } + */ + public static void code(MemorySegment struct, byte fieldValue) { + struct.set(code$LAYOUT, code$OFFSET, fieldValue); + } + + private static final OfByte bits$LAYOUT = (OfByte)$LAYOUT.select(groupElement("bits")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint8_t bits + * } + */ + public static final OfByte bits$layout() { + return bits$LAYOUT; + } + + private static final long bits$OFFSET = 1; + + /** + * Offset for field: + * {@snippet lang=c : + * uint8_t bits + * } + */ + public static final long bits$offset() { + return bits$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint8_t bits + * } + */ + public static byte bits(MemorySegment struct) { + return struct.get(bits$LAYOUT, bits$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint8_t bits + * } + */ + public static void bits(MemorySegment struct, byte fieldValue) { + struct.set(bits$LAYOUT, bits$OFFSET, fieldValue); + } + + private static final OfShort lanes$LAYOUT = (OfShort)$LAYOUT.select(groupElement("lanes")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint16_t lanes + * } + */ + public static final OfShort lanes$layout() { + return lanes$LAYOUT; + } + + private static final long lanes$OFFSET = 2; + + /** + * Offset for field: + * {@snippet lang=c : + * uint16_t lanes + * } + */ + public static final long lanes$offset() { + return lanes$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint16_t lanes + * } + */ + public static short lanes(MemorySegment struct) { + return struct.get(lanes$LAYOUT, lanes$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint16_t lanes + * } + */ + public static void lanes(MemorySegment struct, short fieldValue) { + struct.set(lanes$LAYOUT, lanes$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java new file mode 100644 index 000000000..3e9341f6a --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java @@ -0,0 +1,171 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * DLDeviceType device_type; + * int32_t device_id; + * } + * } + */ +public class DLDevice { + + DLDevice() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_INT.withName("device_type"), + dlpack_h.C_INT.withName("device_id") + ).withName("$anon$126:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt device_type$LAYOUT = (OfInt)$LAYOUT.select(groupElement("device_type")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLDeviceType device_type + * } + */ + public static final OfInt device_type$layout() { + return device_type$LAYOUT; + } + + private static final long device_type$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * DLDeviceType device_type + * } + */ + public static final long device_type$offset() { + return device_type$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLDeviceType device_type + * } + */ + public static int device_type(MemorySegment struct) { + return struct.get(device_type$LAYOUT, device_type$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLDeviceType device_type + * } + */ + public static void device_type(MemorySegment struct, int fieldValue) { + struct.set(device_type$LAYOUT, device_type$OFFSET, fieldValue); + } + + private static final OfInt device_id$LAYOUT = (OfInt)$LAYOUT.select(groupElement("device_id")); + + /** + * Layout for field: + * {@snippet lang=c : + * int32_t device_id + * } + */ + public static final OfInt device_id$layout() { + return device_id$LAYOUT; + } + + private static final long device_id$OFFSET = 4; + + /** + * Offset for field: + * {@snippet lang=c : + * int32_t device_id + * } + */ + public static final long device_id$offset() { + return device_id$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * int32_t device_id + * } + */ + public static int device_id(MemorySegment struct) { + return struct.get(device_id$LAYOUT, device_id$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * int32_t device_id + * } + */ + public static void device_id(MemorySegment struct, int fieldValue) { + struct.set(device_id$LAYOUT, device_id$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java new file mode 100644 index 000000000..6d082d344 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java @@ -0,0 +1,273 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.invoke.MethodHandle; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct DLManagedTensor { + * DLTensor dl_tensor; + * void *manager_ctx; + * void (*deleter)(struct DLManagedTensor *); + * } + * } + */ +public class DLManagedTensor { + + DLManagedTensor() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + DLTensor.layout().withName("dl_tensor"), + dlpack_h.C_POINTER.withName("manager_ctx"), + dlpack_h.C_POINTER.withName("deleter") + ).withName("DLManagedTensor"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final GroupLayout dl_tensor$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dl_tensor")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static final GroupLayout dl_tensor$layout() { + return dl_tensor$LAYOUT; + } + + private static final long dl_tensor$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static final long dl_tensor$offset() { + return dl_tensor$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static MemorySegment dl_tensor(MemorySegment struct) { + return struct.asSlice(dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static void dl_tensor(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); + } + + private static final AddressLayout manager_ctx$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("manager_ctx")); + + /** + * Layout for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static final AddressLayout manager_ctx$layout() { + return manager_ctx$LAYOUT; + } + + private static final long manager_ctx$OFFSET = 48; + + /** + * Offset for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static final long manager_ctx$offset() { + return manager_ctx$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static MemorySegment manager_ctx(MemorySegment struct) { + return struct.get(manager_ctx$LAYOUT, manager_ctx$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static void manager_ctx(MemorySegment struct, MemorySegment fieldValue) { + struct.set(manager_ctx$LAYOUT, manager_ctx$OFFSET, fieldValue); + } + + /** + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static class deleter { + + deleter() { + // Should not be called directly + } + + /** + * The function pointer signature, expressed as a functional interface + */ + public interface Function { + void apply(MemorySegment _x0); + } + + private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( + dlpack_h.C_POINTER + ); + + /** + * The descriptor of this function pointer + */ + public static FunctionDescriptor descriptor() { + return $DESC; + } + + private static final MethodHandle UP$MH = dlpack_h.upcallHandle(deleter.Function.class, "apply", $DESC); + + /** + * Allocates a new upcall stub, whose implementation is defined by {@code fi}. + * The lifetime of the returned segment is managed by {@code arena} + */ + public static MemorySegment allocate(deleter.Function fi, Arena arena) { + return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); + } + + private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); + + /** + * Invoke the upcall stub {@code funcPtr}, with given parameters + */ + public static void invoke(MemorySegment funcPtr,MemorySegment _x0) { + try { + DOWN$MH.invokeExact(funcPtr, _x0); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + } + + private static final AddressLayout deleter$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("deleter")); + + /** + * Layout for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static final AddressLayout deleter$layout() { + return deleter$LAYOUT; + } + + private static final long deleter$OFFSET = 56; + + /** + * Offset for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static final long deleter$offset() { + return deleter$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static MemorySegment deleter(MemorySegment struct) { + return struct.get(deleter$LAYOUT, deleter$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensor *) + * } + */ + public static void deleter(MemorySegment struct, MemorySegment fieldValue) { + struct.set(deleter$LAYOUT, deleter$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java new file mode 100644 index 000000000..ca8716551 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java @@ -0,0 +1,366 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.invoke.MethodHandle; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct DLManagedTensorVersioned { + * DLPackVersion version; + * void *manager_ctx; + * void (*deleter)(struct DLManagedTensorVersioned *); + * uint64_t flags; + * DLTensor dl_tensor; + * } + * } + */ +public class DLManagedTensorVersioned { + + DLManagedTensorVersioned() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + DLPackVersion.layout().withName("version"), + dlpack_h.C_POINTER.withName("manager_ctx"), + dlpack_h.C_POINTER.withName("deleter"), + dlpack_h.C_LONG.withName("flags"), + DLTensor.layout().withName("dl_tensor") + ).withName("DLManagedTensorVersioned"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final GroupLayout version$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("version")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLPackVersion version + * } + */ + public static final GroupLayout version$layout() { + return version$LAYOUT; + } + + private static final long version$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * DLPackVersion version + * } + */ + public static final long version$offset() { + return version$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLPackVersion version + * } + */ + public static MemorySegment version(MemorySegment struct) { + return struct.asSlice(version$OFFSET, version$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLPackVersion version + * } + */ + public static void version(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, version$OFFSET, version$LAYOUT.byteSize()); + } + + private static final AddressLayout manager_ctx$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("manager_ctx")); + + /** + * Layout for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static final AddressLayout manager_ctx$layout() { + return manager_ctx$LAYOUT; + } + + private static final long manager_ctx$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static final long manager_ctx$offset() { + return manager_ctx$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static MemorySegment manager_ctx(MemorySegment struct) { + return struct.get(manager_ctx$LAYOUT, manager_ctx$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void *manager_ctx + * } + */ + public static void manager_ctx(MemorySegment struct, MemorySegment fieldValue) { + struct.set(manager_ctx$LAYOUT, manager_ctx$OFFSET, fieldValue); + } + + /** + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static class deleter { + + deleter() { + // Should not be called directly + } + + /** + * The function pointer signature, expressed as a functional interface + */ + public interface Function { + void apply(MemorySegment _x0); + } + + private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( + dlpack_h.C_POINTER + ); + + /** + * The descriptor of this function pointer + */ + public static FunctionDescriptor descriptor() { + return $DESC; + } + + private static final MethodHandle UP$MH = dlpack_h.upcallHandle(deleter.Function.class, "apply", $DESC); + + /** + * Allocates a new upcall stub, whose implementation is defined by {@code fi}. + * The lifetime of the returned segment is managed by {@code arena} + */ + public static MemorySegment allocate(deleter.Function fi, Arena arena) { + return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); + } + + private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); + + /** + * Invoke the upcall stub {@code funcPtr}, with given parameters + */ + public static void invoke(MemorySegment funcPtr,MemorySegment _x0) { + try { + DOWN$MH.invokeExact(funcPtr, _x0); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + } + + private static final AddressLayout deleter$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("deleter")); + + /** + * Layout for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static final AddressLayout deleter$layout() { + return deleter$LAYOUT; + } + + private static final long deleter$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static final long deleter$offset() { + return deleter$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static MemorySegment deleter(MemorySegment struct) { + return struct.get(deleter$LAYOUT, deleter$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void (*deleter)(struct DLManagedTensorVersioned *) + * } + */ + public static void deleter(MemorySegment struct, MemorySegment fieldValue) { + struct.set(deleter$LAYOUT, deleter$OFFSET, fieldValue); + } + + private static final OfLong flags$LAYOUT = (OfLong)$LAYOUT.select(groupElement("flags")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint64_t flags + * } + */ + public static final OfLong flags$layout() { + return flags$LAYOUT; + } + + private static final long flags$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * uint64_t flags + * } + */ + public static final long flags$offset() { + return flags$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint64_t flags + * } + */ + public static long flags(MemorySegment struct) { + return struct.get(flags$LAYOUT, flags$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint64_t flags + * } + */ + public static void flags(MemorySegment struct, long fieldValue) { + struct.set(flags$LAYOUT, flags$OFFSET, fieldValue); + } + + private static final GroupLayout dl_tensor$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dl_tensor")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static final GroupLayout dl_tensor$layout() { + return dl_tensor$LAYOUT; + } + + private static final long dl_tensor$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static final long dl_tensor$offset() { + return dl_tensor$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static MemorySegment dl_tensor(MemorySegment struct) { + return struct.asSlice(dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLTensor dl_tensor + * } + */ + public static void dl_tensor(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dl_tensor$OFFSET, dl_tensor$LAYOUT.byteSize()); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java new file mode 100644 index 000000000..56dec2bae --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java @@ -0,0 +1,171 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * uint32_t major; + * uint32_t minor; + * } + * } + */ +public class DLPackVersion { + + DLPackVersion() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_INT.withName("major"), + dlpack_h.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/java/com/nvidia/cuvs/panama/DLTensor.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java new file mode 100644 index 000000000..cb3aad4fc --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java @@ -0,0 +1,402 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * void *data; + * DLDevice device; + * int32_t ndim; + * DLDataType dtype; + * int64_t *shape; + * int64_t *strides; + * uint64_t byte_offset; + * } + * } + */ +public class DLTensor { + + DLTensor() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_POINTER.withName("data"), + DLDevice.layout().withName("device"), + dlpack_h.C_INT.withName("ndim"), + DLDataType.layout().withName("dtype"), + dlpack_h.C_POINTER.withName("shape"), + dlpack_h.C_POINTER.withName("strides"), + dlpack_h.C_LONG.withName("byte_offset") + ).withName("$anon$192:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final AddressLayout data$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("data")); + + /** + * Layout for field: + * {@snippet lang=c : + * void *data + * } + */ + public static final AddressLayout data$layout() { + return data$LAYOUT; + } + + private static final long data$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * void *data + * } + */ + public static final long data$offset() { + return data$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void *data + * } + */ + public static MemorySegment data(MemorySegment struct) { + return struct.get(data$LAYOUT, data$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void *data + * } + */ + public static void data(MemorySegment struct, MemorySegment fieldValue) { + struct.set(data$LAYOUT, data$OFFSET, fieldValue); + } + + private static final GroupLayout device$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("device")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLDevice device + * } + */ + public static final GroupLayout device$layout() { + return device$LAYOUT; + } + + private static final long device$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * DLDevice device + * } + */ + public static final long device$offset() { + return device$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLDevice device + * } + */ + public static MemorySegment device(MemorySegment struct) { + return struct.asSlice(device$OFFSET, device$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLDevice device + * } + */ + public static void device(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, device$OFFSET, device$LAYOUT.byteSize()); + } + + private static final OfInt ndim$LAYOUT = (OfInt)$LAYOUT.select(groupElement("ndim")); + + /** + * Layout for field: + * {@snippet lang=c : + * int32_t ndim + * } + */ + public static final OfInt ndim$layout() { + return ndim$LAYOUT; + } + + private static final long ndim$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * int32_t ndim + * } + */ + public static final long ndim$offset() { + return ndim$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * int32_t ndim + * } + */ + public static int ndim(MemorySegment struct) { + return struct.get(ndim$LAYOUT, ndim$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * int32_t ndim + * } + */ + public static void ndim(MemorySegment struct, int fieldValue) { + struct.set(ndim$LAYOUT, ndim$OFFSET, fieldValue); + } + + private static final GroupLayout dtype$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dtype")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static final GroupLayout dtype$layout() { + return dtype$LAYOUT; + } + + private static final long dtype$OFFSET = 20; + + /** + * Offset for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static final long dtype$offset() { + return dtype$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static MemorySegment dtype(MemorySegment struct) { + return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static void dtype(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + private static final AddressLayout shape$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("shape")); + + /** + * Layout for field: + * {@snippet lang=c : + * int64_t *shape + * } + */ + public static final AddressLayout shape$layout() { + return shape$LAYOUT; + } + + private static final long shape$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * int64_t *shape + * } + */ + public static final long shape$offset() { + return shape$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * int64_t *shape + * } + */ + public static MemorySegment shape(MemorySegment struct) { + return struct.get(shape$LAYOUT, shape$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * int64_t *shape + * } + */ + public static void shape(MemorySegment struct, MemorySegment fieldValue) { + struct.set(shape$LAYOUT, shape$OFFSET, fieldValue); + } + + private static final AddressLayout strides$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("strides")); + + /** + * Layout for field: + * {@snippet lang=c : + * int64_t *strides + * } + */ + public static final AddressLayout strides$layout() { + return strides$LAYOUT; + } + + private static final long strides$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang=c : + * int64_t *strides + * } + */ + public static final long strides$offset() { + return strides$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * int64_t *strides + * } + */ + public static MemorySegment strides(MemorySegment struct) { + return struct.get(strides$LAYOUT, strides$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * int64_t *strides + * } + */ + public static void strides(MemorySegment struct, MemorySegment fieldValue) { + struct.set(strides$LAYOUT, strides$OFFSET, fieldValue); + } + + private static final OfLong byte_offset$LAYOUT = (OfLong)$LAYOUT.select(groupElement("byte_offset")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint64_t byte_offset + * } + */ + public static final OfLong byte_offset$layout() { + return byte_offset$LAYOUT; + } + + private static final long byte_offset$OFFSET = 40; + + /** + * Offset for field: + * {@snippet lang=c : + * uint64_t byte_offset + * } + */ + public static final long byte_offset$offset() { + return byte_offset$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint64_t byte_offset + * } + */ + public static long byte_offset(MemorySegment struct) { + return struct.get(byte_offset$LAYOUT, byte_offset$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint64_t byte_offset + * } + */ + public static void byte_offset(MemorySegment struct, long fieldValue) { + struct.set(byte_offset$LAYOUT, byte_offset$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java new file mode 100644 index 000000000..714aed5e9 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java @@ -0,0 +1,159 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; +import static java.lang.foreign.MemoryLayout.PathElement.sequenceElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.SequenceLayout; +import java.lang.invoke.VarHandle; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct { + * int __val[2]; + * } + * } + */ +public class __fsid_t { + + __fsid_t() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(MemoryLayout.sequenceLayout(2, dlpack_h.C_INT).withName("__val")).withName("$anon$155:12"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final SequenceLayout __val$LAYOUT = (SequenceLayout) $LAYOUT.select(groupElement("__val")); + + /** + * Layout for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static final SequenceLayout __val$layout() { + return __val$LAYOUT; + } + + private static final long __val$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static final long __val$offset() { + return __val$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static MemorySegment __val(MemorySegment struct) { + return struct.asSlice(__val$OFFSET, __val$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static void __val(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, __val$OFFSET, __val$LAYOUT.byteSize()); + } + + private static long[] __val$DIMS = { 2 }; + + /** + * Dimensions for array field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static long[] __val$dimensions() { + return __val$DIMS; + } + + private static final VarHandle __val$ELEM_HANDLE = __val$LAYOUT.varHandle(sequenceElement()); + + /** + * Indexed getter for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static int __val(MemorySegment struct, long index0) { + return (int) __val$ELEM_HANDLE.get(struct, 0L, index0); + } + + /** + * Indexed setter for field: + * {@snippet lang = c : * int __val[2] + * } + */ + public static void __val(MemorySegment struct, long index0, int fieldValue) { + __val$ELEM_HANDLE.set(struct, 0L, index0, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java new file mode 100644 index 000000000..0af404e19 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java @@ -0,0 +1,2357 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +public class brute_force_h { + + brute_force_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = brute_force_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = brute_force_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = brute_force_h.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 = brute_force_h.C_LONG; + private static final int L2Expanded = (int)0L; + /** + * {@snippet lang=c : + * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + private static final int L2SqrtExpanded = (int)1L; + /** + * {@snippet lang=c : + * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + private static final int CosineExpanded = (int)2L; + /** + * {@snippet lang=c : + * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + private static final int L1 = (int)3L; + /** + * {@snippet lang=c : + * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + private static final int L2Unexpanded = (int)4L; + /** + * {@snippet lang=c : + * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + private static final int L2SqrtUnexpanded = (int)5L; + /** + * {@snippet lang=c : + * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + private static final int InnerProduct = (int)6L; + /** + * {@snippet lang=c : + * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + private static final int Linf = (int)7L; + /** + * {@snippet lang=c : + * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + private static final int Canberra = (int)8L; + /** + * {@snippet lang=c : + * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + private static final int LpUnexpanded = (int)9L; + /** + * {@snippet lang=c : + * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + private static final int CorrelationExpanded = (int)10L; + /** + * {@snippet lang=c : + * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + private static final int JaccardExpanded = (int)11L; + /** + * {@snippet lang=c : + * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + private static final int HellingerExpanded = (int)12L; + /** + * {@snippet lang=c : + * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + private static final int Haversine = (int)13L; + /** + * {@snippet lang=c : + * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + private static final int BrayCurtis = (int)14L; + /** + * {@snippet lang=c : + * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + private static final int JensenShannon = (int)15L; + /** + * {@snippet lang=c : + * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + private static final int HammingUnexpanded = (int)16L; + /** + * {@snippet lang=c : + * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + private static final int KLDivergence = (int)17L; + /** + * {@snippet lang=c : + * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + private static final int RusselRaoExpanded = (int)18L; + /** + * {@snippet lang=c : + * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + private static final int DiceExpanded = (int)19L; + /** + * {@snippet lang=c : + * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + private static final int Precomputed = (int)100L; + /** + * {@snippet lang=c : + * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = brute_force_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = brute_force_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + private static final int NO_FILTER = (int)0L; + /** + * {@snippet lang=c : + * enum cuvsFilterType.NO_FILTER = 0 + * } + */ + public static int NO_FILTER() { + return NO_FILTER; + } + private static final int BITSET = (int)1L; + /** + * {@snippet lang=c : + * enum cuvsFilterType.BITSET = 1 + * } + */ + public static int BITSET() { + return BITSET; + } + private static final int BITMAP = (int)2L; + /** + * {@snippet lang=c : + * enum cuvsFilterType.BITMAP = 2 + * } + */ + public static int BITMAP() { + return BITMAP; + } + /** + * {@snippet lang=c : + * typedef cuvsBruteForceIndex *cuvsBruteForceIndex_t + * } + */ + public static final AddressLayout cuvsBruteForceIndex_t = brute_force_h.C_POINTER; + + private static class cuvsBruteForceIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + brute_force_h.C_INT, + brute_force_h.C_POINTER + ); + + public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsBruteForceIndexCreate$descriptor() { + return cuvsBruteForceIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) + * } + */ + public static MethodHandle cuvsBruteForceIndexCreate$handle() { + return cuvsBruteForceIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) + * } + */ + public static MemorySegment cuvsBruteForceIndexCreate$address() { + return cuvsBruteForceIndexCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) + * } + */ + public static int cuvsBruteForceIndexCreate(MemorySegment index) { + var mh$ = cuvsBruteForceIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsBruteForceIndexCreate", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsBruteForceIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + brute_force_h.C_INT, + brute_force_h.C_POINTER + ); + + public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) + * } + */ + public static FunctionDescriptor cuvsBruteForceIndexDestroy$descriptor() { + return cuvsBruteForceIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) + * } + */ + public static MethodHandle cuvsBruteForceIndexDestroy$handle() { + return cuvsBruteForceIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) + * } + */ + public static MemorySegment cuvsBruteForceIndexDestroy$address() { + return cuvsBruteForceIndexDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) + * } + */ + public static int cuvsBruteForceIndexDestroy(MemorySegment index) { + var mh$ = cuvsBruteForceIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsBruteForceIndexDestroy", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsBruteForceBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + brute_force_h.C_INT, + brute_force_h.C_LONG, + brute_force_h.C_POINTER, + brute_force_h.C_INT, + brute_force_h.C_FLOAT, + brute_force_h.C_POINTER + ); + + public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) + * } + */ + public static FunctionDescriptor cuvsBruteForceBuild$descriptor() { + return cuvsBruteForceBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) + * } + */ + public static MethodHandle cuvsBruteForceBuild$handle() { + return cuvsBruteForceBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) + * } + */ + public static MemorySegment cuvsBruteForceBuild$address() { + return cuvsBruteForceBuild.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) + * } + */ + public static int cuvsBruteForceBuild(long res, MemorySegment dataset, int metric, float metric_arg, MemorySegment index) { + var mh$ = cuvsBruteForceBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsBruteForceBuild", res, dataset, metric, metric_arg, index); + } + return (int)mh$.invokeExact(res, dataset, metric, metric_arg, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsBruteForceSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + brute_force_h.C_INT, + brute_force_h.C_LONG, + brute_force_h.C_POINTER, + brute_force_h.C_POINTER, + brute_force_h.C_POINTER, + brute_force_h.C_POINTER, + cuvsFilter.layout() + ); + + public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) + * } + */ + public static FunctionDescriptor cuvsBruteForceSearch$descriptor() { + return cuvsBruteForceSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) + * } + */ + public static MethodHandle cuvsBruteForceSearch$handle() { + return cuvsBruteForceSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) + * } + */ + public static MemorySegment cuvsBruteForceSearch$address() { + return cuvsBruteForceSearch.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) + * } + */ + public static int cuvsBruteForceSearch(long res, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances, MemorySegment prefilter) { + var mh$ = cuvsBruteForceSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsBruteForceSearch", res, index, queries, neighbors, distances, prefilter); + } + return (int)mh$.invokeExact(res, index, queries, neighbors, distances, prefilter); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java new file mode 100644 index 000000000..27e7888bc --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java @@ -0,0 +1,2051 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; + +public class cagra_h { + + cagra_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int true_ = (int)1L; + /** + * {@snippet lang=c : + * #define true 1 + * } + */ + public static int true_() { + return true_; + } + private static final int false_ = (int)0L; + /** + * {@snippet lang=c : + * #define false 0 + * } + */ + public static int false_() { + return false_; + } + private static final int __bool_true_false_are_defined = (int)1L; + /** + * {@snippet lang=c : + * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = cagra_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = cagra_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = cagra_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = cagra_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = cagra_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = cagra_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + private static final int AUTO_SELECT = (int)0L; + /** + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 + * } + */ + public static int AUTO_SELECT() { + return AUTO_SELECT; + } + private static final int IVF_PQ = (int)1L; + /** + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 + * } + */ + public static int IVF_PQ() { + return IVF_PQ; + } + private static final int NN_DESCENT = (int)2L; + /** + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 + * } + */ + public static int NN_DESCENT() { + return NN_DESCENT; + } + /** + * {@snippet lang=c : + * typedef struct cuvsCagraCompressionParams { + * uint32_t pq_bits; + * uint32_t pq_dim; + * uint32_t vq_n_centers; + * uint32_t kmeans_n_iters; + * double vq_kmeans_trainset_fraction; + * double pq_kmeans_trainset_fraction; + * } *cuvsCagraCompressionParams_t + * } + */ + public static final AddressLayout cuvsCagraCompressionParams_t = cagra_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef struct cuvsCagraIndexParams { + * size_t intermediate_graph_degree; + * size_t graph_degree; + * enum cuvsCagraGraphBuildAlgo build_algo; + * size_t nn_descent_niter; + * cuvsCagraCompressionParams_t compression; + * } *cuvsCagraIndexParams_t + * } + */ + public static final AddressLayout cuvsCagraIndexParams_t = cagra_h.C_POINTER; + private static final int SINGLE_CTA = (int)0L; + /** + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo.SINGLE_CTA = 0 + * } + */ + public static int SINGLE_CTA() { + return SINGLE_CTA; + } + private static final int MULTI_CTA = (int)1L; + /** + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo.MULTI_CTA = 1 + * } + */ + public static int MULTI_CTA() { + return MULTI_CTA; + } + private static final int MULTI_KERNEL = (int)2L; + /** + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo.MULTI_KERNEL = 2 + * } + */ + public static int MULTI_KERNEL() { + return MULTI_KERNEL; + } + private static final int AUTO = (int)3L; + /** + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo.AUTO = 3 + * } + */ + public static int AUTO() { + return AUTO; + } + private static final int HASH = (int)0L; + /** + * {@snippet lang=c : + * enum cuvsCagraHashMode.HASH = 0 + * } + */ + public static int HASH() { + return HASH; + } + private static final int SMALL = (int)1L; + /** + * {@snippet lang=c : + * enum cuvsCagraHashMode.SMALL = 1 + * } + */ + public static int SMALL() { + return SMALL; + } + private static final int AUTO_HASH = (int)2L; + /** + * {@snippet lang=c : + * enum cuvsCagraHashMode.AUTO_HASH = 2 + * } + */ + public static int AUTO_HASH() { + return AUTO_HASH; + } + /** + * {@snippet lang=c : + * typedef struct cuvsCagraSearchParams { + * size_t max_queries; + * size_t itopk_size; + * size_t max_iterations; + * enum cuvsCagraSearchAlgo algo; + * size_t team_size; + * size_t search_width; + * size_t min_iterations; + * size_t thread_block_size; + * enum cuvsCagraHashMode hashmap_mode; + * size_t hashmap_min_bitlen; + * float hashmap_max_fill_rate; + * uint32_t num_random_samplings; + * uint64_t rand_xor_mask; + * } *cuvsCagraSearchParams_t + * } + */ + public static final AddressLayout cuvsCagraSearchParams_t = cagra_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef cuvsCagraIndex *cuvsCagraIndex_t + * } + */ + public static final AddressLayout cuvsCagraIndex_t = cagra_h.C_POINTER; + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + 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/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java new file mode 100644 index 000000000..b81d453cf --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java @@ -0,0 +1,356 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfDouble; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct cuvsCagraCompressionParams { + * uint32_t pq_bits; + * uint32_t pq_dim; + * uint32_t vq_n_centers; + * uint32_t kmeans_n_iters; + * double vq_kmeans_trainset_fraction; + * double pq_kmeans_trainset_fraction; + * } + * } + */ +public class cuvsCagraCompressionParams { + + cuvsCagraCompressionParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + cagra_h.C_INT.withName("pq_bits"), + cagra_h.C_INT.withName("pq_dim"), + cagra_h.C_INT.withName("vq_n_centers"), + cagra_h.C_INT.withName("kmeans_n_iters"), + cagra_h.C_DOUBLE.withName("vq_kmeans_trainset_fraction"), + cagra_h.C_DOUBLE.withName("pq_kmeans_trainset_fraction") + ).withName("cuvsCagraCompressionParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt pq_bits$LAYOUT = (OfInt)$LAYOUT.select(groupElement("pq_bits")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t pq_bits + * } + */ + public static final OfInt pq_bits$layout() { + return pq_bits$LAYOUT; + } + + private static final long pq_bits$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t pq_bits + * } + */ + public static final long pq_bits$offset() { + return pq_bits$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t pq_bits + * } + */ + public static int pq_bits(MemorySegment struct) { + return struct.get(pq_bits$LAYOUT, pq_bits$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t pq_bits + * } + */ + public static void pq_bits(MemorySegment struct, int fieldValue) { + struct.set(pq_bits$LAYOUT, pq_bits$OFFSET, fieldValue); + } + + private static final OfInt pq_dim$LAYOUT = (OfInt)$LAYOUT.select(groupElement("pq_dim")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t pq_dim + * } + */ + public static final OfInt pq_dim$layout() { + return pq_dim$LAYOUT; + } + + private static final long pq_dim$OFFSET = 4; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t pq_dim + * } + */ + public static final long pq_dim$offset() { + return pq_dim$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t pq_dim + * } + */ + public static int pq_dim(MemorySegment struct) { + return struct.get(pq_dim$LAYOUT, pq_dim$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t pq_dim + * } + */ + public static void pq_dim(MemorySegment struct, int fieldValue) { + struct.set(pq_dim$LAYOUT, pq_dim$OFFSET, fieldValue); + } + + private static final OfInt vq_n_centers$LAYOUT = (OfInt)$LAYOUT.select(groupElement("vq_n_centers")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t vq_n_centers + * } + */ + public static final OfInt vq_n_centers$layout() { + return vq_n_centers$LAYOUT; + } + + private static final long vq_n_centers$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t vq_n_centers + * } + */ + public static final long vq_n_centers$offset() { + return vq_n_centers$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t vq_n_centers + * } + */ + public static int vq_n_centers(MemorySegment struct) { + return struct.get(vq_n_centers$LAYOUT, vq_n_centers$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t vq_n_centers + * } + */ + public static void vq_n_centers(MemorySegment struct, int fieldValue) { + struct.set(vq_n_centers$LAYOUT, vq_n_centers$OFFSET, fieldValue); + } + + private static final OfInt kmeans_n_iters$LAYOUT = (OfInt)$LAYOUT.select(groupElement("kmeans_n_iters")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t kmeans_n_iters + * } + */ + public static final OfInt kmeans_n_iters$layout() { + return kmeans_n_iters$LAYOUT; + } + + private static final long kmeans_n_iters$OFFSET = 12; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t kmeans_n_iters + * } + */ + public static final long kmeans_n_iters$offset() { + return kmeans_n_iters$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t kmeans_n_iters + * } + */ + public static int kmeans_n_iters(MemorySegment struct) { + return struct.get(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t kmeans_n_iters + * } + */ + public static void kmeans_n_iters(MemorySegment struct, int fieldValue) { + struct.set(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET, fieldValue); + } + + private static final OfDouble vq_kmeans_trainset_fraction$LAYOUT = (OfDouble)$LAYOUT.select(groupElement("vq_kmeans_trainset_fraction")); + + /** + * Layout for field: + * {@snippet lang=c : + * double vq_kmeans_trainset_fraction + * } + */ + public static final OfDouble vq_kmeans_trainset_fraction$layout() { + return vq_kmeans_trainset_fraction$LAYOUT; + } + + private static final long vq_kmeans_trainset_fraction$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * double vq_kmeans_trainset_fraction + * } + */ + public static final long vq_kmeans_trainset_fraction$offset() { + return vq_kmeans_trainset_fraction$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * double vq_kmeans_trainset_fraction + * } + */ + public static double vq_kmeans_trainset_fraction(MemorySegment struct) { + return struct.get(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * double vq_kmeans_trainset_fraction + * } + */ + public static void vq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { + struct.set(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET, fieldValue); + } + + private static final OfDouble pq_kmeans_trainset_fraction$LAYOUT = (OfDouble)$LAYOUT.select(groupElement("pq_kmeans_trainset_fraction")); + + /** + * Layout for field: + * {@snippet lang=c : + * double pq_kmeans_trainset_fraction + * } + */ + public static final OfDouble pq_kmeans_trainset_fraction$layout() { + return pq_kmeans_trainset_fraction$LAYOUT; + } + + private static final long pq_kmeans_trainset_fraction$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * double pq_kmeans_trainset_fraction + * } + */ + public static final long pq_kmeans_trainset_fraction$offset() { + return pq_kmeans_trainset_fraction$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * double pq_kmeans_trainset_fraction + * } + */ + public static double pq_kmeans_trainset_fraction(MemorySegment struct) { + return struct.get(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * double pq_kmeans_trainset_fraction + * } + */ + public static void pq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { + struct.set(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java new file mode 100644 index 000000000..a18ebae86 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java @@ -0,0 +1,172 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * uintptr_t addr; + * DLDataType dtype; + * } + * } + */ +public class cuvsCagraIndex { + + cuvsCagraIndex() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + cagra_h.C_LONG.withName("addr"), + DLDataType.layout().withName("dtype"), + MemoryLayout.paddingLayout(4) + ).withName("$anon$175:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong addr$LAYOUT = (OfLong)$LAYOUT.select(groupElement("addr")); + + /** + * Layout for field: + * {@snippet lang=c : + * uintptr_t addr + * } + */ + public static final OfLong addr$layout() { + return addr$LAYOUT; + } + + private static final long addr$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * uintptr_t addr + * } + */ + public static final long addr$offset() { + return addr$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uintptr_t addr + * } + */ + public static long addr(MemorySegment struct) { + return struct.get(addr$LAYOUT, addr$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uintptr_t addr + * } + */ + public static void addr(MemorySegment struct, long fieldValue) { + struct.set(addr$LAYOUT, addr$OFFSET, fieldValue); + } + + private static final GroupLayout dtype$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dtype")); + + /** + * Layout for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static final GroupLayout dtype$layout() { + return dtype$LAYOUT; + } + + private static final long dtype$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static final long dtype$offset() { + return dtype$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static MemorySegment dtype(MemorySegment struct) { + return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * DLDataType dtype + * } + */ + public static void dtype(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java new file mode 100644 index 000000000..aaa87af8e --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java @@ -0,0 +1,265 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct cuvsCagraIndexParams { + * size_t intermediate_graph_degree; + * size_t graph_degree; + * enum cuvsCagraGraphBuildAlgo build_algo; + * size_t nn_descent_niter; + * } + * } + */ +public class cuvsCagraIndexParams { + + cuvsCagraIndexParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + cagra_h.C_LONG.withName("intermediate_graph_degree"), + cagra_h.C_LONG.withName("graph_degree"), + cagra_h.C_INT.withName("build_algo"), + MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("nn_descent_niter") + ).withName("cuvsCagraIndexParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong intermediate_graph_degree$LAYOUT = (OfLong)$LAYOUT.select(groupElement("intermediate_graph_degree")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t intermediate_graph_degree + * } + */ + public static final OfLong intermediate_graph_degree$layout() { + return intermediate_graph_degree$LAYOUT; + } + + private static final long intermediate_graph_degree$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t intermediate_graph_degree + * } + */ + public static final long intermediate_graph_degree$offset() { + return intermediate_graph_degree$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t intermediate_graph_degree + * } + */ + public static long intermediate_graph_degree(MemorySegment struct) { + return struct.get(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t intermediate_graph_degree + * } + */ + public static void intermediate_graph_degree(MemorySegment struct, long fieldValue) { + struct.set(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET, fieldValue); + } + + private static final OfLong graph_degree$LAYOUT = (OfLong)$LAYOUT.select(groupElement("graph_degree")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t graph_degree + * } + */ + public static final OfLong graph_degree$layout() { + return graph_degree$LAYOUT; + } + + private static final long graph_degree$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t graph_degree + * } + */ + public static final long graph_degree$offset() { + return graph_degree$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t graph_degree + * } + */ + public static long graph_degree(MemorySegment struct) { + return struct.get(graph_degree$LAYOUT, graph_degree$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t graph_degree + * } + */ + public static void graph_degree(MemorySegment struct, long fieldValue) { + struct.set(graph_degree$LAYOUT, graph_degree$OFFSET, fieldValue); + } + + private static final OfInt build_algo$LAYOUT = (OfInt)$LAYOUT.select(groupElement("build_algo")); + + /** + * Layout for field: + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static final OfInt build_algo$layout() { + return build_algo$LAYOUT; + } + + private static final long build_algo$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static final long build_algo$offset() { + return build_algo$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static int build_algo(MemorySegment struct) { + return struct.get(build_algo$LAYOUT, build_algo$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static void build_algo(MemorySegment struct, int fieldValue) { + struct.set(build_algo$LAYOUT, build_algo$OFFSET, fieldValue); + } + + private static final OfLong nn_descent_niter$LAYOUT = (OfLong)$LAYOUT.select(groupElement("nn_descent_niter")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t nn_descent_niter + * } + */ + public static final OfLong nn_descent_niter$layout() { + return nn_descent_niter$LAYOUT; + } + + private static final long nn_descent_niter$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t nn_descent_niter + * } + */ + public static final long nn_descent_niter$offset() { + return nn_descent_niter$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t nn_descent_niter + * } + */ + public static long nn_descent_niter(MemorySegment struct) { + return struct.get(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t nn_descent_niter + * } + */ + public static void nn_descent_niter(MemorySegment struct, long fieldValue) { + struct.set(nn_descent_niter$LAYOUT, nn_descent_niter$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/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java new file mode 100644 index 000000000..4011df7e5 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java @@ -0,0 +1,681 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfFloat; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct cuvsCagraSearchParams { + * size_t max_queries; + * size_t itopk_size; + * size_t max_iterations; + * enum cuvsCagraSearchAlgo algo; + * size_t team_size; + * size_t search_width; + * size_t min_iterations; + * size_t thread_block_size; + * enum cuvsCagraHashMode hashmap_mode; + * size_t hashmap_min_bitlen; + * float hashmap_max_fill_rate; + * uint32_t num_random_samplings; + * uint64_t rand_xor_mask; + * } + * } + */ +public class cuvsCagraSearchParams { + + cuvsCagraSearchParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + cagra_h.C_LONG.withName("max_queries"), + cagra_h.C_LONG.withName("itopk_size"), + cagra_h.C_LONG.withName("max_iterations"), + cagra_h.C_INT.withName("algo"), + MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("team_size"), + cagra_h.C_LONG.withName("search_width"), + cagra_h.C_LONG.withName("min_iterations"), + cagra_h.C_LONG.withName("thread_block_size"), + cagra_h.C_INT.withName("hashmap_mode"), + MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("hashmap_min_bitlen"), + cagra_h.C_FLOAT.withName("hashmap_max_fill_rate"), + cagra_h.C_INT.withName("num_random_samplings"), + cagra_h.C_LONG.withName("rand_xor_mask") + ).withName("cuvsCagraSearchParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong max_queries$LAYOUT = (OfLong)$LAYOUT.select(groupElement("max_queries")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t max_queries + * } + */ + public static final OfLong max_queries$layout() { + return max_queries$LAYOUT; + } + + private static final long max_queries$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t max_queries + * } + */ + public static final long max_queries$offset() { + return max_queries$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t max_queries + * } + */ + public static long max_queries(MemorySegment struct) { + return struct.get(max_queries$LAYOUT, max_queries$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t max_queries + * } + */ + public static void max_queries(MemorySegment struct, long fieldValue) { + struct.set(max_queries$LAYOUT, max_queries$OFFSET, fieldValue); + } + + private static final OfLong itopk_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("itopk_size")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t itopk_size + * } + */ + public static final OfLong itopk_size$layout() { + return itopk_size$LAYOUT; + } + + private static final long itopk_size$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t itopk_size + * } + */ + public static final long itopk_size$offset() { + return itopk_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t itopk_size + * } + */ + public static long itopk_size(MemorySegment struct) { + return struct.get(itopk_size$LAYOUT, itopk_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t itopk_size + * } + */ + public static void itopk_size(MemorySegment struct, long fieldValue) { + struct.set(itopk_size$LAYOUT, itopk_size$OFFSET, fieldValue); + } + + private static final OfLong max_iterations$LAYOUT = (OfLong)$LAYOUT.select(groupElement("max_iterations")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t max_iterations + * } + */ + public static final OfLong max_iterations$layout() { + return max_iterations$LAYOUT; + } + + private static final long max_iterations$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t max_iterations + * } + */ + public static final long max_iterations$offset() { + return max_iterations$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t max_iterations + * } + */ + public static long max_iterations(MemorySegment struct) { + return struct.get(max_iterations$LAYOUT, max_iterations$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t max_iterations + * } + */ + public static void max_iterations(MemorySegment struct, long fieldValue) { + struct.set(max_iterations$LAYOUT, max_iterations$OFFSET, fieldValue); + } + + private static final OfInt algo$LAYOUT = (OfInt)$LAYOUT.select(groupElement("algo")); + + /** + * Layout for field: + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo algo + * } + */ + public static final OfInt algo$layout() { + return algo$LAYOUT; + } + + private static final long algo$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo algo + * } + */ + public static final long algo$offset() { + return algo$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo algo + * } + */ + public static int algo(MemorySegment struct) { + return struct.get(algo$LAYOUT, algo$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * enum cuvsCagraSearchAlgo algo + * } + */ + public static void algo(MemorySegment struct, int fieldValue) { + struct.set(algo$LAYOUT, algo$OFFSET, fieldValue); + } + + private static final OfLong team_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("team_size")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t team_size + * } + */ + public static final OfLong team_size$layout() { + return team_size$LAYOUT; + } + + private static final long team_size$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t team_size + * } + */ + public static final long team_size$offset() { + return team_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t team_size + * } + */ + public static long team_size(MemorySegment struct) { + return struct.get(team_size$LAYOUT, team_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t team_size + * } + */ + public static void team_size(MemorySegment struct, long fieldValue) { + struct.set(team_size$LAYOUT, team_size$OFFSET, fieldValue); + } + + private static final OfLong search_width$LAYOUT = (OfLong)$LAYOUT.select(groupElement("search_width")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t search_width + * } + */ + public static final OfLong search_width$layout() { + return search_width$LAYOUT; + } + + private static final long search_width$OFFSET = 40; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t search_width + * } + */ + public static final long search_width$offset() { + return search_width$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t search_width + * } + */ + public static long search_width(MemorySegment struct) { + return struct.get(search_width$LAYOUT, search_width$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t search_width + * } + */ + public static void search_width(MemorySegment struct, long fieldValue) { + struct.set(search_width$LAYOUT, search_width$OFFSET, fieldValue); + } + + private static final OfLong min_iterations$LAYOUT = (OfLong)$LAYOUT.select(groupElement("min_iterations")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t min_iterations + * } + */ + public static final OfLong min_iterations$layout() { + return min_iterations$LAYOUT; + } + + private static final long min_iterations$OFFSET = 48; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t min_iterations + * } + */ + public static final long min_iterations$offset() { + return min_iterations$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t min_iterations + * } + */ + public static long min_iterations(MemorySegment struct) { + return struct.get(min_iterations$LAYOUT, min_iterations$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t min_iterations + * } + */ + public static void min_iterations(MemorySegment struct, long fieldValue) { + struct.set(min_iterations$LAYOUT, min_iterations$OFFSET, fieldValue); + } + + private static final OfLong thread_block_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("thread_block_size")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t thread_block_size + * } + */ + public static final OfLong thread_block_size$layout() { + return thread_block_size$LAYOUT; + } + + private static final long thread_block_size$OFFSET = 56; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t thread_block_size + * } + */ + public static final long thread_block_size$offset() { + return thread_block_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t thread_block_size + * } + */ + public static long thread_block_size(MemorySegment struct) { + return struct.get(thread_block_size$LAYOUT, thread_block_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t thread_block_size + * } + */ + public static void thread_block_size(MemorySegment struct, long fieldValue) { + struct.set(thread_block_size$LAYOUT, thread_block_size$OFFSET, fieldValue); + } + + private static final OfInt hashmap_mode$LAYOUT = (OfInt)$LAYOUT.select(groupElement("hashmap_mode")); + + /** + * Layout for field: + * {@snippet lang=c : + * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static final OfInt hashmap_mode$layout() { + return hashmap_mode$LAYOUT; + } + + private static final long hashmap_mode$OFFSET = 64; + + /** + * Offset for field: + * {@snippet lang=c : + * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static final long hashmap_mode$offset() { + return hashmap_mode$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static int hashmap_mode(MemorySegment struct) { + return struct.get(hashmap_mode$LAYOUT, hashmap_mode$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static void hashmap_mode(MemorySegment struct, int fieldValue) { + struct.set(hashmap_mode$LAYOUT, hashmap_mode$OFFSET, fieldValue); + } + + private static final OfLong hashmap_min_bitlen$LAYOUT = (OfLong)$LAYOUT.select(groupElement("hashmap_min_bitlen")); + + /** + * Layout for field: + * {@snippet lang=c : + * size_t hashmap_min_bitlen + * } + */ + public static final OfLong hashmap_min_bitlen$layout() { + return hashmap_min_bitlen$LAYOUT; + } + + private static final long hashmap_min_bitlen$OFFSET = 72; + + /** + * Offset for field: + * {@snippet lang=c : + * size_t hashmap_min_bitlen + * } + */ + public static final long hashmap_min_bitlen$offset() { + return hashmap_min_bitlen$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * size_t hashmap_min_bitlen + * } + */ + public static long hashmap_min_bitlen(MemorySegment struct) { + return struct.get(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * size_t hashmap_min_bitlen + * } + */ + public static void hashmap_min_bitlen(MemorySegment struct, long fieldValue) { + struct.set(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET, fieldValue); + } + + private static final OfFloat hashmap_max_fill_rate$LAYOUT = (OfFloat)$LAYOUT.select(groupElement("hashmap_max_fill_rate")); + + /** + * Layout for field: + * {@snippet lang=c : + * float hashmap_max_fill_rate + * } + */ + public static final OfFloat hashmap_max_fill_rate$layout() { + return hashmap_max_fill_rate$LAYOUT; + } + + private static final long hashmap_max_fill_rate$OFFSET = 80; + + /** + * Offset for field: + * {@snippet lang=c : + * float hashmap_max_fill_rate + * } + */ + public static final long hashmap_max_fill_rate$offset() { + return hashmap_max_fill_rate$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * float hashmap_max_fill_rate + * } + */ + public static float hashmap_max_fill_rate(MemorySegment struct) { + return struct.get(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * float hashmap_max_fill_rate + * } + */ + public static void hashmap_max_fill_rate(MemorySegment struct, float fieldValue) { + struct.set(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET, fieldValue); + } + + private static final OfInt num_random_samplings$LAYOUT = (OfInt)$LAYOUT.select(groupElement("num_random_samplings")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t num_random_samplings + * } + */ + public static final OfInt num_random_samplings$layout() { + return num_random_samplings$LAYOUT; + } + + private static final long num_random_samplings$OFFSET = 84; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t num_random_samplings + * } + */ + public static final long num_random_samplings$offset() { + return num_random_samplings$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t num_random_samplings + * } + */ + public static int num_random_samplings(MemorySegment struct) { + return struct.get(num_random_samplings$LAYOUT, num_random_samplings$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t num_random_samplings + * } + */ + public static void num_random_samplings(MemorySegment struct, int fieldValue) { + struct.set(num_random_samplings$LAYOUT, num_random_samplings$OFFSET, fieldValue); + } + + private static final OfLong rand_xor_mask$LAYOUT = (OfLong)$LAYOUT.select(groupElement("rand_xor_mask")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint64_t rand_xor_mask + * } + */ + public static final OfLong rand_xor_mask$layout() { + return rand_xor_mask$LAYOUT; + } + + private static final long rand_xor_mask$OFFSET = 88; + + /** + * Offset for field: + * {@snippet lang=c : + * uint64_t rand_xor_mask + * } + */ + public static final long rand_xor_mask$offset() { + return rand_xor_mask$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint64_t rand_xor_mask + * } + */ + public static long rand_xor_mask(MemorySegment struct) { + return struct.get(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint64_t rand_xor_mask + * } + */ + public static void rand_xor_mask(MemorySegment struct, long fieldValue) { + struct.set(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java new file mode 100644 index 000000000..61d0e4625 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java @@ -0,0 +1,172 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +/** + * {@snippet lang=c : + * struct { + * uintptr_t addr; + * enum cuvsFilterType type; + * } + * } + */ +public class cuvsFilter { + + cuvsFilter() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + brute_force_h.C_LONG.withName("addr"), + brute_force_h.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/java/com/nvidia/cuvs/panama/dlpack_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java new file mode 100644 index 000000000..3afc5c792 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java @@ -0,0 +1,1883 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; + +public class dlpack_h { + + dlpack_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = dlpack_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = dlpack_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = dlpack_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = dlpack_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = dlpack_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = dlpack_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = dlpack_h.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/java/com/nvidia/cuvs/panama/hnsw_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java new file mode 100644 index 000000000..4835982f1 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java @@ -0,0 +1,2482 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +public class hnsw_h { + + hnsw_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int true_ = (int)1L; + /** + * {@snippet lang=c : + * #define true 1 + * } + */ + public static int true_() { + return true_; + } + private static final int false_ = (int)0L; + /** + * {@snippet lang=c : + * #define false 0 + * } + */ + public static int false_() { + return false_; + } + private static final int __bool_true_false_are_defined = (int)1L; + /** + * {@snippet lang=c : + * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = hnsw_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = hnsw_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = hnsw_h.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 = hnsw_h.C_LONG; + private static final int L2Expanded = (int)0L; + /** + * {@snippet lang=c : + * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + private static final int L2SqrtExpanded = (int)1L; + /** + * {@snippet lang=c : + * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + private static final int CosineExpanded = (int)2L; + /** + * {@snippet lang=c : + * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + private static final int L1 = (int)3L; + /** + * {@snippet lang=c : + * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + private static final int L2Unexpanded = (int)4L; + /** + * {@snippet lang=c : + * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + private static final int L2SqrtUnexpanded = (int)5L; + /** + * {@snippet lang=c : + * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + private static final int InnerProduct = (int)6L; + /** + * {@snippet lang=c : + * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + private static final int Linf = (int)7L; + /** + * {@snippet lang=c : + * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + private static final int Canberra = (int)8L; + /** + * {@snippet lang=c : + * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + private static final int LpUnexpanded = (int)9L; + /** + * {@snippet lang=c : + * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + private static final int CorrelationExpanded = (int)10L; + /** + * {@snippet lang=c : + * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + private static final int JaccardExpanded = (int)11L; + /** + * {@snippet lang=c : + * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + private static final int HellingerExpanded = (int)12L; + /** + * {@snippet lang=c : + * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + private static final int Haversine = (int)13L; + /** + * {@snippet lang=c : + * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + private static final int BrayCurtis = (int)14L; + /** + * {@snippet lang=c : + * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + private static final int JensenShannon = (int)15L; + /** + * {@snippet lang=c : + * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + private static final int HammingUnexpanded = (int)16L; + /** + * {@snippet lang=c : + * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + private static final int KLDivergence = (int)17L; + /** + * {@snippet lang=c : + * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + private static final int RusselRaoExpanded = (int)18L; + /** + * {@snippet lang=c : + * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + private static final int DiceExpanded = (int)19L; + /** + * {@snippet lang=c : + * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + private static final int Precomputed = (int)100L; + /** + * {@snippet lang=c : + * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = hnsw_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = hnsw_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + /** + * {@snippet lang=c : + * typedef struct cuvsHnswSearchParams { + * int32_t ef; + * int32_t numThreads; + * } *cuvsHnswSearchParams_t + * } + */ + public static final AddressLayout cuvsHnswSearchParams_t = hnsw_h.C_POINTER; + + private static class cuvsHnswSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsHnswSearchParamsCreate$descriptor() { + return cuvsHnswSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static MethodHandle cuvsHnswSearchParamsCreate$handle() { + return cuvsHnswSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static MemorySegment cuvsHnswSearchParamsCreate$address() { + return cuvsHnswSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static int cuvsHnswSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsHnswSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearchParamsCreate", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsHnswSearchParamsDestroy$descriptor() { + return cuvsHnswSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static MethodHandle cuvsHnswSearchParamsDestroy$handle() { + return cuvsHnswSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static MemorySegment cuvsHnswSearchParamsDestroy$address() { + return cuvsHnswSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static int cuvsHnswSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsHnswSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearchParamsDestroy", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef cuvsHnswIndex *cuvsHnswIndex_t + * } + */ + public static final AddressLayout cuvsHnswIndex_t = hnsw_h.C_POINTER; + + private static class cuvsHnswIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsHnswIndexCreate$descriptor() { + return cuvsHnswIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static MethodHandle cuvsHnswIndexCreate$handle() { + return cuvsHnswIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static MemorySegment cuvsHnswIndexCreate$address() { + return cuvsHnswIndexCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static int cuvsHnswIndexCreate(MemorySegment index) { + var mh$ = cuvsHnswIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswIndexCreate", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static FunctionDescriptor cuvsHnswIndexDestroy$descriptor() { + return cuvsHnswIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static MethodHandle cuvsHnswIndexDestroy$handle() { + return cuvsHnswIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static MemorySegment cuvsHnswIndexDestroy$address() { + return cuvsHnswIndexDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static int cuvsHnswIndexDestroy(MemorySegment index) { + var mh$ = cuvsHnswIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswIndexDestroy", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_LONG, + hnsw_h.C_POINTER, + hnsw_h.C_POINTER, + hnsw_h.C_POINTER, + hnsw_h.C_POINTER, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsHnswSearch$descriptor() { + return cuvsHnswSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsHnswSearch$handle() { + return cuvsHnswSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsHnswSearch$address() { + return cuvsHnswSearch.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsHnswSearch(long res, MemorySegment params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsHnswSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearch", res, params, index, queries, neighbors, distances); + } + return (int)mh$.invokeExact(res, params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + hnsw_h.C_INT, + hnsw_h.C_LONG, + hnsw_h.C_POINTER, + hnsw_h.C_INT, + hnsw_h.C_INT, + hnsw_h.C_POINTER + ); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static FunctionDescriptor cuvsHnswDeserialize$descriptor() { + return cuvsHnswDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static MethodHandle cuvsHnswDeserialize$handle() { + return cuvsHnswDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static MemorySegment cuvsHnswDeserialize$address() { + return cuvsHnswDeserialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static int cuvsHnswDeserialize(long res, MemorySegment filename, int dim, int metric, MemorySegment index) { + var mh$ = cuvsHnswDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswDeserialize", res, filename, dim, metric, index); + } + return (int)mh$.invokeExact(res, filename, dim, metric, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java new file mode 100644 index 000000000..0848589b6 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java @@ -0,0 +1,2792 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +public class ivf_flat_h { + + ivf_flat_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int true_ = (int)1L; + /** + * {@snippet lang=c : + * #define true 1 + * } + */ + public static int true_() { + return true_; + } + private static final int false_ = (int)0L; + /** + * {@snippet lang=c : + * #define false 0 + * } + */ + public static int false_() { + return false_; + } + private static final int __bool_true_false_are_defined = (int)1L; + /** + * {@snippet lang=c : + * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = ivf_flat_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = ivf_flat_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = ivf_flat_h.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 = ivf_flat_h.C_LONG; + private static final int L2Expanded = (int)0L; + /** + * {@snippet lang=c : + * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + private static final int L2SqrtExpanded = (int)1L; + /** + * {@snippet lang=c : + * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + private static final int CosineExpanded = (int)2L; + /** + * {@snippet lang=c : + * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + private static final int L1 = (int)3L; + /** + * {@snippet lang=c : + * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + private static final int L2Unexpanded = (int)4L; + /** + * {@snippet lang=c : + * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + private static final int L2SqrtUnexpanded = (int)5L; + /** + * {@snippet lang=c : + * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + private static final int InnerProduct = (int)6L; + /** + * {@snippet lang=c : + * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + private static final int Linf = (int)7L; + /** + * {@snippet lang=c : + * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + private static final int Canberra = (int)8L; + /** + * {@snippet lang=c : + * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + private static final int LpUnexpanded = (int)9L; + /** + * {@snippet lang=c : + * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + private static final int CorrelationExpanded = (int)10L; + /** + * {@snippet lang=c : + * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + private static final int JaccardExpanded = (int)11L; + /** + * {@snippet lang=c : + * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + private static final int HellingerExpanded = (int)12L; + /** + * {@snippet lang=c : + * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + private static final int Haversine = (int)13L; + /** + * {@snippet lang=c : + * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + private static final int BrayCurtis = (int)14L; + /** + * {@snippet lang=c : + * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + private static final int JensenShannon = (int)15L; + /** + * {@snippet lang=c : + * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + private static final int HammingUnexpanded = (int)16L; + /** + * {@snippet lang=c : + * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + private static final int KLDivergence = (int)17L; + /** + * {@snippet lang=c : + * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + private static final int RusselRaoExpanded = (int)18L; + /** + * {@snippet lang=c : + * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + private static final int DiceExpanded = (int)19L; + /** + * {@snippet lang=c : + * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + private static final int Precomputed = (int)100L; + /** + * {@snippet lang=c : + * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = ivf_flat_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + /** + * {@snippet lang=c : + * typedef struct cuvsIvfFlatIndexParams { + * cuvsDistanceType metric; + * float metric_arg; + * _Bool add_data_on_build; + * uint32_t n_lists; + * uint32_t kmeans_n_iters; + * double kmeans_trainset_fraction; + * _Bool adaptive_centers; + * _Bool conservative_memory_allocation; + * } *cuvsIvfFlatIndexParams_t + * } + */ + public static final AddressLayout cuvsIvfFlatIndexParams_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexParamsCreate$descriptor() { + return cuvsIvfFlatIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static MethodHandle cuvsIvfFlatIndexParamsCreate$handle() { + return cuvsIvfFlatIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static MemorySegment cuvsIvfFlatIndexParamsCreate$address() { + return cuvsIvfFlatIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static int cuvsIvfFlatIndexParamsCreate(MemorySegment index_params) { + var mh$ = cuvsIvfFlatIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexParamsCreate", index_params); + } + return (int)mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexParamsDestroy$descriptor() { + return cuvsIvfFlatIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static MethodHandle cuvsIvfFlatIndexParamsDestroy$handle() { + return cuvsIvfFlatIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static MemorySegment cuvsIvfFlatIndexParamsDestroy$address() { + return cuvsIvfFlatIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static int cuvsIvfFlatIndexParamsDestroy(MemorySegment index_params) { + var mh$ = cuvsIvfFlatIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexParamsDestroy", index_params); + } + return (int)mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef struct cuvsIvfFlatSearchParams { + * uint32_t n_probes; + * } *cuvsIvfFlatSearchParams_t + * } + */ + public static final AddressLayout cuvsIvfFlatSearchParams_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearchParamsCreate$descriptor() { + return cuvsIvfFlatSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static MethodHandle cuvsIvfFlatSearchParamsCreate$handle() { + return cuvsIvfFlatSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static MemorySegment cuvsIvfFlatSearchParamsCreate$address() { + return cuvsIvfFlatSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static int cuvsIvfFlatSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsIvfFlatSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearchParamsCreate", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearchParamsDestroy$descriptor() { + return cuvsIvfFlatSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static MethodHandle cuvsIvfFlatSearchParamsDestroy$handle() { + return cuvsIvfFlatSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static MemorySegment cuvsIvfFlatSearchParamsDestroy$address() { + return cuvsIvfFlatSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static int cuvsIvfFlatSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsIvfFlatSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearchParamsDestroy", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef cuvsIvfFlatIndex *cuvsIvfFlatIndex_t + * } + */ + public static final AddressLayout cuvsIvfFlatIndex_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexCreate$descriptor() { + return cuvsIvfFlatIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static MethodHandle cuvsIvfFlatIndexCreate$handle() { + return cuvsIvfFlatIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static MemorySegment cuvsIvfFlatIndexCreate$address() { + return cuvsIvfFlatIndexCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static int cuvsIvfFlatIndexCreate(MemorySegment index) { + var mh$ = cuvsIvfFlatIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexCreate", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexDestroy$descriptor() { + return cuvsIvfFlatIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatIndexDestroy$handle() { + return cuvsIvfFlatIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatIndexDestroy$address() { + return cuvsIvfFlatIndexDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatIndexDestroy(MemorySegment index) { + var mh$ = cuvsIvfFlatIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexDestroy", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatBuild$descriptor() { + return cuvsIvfFlatBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatBuild$handle() { + return cuvsIvfFlatBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatBuild$address() { + return cuvsIvfFlatBuild.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatBuild(long res, MemorySegment index_params, MemorySegment dataset, MemorySegment index) { + var mh$ = cuvsIvfFlatBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatBuild", res, index_params, dataset, index); + } + return (int)mh$.invokeExact(res, index_params, dataset, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearch$descriptor() { + return cuvsIvfFlatSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsIvfFlatSearch$handle() { + return cuvsIvfFlatSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsIvfFlatSearch$address() { + return cuvsIvfFlatSearch.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsIvfFlatSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsIvfFlatSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearch", res, search_params, index, queries, neighbors, distances); + } + return (int)mh$.invokeExact(res, search_params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSerialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSerialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSerialize$descriptor() { + return cuvsIvfFlatSerialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatSerialize$handle() { + return cuvsIvfFlatSerialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatSerialize$address() { + return cuvsIvfFlatSerialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatSerialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfFlatSerialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSerialize", res, filename, index); + } + return (int)mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatDeserialize$descriptor() { + return cuvsIvfFlatDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatDeserialize$handle() { + return cuvsIvfFlatDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatDeserialize$address() { + return cuvsIvfFlatDeserialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatDeserialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfFlatDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatDeserialize", res, filename, index); + } + return (int)mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatExtend { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_flat_h.C_INT, + ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER, + ivf_flat_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatExtend"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatExtend$descriptor() { + return cuvsIvfFlatExtend.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatExtend$handle() { + return cuvsIvfFlatExtend.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatExtend$address() { + return cuvsIvfFlatExtend.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, MemorySegment index) { + var mh$ = cuvsIvfFlatExtend.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatExtend", res, new_vectors, new_indices, index); + } + return (int)mh$.invokeExact(res, new_vectors, new_indices, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java new file mode 100644 index 000000000..fd57078b6 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java @@ -0,0 +1,3096 @@ +package com.nvidia.cuvs.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +public class ivf_pq_h { + + ivf_pq_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + private static final int _FEATURES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + private static final int _DEFAULT_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + private static final int __GLIBC_USE_ISOC2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + private static final int __USE_ISOC11 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + private static final int __USE_ISOC99 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + private static final int __USE_ISOC95 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + private static final int __USE_POSIX_IMPLICITLY = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + private static final int _POSIX_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + private static final int __USE_POSIX = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + private static final int __USE_POSIX2 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + private static final int __USE_POSIX199309 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + private static final int __USE_POSIX199506 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + private static final int __USE_XOPEN2K = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + private static final int __USE_XOPEN2K8 = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + private static final int _ATFILE_SOURCE = (int)1L; + /** + * {@snippet lang=c : + * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + private static final int __WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; + /** + * {@snippet lang=c : + * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + private static final int __SYSCALL_WORDSIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + private static final int __USE_MISC = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + private static final int __USE_ATFILE = (int)1L; + /** + * {@snippet lang=c : + * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + private static final int __USE_FORTIFY_LEVEL = (int)0L; + /** + * {@snippet lang=c : + * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + private static final int _STDC_PREDEF_H = (int)1L; + /** + * {@snippet lang=c : + * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + private static final int __STDC_IEC_559__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + private static final int __GNU_LIBRARY__ = (int)6L; + /** + * {@snippet lang=c : + * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + private static final int __GLIBC__ = (int)2L; + /** + * {@snippet lang=c : + * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + private static final int __GLIBC_MINOR__ = (int)35L; + /** + * {@snippet lang=c : + * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + private static final int _SYS_CDEFS_H = (int)1L; + /** + * {@snippet lang=c : + * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + private static final int __glibc_c99_flexarr_available = (int)1L; + /** + * {@snippet lang=c : + * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; + /** + * {@snippet lang=c : + * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + private static final int __HAVE_GENERIC_SELECTION = (int)1L; + /** + * {@snippet lang=c : + * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; + /** + * {@snippet lang=c : + * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + private static final int _BITS_TYPES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + private static final int _BITS_TYPESIZES_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + private static final int __INO_T_MATCHES_INO64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; + /** + * {@snippet lang=c : + * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int)1L; + /** + * {@snippet lang=c : + * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; + /** + * {@snippet lang=c : + * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + private static final int __FD_SETSIZE = (int)1024L; + /** + * {@snippet lang=c : + * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + private static final int _BITS_TIME64_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + private static final int _BITS_WCHAR_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + private static final int _BITS_STDINT_INTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + private static final int _BITS_STDINT_UINTN_H = (int)1L; + /** + * {@snippet lang=c : + * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + private static final int DLPACK_MAJOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + private static final int DLPACK_MINOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + private static final int true_ = (int)1L; + /** + * {@snippet lang=c : + * #define true 1 + * } + */ + public static int true_() { + return true_; + } + private static final int false_ = (int)0L; + /** + * {@snippet lang=c : + * #define false 0 + * } + */ + public static int false_() { + return false_; + } + private static final int __bool_true_false_are_defined = (int)1L; + /** + * {@snippet lang=c : + * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + /** + * {@snippet lang=c : + * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off_t + * } + */ + public static final OfLong __off_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __time_t + * } + */ + public static final OfLong __time_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __key_t + * } + */ + public static final OfInt __key_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = ivf_pq_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = ivf_pq_h.C_POINTER; + /** + * {@snippet lang=c : + * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang=c : + * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang=c : + * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = ivf_pq_h.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 = ivf_pq_h.C_LONG; + private static final int L2Expanded = (int)0L; + /** + * {@snippet lang=c : + * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + private static final int L2SqrtExpanded = (int)1L; + /** + * {@snippet lang=c : + * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + private static final int CosineExpanded = (int)2L; + /** + * {@snippet lang=c : + * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + private static final int L1 = (int)3L; + /** + * {@snippet lang=c : + * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + private static final int L2Unexpanded = (int)4L; + /** + * {@snippet lang=c : + * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + private static final int L2SqrtUnexpanded = (int)5L; + /** + * {@snippet lang=c : + * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + private static final int InnerProduct = (int)6L; + /** + * {@snippet lang=c : + * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + private static final int Linf = (int)7L; + /** + * {@snippet lang=c : + * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + private static final int Canberra = (int)8L; + /** + * {@snippet lang=c : + * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + private static final int LpUnexpanded = (int)9L; + /** + * {@snippet lang=c : + * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + private static final int CorrelationExpanded = (int)10L; + /** + * {@snippet lang=c : + * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + private static final int JaccardExpanded = (int)11L; + /** + * {@snippet lang=c : + * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + private static final int HellingerExpanded = (int)12L; + /** + * {@snippet lang=c : + * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + private static final int Haversine = (int)13L; + /** + * {@snippet lang=c : + * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + private static final int BrayCurtis = (int)14L; + /** + * {@snippet lang=c : + * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + private static final int JensenShannon = (int)15L; + /** + * {@snippet lang=c : + * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + private static final int HammingUnexpanded = (int)16L; + /** + * {@snippet lang=c : + * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + private static final int KLDivergence = (int)17L; + /** + * {@snippet lang=c : + * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + private static final int RusselRaoExpanded = (int)18L; + /** + * {@snippet lang=c : + * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + private static final int DiceExpanded = (int)19L; + /** + * {@snippet lang=c : + * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + private static final int Precomputed = (int)100L; + /** + * {@snippet lang=c : + * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + /** + * {@snippet lang=c : + * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang=c : + * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = ivf_pq_h.C_INT; + private static final int kDLCPU = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + private static final int kDLCUDA = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + private static final int kDLCUDAHost = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + private static final int kDLOpenCL = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + private static final int kDLVulkan = (int)7L; + /** + * {@snippet lang=c : + * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + private static final int kDLMetal = (int)8L; + /** + * {@snippet lang=c : + * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + private static final int kDLVPI = (int)9L; + /** + * {@snippet lang=c : + * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + private static final int kDLROCM = (int)10L; + /** + * {@snippet lang=c : + * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + private static final int kDLROCMHost = (int)11L; + /** + * {@snippet lang=c : + * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + private static final int kDLExtDev = (int)12L; + /** + * {@snippet lang=c : + * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + private static final int kDLCUDAManaged = (int)13L; + /** + * {@snippet lang=c : + * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + private static final int kDLOneAPI = (int)14L; + /** + * {@snippet lang=c : + * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + private static final int kDLWebGPU = (int)15L; + /** + * {@snippet lang=c : + * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + private static final int kDLHexagon = (int)16L; + /** + * {@snippet lang=c : + * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + private static final int kDLMAIA = (int)17L; + /** + * {@snippet lang=c : + * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + private static final int kDLInt = (int)0L; + /** + * {@snippet lang=c : + * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + private static final int kDLUInt = (int)1L; + /** + * {@snippet lang=c : + * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + private static final int kDLFloat = (int)2L; + /** + * {@snippet lang=c : + * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + private static final int kDLOpaqueHandle = (int)3L; + /** + * {@snippet lang=c : + * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + private static final int kDLBfloat = (int)4L; + /** + * {@snippet lang=c : + * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + private static final int kDLComplex = (int)5L; + /** + * {@snippet lang=c : + * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + private static final int kDLBool = (int)6L; + /** + * {@snippet lang=c : + * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + private static final int CUDA_R_16F = (int)2L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_16F = 2 + * } + */ + public static int CUDA_R_16F() { + return CUDA_R_16F; + } + private static final int CUDA_C_16F = (int)6L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_16F = 6 + * } + */ + public static int CUDA_C_16F() { + return CUDA_C_16F; + } + private static final int CUDA_R_16BF = (int)14L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_16BF = 14 + * } + */ + public static int CUDA_R_16BF() { + return CUDA_R_16BF; + } + private static final int CUDA_C_16BF = (int)15L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_16BF = 15 + * } + */ + public static int CUDA_C_16BF() { + return CUDA_C_16BF; + } + private static final int CUDA_R_32F = (int)0L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_32F = 0 + * } + */ + public static int CUDA_R_32F() { + return CUDA_R_32F; + } + private static final int CUDA_C_32F = (int)4L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_32F = 4 + * } + */ + public static int CUDA_C_32F() { + return CUDA_C_32F; + } + private static final int CUDA_R_64F = (int)1L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_64F = 1 + * } + */ + public static int CUDA_R_64F() { + return CUDA_R_64F; + } + private static final int CUDA_C_64F = (int)5L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_64F = 5 + * } + */ + public static int CUDA_C_64F() { + return CUDA_C_64F; + } + private static final int CUDA_R_4I = (int)16L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_4I = 16 + * } + */ + public static int CUDA_R_4I() { + return CUDA_R_4I; + } + private static final int CUDA_C_4I = (int)17L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_4I = 17 + * } + */ + public static int CUDA_C_4I() { + return CUDA_C_4I; + } + private static final int CUDA_R_4U = (int)18L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_4U = 18 + * } + */ + public static int CUDA_R_4U() { + return CUDA_R_4U; + } + private static final int CUDA_C_4U = (int)19L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_4U = 19 + * } + */ + public static int CUDA_C_4U() { + return CUDA_C_4U; + } + private static final int CUDA_R_8I = (int)3L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_8I = 3 + * } + */ + public static int CUDA_R_8I() { + return CUDA_R_8I; + } + private static final int CUDA_C_8I = (int)7L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_8I = 7 + * } + */ + public static int CUDA_C_8I() { + return CUDA_C_8I; + } + private static final int CUDA_R_8U = (int)8L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_8U = 8 + * } + */ + public static int CUDA_R_8U() { + return CUDA_R_8U; + } + private static final int CUDA_C_8U = (int)9L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_8U = 9 + * } + */ + public static int CUDA_C_8U() { + return CUDA_C_8U; + } + private static final int CUDA_R_16I = (int)20L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_16I = 20 + * } + */ + public static int CUDA_R_16I() { + return CUDA_R_16I; + } + private static final int CUDA_C_16I = (int)21L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_16I = 21 + * } + */ + public static int CUDA_C_16I() { + return CUDA_C_16I; + } + private static final int CUDA_R_16U = (int)22L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_16U = 22 + * } + */ + public static int CUDA_R_16U() { + return CUDA_R_16U; + } + private static final int CUDA_C_16U = (int)23L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_16U = 23 + * } + */ + public static int CUDA_C_16U() { + return CUDA_C_16U; + } + private static final int CUDA_R_32I = (int)10L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_32I = 10 + * } + */ + public static int CUDA_R_32I() { + return CUDA_R_32I; + } + private static final int CUDA_C_32I = (int)11L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_32I = 11 + * } + */ + public static int CUDA_C_32I() { + return CUDA_C_32I; + } + private static final int CUDA_R_32U = (int)12L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_32U = 12 + * } + */ + public static int CUDA_R_32U() { + return CUDA_R_32U; + } + private static final int CUDA_C_32U = (int)13L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_32U = 13 + * } + */ + public static int CUDA_C_32U() { + return CUDA_C_32U; + } + private static final int CUDA_R_64I = (int)24L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_64I = 24 + * } + */ + public static int CUDA_R_64I() { + return CUDA_R_64I; + } + private static final int CUDA_C_64I = (int)25L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_64I = 25 + * } + */ + public static int CUDA_C_64I() { + return CUDA_C_64I; + } + private static final int CUDA_R_64U = (int)26L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_R_64U = 26 + * } + */ + public static int CUDA_R_64U() { + return CUDA_R_64U; + } + private static final int CUDA_C_64U = (int)27L; + /** + * {@snippet lang=c : + * enum cudaDataType_t.CUDA_C_64U = 27 + * } + */ + public static int CUDA_C_64U() { + return CUDA_C_64U; + } + private static final int MAJOR_VERSION = (int)0L; + /** + * {@snippet lang=c : + * enum libraryPropertyType_t.MAJOR_VERSION = 0 + * } + */ + public static int MAJOR_VERSION() { + return MAJOR_VERSION; + } + private static final int MINOR_VERSION = (int)1L; + /** + * {@snippet lang=c : + * enum libraryPropertyType_t.MINOR_VERSION = 1 + * } + */ + public static int MINOR_VERSION() { + return MINOR_VERSION; + } + private static final int PATCH_LEVEL = (int)2L; + /** + * {@snippet lang=c : + * enum libraryPropertyType_t.PATCH_LEVEL = 2 + * } + */ + public static int PATCH_LEVEL() { + return PATCH_LEVEL; + } + private static final int PER_SUBSPACE = (int)0L; + /** + * {@snippet lang=c : + * enum codebook_gen.PER_SUBSPACE = 0 + * } + */ + public static int PER_SUBSPACE() { + return PER_SUBSPACE; + } + private static final int PER_CLUSTER = (int)1L; + /** + * {@snippet lang=c : + * enum codebook_gen.PER_CLUSTER = 1 + * } + */ + public static int PER_CLUSTER() { + return PER_CLUSTER; + } + /** + * {@snippet lang=c : + * typedef struct cuvsIvfPqIndexParams { + * cuvsDistanceType metric; + * float metric_arg; + * _Bool add_data_on_build; + * uint32_t n_lists; + * uint32_t kmeans_n_iters; + * double kmeans_trainset_fraction; + * uint32_t pq_bits; + * uint32_t pq_dim; + * enum codebook_gen codebook_kind; + * _Bool force_random_rotation; + * _Bool conservative_memory_allocation; + * uint32_t max_train_points_per_pq_code; + * } *cuvsIvfPqIndexParams_t + * } + */ + public static final AddressLayout cuvsIvfPqIndexParams_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexParamsCreate$descriptor() { + return cuvsIvfPqIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static MethodHandle cuvsIvfPqIndexParamsCreate$handle() { + return cuvsIvfPqIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static MemorySegment cuvsIvfPqIndexParamsCreate$address() { + return cuvsIvfPqIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static int cuvsIvfPqIndexParamsCreate(MemorySegment index_params) { + var mh$ = cuvsIvfPqIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexParamsCreate", index_params); + } + return (int)mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexParamsDestroy$descriptor() { + return cuvsIvfPqIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static MethodHandle cuvsIvfPqIndexParamsDestroy$handle() { + return cuvsIvfPqIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static MemorySegment cuvsIvfPqIndexParamsDestroy$address() { + return cuvsIvfPqIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static int cuvsIvfPqIndexParamsDestroy(MemorySegment index_params) { + var mh$ = cuvsIvfPqIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexParamsDestroy", index_params); + } + return (int)mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef struct cuvsIvfPqSearchParams { + * uint32_t n_probes; + * cudaDataType_t lut_dtype; + * cudaDataType_t internal_distance_dtype; + * double preferred_shmem_carveout; + * } *cuvsIvfPqSearchParams_t + * } + */ + public static final AddressLayout cuvsIvfPqSearchParams_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearchParamsCreate$descriptor() { + return cuvsIvfPqSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static MethodHandle cuvsIvfPqSearchParamsCreate$handle() { + return cuvsIvfPqSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static MemorySegment cuvsIvfPqSearchParamsCreate$address() { + return cuvsIvfPqSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static int cuvsIvfPqSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsIvfPqSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearchParamsCreate", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearchParamsDestroy$descriptor() { + return cuvsIvfPqSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static MethodHandle cuvsIvfPqSearchParamsDestroy$handle() { + return cuvsIvfPqSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static MemorySegment cuvsIvfPqSearchParamsDestroy$address() { + return cuvsIvfPqSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static int cuvsIvfPqSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsIvfPqSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearchParamsDestroy", params); + } + return (int)mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + /** + * {@snippet lang=c : + * typedef cuvsIvfPq *cuvsIvfPqIndex_t + * } + */ + public static final AddressLayout cuvsIvfPqIndex_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexCreate$descriptor() { + return cuvsIvfPqIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static MethodHandle cuvsIvfPqIndexCreate$handle() { + return cuvsIvfPqIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static MemorySegment cuvsIvfPqIndexCreate$address() { + return cuvsIvfPqIndexCreate.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static int cuvsIvfPqIndexCreate(MemorySegment index) { + var mh$ = cuvsIvfPqIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexCreate", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexDestroy$descriptor() { + return cuvsIvfPqIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqIndexDestroy$handle() { + return cuvsIvfPqIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqIndexDestroy$address() { + return cuvsIvfPqIndexDestroy.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqIndexDestroy(MemorySegment index) { + var mh$ = cuvsIvfPqIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexDestroy", index); + } + return (int)mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqBuild$descriptor() { + return cuvsIvfPqBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqBuild$handle() { + return cuvsIvfPqBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqBuild$address() { + return cuvsIvfPqBuild.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqBuild(long res, MemorySegment params, MemorySegment dataset, MemorySegment index) { + var mh$ = cuvsIvfPqBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqBuild", res, params, dataset, index); + } + return (int)mh$.invokeExact(res, params, dataset, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearch$descriptor() { + return cuvsIvfPqSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsIvfPqSearch$handle() { + return cuvsIvfPqSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsIvfPqSearch$address() { + return cuvsIvfPqSearch.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsIvfPqSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsIvfPqSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearch", res, search_params, index, queries, neighbors, distances); + } + return (int)mh$.invokeExact(res, search_params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSerialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSerialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqSerialize$descriptor() { + return cuvsIvfPqSerialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqSerialize$handle() { + return cuvsIvfPqSerialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqSerialize$address() { + return cuvsIvfPqSerialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqSerialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfPqSerialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSerialize", res, filename, index); + } + return (int)mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqDeserialize$descriptor() { + return cuvsIvfPqDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqDeserialize$handle() { + return cuvsIvfPqDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqDeserialize$address() { + return cuvsIvfPqDeserialize.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqDeserialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfPqDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqDeserialize", res, filename, index); + } + return (int)mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqExtend { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ivf_pq_h.C_INT, + ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER, + ivf_pq_h.C_POINTER + ); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqExtend"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqExtend$descriptor() { + return cuvsIvfPqExtend.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqExtend$handle() { + return cuvsIvfPqExtend.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqExtend$address() { + return cuvsIvfPqExtend.ADDR; + } + + /** + * {@snippet lang=c : + * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, MemorySegment index) { + var mh$ = cuvsIvfPqExtend.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqExtend", res, new_vectors, new_indices, index); + } + return (int)mh$.invokeExact(res, new_vectors, new_indices, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static final long _POSIX_C_SOURCE = 200809L; + /** + * {@snippet lang=c : + * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + private static final int __TIMESIZE = (int)64L; + /** + * {@snippet lang=c : + * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + private static final long __STDC_IEC_60559_BFP__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + /** + * {@snippet lang=c : + * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + private static final long __STDC_ISO_10646__ = 201706L; + /** + * {@snippet lang=c : + * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + private static final int __WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + private static final int __WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + private static final int INT8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + private static final int INT16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + private static final int INT32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + private static final long INT64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + private static final int INT8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + private static final int INT16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + private static final int INT32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + private static final long INT64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + private static final int UINT8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + private static final int UINT16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + private static final int UINT32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + private static final long UINT64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + private static final int INT_LEAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + private static final int INT_LEAST16_MIN = (int)-32768L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + private static final int INT_LEAST32_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + private static final long INT_LEAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + private static final int INT_LEAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + private static final int INT_LEAST16_MAX = (int)32767L; + /** + * {@snippet lang=c : + * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + private static final int INT_LEAST32_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + private static final long INT_LEAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + private static final int UINT_LEAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + private static final int UINT_LEAST16_MAX = (int)65535L; + /** + * {@snippet lang=c : + * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + private static final int UINT_LEAST32_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + private static final long UINT_LEAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + private static final int INT_FAST8_MIN = (int)-128L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + private static final long INT_FAST16_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + private static final long INT_FAST32_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + private static final long INT_FAST64_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + private static final int INT_FAST8_MAX = (int)127L; + /** + * {@snippet lang=c : + * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + private static final long INT_FAST16_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + private static final long INT_FAST32_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + private static final long INT_FAST64_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + private static final int UINT_FAST8_MAX = (int)255L; + /** + * {@snippet lang=c : + * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + private static final long UINT_FAST16_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + private static final long UINT_FAST32_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + private static final long UINT_FAST64_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + private static final long INTPTR_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + private static final long INTPTR_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + private static final long UINTPTR_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + private static final long INTMAX_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + private static final long INTMAX_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + private static final long UINTMAX_MAX = -1L; + /** + * {@snippet lang=c : + * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + private static final long PTRDIFF_MIN = -9223372036854775808L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + private static final long PTRDIFF_MAX = 9223372036854775807L; + /** + * {@snippet lang=c : + * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + private static final int SIG_ATOMIC_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + private static final int SIG_ATOMIC_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + private static final long SIZE_MAX = -1L; + /** + * {@snippet lang=c : + * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + private static final int WCHAR_MIN = (int)-2147483648L; + /** + * {@snippet lang=c : + * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + private static final int WCHAR_MAX = (int)2147483647L; + /** + * {@snippet lang=c : + * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + private static final int WINT_MIN = (int)0L; + /** + * {@snippet lang=c : + * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + private static final int WINT_MAX = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + /** + * {@snippet lang=c : + * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + /** + * {@snippet lang=c : + * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java new file mode 100644 index 000000000..555a4316e --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java @@ -0,0 +1,127 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang=c : + * struct { + * long long __clang_max_align_nonce1; + * long double __clang_max_align_nonce2; + * } + * } + */ +public class max_align_t { + + max_align_t() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + dlpack_h.C_LONG_LONG.withName("__clang_max_align_nonce1"), + MemoryLayout.paddingLayout(24) + ).withName("$anon$19:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong __clang_max_align_nonce1$LAYOUT = (OfLong)$LAYOUT.select(groupElement("__clang_max_align_nonce1")); + + /** + * Layout for field: + * {@snippet lang=c : + * long long __clang_max_align_nonce1 + * } + */ + public static final OfLong __clang_max_align_nonce1$layout() { + return __clang_max_align_nonce1$LAYOUT; + } + + private static final long __clang_max_align_nonce1$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * long long __clang_max_align_nonce1 + * } + */ + public static final long __clang_max_align_nonce1$offset() { + return __clang_max_align_nonce1$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * long long __clang_max_align_nonce1 + * } + */ + public static long __clang_max_align_nonce1(MemorySegment struct) { + return struct.get(__clang_max_align_nonce1$LAYOUT, __clang_max_align_nonce1$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * long long __clang_max_align_nonce1 + * } + */ + public static void __clang_max_align_nonce1(MemorySegment struct, long fieldValue) { + struct.set(__clang_max_align_nonce1$LAYOUT, __clang_max_align_nonce1$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java new file mode 100644 index 000000000..6f4b031bb --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java @@ -0,0 +1,211 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct results { + * int test; + * int *neighbors_h; + * float *distances_h; + * } + * } + */ +public class results { + + results() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(results_h.C_INT.withName("test"), MemoryLayout.paddingLayout(4), + results_h.C_POINTER.withName("neighbors_h"), results_h.C_POINTER.withName("distances_h")) + .withName("results"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt test$LAYOUT = (OfInt) $LAYOUT.select(groupElement("test")); + + /** + * Layout for field: + * {@snippet lang = c : * int test + * } + */ + public static final OfInt test$layout() { + return test$LAYOUT; + } + + private static final long test$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * int test + * } + */ + public static final long test$offset() { + return test$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * int test + * } + */ + public static int test(MemorySegment struct) { + return struct.get(test$LAYOUT, test$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * int test + * } + */ + public static void test(MemorySegment struct, int fieldValue) { + struct.set(test$LAYOUT, test$OFFSET, fieldValue); + } + + private static final AddressLayout neighbors_h$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("neighbors_h")); + + /** + * Layout for field: + * {@snippet lang = c : * int *neighbors_h + * } + */ + public static final AddressLayout neighbors_h$layout() { + return neighbors_h$LAYOUT; + } + + private static final long neighbors_h$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * int *neighbors_h + * } + */ + public static final long neighbors_h$offset() { + return neighbors_h$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * int *neighbors_h + * } + */ + public static MemorySegment neighbors_h(MemorySegment struct) { + return struct.get(neighbors_h$LAYOUT, neighbors_h$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * int *neighbors_h + * } + */ + public static void neighbors_h(MemorySegment struct, MemorySegment fieldValue) { + struct.set(neighbors_h$LAYOUT, neighbors_h$OFFSET, fieldValue); + } + + private static final AddressLayout distances_h$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("distances_h")); + + /** + * Layout for field: + * {@snippet lang = c : * float *distances_h + * } + */ + public static final AddressLayout distances_h$layout() { + return distances_h$LAYOUT; + } + + private static final long distances_h$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * float *distances_h + * } + */ + public static final long distances_h$offset() { + return distances_h$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * float *distances_h + * } + */ + public static MemorySegment distances_h(MemorySegment struct) { + return struct.get(distances_h$LAYOUT, distances_h$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * float *distances_h + * } + */ + public static void distances_h(MemorySegment struct, MemorySegment fieldValue) { + struct.set(distances_h$LAYOUT, distances_h$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/java/com/nvidia/cuvs/panama/results_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java new file mode 100644 index 000000000..aabd8b41b --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java @@ -0,0 +1,83 @@ +package com.nvidia.cuvs.panama; + +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; + +public class results_h { + + results_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) + : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + /** + * {@snippet lang = c : + * typedef struct results { + * int test; + * int *neighbors_h; + * float *distances_h; + * } *rsltp + * } + */ + public static final AddressLayout rsltp = results_h.C_POINTER; +} diff --git a/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java b/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java new file mode 100644 index 000000000..73037fabb --- /dev/null +++ b/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java @@ -0,0 +1,19 @@ +package ai.rapids.cuvs; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +/** + * Unit test for simple App. + */ +public class AppTest { + + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() { + assertTrue(true); + } +} diff --git a/java/internal/CMakeLists.txt b/java/internal/CMakeLists.txt new file mode 100644 index 000000000..d9a851872 --- /dev/null +++ b/java/internal/CMakeLists.txt @@ -0,0 +1,56 @@ +# ============================================================================= +# Copyright (c) 2024, 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. +# ============================================================================= + +cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) + +include(rapids_config.cmake) +include(rapids-cmake) +include(rapids-cpm) +include(rapids-export) +include(rapids-find) +rapids_cpm_init() + +project( + cuvs-java + VERSION "${RAPIDS_VERSION}" + LANGUAGES CXX C +) + +option(FIND_CUVS_CPP "Search for existing CUVS C++ installations before defaulting to local files" + ON +) + +if(FIND_CUVS_CPP) + find_package(cuvs "${RAPIDS_VERSION}" REQUIRED COMPONENTS c_api) + if(NOT TARGET cuvs::c_api) + message( + FATAL_ERROR + "Building against a preexisting libcuvs library requires the compiled libcuvs to have been built!" + ) + endif() +else() + set(cuvs_FOUND OFF) +endif() + +if(NOT cuvs_FOUND) + set(BUILD_TESTS OFF) + set(BUILD_C_LIBRARY ON) + add_subdirectory(../../cpp cuvs-cpp EXCLUDE_FROM_ALL) +endif() + +include(get_dlpack.cmake) + +ADD_LIBRARY(cuvs_java SHARED src/cuvs_java.c) +target_include_directories(cuvs_java PUBLIC "$") +target_link_libraries(cuvs_java PRIVATE cuvs::c_api $) diff --git a/java/internal/VERSION b/java/internal/VERSION new file mode 120000 index 000000000..558194c5a --- /dev/null +++ b/java/internal/VERSION @@ -0,0 +1 @@ +../../VERSION \ No newline at end of file diff --git a/java/internal/get_dlpack.cmake b/java/internal/get_dlpack.cmake new file mode 120000 index 000000000..93a54ca4d --- /dev/null +++ b/java/internal/get_dlpack.cmake @@ -0,0 +1 @@ +../../cpp/cmake/thirdparty/get_dlpack.cmake \ No newline at end of file diff --git a/java/internal/rapids_config.cmake b/java/internal/rapids_config.cmake new file mode 120000 index 000000000..398eea52d --- /dev/null +++ b/java/internal/rapids_config.cmake @@ -0,0 +1 @@ +../../rapids_config.cmake \ No newline at end of file diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c new file mode 100644 index 000000000..da11cfd15 --- /dev/null +++ b/java/internal/src/cuvs_java.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include +#include + +cuvsResources_t create_resource(int *rv) { + cuvsResources_t res; + *rv = cuvsResourcesCreate(&res); + return res; +} + +DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) { + DLManagedTensor tensor; + + tensor.dl_tensor.data = data; + tensor.dl_tensor.device.device_type = kDLCUDA; + tensor.dl_tensor.ndim = 2; + tensor.dl_tensor.dtype.code = code; + tensor.dl_tensor.dtype.bits = 32; + tensor.dl_tensor.dtype.lanes = 1; + tensor.dl_tensor.shape = shape; + tensor.dl_tensor.strides = NULL; + + return tensor; +} + +cuvsCagraIndex_t build_index(float *dataset, long rows, long dimension, cuvsResources_t res, int *rv, + cuvsCagraIndexParams_t index_params) { + + int64_t dataset_shape[2] = {rows, dimension}; + DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat); + + cuvsCagraIndex_t index; + cuvsCagraIndexCreate(&index); + + *rv = cuvsCagraBuild(res, index_params, &dataset_tensor, index); + return index; +} + +void serialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, char* filename) { + *rv = cuvsCagraSerialize(res, filename, index, true); +} + +void deserialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, char* filename) { + *rv = cuvsCagraDeserialize(res, filename, index); +} + +void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimension, + cuvsResources_t res, int *neighbors_h, float *distances_h, int *rv, cuvsCagraSearchParams_t search_params1) { + + uint32_t *neighbors; + float *distances, *queries_d; + cuvsRMMAlloc(res, (void**) &queries_d, sizeof(float) * n_queries * dimension); + cuvsRMMAlloc(res, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); + cuvsRMMAlloc(res, (void**) &distances, sizeof(float) * n_queries * topk); + + cudaMemcpy(queries_d, queries, sizeof(float) * 4 * 2, cudaMemcpyDefault); + + int64_t queries_shape[2] = {n_queries, dimension}; + DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat); + + int64_t neighbors_shape[2] = {n_queries, topk}; + DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt); + + int64_t distances_shape[2] = {n_queries, topk}; + DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat); + + cuvsCagraSearchParams_t search_params; + cuvsCagraSearchParamsCreate(&search_params); + + *rv = cuvsCagraSearch(res, search_params, index, &queries_tensor, &neighbors_tensor, + &distances_tensor); + + cudaMemcpy(neighbors_h, neighbors, sizeof(uint32_t) * n_queries * topk, cudaMemcpyDefault); + cudaMemcpy(distances_h, distances, sizeof(float) * n_queries * topk, cudaMemcpyDefault); +} From 44116294d09bab3326dd20af314a6cc7ff137c7a Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Sat, 9 Nov 2024 07:11:57 -0500 Subject: [PATCH 22/53] API changes, serialize optional tmpFile param + other changes --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 15 ++-- .../cagra/{CuVSIndex.java => CagraIndex.java} | 79 +++++++++---------- .../nvidia/cuvs/cagra/CagraIndexParams.java | 19 ++--- .../cuvs/cagra/CagraIndexReference.java | 2 +- .../nvidia/cuvs/cagra/CagraSearchParams.java | 40 +++++----- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 31 ++------ .../com/nvidia/cuvs/cagra/CuVSResources.java | 18 +++-- .../com/nvidia/cuvs/cagra/IndexParams.java | 9 --- .../com/nvidia/cuvs/cagra/SearchParams.java | 9 --- .../com/nvidia/cuvs/cagra/SearchResult.java | 14 ++-- 10 files changed, 100 insertions(+), 136 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/{CuVSIndex.java => CagraIndex.java} (81%) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 3497810bf..8f2e5ec2e 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -6,8 +6,7 @@ import java.io.InputStream; import java.util.Map; -import com.nvidia.cuvs.cagra.CuVSIndex; -import com.nvidia.cuvs.cagra.CuVSIndex.ANNAlgorithms; +import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; import com.nvidia.cuvs.cagra.CagraIndexParams.CuvsCagraGraphBuildAlgo; import com.nvidia.cuvs.cagra.CagraSearchParams; @@ -39,24 +38,22 @@ public static void main(String[] args) throws Throwable { .build(); // Creating a new index - CuVSIndex index = new CuVSIndex.Builder(res) + CagraIndex index = new CagraIndex.Builder(res) .withDataset(dataset) - .withANNAlgorithm(ANNAlgorithms.CAGRA) .withIndexParams(cagraIndexParams) .build(); // Saving the index on to the disk. - index.serialize(new FileOutputStream("abc.cag"), "/tmp/index.cag"); + index.serialize(new FileOutputStream("abc.cag")); // Loading a cagra index from disk. InputStream fin = new FileInputStream(new File("abc.cag")); - CuVSIndex index2 = new CuVSIndex.Builder(res) + CagraIndex index2 = new CagraIndex.Builder(res) .from(fin) .build(); // Query CuVSQuery query = new CuVSQuery.Builder() - .withANNAlgorithm(ANNAlgorithms.CAGRA) .withSearchParams(cagraSearchParams) .withQueryVectors(queries) .withMapping(map) @@ -64,11 +61,11 @@ public static void main(String[] args) throws Throwable { // Search SearchResult rslt = index.search(query); - System.out.println(rslt.results); + System.out.println(rslt.getResults()); // Search from de-serialized index SearchResult rslt2 = index2.search(query); - System.out.println(rslt2.results); + System.out.println(rslt2.getResults()); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java similarity index 81% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index df0cc3f2d..440ada990 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -18,17 +18,12 @@ import java.lang.invoke.VarHandle; import java.util.UUID; -public class CuVSIndex { +public class CagraIndex { - private IndexParams indexParams; + private CagraIndexParams indexParams; private final float[][] dataset; private final CuVSResources res; private CagraIndexReference ref; - private ANNAlgorithms algo; - - public enum ANNAlgorithms { - BRUTEFORCE, CAGRA, IVF_PQ, IVF_FLAT - } Linker linker; Arena arena; @@ -48,14 +43,12 @@ public enum ANNAlgorithms { * @param res * @throws Throwable */ - private CuVSIndex(IndexParams indexParams, float[][] dataset, CuVSResources res, ANNAlgorithms algo) - throws Throwable { + private CagraIndex(CagraIndexParams indexParams, float[][] dataset, CuVSResources res) throws Throwable { this.indexParams = indexParams; this.dataset = dataset; this.init(); this.res = res; this.ref = build(); - this.algo = algo; } /** @@ -64,7 +57,7 @@ private CuVSIndex(IndexParams indexParams, float[][] dataset, CuVSResources res, * @param res * @throws Throwable */ - private CuVSIndex(InputStream in, CuVSResources res) throws Throwable { + private CagraIndex(InputStream in, CuVSResources res) throws Throwable { this.indexParams = null; this.dataset = null; this.res = res; @@ -81,7 +74,7 @@ private void init() throws Throwable { arena = Arena.ofConfined(); File wd = new File(System.getProperty("user.dir")); - bridge = SymbolLookup.libraryLookup(wd.getParent() + "/api-sys/build/libcuvs_wrapper.so", arena); + bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); indexMH = linker.downcallHandle(bridge.findOrThrow("build_index"), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), @@ -154,9 +147,7 @@ private CagraIndexReference build() throws Throwable { MemorySegment rvMS = arena.allocate(rvML); ref = new CagraIndexReference((MemorySegment) indexMH.invokeExact(getMemorySegment(dataset), rows, cols, - res.resource, rvMS, indexParams.indexParamsMS)); - - System.out.println("Build call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + res.getResource(), rvMS, indexParams.cagraIndexParamsMS)); return ref; } @@ -177,14 +168,35 @@ public SearchResult search(CuVSQuery query) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.queryVectors), 2, 4L, 2L, res.resource, - neighborsMS, distancesMS, rvMS, query.searchParams.searchParamsMS); - - System.out.println("Search call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); + searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.queryVectors), 2, 4L, 2L, res.getResource(), + neighborsMS, distancesMS, rvMS, query.searchParams.cagraSearchParamsMS); return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, 2, query.mapping); } + /** + * + * @param out + * @param tmpFilePath + * @throws Throwable + */ + public void serialize(OutputStream out) throws Throwable { + MemoryLayout rvML = linker.canonicalLayouts().get("int"); + MemorySegment rvMS = arena.allocate(rvML); + String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; + serializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, + getStringSegment(new StringBuilder(tmpIndexFile))); + File tempFile = new File(tmpIndexFile); + FileInputStream is = new FileInputStream(tempFile); + byte[] chunk = new byte[1024]; + int chunkLen = 0; + while ((chunkLen = is.read(chunk)) != -1) { + out.write(chunk, 0, chunkLen); + } + is.close(); + tempFile.delete(); + } + /** * * @param out @@ -194,10 +206,8 @@ public SearchResult search(CuVSQuery query) throws Throwable { public void serialize(OutputStream out, String tmpFilePath) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - serializeMH.invokeExact(res.resource, ref.indexMemorySegment, rvMS, + serializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, getStringSegment(new StringBuilder(tmpFilePath))); - System.out.println("Serialize call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); - File tempFile = new File(tmpFilePath); FileInputStream is = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; @@ -228,7 +238,7 @@ private CagraIndexReference deserialize(InputStream in) throws Throwable { while ((chunkLen = in.read(chunk)) != -1) { out.write(chunk, 0, chunkLen); } - deserializeMH.invokeExact(res.resource, ref.indexMemorySegment, rvMS, + deserializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, getStringSegment(new StringBuilder(tmpIndexFile))); in.close(); @@ -242,7 +252,7 @@ private CagraIndexReference deserialize(InputStream in) throws Throwable { * * @return */ - public IndexParams getParams() { + public CagraIndexParams getParams() { return indexParams; } @@ -263,10 +273,9 @@ public CuVSResources getResources() { } public static class Builder { - private IndexParams indexParams; + private CagraIndexParams indexParams; float[][] dataset; CuVSResources res; - ANNAlgorithms algo = ANNAlgorithms.CAGRA; InputStream in; @@ -303,31 +312,21 @@ public Builder withDataset(float[][] dataset) { * @param params * @return */ - public Builder withIndexParams(IndexParams indexParams) { + public Builder withIndexParams(CagraIndexParams indexParams) { this.indexParams = indexParams; return this; } - /** - * - * @param params - * @return - */ - public Builder withANNAlgorithm(ANNAlgorithms algo) { - this.algo = algo; - return this; - } - /** * * @return * @throws Throwable */ - public CuVSIndex build() throws Throwable { + public CagraIndex build() throws Throwable { if (in != null) { - return new CuVSIndex(in, res); + return new CagraIndex(in, res); } else { - return new CuVSIndex(indexParams, dataset, res, algo); + return new CagraIndex(indexParams, dataset, res); } } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index 1c99bdfdf..8f8e9c3ff 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -13,13 +13,14 @@ * size_t nn_descent_niter; * } */ -public class CagraIndexParams extends IndexParams { +public class CagraIndexParams { Arena arena; int intermediateGraphDegree; int graphDegree; CuvsCagraGraphBuildAlgo buildAlgo; int nnDescentNiter; + public MemorySegment cagraIndexParamsMS; public enum CuvsCagraGraphBuildAlgo { AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); @@ -31,8 +32,8 @@ private CuvsCagraGraphBuildAlgo(int label) { } } - public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, - CuvsCagraGraphBuildAlgo buildAlgo, int nnDescentNiter) { + public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, CuvsCagraGraphBuildAlgo buildAlgo, + int nnDescentNiter) { this.arena = arena; this.intermediateGraphDegree = intermediateGraphDegree; this.graphDegree = graphDegree; @@ -42,11 +43,11 @@ public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegre } private void set() { - indexParamsMS = cuvsCagraIndexParams.allocate(arena); - cuvsCagraIndexParams.intermediate_graph_degree(indexParamsMS, intermediateGraphDegree); - cuvsCagraIndexParams.graph_degree(indexParamsMS, graphDegree); - cuvsCagraIndexParams.build_algo(indexParamsMS, buildAlgo.label); - cuvsCagraIndexParams.nn_descent_niter(indexParamsMS, nnDescentNiter); + cagraIndexParamsMS = cuvsCagraIndexParams.allocate(arena); + cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMS, intermediateGraphDegree); + cuvsCagraIndexParams.graph_degree(cagraIndexParamsMS, graphDegree); + cuvsCagraIndexParams.build_algo(cagraIndexParamsMS, buildAlgo.label); + cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMS, nnDescentNiter); } public int getIntermediate_graph_degree() { @@ -103,7 +104,7 @@ public Builder withNNDescentNiter(int nnDescentNiter) { this.nnDescentNiter = nnDescentNiter; return this; } - + public Builder withWriterThreads(int writerThreads) { this.writerThreads = writerThreads; return this; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java index bbcca2407..897ab5d0f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -8,7 +8,7 @@ public class CagraIndexReference { public MemorySegment indexMemorySegment; - + /** * */ diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index 3dd5aebd2..dcf856ff9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -22,7 +22,7 @@ * uint64_t rand_xor_mask; * } */ -public class CagraSearchParams extends SearchParams { +public class CagraSearchParams { Arena arena; int maxQueries; @@ -38,6 +38,7 @@ public class CagraSearchParams extends SearchParams { float hashmapMaxFillRate; int numRandomSamplings; long randXorMask; + public MemorySegment cagraSearchParamsMS; enum CuvsCagraSearchAlgo { SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); @@ -82,20 +83,20 @@ public CagraSearchParams(Arena arena, int max_queries, int itopk_size, int max_i } public void set() { - searchParamsMS = cuvsCagraSearchParams.allocate(arena); - cuvsCagraSearchParams.max_queries(searchParamsMS, maxQueries); - cuvsCagraSearchParams.itopk_size(searchParamsMS, itopkSize); - cuvsCagraSearchParams.max_iterations(searchParamsMS, maxIterations); - cuvsCagraSearchParams.algo(searchParamsMS, algo.label); - cuvsCagraSearchParams.team_size(searchParamsMS, teamSize); - cuvsCagraSearchParams.search_width(searchParamsMS, searchWidth); - cuvsCagraSearchParams.min_iterations(searchParamsMS, minIterations); - cuvsCagraSearchParams.thread_block_size(searchParamsMS, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(searchParamsMS, hashmapMode.label); - cuvsCagraSearchParams.hashmap_min_bitlen(searchParamsMS, hashmapMinBitlen); - cuvsCagraSearchParams.hashmap_max_fill_rate(searchParamsMS, hashmapMaxFillRate); - cuvsCagraSearchParams.num_random_samplings(searchParamsMS, numRandomSamplings); - cuvsCagraSearchParams.rand_xor_mask(searchParamsMS, randXorMask); + cagraSearchParamsMS = cuvsCagraSearchParams.allocate(arena); + cuvsCagraSearchParams.max_queries(cagraSearchParamsMS, maxQueries); + cuvsCagraSearchParams.itopk_size(cagraSearchParamsMS, itopkSize); + cuvsCagraSearchParams.max_iterations(cagraSearchParamsMS, maxIterations); + cuvsCagraSearchParams.algo(cagraSearchParamsMS, algo.label); + cuvsCagraSearchParams.team_size(cagraSearchParamsMS, teamSize); + cuvsCagraSearchParams.search_width(cagraSearchParamsMS, searchWidth); + cuvsCagraSearchParams.min_iterations(cagraSearchParamsMS, minIterations); + cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMS, threadBlockSize); + cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMS, hashmapMode.label); + cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMS, hashmapMinBitlen); + cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMS, hashmapMaxFillRate); + cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMS, numRandomSamplings); + cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMS, randXorMask); } public int getMax_queries() { @@ -155,9 +156,8 @@ public String toString() { return "CagraSearchParams [max_queries=" + maxQueries + ", itopk_size=" + itopkSize + ", max_iterations=" + maxIterations + ", algo=" + algo + ", team_size=" + teamSize + ", search_width=" + searchWidth + ", min_iterations=" + minIterations + ", thread_block_size=" + threadBlockSize + ", hashmap_mode=" - + hashmapMode + ", hashmap_min_bitlen=" + hashmapMinBitlen + ", hashmap_max_fill_rate=" - + hashmapMaxFillRate + ", num_random_samplings=" + numRandomSamplings + ", rand_xor_mask=" + randXorMask - + "]"; + + hashmapMode + ", hashmap_min_bitlen=" + hashmapMinBitlen + ", hashmap_max_fill_rate=" + hashmapMaxFillRate + + ", num_random_samplings=" + numRandomSamplings + ", rand_xor_mask=" + randXorMask + "]"; } public static class Builder { @@ -248,8 +248,8 @@ public Builder withRandXorMask(long rand_xor_mask) { public CagraSearchParams build() throws Throwable { return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, algo, teamSize, searchWidth, - minIterations, threadBlockSize, hashmapMode, hashmapMinBitlen, hashmapMaxFillRate, - numRandomSamplings, randXorMask); + minIterations, threadBlockSize, hashmapMode, hashmapMinBitlen, hashmapMaxFillRate, numRandomSamplings, + randXorMask); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index 96111b0eb..027ceebe8 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -3,24 +3,20 @@ import java.util.Arrays; import java.util.Map; -import com.nvidia.cuvs.cagra.CuVSIndex.ANNAlgorithms; - public class CuVSQuery { - SearchParams searchParams; + CagraSearchParams searchParams; PreFilter preFilter; float[][] queryVectors; public Map mapping; - ANNAlgorithms algo; - - public CuVSQuery(SearchParams searchParams, PreFilter preFilter, float[][] queryVectors, - Map mapping, ANNAlgorithms algo) { + + public CuVSQuery(CagraSearchParams searchParams, PreFilter preFilter, float[][] queryVectors, + Map mapping) { super(); this.searchParams = searchParams; this.preFilter = preFilter; this.queryVectors = queryVectors; this.mapping = mapping; - this.algo = algo; } @Override @@ -29,7 +25,7 @@ public String toString() { + Arrays.toString(queryVectors) + "]"; } - public SearchParams getSearchParams() { + public CagraSearchParams getSearchParams() { return searchParams; } @@ -42,11 +38,10 @@ public float[][] getQueries() { } public static class Builder { - SearchParams searchParams; + CagraSearchParams searchParams; PreFilter preFilter; float[][] queryVectors; Map mapping; - ANNAlgorithms algo = ANNAlgorithms.CAGRA; /** * @@ -60,7 +55,7 @@ public Builder() { * @param dataset * @return */ - public Builder withSearchParams(SearchParams searchParams) { + public Builder withSearchParams(CagraSearchParams searchParams) { this.searchParams = searchParams; return this; } @@ -95,23 +90,13 @@ public Builder withMapping(Map mapping) { return this; } - /** - * - * @param params - * @return - */ - public Builder withANNAlgorithm(ANNAlgorithms algo) { - this.algo = algo; - return this; - } - /** * * @return * @throws Throwable */ public CuVSQuery build() throws Throwable { - return new CuVSQuery(searchParams, preFilter, queryVectors, mapping, algo); + return new CuVSQuery(searchParams, preFilter, queryVectors, mapping); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java index 14affd3b8..77fb36ff2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -16,7 +16,7 @@ public class CuVSResources { private Arena arena; private MethodHandle cresMH; private SymbolLookup bridge; - public MemorySegment resource; + private MemorySegment resource; /** * @@ -27,17 +27,19 @@ public CuVSResources() throws Throwable { arena = Arena.ofConfined(); File wd = new File(System.getProperty("user.dir")); - bridge = SymbolLookup.libraryLookup(wd.getParent() + "/api-sys/build/libcuvs_wrapper.so", arena); + bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); + + cresMH = linker.downcallHandle(bridge.findOrThrow("create_resource"), + FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - cresMH = linker.downcallHandle(bridge.findOrThrow("create_resource"), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - + resource = (MemorySegment) cresMH.invokeExact(rvMS); - - System.out.println("Create resource call return value: " + rvMS.get(ValueLayout.JAVA_INT, 0)); - + } + + public MemorySegment getResource() { + return resource; } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java deleted file mode 100644 index df073f36e..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/IndexParams.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.nvidia.cuvs.cagra; - -import java.lang.foreign.MemorySegment; - -public class IndexParams { - - public MemorySegment indexParamsMS; - -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java deleted file mode 100644 index 6cca9bf49..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchParams.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.nvidia.cuvs.cagra; - -import java.lang.foreign.MemorySegment; - -public class SearchParams { - - public MemorySegment searchParamsMS; - -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index ccc722267..8f9dc360f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -4,17 +4,13 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.invoke.VarHandle; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; public class SearchResult { - public List neighbours; // TODO: Get clarity on these two. - public List distances; - public Map results; - public Map mapping; + private Map results; + private Map mapping; SequenceLayout neighboursSL; SequenceLayout distancesSL; MemorySegment neighboursMS; @@ -30,8 +26,6 @@ public SearchResult(SequenceLayout neighboursSL, SequenceLayout distancesSL, Mem this.neighboursMS = neighboursMS; this.distancesMS = distancesMS; this.mapping = mapping; - neighbours = new ArrayList(); - distances = new ArrayList(); results = new HashMap(); this.load(); } @@ -46,4 +40,8 @@ private void load() { } } + public Map getResults() { + return results; + } + } From b7da0ef4949e8340f6fc7f656ba93010a1d1f35c Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Mon, 11 Nov 2024 09:58:22 -0500 Subject: [PATCH 23/53] make topK configurable --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 1 + .../com/nvidia/cuvs/cagra/CagraIndex.java | 6 ++--- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 25 +++++++++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 8f2e5ec2e..aa8f3dbd9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -54,6 +54,7 @@ public static void main(String[] args) throws Throwable { // Query CuVSQuery query = new CuVSQuery.Builder() + .withTopK(1) .withSearchParams(cagraSearchParams) .withQueryVectors(queries) .withMapping(map) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 440ada990..5b8557d20 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -168,10 +168,10 @@ public SearchResult search(CuVSQuery query) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.queryVectors), 2, 4L, 2L, res.getResource(), - neighborsMS, distancesMS, rvMS, query.searchParams.cagraSearchParamsMS); + searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, res.getResource(), + neighborsMS, distancesMS, rvMS, query.getSearchParams().cagraSearchParamsMS); - return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, 2, query.mapping); + return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping()); } /** diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index 027ceebe8..b99314503 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -9,14 +9,16 @@ public class CuVSQuery { PreFilter preFilter; float[][] queryVectors; public Map mapping; + int topK; public CuVSQuery(CagraSearchParams searchParams, PreFilter preFilter, float[][] queryVectors, - Map mapping) { + Map mapping, int topK) { super(); this.searchParams = searchParams; this.preFilter = preFilter; this.queryVectors = queryVectors; this.mapping = mapping; + this.topK = topK; } @Override @@ -37,11 +39,20 @@ public float[][] getQueries() { return queryVectors; } + public Map getMapping() { + return mapping; + } + + public int getTopK() { + return topK; + } + public static class Builder { CagraSearchParams searchParams; PreFilter preFilter; float[][] queryVectors; Map mapping; + int topK = 2; /** * @@ -89,6 +100,16 @@ public Builder withMapping(Map mapping) { this.mapping = mapping; return this; } + + /** + * + * @param topK + * @return + */ + public Builder withTopK(int topK) { + this.topK = topK; + return this; + } /** * @@ -96,7 +117,7 @@ public Builder withMapping(Map mapping) { * @throws Throwable */ public CuVSQuery build() throws Throwable { - return new CuVSQuery(searchParams, preFilter, queryVectors, mapping); + return new CuVSQuery(searchParams, preFilter, queryVectors, mapping, topK); } } From c4346d9a9e84d873bb0fbf4b4ffcfb1eae3a5641 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 05:39:47 -0500 Subject: [PATCH 24/53] multiple fixes --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 6 +-- .../com/nvidia/cuvs/cagra/CagraIndex.java | 39 +++++++++---------- .../nvidia/cuvs/cagra/CagraIndexParams.java | 16 +++++--- .../cuvs/cagra/CagraIndexReference.java | 6 ++- .../nvidia/cuvs/cagra/CagraSearchParams.java | 34 +++++++++------- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 12 +++--- .../com/nvidia/cuvs/cagra/CuVSResources.java | 6 +-- .../com/nvidia/cuvs/cagra/SearchResult.java | 35 +++++++++++------ .../src/test/java/ai/rapids/cuvs/AppTest.java | 19 --------- java/internal/src/cuvs_java.c | 29 +++++++------- 10 files changed, 101 insertions(+), 101 deletions(-) delete mode 100644 java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index aa8f3dbd9..516ec5797 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -29,15 +29,13 @@ public static void main(String[] args) throws Throwable { CagraIndexParams cagraIndexParams = new CagraIndexParams.Builder() .withIntermediateGraphDegree(10) .withBuildAlgo(CuvsCagraGraphBuildAlgo.IVF_PQ) - .withWriterThreads(1) .build(); CagraSearchParams cagraSearchParams = new CagraSearchParams .Builder() - .withMaxQueries(15) .build(); - // Creating a new index + // Creating a new CAGRA index CagraIndex index = new CagraIndex.Builder(res) .withDataset(dataset) .withIndexParams(cagraIndexParams) @@ -46,7 +44,7 @@ public static void main(String[] args) throws Throwable { // Saving the index on to the disk. index.serialize(new FileOutputStream("abc.cag")); - // Loading a cagra index from disk. + // Loading a CAGRA index from disk. InputStream fin = new FileInputStream(new File("abc.cag")); CagraIndex index2 = new CagraIndex.Builder(res) .from(fin) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 5b8557d20..a3b0d108d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -20,20 +20,17 @@ public class CagraIndex { + private Arena arena; private CagraIndexParams indexParams; private final float[][] dataset; private final CuVSResources res; private CagraIndexReference ref; - - Linker linker; - Arena arena; - MethodHandle cresMH; - MethodHandle indexMH; - MethodHandle searchMH; - MethodHandle serializeMH; - MethodHandle deserializeMH; - MemorySegment dataMS; - SymbolLookup bridge; + private Linker linker; + private MethodHandle indexMH; + private MethodHandle searchMH; + private MethodHandle serializeMH; + private MethodHandle deserializeMH; + private SymbolLookup bridge; /** * @@ -76,19 +73,19 @@ private void init() throws Throwable { File wd = new File(System.getProperty("user.dir")); bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); - indexMH = linker.downcallHandle(bridge.findOrThrow("build_index"), + indexMH = linker.downcallHandle(bridge.find("build_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - searchMH = linker.downcallHandle(bridge.findOrThrow("search_index"), + searchMH = linker.downcallHandle(bridge.find("search_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMH = linker.downcallHandle(bridge.findOrThrow("serialize_index"), + serializeMH = linker.downcallHandle(bridge.find("serialize_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMH = linker.downcallHandle(bridge.findOrThrow("deserialize_index"), + deserializeMH = linker.downcallHandle(bridge.find("deserialize_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } @@ -147,7 +144,7 @@ private CagraIndexReference build() throws Throwable { MemorySegment rvMS = arena.allocate(rvML); ref = new CagraIndexReference((MemorySegment) indexMH.invokeExact(getMemorySegment(dataset), rows, cols, - res.getResource(), rvMS, indexParams.cagraIndexParamsMS)); + res.getResource(), rvMS, indexParams.getCagraIndexParamsMS())); return ref; } @@ -168,10 +165,10 @@ public SearchResult search(CuVSQuery query) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - searchMH.invokeExact(ref.indexMemorySegment, getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, res.getResource(), - neighborsMS, distancesMS, rvMS, query.getSearchParams().cagraSearchParamsMS); + searchMH.invokeExact(ref.getIndexMemorySegment(), getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, + res.getResource(), neighborsMS, distancesMS, rvMS, query.getSearchParams().getCagraSearchParamsMS()); - return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping()); + return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping(), query.getQueries().length); } /** @@ -184,7 +181,7 @@ public void serialize(OutputStream out) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - serializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, + serializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, getStringSegment(new StringBuilder(tmpIndexFile))); File tempFile = new File(tmpIndexFile); FileInputStream is = new FileInputStream(tempFile); @@ -206,7 +203,7 @@ public void serialize(OutputStream out) throws Throwable { public void serialize(OutputStream out, String tmpFilePath) throws Throwable { MemoryLayout rvML = linker.canonicalLayouts().get("int"); MemorySegment rvMS = arena.allocate(rvML); - serializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, + serializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, getStringSegment(new StringBuilder(tmpFilePath))); File tempFile = new File(tmpFilePath); FileInputStream is = new FileInputStream(tempFile); @@ -238,7 +235,7 @@ private CagraIndexReference deserialize(InputStream in) throws Throwable { while ((chunkLen = in.read(chunk)) != -1) { out.write(chunk, 0, chunkLen); } - deserializeMH.invokeExact(res.getResource(), ref.indexMemorySegment, rvMS, + deserializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, getStringSegment(new StringBuilder(tmpIndexFile))); in.close(); diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index 8f8e9c3ff..be9991034 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -15,12 +15,12 @@ */ public class CagraIndexParams { - Arena arena; - int intermediateGraphDegree; - int graphDegree; - CuvsCagraGraphBuildAlgo buildAlgo; - int nnDescentNiter; - public MemorySegment cagraIndexParamsMS; + private Arena arena; + private int intermediateGraphDegree; + private int graphDegree; + private CuvsCagraGraphBuildAlgo buildAlgo; + private int nnDescentNiter; + private MemorySegment cagraIndexParamsMS; public enum CuvsCagraGraphBuildAlgo { AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); @@ -66,6 +66,10 @@ public int getNn_descent_niter() { return nnDescentNiter; } + public MemorySegment getCagraIndexParamsMS() { + return cagraIndexParamsMS; + } + @Override public String toString() { return "CagraIndexParams [intermediate_graph_degree=" + intermediateGraphDegree + ", graph_degree=" + graphDegree diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java index 897ab5d0f..ab186933f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -7,7 +7,7 @@ public class CagraIndexReference { - public MemorySegment indexMemorySegment; + private MemorySegment indexMemorySegment; /** * @@ -25,4 +25,8 @@ public CagraIndexReference(MemorySegment indexMemorySegment) { this.indexMemorySegment = indexMemorySegment; } + public MemorySegment getIndexMemorySegment() { + return indexMemorySegment; + } + } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index dcf856ff9..0b2af56f5 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -24,21 +24,21 @@ */ public class CagraSearchParams { - Arena arena; - int maxQueries; - int itopkSize; - int maxIterations; - CuvsCagraSearchAlgo algo; - int teamSize; - int searchWidth; - int minIterations; - int threadBlockSize; - CuvsCagraHashMode hashmapMode; - int hashmapMinBitlen; - float hashmapMaxFillRate; - int numRandomSamplings; - long randXorMask; - public MemorySegment cagraSearchParamsMS; + private Arena arena; + private int maxQueries; + private int itopkSize; + private int maxIterations; + private CuvsCagraSearchAlgo algo; + private int teamSize; + private int searchWidth; + private int minIterations; + private int threadBlockSize; + private CuvsCagraHashMode hashmapMode; + private int hashmapMinBitlen; + private float hashmapMaxFillRate; + private int numRandomSamplings; + private long randXorMask; + private MemorySegment cagraSearchParamsMS; enum CuvsCagraSearchAlgo { SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); @@ -151,6 +151,10 @@ public long getRand_xor_mask() { return randXorMask; } + public MemorySegment getCagraSearchParamsMS() { + return cagraSearchParamsMS; + } + @Override public String toString() { return "CagraSearchParams [max_queries=" + maxQueries + ", itopk_size=" + itopkSize + ", max_iterations=" diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index b99314503..672e0c5b9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -5,11 +5,11 @@ public class CuVSQuery { - CagraSearchParams searchParams; - PreFilter preFilter; - float[][] queryVectors; - public Map mapping; - int topK; + private CagraSearchParams searchParams; + private PreFilter preFilter; + private float[][] queryVectors; + private Map mapping; + private int topK; public CuVSQuery(CagraSearchParams searchParams, PreFilter preFilter, float[][] queryVectors, Map mapping, int topK) { @@ -100,7 +100,7 @@ public Builder withMapping(Map mapping) { this.mapping = mapping; return this; } - + /** * * @param topK diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java index 77fb36ff2..ffbd5b176 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -12,11 +12,11 @@ public class CuVSResources { - private Linker linker; private Arena arena; + private Linker linker; private MethodHandle cresMH; - private SymbolLookup bridge; private MemorySegment resource; + private SymbolLookup bridge; /** * @@ -29,7 +29,7 @@ public CuVSResources() throws Throwable { File wd = new File(System.getProperty("user.dir")); bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); - cresMH = linker.downcallHandle(bridge.findOrThrow("create_resource"), + cresMH = linker.downcallHandle(bridge.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); MemoryLayout rvML = linker.canonicalLayouts().get("int"); diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index 8f9dc360f..00da62f9c 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -5,28 +5,32 @@ import java.lang.foreign.SequenceLayout; import java.lang.invoke.VarHandle; import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; public class SearchResult { - private Map results; + private List> results; private Map mapping; - SequenceLayout neighboursSL; - SequenceLayout distancesSL; - MemorySegment neighboursMS; - MemorySegment distancesMS; - int topK; + private SequenceLayout neighboursSL; + private SequenceLayout distancesSL; + private MemorySegment neighboursMS; + private MemorySegment distancesMS; + private int topK; + private int numQueries; public SearchResult(SequenceLayout neighboursSL, SequenceLayout distancesSL, MemorySegment neighboursMS, - MemorySegment distancesMS, int topK, Map mapping) { + MemorySegment distancesMS, int topK, Map mapping, int numQueries) { super(); this.topK = topK; + this.numQueries = numQueries; this.neighboursSL = neighboursSL; this.distancesSL = distancesSL; this.neighboursMS = neighboursMS; this.distancesMS = distancesMS; this.mapping = mapping; - results = new HashMap(); + results = new LinkedList>(); this.load(); } @@ -34,13 +38,22 @@ private void load() { VarHandle neighboursVH = neighboursSL.varHandle(PathElement.sequenceElement()); VarHandle distancesVH = distancesSL.varHandle(PathElement.sequenceElement()); - for (long i = 0; i < topK; i++) { + Map irm = new HashMap(); + int count = 0; + for (long i = 0; i < topK * numQueries; i++) { int id = (int) neighboursVH.get(neighboursMS, 0L, i); - results.put(mapping != null ? mapping.get(id) : id, (float) distancesVH.get(distancesMS, 0L, i)); + float dst = (float) distancesVH.get(distancesMS, 0L, i); + irm.put(mapping != null ? mapping.get(id) : id, dst); + count += 1; + if (count == topK) { + results.add(irm); + irm = new HashMap(); + count = 0; + } } } - public Map getResults() { + public List> getResults() { return results; } diff --git a/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java b/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java deleted file mode 100644 index 73037fabb..000000000 --- a/java/cuvs-java/src/test/java/ai/rapids/cuvs/AppTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package ai.rapids.cuvs; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import org.junit.jupiter.api.Test; - -/** - * Unit test for simple App. - */ -public class AppTest { - - /** - * Rigorous Test :-) - */ - @Test - public void shouldAnswerWithTrue() { - assertTrue(true); - } -} diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index da11cfd15..db8177e6e 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -11,12 +11,12 @@ cuvsResources_t create_resource(int *rv) { return res; } -DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) { +DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, long dimensions) { DLManagedTensor tensor; tensor.dl_tensor.data = data; tensor.dl_tensor.device.device_type = kDLCUDA; - tensor.dl_tensor.ndim = 2; + tensor.dl_tensor.ndim = dimensions; tensor.dl_tensor.dtype.code = code; tensor.dl_tensor.dtype.bits = 32; tensor.dl_tensor.dtype.lanes = 1; @@ -25,12 +25,12 @@ DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) return tensor; } - -cuvsCagraIndex_t build_index(float *dataset, long rows, long dimension, cuvsResources_t res, int *rv, + +cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsResources_t res, int *rv, cuvsCagraIndexParams_t index_params) { - int64_t dataset_shape[2] = {rows, dimension}; - DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat); + int64_t dataset_shape[2] = {rows, dimensions}; + DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat, dimensions); cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); @@ -47,27 +47,26 @@ void deserialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, cha *rv = cuvsCagraDeserialize(res, filename, index); } -void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimension, - cuvsResources_t res, int *neighbors_h, float *distances_h, int *rv, cuvsCagraSearchParams_t search_params1) { +void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, + cuvsResources_t res, int *neighbors_h, float *distances_h, int *rv, cuvsCagraSearchParams_t search_params) { uint32_t *neighbors; float *distances, *queries_d; - cuvsRMMAlloc(res, (void**) &queries_d, sizeof(float) * n_queries * dimension); + cuvsRMMAlloc(res, (void**) &queries_d, sizeof(float) * n_queries * dimensions); cuvsRMMAlloc(res, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); cuvsRMMAlloc(res, (void**) &distances, sizeof(float) * n_queries * topk); - cudaMemcpy(queries_d, queries, sizeof(float) * 4 * 2, cudaMemcpyDefault); + cudaMemcpy(queries_d, queries, sizeof(float) * n_queries * dimensions, cudaMemcpyDefault); - int64_t queries_shape[2] = {n_queries, dimension}; - DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat); + int64_t queries_shape[2] = {n_queries, dimensions}; + DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat, dimensions); int64_t neighbors_shape[2] = {n_queries, topk}; - DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt); + DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt, dimensions); int64_t distances_shape[2] = {n_queries, topk}; - DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat); + DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat, dimensions); - cuvsCagraSearchParams_t search_params; cuvsCagraSearchParamsCreate(&search_params); *rv = cuvsCagraSearch(res, search_params, index, &queries_tensor, &neighbors_tensor, From cefadb8549db6fe7b4d7d0a275f157551c45b202 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 05:57:23 -0500 Subject: [PATCH 25/53] pom file update --- java/cuvs-java/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 4bf91702f..78c3de33c 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -9,8 +9,8 @@ jar - 21 - 21 + 22 + 22 From 8492c720d468da437285facd3e165a6fd66901c4 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 08:15:28 -0500 Subject: [PATCH 26/53] sample test --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 2 +- .../com/nvidia/cuvs/cagra/SearchResult.java | 6 +- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 144 ++++++++++++++++++ 3 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 516ec5797..6ccb5f5bf 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -52,7 +52,7 @@ public static void main(String[] args) throws Throwable { // Query CuVSQuery query = new CuVSQuery.Builder() - .withTopK(1) + .withTopK(3) .withSearchParams(cagraSearchParams) .withQueryVectors(queries) .withMapping(map) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index 00da62f9c..bfc7a8ba1 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -5,9 +5,11 @@ import java.lang.foreign.SequenceLayout; import java.lang.invoke.VarHandle; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.stream.Stream; public class SearchResult { @@ -38,7 +40,7 @@ private void load() { VarHandle neighboursVH = neighboursSL.varHandle(PathElement.sequenceElement()); VarHandle distancesVH = distancesSL.varHandle(PathElement.sequenceElement()); - Map irm = new HashMap(); + Map irm = new LinkedHashMap(); int count = 0; for (long i = 0; i < topK * numQueries; i++) { int id = (int) neighboursVH.get(neighboursMS, 0L, i); @@ -47,7 +49,7 @@ private void load() { count += 1; if (count == topK) { results.add(irm); - irm = new HashMap(); + irm = new LinkedHashMap(); count = 0; } } diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java new file mode 100644 index 000000000..075f0388c --- /dev/null +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -0,0 +1,144 @@ +package com.nvidia.cuvs; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.AbstractMap; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.PriorityQueue; +import java.util.Random; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import org.junit.jupiter.api.Test; + +import com.nvidia.cuvs.cagra.CagraIndex; +import com.nvidia.cuvs.cagra.CagraIndexParams; +import com.nvidia.cuvs.cagra.CagraSearchParams; +import com.nvidia.cuvs.cagra.CuVSQuery; +import com.nvidia.cuvs.cagra.CuVSResources; +import com.nvidia.cuvs.cagra.SearchResult; + +public class CagraBuildAndSearchTest { + + private static final int VECTOR_DIMENSION = 2; + private static final int DATASET_SIZE = 11; + private static final int QUERY_SIZE = 2; + private static final int TOP_K = 4; + + // Helper method to generate random vectors + private float[][] generateRandomVectors(int size) { + Random rand = new Random(); + float[][] vectors = new float[size][VECTOR_DIMENSION]; + for (int i = 0; i < size; i++) { + for (int j = 0; j < VECTOR_DIMENSION; j++) { + vectors[i][j] = rand.nextFloat(); + } + } + return vectors; + } + + // Helper method to calculate Euclidean distance + private double calculateDistance(float[] v1, float[] v2) { + double sum = 0.0; + for (int i = 0; i < v1.length; i++) { + sum += Math.pow(v1[i] - v2[i], 2); + } + return Math.sqrt(sum); + } + + // Helper method to calculate top-K distances manually + private List> getExpectedTopKItems(float[] query, float[][] dataset, int k) { + PriorityQueue> heap = new PriorityQueue<>( + Comparator.>comparingDouble(Map.Entry::getValue).reversed()); + + for (int i = 0; i < dataset.length; i++) { + double distance = calculateDistance(query, dataset[i]); + if (heap.size() < k) { + heap.offer(new AbstractMap.SimpleEntry<>(i, distance)); + } else if (distance < heap.peek().getValue()) { + heap.poll(); + heap.offer(new AbstractMap.SimpleEntry<>(i, distance)); + } + } + + return heap.stream().sorted(Comparator.comparingDouble(Map.Entry::getValue)).collect(Collectors.toList()); + } + + /** + * A basic test that checks the whole flow - from indexing to search. + * + * @throws Throwable + */ + @Test + public void testIndexingAndSearchingFlow() throws Throwable { + + float[][] dataset = generateRandomVectors(DATASET_SIZE); + float[][] queries = generateRandomVectors(QUERY_SIZE); + + // Create map for dataset IDs + Map map = IntStream + .range(0, dataset.length) + .boxed() + .collect(Collectors.toMap(i -> i, i -> i)); + + CuVSResources res = new CuVSResources(); + + // Configure index parameters + CagraIndexParams cagraIndexParams = new CagraIndexParams + .Builder() + .withIntermediateGraphDegree(10) + .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.IVF_PQ) + .build(); + + // Create the index with the dataset + CagraIndex index = new CagraIndex + .Builder(res) + .withDataset(dataset) + .withIndexParams(cagraIndexParams) + .build(); + + // Configure search parameters + CagraSearchParams cagraSearchParams = new CagraSearchParams + .Builder() + .build(); + + // Create a query object with the query vectors + CuVSQuery query = new CuVSQuery + .Builder() + .withTopK(TOP_K) + .withSearchParams(cagraSearchParams) + .withQueryVectors(queries) + .withMapping(map) + .build(); + + // Perform the search + SearchResult rslt = index.search(query); + List> queryResults = rslt.getResults(); + + // Validate the results for each query + for (int queryIndex = 0; queryIndex < QUERY_SIZE; queryIndex++) { + + // Calculate expected top-K items for the current query + List> expectedTopK = getExpectedTopKItems(queries[queryIndex], dataset, TOP_K); + + // printing expected and actual results + System.out.println("\nQuery " + queryIndex + ":"); + System.out.println("Expected Top-K Results:"); + expectedTopK.forEach(entry -> System.out.println("ID: " + entry.getKey())); + + System.out.println("Actual Top-K Results:"); + queryResults.get(queryIndex).entrySet().stream().limit(TOP_K) + .forEach(entry -> System.out.println("ID: " + entry.getKey())); + + // Check each of the topK IDs retrieved for the current query + List returnedIDs = new LinkedList(queryResults.get(queryIndex).keySet()); + for (int i = 0; i < TOP_K; i++) { + assertEquals(expectedTopK.get(i).getKey(), returnedIDs.get(i), + "Returned ID does not match with expected ID (missing or not in order)"); + } + } + } +} \ No newline at end of file From 8e7c62c062a290502fe667129a28c3837e472b4d Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 09:32:01 -0500 Subject: [PATCH 27/53] sample test update + other changes --- .../com/nvidia/cuvs/cagra/CagraIndex.java | 3 +- .../com/nvidia/cuvs/cagra/SearchResult.java | 2 - .../nvidia/cuvs/CagraBuildAndSearchTest.java | 106 ++++-------------- 3 files changed, 21 insertions(+), 90 deletions(-) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index a3b0d108d..39e62ca5a 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -168,7 +168,8 @@ public SearchResult search(CuVSQuery query) throws Throwable { searchMH.invokeExact(ref.getIndexMemorySegment(), getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, res.getResource(), neighborsMS, distancesMS, rvMS, query.getSearchParams().getCagraSearchParamsMS()); - return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping(), query.getQueries().length); + return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping(), + query.getQueries().length); } /** diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index bfc7a8ba1..e75518fca 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -4,12 +4,10 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.invoke.VarHandle; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.stream.Stream; public class SearchResult { diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index 075f0388c..822c3300e 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -2,15 +2,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import java.util.AbstractMap; -import java.util.Comparator; -import java.util.LinkedList; +import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.PriorityQueue; -import java.util.Random; -import java.util.stream.Collectors; -import java.util.stream.IntStream; import org.junit.jupiter.api.Test; @@ -23,50 +17,6 @@ public class CagraBuildAndSearchTest { - private static final int VECTOR_DIMENSION = 2; - private static final int DATASET_SIZE = 11; - private static final int QUERY_SIZE = 2; - private static final int TOP_K = 4; - - // Helper method to generate random vectors - private float[][] generateRandomVectors(int size) { - Random rand = new Random(); - float[][] vectors = new float[size][VECTOR_DIMENSION]; - for (int i = 0; i < size; i++) { - for (int j = 0; j < VECTOR_DIMENSION; j++) { - vectors[i][j] = rand.nextFloat(); - } - } - return vectors; - } - - // Helper method to calculate Euclidean distance - private double calculateDistance(float[] v1, float[] v2) { - double sum = 0.0; - for (int i = 0; i < v1.length; i++) { - sum += Math.pow(v1[i] - v2[i], 2); - } - return Math.sqrt(sum); - } - - // Helper method to calculate top-K distances manually - private List> getExpectedTopKItems(float[] query, float[][] dataset, int k) { - PriorityQueue> heap = new PriorityQueue<>( - Comparator.>comparingDouble(Map.Entry::getValue).reversed()); - - for (int i = 0; i < dataset.length; i++) { - double distance = calculateDistance(query, dataset[i]); - if (heap.size() < k) { - heap.offer(new AbstractMap.SimpleEntry<>(i, distance)); - } else if (distance < heap.peek().getValue()) { - heap.poll(); - heap.offer(new AbstractMap.SimpleEntry<>(i, distance)); - } - } - - return heap.stream().sorted(Comparator.comparingDouble(Map.Entry::getValue)).collect(Collectors.toList()); - } - /** * A basic test that checks the whole flow - from indexing to search. * @@ -75,21 +25,24 @@ private List> getExpectedTopKItems(float[] query, flo @Test public void testIndexingAndSearchingFlow() throws Throwable { - float[][] dataset = generateRandomVectors(DATASET_SIZE); - float[][] queries = generateRandomVectors(QUERY_SIZE); - - // Create map for dataset IDs - Map map = IntStream - .range(0, dataset.length) - .boxed() - .collect(Collectors.toMap(i -> i, i -> i)); - + // Sample data and query + float[][] dataset = {{ 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, { 0.6673192f, 0.10993068f }}; + Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); + float[][] queries = {{ 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f }}; + + // Expected search result + List> expectedQueryResults = Arrays.asList( + Map.of(3, 0.038782578f, 2, 0.3590463f, 0, 0.83774555f), + Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), + Map.of(3, 0.047766715f, 2, 0.20332818f, 0, 0.48305473f), + Map.of(1, 0.15224178f, 0, 0.59063464f, 3, 0.5986642f)); + + // Create resource CuVSResources res = new CuVSResources(); // Configure index parameters CagraIndexParams cagraIndexParams = new CagraIndexParams .Builder() - .withIntermediateGraphDegree(10) .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.IVF_PQ) .build(); @@ -108,37 +61,16 @@ public void testIndexingAndSearchingFlow() throws Throwable { // Create a query object with the query vectors CuVSQuery query = new CuVSQuery .Builder() - .withTopK(TOP_K) + .withTopK(3) .withSearchParams(cagraSearchParams) .withQueryVectors(queries) .withMapping(map) .build(); // Perform the search - SearchResult rslt = index.search(query); - List> queryResults = rslt.getResults(); - - // Validate the results for each query - for (int queryIndex = 0; queryIndex < QUERY_SIZE; queryIndex++) { - - // Calculate expected top-K items for the current query - List> expectedTopK = getExpectedTopKItems(queries[queryIndex], dataset, TOP_K); - - // printing expected and actual results - System.out.println("\nQuery " + queryIndex + ":"); - System.out.println("Expected Top-K Results:"); - expectedTopK.forEach(entry -> System.out.println("ID: " + entry.getKey())); - - System.out.println("Actual Top-K Results:"); - queryResults.get(queryIndex).entrySet().stream().limit(TOP_K) - .forEach(entry -> System.out.println("ID: " + entry.getKey())); - - // Check each of the topK IDs retrieved for the current query - List returnedIDs = new LinkedList(queryResults.get(queryIndex).keySet()); - for (int i = 0; i < TOP_K; i++) { - assertEquals(expectedTopK.get(i).getKey(), returnedIDs.get(i), - "Returned ID does not match with expected ID (missing or not in order)"); - } - } + SearchResult searchResults = index.search(query); + + // Check results + assertEquals(expectedQueryResults, searchResults.getResults(), "Results different than expected"); } } \ No newline at end of file From eb94a0f9e70794d1fbaeb81657e172acb2e7473c Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Thu, 14 Nov 2024 12:28:52 -0500 Subject: [PATCH 28/53] sample test update + use logging --- .../main/java/com/nvidia/cuvs/ExampleApp.java | 15 +++++--- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 37 ++++++++++++++++++- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 6ccb5f5bf..4aebe902d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -6,6 +6,9 @@ import java.io.InputStream; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; import com.nvidia.cuvs.cagra.CagraIndexParams.CuvsCagraGraphBuildAlgo; @@ -15,6 +18,9 @@ import com.nvidia.cuvs.cagra.SearchResult; public class ExampleApp { + + private static Logger LOGGER = LoggerFactory.getLogger(ExampleApp.class); + public static void main(String[] args) throws Throwable { // Sample data and query @@ -28,7 +34,7 @@ public static void main(String[] args) throws Throwable { CagraIndexParams cagraIndexParams = new CagraIndexParams.Builder() .withIntermediateGraphDegree(10) - .withBuildAlgo(CuvsCagraGraphBuildAlgo.IVF_PQ) + .withBuildAlgo(CuvsCagraGraphBuildAlgo.NN_DESCENT) .build(); CagraSearchParams cagraSearchParams = new CagraSearchParams @@ -60,11 +66,10 @@ public static void main(String[] args) throws Throwable { // Search SearchResult rslt = index.search(query); - System.out.println(rslt.getResults()); + LOGGER.info(rslt.getResults().toString()); // Search from de-serialized index SearchResult rslt2 = index2.search(query); - System.out.println(rslt2.getResults()); - + LOGGER.info(rslt2.getResults().toString()); } -} +} \ No newline at end of file diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index 822c3300e..b5f553108 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -2,11 +2,18 @@ import static org.junit.jupiter.api.Assertions.assertEquals; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.UUID; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; @@ -16,6 +23,8 @@ import com.nvidia.cuvs.cagra.SearchResult; public class CagraBuildAndSearchTest { + + private static Logger LOGGER = LoggerFactory.getLogger(CagraBuildAndSearchTest.class); /** * A basic test that checks the whole flow - from indexing to search. @@ -30,7 +39,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); float[][] queries = {{ 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f }}; - // Expected search result + // Expected search results List> expectedQueryResults = Arrays.asList( Map.of(3, 0.038782578f, 2, 0.3590463f, 0, 0.83774555f), Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), @@ -43,7 +52,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { // Configure index parameters CagraIndexParams cagraIndexParams = new CagraIndexParams .Builder() - .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.IVF_PQ) + .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.NN_DESCENT) .build(); // Create the index with the dataset @@ -53,6 +62,17 @@ public void testIndexingAndSearchingFlow() throws Throwable { .withIndexParams(cagraIndexParams) .build(); + // Saving the index on to the disk. + String fileName = UUID.randomUUID().toString() + ".cag"; + index.serialize(new FileOutputStream(fileName)); + + // Loading a CAGRA index from disk. + File testSerializedIndexFile = new File(fileName); + InputStream fin = new FileInputStream(testSerializedIndexFile); + CagraIndex index2 = new CagraIndex.Builder(res) + .from(fin) + .build(); + // Configure search parameters CagraSearchParams cagraSearchParams = new CagraSearchParams .Builder() @@ -71,6 +91,19 @@ public void testIndexingAndSearchingFlow() throws Throwable { SearchResult searchResults = index.search(query); // Check results + LOGGER.info(searchResults.getResults().toString()); assertEquals(expectedQueryResults, searchResults.getResults(), "Results different than expected"); + + // Search from de-serialized index + SearchResult searchResults2 = index2.search(query); + + // Check results + LOGGER.info(searchResults.getResults().toString()); + assertEquals(expectedQueryResults, searchResults2.getResults(), "Results different than expected"); + + // Cleanup + if (testSerializedIndexFile.exists()) { + testSerializedIndexFile.delete(); + } } } \ No newline at end of file From d32f8f94480e1cc13ca9f5261f9af3770da43457 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Fri, 15 Nov 2024 11:29:56 -0500 Subject: [PATCH 29/53] variable name updates + other --- java/cuvs-java/pom.xml | 52 +- .../main/java/com/nvidia/cuvs/ExampleApp.java | 70 +- .../com/nvidia/cuvs/cagra/CagraIndex.java | 330 +- .../nvidia/cuvs/cagra/CagraIndexParams.java | 84 +- .../cuvs/cagra/CagraIndexReference.java | 24 +- .../nvidia/cuvs/cagra/CagraSearchParams.java | 204 +- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 95 +- .../com/nvidia/cuvs/cagra/CuVSResources.java | 47 +- .../nvidia/cuvs/cagra/PointerToDataset.java | 5 - .../java/com/nvidia/cuvs/cagra/PreFilter.java | 19 + .../com/nvidia/cuvs/cagra/SearchResult.java | 60 +- .../com/nvidia/cuvs/panama/DLDataType.java | 16 + .../java/com/nvidia/cuvs/panama/DLDevice.java | 16 + .../nvidia/cuvs/panama/DLManagedTensor.java | 16 + .../cuvs/panama/DLManagedTensorVersioned.java | 16 + .../com/nvidia/cuvs/panama/DLPackVersion.java | 16 + .../java/com/nvidia/cuvs/panama/DLTensor.java | 16 + .../java/com/nvidia/cuvs/panama/__fsid_t.java | 16 + .../com/nvidia/cuvs/panama/brute_force_h.java | 45 +- .../java/com/nvidia/cuvs/panama/cagra_h.java | 16 + .../panama/cuvsCagraCompressionParams.java | 16 + .../nvidia/cuvs/panama/cuvsCagraIndex.java | 16 + .../cuvs/panama/cuvsCagraIndexParams.java | 16 + .../cuvs/panama/cuvsCagraSearchParams.java | 16 + .../com/nvidia/cuvs/panama/cuvsFilter.java | 33 +- .../java/com/nvidia/cuvs/panama/dlpack_h.java | 16 + .../java/com/nvidia/cuvs/panama/hnsw_h.java | 4933 ++++++------- .../com/nvidia/cuvs/panama/ivf_flat_h.java | 5625 +++++++-------- .../java/com/nvidia/cuvs/panama/ivf_pq_h.java | 6266 +++++++++-------- .../com/nvidia/cuvs/panama/max_align_t.java | 16 + .../java/com/nvidia/cuvs/panama/results.java | 16 + .../com/nvidia/cuvs/panama/results_h.java | 16 + .../nvidia/cuvs/CagraBuildAndSearchTest.java | 61 +- java/internal/src/cuvs_java.c | 50 +- 34 files changed, 9413 insertions(+), 8846 deletions(-) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 78c3de33c..41ea18ca9 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -1,3 +1,20 @@ + @@ -11,6 +28,8 @@ 22 22 + UTF-8 + UTF-8 @@ -26,19 +45,19 @@ 1.1 - - org.slf4j - slf4j-api - 2.0.13 - + + org.slf4j + slf4j-api + 2.0.13 + + + + org.slf4j + slf4j-simple + 2.0.13 + runtime + - - org.slf4j - slf4j-simple - 2.0.13 - runtime - - org.junit.jupiter junit-jupiter-api @@ -130,6 +149,15 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.2 + + com.nvidia.cuvs,com.nvidia.cuvs.panama + ${project.build.directory} + + diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java index 4aebe902d..592720827 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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 java.io.File; @@ -19,7 +35,7 @@ public class ExampleApp { - private static Logger LOGGER = LoggerFactory.getLogger(ExampleApp.class); + private static Logger logger = LoggerFactory.getLogger(ExampleApp.class); public static void main(String[] args) throws Throwable { @@ -30,46 +46,56 @@ public static void main(String[] args) throws Throwable { float[][] queries = { { 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f } }; - CuVSResources res = new CuVSResources(); + CuVSResources cuvsResources = new CuVSResources(); - CagraIndexParams cagraIndexParams = new CagraIndexParams.Builder() - .withIntermediateGraphDegree(10) - .withBuildAlgo(CuvsCagraGraphBuildAlgo.NN_DESCENT) - .build(); - - CagraSearchParams cagraSearchParams = new CagraSearchParams + CagraIndexParams cagraIndexParameters = new CagraIndexParams .Builder() + .withIntermediateGraphDegree(10) + .withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo.NN_DESCENT) .build(); // Creating a new CAGRA index - CagraIndex index = new CagraIndex.Builder(res) + CagraIndex cagraIndex = new CagraIndex + .Builder(cuvsResources) .withDataset(dataset) - .withIndexParams(cagraIndexParams) + .withIndexParams(cagraIndexParameters) .build(); - // Saving the index on to the disk. - index.serialize(new FileOutputStream("abc.cag")); + // Saving the CAGRA index on to the disk. + File indexFile = new File("sample_index.cag"); + cagraIndex.serialize(new FileOutputStream(indexFile)); // Loading a CAGRA index from disk. - InputStream fin = new FileInputStream(new File("abc.cag")); - CagraIndex index2 = new CagraIndex.Builder(res) - .from(fin) + InputStream fileInputStream = new FileInputStream(indexFile); + CagraIndex deserializedIndex = new CagraIndex + .Builder(cuvsResources) + .from(fileInputStream) + .build(); + + CagraSearchParams cagraSearchParameters = new CagraSearchParams + .Builder() .build(); // Query - CuVSQuery query = new CuVSQuery.Builder() + CuVSQuery cuvsQuery = new CuVSQuery + .Builder() .withTopK(3) - .withSearchParams(cagraSearchParams) + .withSearchParams(cagraSearchParameters) .withQueryVectors(queries) .withMapping(map) .build(); // Search - SearchResult rslt = index.search(query); - LOGGER.info(rslt.getResults().toString()); + SearchResult searchResult = cagraIndex.search(cuvsQuery); + logger.info(searchResult.getResults().toString()); - // Search from de-serialized index - SearchResult rslt2 = index2.search(query); - LOGGER.info(rslt2.getResults().toString()); + // Search from deserialized index + SearchResult searchResultFromDeserializedIndex = deserializedIndex.search(cuvsQuery); + logger.info(searchResultFromDeserializedIndex.getResults().toString()); + + // Cleanup + if (indexFile.exists()) { + indexFile.delete(); + } } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 39e62ca5a..75d12736e 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.io.File; @@ -18,313 +34,229 @@ import java.lang.invoke.VarHandle; import java.util.UUID; +/** + * CagraIndex encapsulates the implementation of crucial methods for interacting + * with the CAGRA index. + *

+ * CAGRA is a graph-based nearest neighbors algorithm that was built from the + * ground up for GPU acceleration. CAGRA demonstrates state-of-the art index + * build and query performance for both small- and large-batch sized search. + */ public class CagraIndex { - private Arena arena; - private CagraIndexParams indexParams; private final float[][] dataset; - private final CuVSResources res; - private CagraIndexReference ref; + private final CuVSResources cuvsResources; + private Arena arena; + private CagraIndexParams cagraIndexParameters; + private CagraIndexReference cagraIndesReference; private Linker linker; - private MethodHandle indexMH; - private MethodHandle searchMH; - private MethodHandle serializeMH; - private MethodHandle deserializeMH; - private SymbolLookup bridge; - - /** - * - * @param indexParams - * @param dataset - * @param mapping - * @param res - * @throws Throwable - */ - private CagraIndex(CagraIndexParams indexParams, float[][] dataset, CuVSResources res) throws Throwable { - this.indexParams = indexParams; + private MethodHandle indexMethodHandle; + private MethodHandle searchMethodHandle; + private MethodHandle serializeMethodHandle; + private MethodHandle deserializeMethodHandle; + private SymbolLookup symbolLookup; + + private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources cuvsResources) + throws Throwable { + this.cagraIndexParameters = indexParameters; this.dataset = dataset; this.init(); - this.res = res; - this.ref = build(); + this.cuvsResources = cuvsResources; + this.cagraIndesReference = build(); } - /** - * - * @param in - * @param res - * @throws Throwable - */ - private CagraIndex(InputStream in, CuVSResources res) throws Throwable { - this.indexParams = null; + private CagraIndex(InputStream inputStream, CuVSResources cuvsResources) throws Throwable { + this.cagraIndexParameters = null; this.dataset = null; - this.res = res; + this.cuvsResources = cuvsResources; this.init(); - this.ref = deserialize(in); + this.cagraIndesReference = deserialize(inputStream); } - /** - * - * @throws Throwable - */ private void init() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); - File wd = new File(System.getProperty("user.dir")); - bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); + File workingDirectory = new File(System.getProperty("user.dir")); + symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - indexMH = linker.downcallHandle(bridge.find("build_index").get(), + indexMethodHandle = linker.downcallHandle(symbolLookup.find("build_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - searchMH = linker.downcallHandle(bridge.find("search_index").get(), + searchMethodHandle = linker.downcallHandle(symbolLookup.find("search_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMH = linker.downcallHandle(bridge.find("serialize_index").get(), + serializeMethodHandle = linker.downcallHandle(symbolLookup.find("serialize_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMH = linker.downcallHandle(bridge.find("deserialize_index").get(), + deserializeMethodHandle = linker.downcallHandle(symbolLookup.find("deserialize_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } - /** - * Java String -> C char* - * - * @param str - * @return MemorySegment - */ - public MemorySegment getStringSegment(StringBuilder str) { - str.append('\0'); - MemoryLayout sq = MemoryLayout.sequenceLayout(str.length(), linker.canonicalLayouts().get("char")); + public MemorySegment getStringSegment(StringBuilder string) { + string.append('\0'); + MemoryLayout sq = MemoryLayout.sequenceLayout(string.length(), linker.canonicalLayouts().get("char")); MemorySegment fln = arena.allocate(sq); - for (int i = 0; i < str.length(); i++) { + for (int i = 0; i < string.length(); i++) { VarHandle flnVH = sq.varHandle(PathElement.sequenceElement(i)); - flnVH.set(fln, 0L, (byte) str.charAt(i)); + flnVH.set(fln, 0L, (byte) string.charAt(i)); } return fln; } - /** - * - * @param data - * @return - */ private MemorySegment getMemorySegment(float[][] data) { long rows = data.length; long cols = data[0].length; - MemoryLayout dataML = MemoryLayout.sequenceLayout(rows, + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); - MemorySegment dataMS = arena.allocate(dataML); + MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { - VarHandle element = dataML.arrayElementVarHandle(PathElement.sequenceElement(r), + VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), PathElement.sequenceElement(c)); - element.set(dataMS, 0, 0, data[r][c]); + element.set(dataMemorySegment, 0, 0, data[r][c]); } } - return dataMS; + return dataMemorySegment; } - /** - * - * @return - * @throws Throwable - */ private CagraIndexReference build() throws Throwable { long rows = dataset.length; long cols = dataset[0].length; - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); + MemoryLayout returnvalueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnvalueMemorySegment = arena.allocate(returnvalueMemoryLayout); - ref = new CagraIndexReference((MemorySegment) indexMH.invokeExact(getMemorySegment(dataset), rows, cols, - res.getResource(), rvMS, indexParams.getCagraIndexParamsMS())); + cagraIndesReference = new CagraIndexReference((MemorySegment) indexMethodHandle.invokeExact( + getMemorySegment(dataset), rows, cols, cuvsResources.getCuvsResourcesMemorySegment(), returnvalueMemorySegment, + cagraIndexParameters.getCagraIndexParamsMemorySegment())); - return ref; + return cagraIndesReference; } - /** - * - * @param params - * @param queryVectors - * @return - * @throws Throwable - */ - public SearchResult search(CuVSQuery query) throws Throwable { - - SequenceLayout neighborsSL = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); - SequenceLayout distancesSL = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); - MemorySegment neighborsMS = arena.allocate(neighborsSL); - MemorySegment distancesMS = arena.allocate(distancesSL); - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); - - searchMH.invokeExact(ref.getIndexMemorySegment(), getMemorySegment(query.getQueries()), query.getTopK(), 4L, 2L, - res.getResource(), neighborsMS, distancesMS, rvMS, query.getSearchParams().getCagraSearchParamsMS()); - - return new SearchResult(neighborsSL, distancesSL, neighborsMS, distancesMS, query.getTopK(), query.getMapping(), - query.getQueries().length); + public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { + + SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); + SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); + MemorySegment neighborsMemorySegment = arena.allocate(neighborsSequenceLayout); + MemorySegment distancesMemorySegment = arena.allocate(distancesSequenceLayout); + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); + + searchMethodHandle.invokeExact(cagraIndesReference.getIndexMemorySegment(), + getMemorySegment(cuvsQuery.getQueryVectors()), cuvsQuery.getTopK(), 4L, 2L, + cuvsResources.getCuvsResourcesMemorySegment(), neighborsMemorySegment, distancesMemorySegment, + returnValueMemorySegment, cuvsQuery.getCagraSearchParameters().getCagraSearchParamsMS()); + + return new SearchResult(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, + distancesMemorySegment, cuvsQuery.getTopK(), cuvsQuery.getMapping(), cuvsQuery.getQueryVectors().length); } - /** - * - * @param out - * @param tmpFilePath - * @throws Throwable - */ - public void serialize(OutputStream out) throws Throwable { - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); + public void serialize(OutputStream outputStream) throws Throwable { + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - serializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, + serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), + cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, getStringSegment(new StringBuilder(tmpIndexFile))); File tempFile = new File(tmpIndexFile); - FileInputStream is = new FileInputStream(tempFile); + FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; - int chunkLen = 0; - while ((chunkLen = is.read(chunk)) != -1) { - out.write(chunk, 0, chunkLen); + int chunkLength = 0; + while ((chunkLength = fileInputStream.read(chunk)) != -1) { + outputStream.write(chunk, 0, chunkLength); } - is.close(); + fileInputStream.close(); tempFile.delete(); } - /** - * - * @param out - * @param tmpFilePath - * @throws Throwable - */ - public void serialize(OutputStream out, String tmpFilePath) throws Throwable { - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); - serializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, + public void serialize(OutputStream outputStream, String tmpFilePath) throws Throwable { + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); + serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), + cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, getStringSegment(new StringBuilder(tmpFilePath))); File tempFile = new File(tmpFilePath); - FileInputStream is = new FileInputStream(tempFile); + FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; - int chunkLen = 0; - while ((chunkLen = is.read(chunk)) != -1) { - out.write(chunk, 0, chunkLen); + int chunkLength = 0; + while ((chunkLength = fileInputStream.read(chunk)) != -1) { + outputStream.write(chunk, 0, chunkLength); } - is.close(); + fileInputStream.close(); tempFile.delete(); } - /** - * - * @param in - * @return - * @throws Throwable - */ - private CagraIndexReference deserialize(InputStream in) throws Throwable { - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); + private CagraIndexReference deserialize(InputStream inputStream) throws Throwable { + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - CagraIndexReference ref = new CagraIndexReference(); + CagraIndexReference cagraIndexReference = new CagraIndexReference(); File tempFile = new File(tmpIndexFile); - FileOutputStream out = new FileOutputStream(tempFile); + FileOutputStream fileOutputStream = new FileOutputStream(tempFile); byte[] chunk = new byte[1024]; - int chunkLen = 0; - while ((chunkLen = in.read(chunk)) != -1) { - out.write(chunk, 0, chunkLen); + int chunkLength = 0; + while ((chunkLength = inputStream.read(chunk)) != -1) { + fileOutputStream.write(chunk, 0, chunkLength); } - deserializeMH.invokeExact(res.getResource(), ref.getIndexMemorySegment(), rvMS, + deserializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), + cagraIndexReference.getIndexMemorySegment(), returnValueMemorySegment, getStringSegment(new StringBuilder(tmpIndexFile))); - in.close(); - out.close(); + inputStream.close(); + fileOutputStream.close(); tempFile.delete(); - return ref; + return cagraIndexReference; } - /** - * - * @return - */ public CagraIndexParams getParams() { - return indexParams; - } - - /** - * - * @return - */ - public PointerToDataset getDataset() { - return null; + return cagraIndexParameters; } - /** - * - * @return - */ public CuVSResources getResources() { - return res; + return cuvsResources; } public static class Builder { - private CagraIndexParams indexParams; - float[][] dataset; - CuVSResources res; - - InputStream in; - - /** - * - * @param res - */ - public Builder(CuVSResources res) { - this.res = res; + + private CagraIndexParams cagraIndexParams; + private float[][] dataset; + private CuVSResources cuvsResources; + private InputStream inputStream; + + public Builder(CuVSResources cuvsResources) { + this.cuvsResources = cuvsResources; } - /** - * - * @param in - * @return - */ - public Builder from(InputStream in) { - this.in = in; + public Builder from(InputStream inputStream) { + this.inputStream = inputStream; return this; } - /** - * - * @param dataset - * @return - */ public Builder withDataset(float[][] dataset) { this.dataset = dataset; return this; } - /** - * - * @param params - * @return - */ - public Builder withIndexParams(CagraIndexParams indexParams) { - this.indexParams = indexParams; + public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { + this.cagraIndexParams = cagraIndexParameters; return this; } - /** - * - * @return - * @throws Throwable - */ public CagraIndex build() throws Throwable { - if (in != null) { - return new CagraIndex(in, res); + if (inputStream != null) { + return new CagraIndex(inputStream, cuvsResources); } else { - return new CagraIndex(indexParams, dataset, res); + return new CagraIndex(cagraIndexParams, dataset, cuvsResources); } } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index be9991034..3030e458f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.lang.foreign.Arena; @@ -6,21 +22,16 @@ import com.nvidia.cuvs.panama.cuvsCagraIndexParams; /* -* struct cuvsCagraIndexParams { -* size_t intermediate_graph_degree; -* size_t graph_degree; -* enum cuvsCagraGraphBuildAlgo build_algo; -* size_t nn_descent_niter; -* } +* Supplemental parameters to build CAGRA Index. */ public class CagraIndexParams { private Arena arena; private int intermediateGraphDegree; private int graphDegree; - private CuvsCagraGraphBuildAlgo buildAlgo; + private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; private int nnDescentNiter; - private MemorySegment cagraIndexParamsMS; + private MemorySegment cagraIndexParamsMemorySegment; public enum CuvsCagraGraphBuildAlgo { AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); @@ -32,58 +43,59 @@ private CuvsCagraGraphBuildAlgo(int label) { } } - public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, CuvsCagraGraphBuildAlgo buildAlgo, - int nnDescentNiter) { + public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, + CuvsCagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter) { this.arena = arena; this.intermediateGraphDegree = intermediateGraphDegree; this.graphDegree = graphDegree; - this.buildAlgo = buildAlgo; + this.cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo; this.nnDescentNiter = nnDescentNiter; this.set(); } private void set() { - cagraIndexParamsMS = cuvsCagraIndexParams.allocate(arena); - cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMS, intermediateGraphDegree); - cuvsCagraIndexParams.graph_degree(cagraIndexParamsMS, graphDegree); - cuvsCagraIndexParams.build_algo(cagraIndexParamsMS, buildAlgo.label); - cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMS, nnDescentNiter); + cagraIndexParamsMemorySegment = cuvsCagraIndexParams.allocate(arena); + cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMemorySegment, intermediateGraphDegree); + cuvsCagraIndexParams.graph_degree(cagraIndexParamsMemorySegment, graphDegree); + cuvsCagraIndexParams.build_algo(cagraIndexParamsMemorySegment, cuvsCagraGraphBuildAlgo.label); + cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMemorySegment, nnDescentNiter); } - public int getIntermediate_graph_degree() { + public int getIntermediateGraphDegree() { return intermediateGraphDegree; } - public int getGraph_degree() { + public int getGraphDegree() { return graphDegree; } - public CuvsCagraGraphBuildAlgo getBuild_algo() { - return buildAlgo; + public CuvsCagraGraphBuildAlgo getCuvsCagraGraphBuildAlgo() { + return cuvsCagraGraphBuildAlgo; } - public int getNn_descent_niter() { + public int getNNDescentNiter() { return nnDescentNiter; } - public MemorySegment getCagraIndexParamsMS() { - return cagraIndexParamsMS; + public MemorySegment getCagraIndexParamsMemorySegment() { + return cagraIndexParamsMemorySegment; } @Override public String toString() { - return "CagraIndexParams [intermediate_graph_degree=" + intermediateGraphDegree + ", graph_degree=" + graphDegree - + ", build_algo=" + buildAlgo + ", nn_descent_niter=" + nnDescentNiter + "]"; + return "CagraIndexParams [arena=" + arena + ", intermediateGraphDegree=" + intermediateGraphDegree + + ", graphDegree=" + graphDegree + ", cuvsCagraGraphBuildAlgo=" + cuvsCagraGraphBuildAlgo + ", nnDescentNiter=" + + nnDescentNiter + ", cagraIndexParamsMemorySegment=" + cagraIndexParamsMemorySegment + "]"; } public static class Builder { - Arena arena; - int intermediateGraphDegree = 128; - int graphDegree = 64; - CuvsCagraGraphBuildAlgo buildAlgo = CuvsCagraGraphBuildAlgo.IVF_PQ; - int nnDescentNiter = 20; - int writerThreads = 1; + private Arena arena; + private int intermediateGraphDegree = 128; + private int graphDegree = 64; + private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo.NN_DESCENT; + private int nnDescentNiter = 20; + private int writerThreads = 1; public Builder() { this.arena = Arena.ofConfined(); @@ -99,8 +111,8 @@ public Builder withGraphDegree(int graphDegree) { return this; } - public Builder withBuildAlgo(CuvsCagraGraphBuildAlgo buildAlgo) { - this.buildAlgo = buildAlgo; + public Builder withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo) { + this.cuvsCagraGraphBuildAlgo = cuvsCagraGraphBuildAlgo; return this; } @@ -115,9 +127,7 @@ public Builder withWriterThreads(int writerThreads) { } public CagraIndexParams build() throws Throwable { - return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, buildAlgo, nnDescentNiter); + return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, nnDescentNiter); } - } - -} +} \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java index ab186933f..2eab62147 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.lang.foreign.Arena; @@ -9,18 +25,11 @@ public class CagraIndexReference { private MemorySegment indexMemorySegment; - /** - * - */ public CagraIndexReference() { Arena arena = Arena.ofConfined(); indexMemorySegment = cuvsCagraIndex.allocate(arena); } - /** - * - * @param indexMemorySegment - */ public CagraIndexReference(MemorySegment indexMemorySegment) { this.indexMemorySegment = indexMemorySegment; } @@ -28,5 +37,4 @@ public CagraIndexReference(MemorySegment indexMemorySegment) { public MemorySegment getIndexMemorySegment() { return indexMemorySegment; } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index 0b2af56f5..df4398fd2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.lang.foreign.Arena; @@ -5,40 +21,23 @@ import com.nvidia.cuvs.panama.cuvsCagraSearchParams; -/* -* struct cuvsCagraSearchParams { -* size_t max_queries; -* size_t itopk_size; -* size_t max_iterations; -* enum cuvsCagraSearchAlgo algo; -* size_t team_size; -* size_t search_width; -* size_t min_iterations; -* size_t thread_block_size; -* enum cuvsCagraHashMode hashmap_mode; -* size_t hashmap_min_bitlen; -* float hashmap_max_fill_rate; -* uint32_t num_random_samplings; -* uint64_t rand_xor_mask; -* } -*/ public class CagraSearchParams { private Arena arena; private int maxQueries; private int itopkSize; private int maxIterations; - private CuvsCagraSearchAlgo algo; + private CuvsCagraSearchAlgo cuvsCagraSearchAlgo; private int teamSize; private int searchWidth; private int minIterations; private int threadBlockSize; - private CuvsCagraHashMode hashmapMode; + private CuvsCagraHashMode cuvsCagraHashMode; private int hashmapMinBitlen; private float hashmapMaxFillRate; private int numRandomSamplings; private long randXorMask; - private MemorySegment cagraSearchParamsMS; + private MemorySegment cagraSearchParamsMemorySegment; enum CuvsCagraSearchAlgo { SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); @@ -48,7 +47,6 @@ enum CuvsCagraSearchAlgo { private CuvsCagraSearchAlgo(int label) { this.label = label; } - } enum CuvsCagraHashMode { @@ -61,42 +59,43 @@ private CuvsCagraHashMode(int label) { } } - public CagraSearchParams(Arena arena, int max_queries, int itopk_size, int max_iterations, CuvsCagraSearchAlgo algo, - int team_size, int search_width, int min_iterations, int thread_block_size, CuvsCagraHashMode hashmap_mode, - int hashmap_min_bitlen, float hashmap_max_fill_rate, int num_random_samplings, long rand_xor_mask) { + public CagraSearchParams(Arena arena, int maxQueries, int itopkSize, int maxIterations, + CuvsCagraSearchAlgo cuvsCagraSearchAlgo, int teamSize, int searchWidth, int minIterations, int threadBlockSize, + CuvsCagraHashMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, + long randXorMask) { super(); this.arena = arena; - this.maxQueries = max_queries; - this.itopkSize = itopk_size; - this.maxIterations = max_iterations; - this.algo = algo; - this.teamSize = team_size; - this.searchWidth = search_width; - this.minIterations = min_iterations; - this.threadBlockSize = thread_block_size; - this.hashmapMode = hashmap_mode; - this.hashmapMinBitlen = hashmap_min_bitlen; - this.hashmapMaxFillRate = hashmap_max_fill_rate; - this.numRandomSamplings = num_random_samplings; - this.randXorMask = rand_xor_mask; + this.maxQueries = maxQueries; + this.itopkSize = itopkSize; + this.maxIterations = maxIterations; + this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; + this.teamSize = teamSize; + this.searchWidth = searchWidth; + this.minIterations = minIterations; + this.threadBlockSize = threadBlockSize; + this.cuvsCagraHashMode = hashmapMode; + this.hashmapMinBitlen = hashmapMinBitlen; + this.hashmapMaxFillRate = hashmapMaxFillRate; + this.numRandomSamplings = numRandomSamplings; + this.randXorMask = randXorMask; this.set(); } public void set() { - cagraSearchParamsMS = cuvsCagraSearchParams.allocate(arena); - cuvsCagraSearchParams.max_queries(cagraSearchParamsMS, maxQueries); - cuvsCagraSearchParams.itopk_size(cagraSearchParamsMS, itopkSize); - cuvsCagraSearchParams.max_iterations(cagraSearchParamsMS, maxIterations); - cuvsCagraSearchParams.algo(cagraSearchParamsMS, algo.label); - cuvsCagraSearchParams.team_size(cagraSearchParamsMS, teamSize); - cuvsCagraSearchParams.search_width(cagraSearchParamsMS, searchWidth); - cuvsCagraSearchParams.min_iterations(cagraSearchParamsMS, minIterations); - cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMS, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMS, hashmapMode.label); - cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMS, hashmapMinBitlen); - cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMS, hashmapMaxFillRate); - cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMS, numRandomSamplings); - cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMS, randXorMask); + cagraSearchParamsMemorySegment = cuvsCagraSearchParams.allocate(arena); + cuvsCagraSearchParams.max_queries(cagraSearchParamsMemorySegment, maxQueries); + cuvsCagraSearchParams.itopk_size(cagraSearchParamsMemorySegment, itopkSize); + cuvsCagraSearchParams.max_iterations(cagraSearchParamsMemorySegment, maxIterations); + cuvsCagraSearchParams.algo(cagraSearchParamsMemorySegment, cuvsCagraSearchAlgo.label); + cuvsCagraSearchParams.team_size(cagraSearchParamsMemorySegment, teamSize); + cuvsCagraSearchParams.search_width(cagraSearchParamsMemorySegment, searchWidth); + cuvsCagraSearchParams.min_iterations(cagraSearchParamsMemorySegment, minIterations); + cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMemorySegment, threadBlockSize); + cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMemorySegment, cuvsCagraHashMode.label); + cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMemorySegment, hashmapMinBitlen); + cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMemorySegment, hashmapMaxFillRate); + cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMemorySegment, numRandomSamplings); + cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMemorySegment, randXorMask); } public int getMax_queries() { @@ -112,7 +111,7 @@ public int getMax_iterations() { } public CuvsCagraSearchAlgo getAlgo() { - return algo; + return cuvsCagraSearchAlgo; } public int getTeam_size() { @@ -132,7 +131,7 @@ public int getThread_block_size() { } public CuvsCagraHashMode getHashmap_mode() { - return hashmapMode; + return cuvsCagraHashMode; } public int getHashmap_min_bitlen() { @@ -152,108 +151,109 @@ public long getRand_xor_mask() { } public MemorySegment getCagraSearchParamsMS() { - return cagraSearchParamsMS; + return cagraSearchParamsMemorySegment; } @Override public String toString() { - return "CagraSearchParams [max_queries=" + maxQueries + ", itopk_size=" + itopkSize + ", max_iterations=" - + maxIterations + ", algo=" + algo + ", team_size=" + teamSize + ", search_width=" + searchWidth - + ", min_iterations=" + minIterations + ", thread_block_size=" + threadBlockSize + ", hashmap_mode=" - + hashmapMode + ", hashmap_min_bitlen=" + hashmapMinBitlen + ", hashmap_max_fill_rate=" + hashmapMaxFillRate - + ", num_random_samplings=" + numRandomSamplings + ", rand_xor_mask=" + randXorMask + "]"; + return "CagraSearchParams [arena=" + arena + ", maxQueries=" + maxQueries + ", itopkSize=" + itopkSize + + ", maxIterations=" + maxIterations + ", cuvsCagraSearchAlgo=" + cuvsCagraSearchAlgo + ", teamSize=" + teamSize + + ", searchWidth=" + searchWidth + ", minIterations=" + minIterations + ", threadBlockSize=" + threadBlockSize + + ", cuvsCagraHashMode=" + cuvsCagraHashMode + ", hashmapMinBitlen=" + hashmapMinBitlen + + ", hashmapMaxFillRate=" + hashmapMaxFillRate + ", numRandomSamplings=" + numRandomSamplings + ", randXorMask=" + + randXorMask + ", cagraSearchParamsMemorySegment=" + cagraSearchParamsMemorySegment + "]"; } public static class Builder { - Arena arena; - int maxQueries = 1; - int itopkSize = 2; - int maxIterations = 3; - CuvsCagraSearchAlgo algo = CuvsCagraSearchAlgo.MULTI_KERNEL; - int teamSize = 4; - int searchWidth = 5; - int minIterations = 6; - int threadBlockSize = 7; - CuvsCagraHashMode hashmapMode = CuvsCagraHashMode.AUTO_HASH; - int hashmapMinBitlen = 8; - float hashmapMaxFillRate = 9.0f; - int numRandomSamplings = 10; - long randXorMask = 11L; + private Arena arena; + private int maxQueries = 1; + private int itopkSize = 2; + private int maxIterations = 3; + private CuvsCagraSearchAlgo cuvsCagraSearchAlgo = CuvsCagraSearchAlgo.MULTI_KERNEL; + private int teamSize = 4; + private int searchWidth = 5; + private int minIterations = 6; + private int threadBlockSize = 7; + private CuvsCagraHashMode cuvsCagraHashMode = CuvsCagraHashMode.AUTO_HASH; + private int hashmapMinBitlen = 8; + private float hashmapMaxFillRate = 9.0f; + private int numRandomSamplings = 10; + private long randXorMask = 11L; public Builder() { this.arena = Arena.ofConfined(); } - public Builder withMaxQueries(int max_queries) { - this.maxQueries = max_queries; + public Builder withMaxQueries(int maxQueries) { + this.maxQueries = maxQueries; return this; } - public Builder withItopkSize(int itopk_size) { - this.itopkSize = itopk_size; + public Builder withItopkSize(int itopkSize) { + this.itopkSize = itopkSize; return this; } - public Builder withMaxIterations(int max_iterations) { - this.maxIterations = max_iterations; + public Builder withMaxIterations(int maxIterations) { + this.maxIterations = maxIterations; return this; } - public Builder withAlgo(CuvsCagraSearchAlgo algo) { - this.algo = algo; + public Builder withAlgo(CuvsCagraSearchAlgo cuvsCagraSearchAlgo) { + this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; return this; } - public Builder withTeamSize(int team_size) { - this.teamSize = team_size; + public Builder withTeamSize(int teamSize) { + this.teamSize = teamSize; return this; } - public Builder withSearchWidth(int search_width) { - this.searchWidth = search_width; + public Builder withSearchWidth(int searchWidth) { + this.searchWidth = searchWidth; return this; } - public Builder withMinIterations(int min_iterations) { - this.minIterations = min_iterations; + public Builder withMinIterations(int minIterations) { + this.minIterations = minIterations; return this; } - public Builder withThreadBlockSize(int thread_block_size) { - this.threadBlockSize = thread_block_size; + public Builder withThreadBlockSize(int threadBlockSize) { + this.threadBlockSize = threadBlockSize; return this; } - public Builder withHashmapMode(CuvsCagraHashMode hashmap_mode) { - this.hashmapMode = hashmap_mode; + public Builder withHashmapMode(CuvsCagraHashMode cuvsCagraHashMode) { + this.cuvsCagraHashMode = cuvsCagraHashMode; return this; } - public Builder withHashmapMinBitlen(int hashmap_min_bitlen) { - this.hashmapMinBitlen = hashmap_min_bitlen; + public Builder withHashmapMinBitlen(int hashmapMinBitlen) { + this.hashmapMinBitlen = hashmapMinBitlen; return this; } - public Builder withHashmapMaxFillRate(float hashmap_max_fill_rate) { - this.hashmapMaxFillRate = hashmap_max_fill_rate; + public Builder withHashmapMaxFillRate(float hashmapMaxFillRate) { + this.hashmapMaxFillRate = hashmapMaxFillRate; return this; } - public Builder withNumRandomSamplings(int num_random_samplings) { - this.numRandomSamplings = num_random_samplings; + public Builder withNumRandomSamplings(int numRandomSamplings) { + this.numRandomSamplings = numRandomSamplings; return this; } - public Builder withRandXorMask(long rand_xor_mask) { - this.randXorMask = rand_xor_mask; + public Builder withRandXorMask(long randXorMask) { + this.randXorMask = randXorMask; return this; } public CagraSearchParams build() throws Throwable { - return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, algo, teamSize, searchWidth, - minIterations, threadBlockSize, hashmapMode, hashmapMinBitlen, hashmapMaxFillRate, numRandomSamplings, - randXorMask); + return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, cuvsCagraSearchAlgo, teamSize, + searchWidth, minIterations, threadBlockSize, cuvsCagraHashMode, hashmapMinBitlen, hashmapMaxFillRate, + numRandomSamplings, randXorMask); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index 672e0c5b9..1fc3321de 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.util.Arrays; @@ -5,37 +21,31 @@ public class CuVSQuery { - private CagraSearchParams searchParams; + private CagraSearchParams cagraSearchParameters; private PreFilter preFilter; private float[][] queryVectors; private Map mapping; private int topK; - public CuVSQuery(CagraSearchParams searchParams, PreFilter preFilter, float[][] queryVectors, + public CuVSQuery(CagraSearchParams cagraSearchParameters, PreFilter preFilter, float[][] queryVectors, Map mapping, int topK) { super(); - this.searchParams = searchParams; + this.cagraSearchParameters = cagraSearchParameters; this.preFilter = preFilter; this.queryVectors = queryVectors; this.mapping = mapping; this.topK = topK; } - @Override - public String toString() { - return "CuVSQuery [searchParams=" + searchParams + ", preFilter=" + preFilter + ", queries=" - + Arrays.toString(queryVectors) + "]"; - } - - public CagraSearchParams getSearchParams() { - return searchParams; + public CagraSearchParams getCagraSearchParameters() { + return cagraSearchParameters; } public PreFilter getPreFilter() { return preFilter; } - public float[][] getQueries() { + public float[][] getQueryVectors() { return queryVectors; } @@ -47,78 +57,47 @@ public int getTopK() { return topK; } + @Override + public String toString() { + return "CuVSQuery [cagraSearchParameters=" + cagraSearchParameters + ", preFilter=" + preFilter + ", queryVectors=" + + Arrays.toString(queryVectors) + ", mapping=" + mapping + ", topK=" + topK + "]"; + } + public static class Builder { - CagraSearchParams searchParams; - PreFilter preFilter; - float[][] queryVectors; - Map mapping; - int topK = 2; - - /** - * - * @param res - */ - public Builder() { - } - /** - * - * @param dataset - * @return - */ - public Builder withSearchParams(CagraSearchParams searchParams) { - this.searchParams = searchParams; + private CagraSearchParams cagraSearchParams; + private PreFilter preFilter; + private float[][] queryVectors; + private Map mapping; + private int topK = 2; + + public Builder withSearchParams(CagraSearchParams cagraSearchParams) { + this.cagraSearchParams = cagraSearchParams; return this; } - /** - * - * @param queryVectors - * @return - */ public Builder withQueryVectors(float[][] queryVectors) { this.queryVectors = queryVectors; return this; } - /** - * - * @param preFilter - * @return - */ public Builder withPreFilter(PreFilter preFilter) { this.preFilter = preFilter; return this; } - /** - * - * @param mapping - * @return - */ public Builder withMapping(Map mapping) { this.mapping = mapping; return this; } - /** - * - * @param topK - * @return - */ public Builder withTopK(int topK) { this.topK = topK; return this; } - /** - * - * @return - * @throws Throwable - */ public CuVSQuery build() throws Throwable { - return new CuVSQuery(searchParams, preFilter, queryVectors, mapping, topK); + return new CuVSQuery(cagraSearchParams, preFilter, queryVectors, mapping, topK); } } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java index ffbd5b176..6ab5b7554 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.io.File; @@ -14,32 +30,27 @@ public class CuVSResources { private Arena arena; private Linker linker; - private MethodHandle cresMH; - private MemorySegment resource; - private SymbolLookup bridge; - - /** - * - * @throws Throwable - */ + private MethodHandle createResourcesMemoryHandler; + private MemorySegment cuvsResourcesMemorySegment; + private SymbolLookup symbolLookup; + public CuVSResources() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); - File wd = new File(System.getProperty("user.dir")); - bridge = SymbolLookup.libraryLookup(wd.getParent() + "/internal/libcuvs_java.so", arena); + File workingDirectory = new File(System.getProperty("user.dir")); + symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - cresMH = linker.downcallHandle(bridge.find("create_resource").get(), + createResourcesMemoryHandler = linker.downcallHandle(symbolLookup.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - MemoryLayout rvML = linker.canonicalLayouts().get("int"); - MemorySegment rvMS = arena.allocate(rvML); + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - resource = (MemorySegment) cresMH.invokeExact(rvMS); + cuvsResourcesMemorySegment = (MemorySegment) createResourcesMemoryHandler.invokeExact(returnValueMemorySegment); } - public MemorySegment getResource() { - return resource; + public MemorySegment getCuvsResourcesMemorySegment() { + return cuvsResourcesMemorySegment; } - -} +} \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java deleted file mode 100644 index c5fc4f074..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PointerToDataset.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.nvidia.cuvs.cagra; - -public class PointerToDataset { - -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java index b8310af31..5034d2e45 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java @@ -1,5 +1,24 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; +/** + * TODO: Pending implementation + */ public class PreFilter { } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index e75518fca..0eea21c9a 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; import java.lang.foreign.MemoryLayout.PathElement; @@ -13,41 +29,42 @@ public class SearchResult { private List> results; private Map mapping; - private SequenceLayout neighboursSL; - private SequenceLayout distancesSL; - private MemorySegment neighboursMS; - private MemorySegment distancesMS; + private SequenceLayout neighboursSequenceLayout; + private SequenceLayout distancesSequenceLayout; + private MemorySegment neighboursMemorySegment; + private MemorySegment distancesMemorySegment; private int topK; - private int numQueries; + private int numberOfQueries; - public SearchResult(SequenceLayout neighboursSL, SequenceLayout distancesSL, MemorySegment neighboursMS, - MemorySegment distancesMS, int topK, Map mapping, int numQueries) { + public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, + MemorySegment neighboursMemorySegment, MemorySegment distancesMemorySegment, int topK, + Map mapping, int numberOfQueries) { super(); this.topK = topK; - this.numQueries = numQueries; - this.neighboursSL = neighboursSL; - this.distancesSL = distancesSL; - this.neighboursMS = neighboursMS; - this.distancesMS = distancesMS; + this.numberOfQueries = numberOfQueries; + this.neighboursSequenceLayout = neighboursSequenceLayout; + this.distancesSequenceLayout = distancesSequenceLayout; + this.neighboursMemorySegment = neighboursMemorySegment; + this.distancesMemorySegment = distancesMemorySegment; this.mapping = mapping; results = new LinkedList>(); this.load(); } private void load() { - VarHandle neighboursVH = neighboursSL.varHandle(PathElement.sequenceElement()); - VarHandle distancesVH = distancesSL.varHandle(PathElement.sequenceElement()); + VarHandle neighboursVH = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); + VarHandle distancesVH = distancesSequenceLayout.varHandle(PathElement.sequenceElement()); - Map irm = new LinkedHashMap(); + Map intermediateResultMap = new LinkedHashMap(); int count = 0; - for (long i = 0; i < topK * numQueries; i++) { - int id = (int) neighboursVH.get(neighboursMS, 0L, i); - float dst = (float) distancesVH.get(distancesMS, 0L, i); - irm.put(mapping != null ? mapping.get(id) : id, dst); + for (long i = 0; i < topK * numberOfQueries; i++) { + int id = (int) neighboursVH.get(neighboursMemorySegment, 0L, i); + float dst = (float) distancesVH.get(distancesMemorySegment, 0L, i); + intermediateResultMap.put(mapping != null ? mapping.get(id) : id, dst); count += 1; if (count == topK) { - results.add(irm); - irm = new LinkedHashMap(); + results.add(intermediateResultMap); + intermediateResultMap = new LinkedHashMap(); count = 0; } } @@ -56,5 +73,4 @@ private void load() { public List> getResults() { return results; } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java index 0326aa8f4..68dfbbb33 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDataType.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java index 3e9341f6a..9c92c68e9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLDevice.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java index 6d082d344..ac6b89a64 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java index ca8716551..2f357a459 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java index 56dec2bae..cd83ac54d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java index cb3aad4fc..8b000c6bc 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/DLTensor.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java index 714aed5e9..29cb7ba70 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java index 0af404e19..ab350eb93 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java @@ -1,14 +1,43 @@ +/* + * Copyright (c) 2023-2024, 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.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.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; public class brute_force_h { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java index 27e7888bc..f86edb0f2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.ValueLayout.JAVA_BYTE; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java index b81d453cf..981760359 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java index a18ebae86..c70555711 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java index aaa87af8e..022793289 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java index 4011df7e5..880ddda95 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java index 61d0e4625..8687407ce 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java @@ -1,14 +1,31 @@ +/* + * Copyright (c) 2023-2024, 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.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.MemoryLayout.PathElement.groupElement; -import static java.lang.foreign.ValueLayout.*; -import static java.lang.foreign.MemoryLayout.PathElement.*; +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; /** * {@snippet lang=c : diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java index 3afc5c792..283b3af9b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/dlpack_h.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.ValueLayout.JAVA_BYTE; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java index 4835982f1..a5f203fc2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java @@ -1,2482 +1,2551 @@ +/* + * Copyright (c) 2023-2024, 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.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.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; public class hnsw_h { - hnsw_h() { - // Should not be called directly - } + hnsw_h() { + // 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 _STDINT_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - private static final int _FEATURES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - private static final int _DEFAULT_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - private static final int __GLIBC_USE_ISOC2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - private static final int __USE_ISOC11 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - private static final int __USE_ISOC99 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - private static final int __USE_ISOC95 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - private static final int __USE_POSIX_IMPLICITLY = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - private static final int _POSIX_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - private static final int __USE_POSIX = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - private static final int __USE_POSIX2 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - private static final int __USE_POSIX199309 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - private static final int __USE_POSIX199506 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - private static final int __USE_XOPEN2K = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - private static final int __USE_XOPEN2K8 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - private static final int _ATFILE_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - private static final int __WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; - /** - * {@snippet lang=c : - * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - private static final int __SYSCALL_WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - private static final int __USE_MISC = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - private static final int __USE_ATFILE = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - private static final int __USE_FORTIFY_LEVEL = (int)0L; - /** - * {@snippet lang=c : - * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - private static final int _STDC_PREDEF_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - private static final int __STDC_IEC_559__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - private static final int __GNU_LIBRARY__ = (int)6L; - /** - * {@snippet lang=c : - * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - private static final int __GLIBC__ = (int)2L; - /** - * {@snippet lang=c : - * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - private static final int __GLIBC_MINOR__ = (int)35L; - /** - * {@snippet lang=c : - * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - private static final int _SYS_CDEFS_H = (int)1L; - /** - * {@snippet lang=c : - * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - private static final int __glibc_c99_flexarr_available = (int)1L; - /** - * {@snippet lang=c : - * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; - /** - * {@snippet lang=c : - * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - private static final int __HAVE_GENERIC_SELECTION = (int)1L; - /** - * {@snippet lang=c : - * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - private static final int _BITS_TYPES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - private static final int _BITS_TYPESIZES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - private static final int __INO_T_MATCHES_INO64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - private static final int __STATFS_MATCHES_STATFS64 = (int)1L; - /** - * {@snippet lang=c : - * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; - /** - * {@snippet lang=c : - * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - private static final int __FD_SETSIZE = (int)1024L; - /** - * {@snippet lang=c : - * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - private static final int _BITS_TIME64_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - private static final int _BITS_WCHAR_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - private static final int _BITS_STDINT_INTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - private static final int _BITS_STDINT_UINTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - private static final int DLPACK_MAJOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - private static final int DLPACK_MINOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - private static final int true_ = (int)1L; - /** - * {@snippet lang=c : - * #define true 1 - * } - */ - public static int true_() { - return true_; - } - private static final int false_ = (int)0L; - /** - * {@snippet lang=c : - * #define false 0 - * } - */ - public static int false_() { - return false_; - } - private static final int __bool_true_false_are_defined = (int)1L; - /** - * {@snippet lang=c : - * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = hnsw_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = hnsw_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = hnsw_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = hnsw_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = hnsw_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = hnsw_h.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 = hnsw_h.C_LONG; - private static final int L2Expanded = (int)0L; - /** - * {@snippet lang=c : - * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - private static final int L2SqrtExpanded = (int)1L; - /** - * {@snippet lang=c : - * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - private static final int CosineExpanded = (int)2L; - /** - * {@snippet lang=c : - * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - private static final int L1 = (int)3L; - /** - * {@snippet lang=c : - * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - private static final int L2Unexpanded = (int)4L; - /** - * {@snippet lang=c : - * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - private static final int L2SqrtUnexpanded = (int)5L; - /** - * {@snippet lang=c : - * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - private static final int InnerProduct = (int)6L; - /** - * {@snippet lang=c : - * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - private static final int Linf = (int)7L; - /** - * {@snippet lang=c : - * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - private static final int Canberra = (int)8L; - /** - * {@snippet lang=c : - * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - private static final int LpUnexpanded = (int)9L; - /** - * {@snippet lang=c : - * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - private static final int CorrelationExpanded = (int)10L; - /** - * {@snippet lang=c : - * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - private static final int JaccardExpanded = (int)11L; - /** - * {@snippet lang=c : - * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - private static final int HellingerExpanded = (int)12L; - /** - * {@snippet lang=c : - * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - private static final int Haversine = (int)13L; - /** - * {@snippet lang=c : - * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - private static final int BrayCurtis = (int)14L; - /** - * {@snippet lang=c : - * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - private static final int JensenShannon = (int)15L; - /** - * {@snippet lang=c : - * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - private static final int HammingUnexpanded = (int)16L; - /** - * {@snippet lang=c : - * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - private static final int KLDivergence = (int)17L; - /** - * {@snippet lang=c : - * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - private static final int RusselRaoExpanded = (int)18L; - /** - * {@snippet lang=c : - * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - private static final int DiceExpanded = (int)19L; - /** - * {@snippet lang=c : - * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - private static final int Precomputed = (int)100L; - /** - * {@snippet lang=c : - * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = hnsw_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = hnsw_h.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - /** - * {@snippet lang=c : - * typedef struct cuvsHnswSearchParams { - * int32_t ef; - * int32_t numThreads; - * } *cuvsHnswSearchParams_t - * } - */ - public static final AddressLayout cuvsHnswSearchParams_t = hnsw_h.C_POINTER; - - private static class cuvsHnswSearchParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); - - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) - * } - */ - public static FunctionDescriptor cuvsHnswSearchParamsCreate$descriptor() { - return cuvsHnswSearchParamsCreate.DESC; - } + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int) 1L; - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) - * } - */ - public static MethodHandle cuvsHnswSearchParamsCreate$handle() { - return cuvsHnswSearchParamsCreate.HANDLE; - } + /** + * {@snippet lang = c : * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) - * } - */ - public static MemorySegment cuvsHnswSearchParamsCreate$address() { - return cuvsHnswSearchParamsCreate.ADDR; - } + private static final int _FEATURES_H = (int) 1L; - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) - * } - */ - public static int cuvsHnswSearchParamsCreate(MemorySegment params) { - var mh$ = cuvsHnswSearchParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswSearchParamsCreate", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + /** + * {@snippet lang = c : * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } - private static class cuvsHnswSearchParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); + private static final int _DEFAULT_SOURCE = (int) 1L; - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsDestroy"); + /** + * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int __GLIBC_USE_ISOC2X = (int) 0L; - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) - * } - */ - public static FunctionDescriptor cuvsHnswSearchParamsDestroy$descriptor() { - return cuvsHnswSearchParamsDestroy.DESC; - } + /** + * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) - * } - */ - public static MethodHandle cuvsHnswSearchParamsDestroy$handle() { - return cuvsHnswSearchParamsDestroy.HANDLE; - } + private static final int __USE_ISOC11 = (int) 1L; - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) - * } - */ - public static MemorySegment cuvsHnswSearchParamsDestroy$address() { - return cuvsHnswSearchParamsDestroy.ADDR; - } + /** + * {@snippet lang = c : * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) - * } - */ - public static int cuvsHnswSearchParamsDestroy(MemorySegment params) { - var mh$ = cuvsHnswSearchParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswSearchParamsDestroy", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef cuvsHnswIndex *cuvsHnswIndex_t - * } - */ - public static final AddressLayout cuvsHnswIndex_t = hnsw_h.C_POINTER; - - private static class cuvsHnswIndexCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); - - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int __USE_ISOC99 = (int) 1L; - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) - * } - */ - public static FunctionDescriptor cuvsHnswIndexCreate$descriptor() { - return cuvsHnswIndexCreate.DESC; - } + /** + * {@snippet lang = c : * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) - * } - */ - public static MethodHandle cuvsHnswIndexCreate$handle() { - return cuvsHnswIndexCreate.HANDLE; - } + private static final int __USE_ISOC95 = (int) 1L; - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) - * } - */ - public static MemorySegment cuvsHnswIndexCreate$address() { - return cuvsHnswIndexCreate.ADDR; - } + /** + * {@snippet lang = c : * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) - * } - */ - public static int cuvsHnswIndexCreate(MemorySegment index) { - var mh$ = cuvsHnswIndexCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswIndexCreate", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + private static final int __USE_POSIX_IMPLICITLY = (int) 1L; - private static class cuvsHnswIndexDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); + /** + * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexDestroy"); + private static final int _POSIX_SOURCE = (int) 1L; - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + /** + * {@snippet lang = c : * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) - * } - */ - public static FunctionDescriptor cuvsHnswIndexDestroy$descriptor() { - return cuvsHnswIndexDestroy.DESC; - } + private static final int __USE_POSIX = (int) 1L; - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) - * } - */ - public static MethodHandle cuvsHnswIndexDestroy$handle() { - return cuvsHnswIndexDestroy.HANDLE; - } + /** + * {@snippet lang = c : * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) - * } - */ - public static MemorySegment cuvsHnswIndexDestroy$address() { - return cuvsHnswIndexDestroy.ADDR; - } + private static final int __USE_POSIX2 = (int) 1L; - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) - * } - */ - public static int cuvsHnswIndexDestroy(MemorySegment index) { - var mh$ = cuvsHnswIndexDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswIndexDestroy", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + /** + * {@snippet lang = c : * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } - private static class cuvsHnswSearch { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_LONG, - hnsw_h.C_POINTER, - hnsw_h.C_POINTER, - hnsw_h.C_POINTER, - hnsw_h.C_POINTER, - hnsw_h.C_POINTER - ); + private static final int __USE_POSIX199309 = (int) 1L; - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearch"); + /** + * {@snippet lang = c : * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int __USE_POSIX199506 = (int) 1L; - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static FunctionDescriptor cuvsHnswSearch$descriptor() { - return cuvsHnswSearch.DESC; - } + /** + * {@snippet lang = c : * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MethodHandle cuvsHnswSearch$handle() { - return cuvsHnswSearch.HANDLE; - } + private static final int __USE_XOPEN2K = (int) 1L; - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MemorySegment cuvsHnswSearch$address() { - return cuvsHnswSearch.ADDR; - } + /** + * {@snippet lang = c : * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static int cuvsHnswSearch(long res, MemorySegment params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { - var mh$ = cuvsHnswSearch.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswSearch", res, params, index, queries, neighbors, distances); - } - return (int)mh$.invokeExact(res, params, index, queries, neighbors, distances); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + private static final int __USE_XOPEN2K8 = (int) 1L; - private static class cuvsHnswDeserialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - hnsw_h.C_INT, - hnsw_h.C_LONG, - hnsw_h.C_POINTER, - hnsw_h.C_INT, - hnsw_h.C_INT, - hnsw_h.C_POINTER - ); + /** + * {@snippet lang = c : * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } - public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswDeserialize"); + private static final int _ATFILE_SOURCE = (int) 1L; - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + /** + * {@snippet lang = c : * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) - * } - */ - public static FunctionDescriptor cuvsHnswDeserialize$descriptor() { - return cuvsHnswDeserialize.DESC; - } + private static final int __WORDSIZE = (int) 64L; - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) - * } - */ - public static MethodHandle cuvsHnswDeserialize$handle() { - return cuvsHnswDeserialize.HANDLE; - } + /** + * {@snippet lang = c : * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) - * } - */ - public static MemorySegment cuvsHnswDeserialize$address() { - return cuvsHnswDeserialize.ADDR; - } + private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; - /** - * {@snippet lang=c : - * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) - * } - */ - public static int cuvsHnswDeserialize(long res, MemorySegment filename, int dim, int metric, MemorySegment index) { - var mh$ = cuvsHnswDeserialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsHnswDeserialize", res, filename, dim, metric, index); - } - return (int)mh$.invokeExact(res, filename, dim, metric, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } -} + /** + * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + + private static final int __SYSCALL_WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + + private static final int __USE_MISC = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + + private static final int __USE_ATFILE = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + + private static final int __USE_FORTIFY_LEVEL = (int) 0L; + + /** + * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + + private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + + private static final int _STDC_PREDEF_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + + private static final int __STDC_IEC_559__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + + private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + + private static final int __GNU_LIBRARY__ = (int) 6L; + + /** + * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + + private static final int __GLIBC__ = (int) 2L; + + /** + * {@snippet lang = c : * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + + private static final int __GLIBC_MINOR__ = (int) 35L; + + /** + * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + + private static final int _SYS_CDEFS_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + + private static final int __glibc_c99_flexarr_available = (int) 1L; + + /** + * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; + + /** + * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + + private static final int __HAVE_GENERIC_SELECTION = (int) 1L; + + /** + * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + + private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + + private static final int _BITS_TYPES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + + private static final int _BITS_TYPESIZES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + + private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + + private static final int __INO_T_MATCHES_INO64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + + private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + + private static final int __FD_SETSIZE = (int) 1024L; + + /** + * {@snippet lang = c : * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + + private static final int _BITS_TIME64_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + + private static final int _BITS_WCHAR_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + + private static final int _BITS_STDINT_INTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + + private static final int _BITS_STDINT_UINTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + + private static final int DLPACK_MAJOR_VERSION = (int) 1L; + + /** + * {@snippet lang = c : * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + + private static final int DLPACK_MINOR_VERSION = (int) 0L; + + /** + * {@snippet lang = c : * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + + private static final int true_ = (int) 1L; + + /** + * {@snippet lang = c : * #define true 1 + * } + */ + public static int true_() { + return true_; + } + + private static final int false_ = (int) 0L; + + /** + * {@snippet lang = c : * #define false 0 + * } + */ + public static int false_() { + return false_; + } + + private static final int __bool_true_false_are_defined = (int) 1L; + + /** + * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + + /** + * {@snippet lang = c : * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off_t + * } + */ + public static final OfLong __off_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef long __time_t + * } + */ + public static final OfLong __time_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef int __key_t + * } + */ + public static final OfInt __key_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = hnsw_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = hnsw_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = hnsw_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = hnsw_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = hnsw_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = hnsw_h.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 = hnsw_h.C_LONG; + private static final int L2Expanded = (int) 0L; + + /** + * {@snippet lang = c : * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + + private static final int L2SqrtExpanded = (int) 1L; + + /** + * {@snippet lang = c : * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + + private static final int CosineExpanded = (int) 2L; + + /** + * {@snippet lang = c : * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + + private static final int L1 = (int) 3L; + + /** + * {@snippet lang = c : * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + + private static final int L2Unexpanded = (int) 4L; + + /** + * {@snippet lang = c : * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + + private static final int L2SqrtUnexpanded = (int) 5L; + + /** + * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + + private static final int InnerProduct = (int) 6L; + + /** + * {@snippet lang = c : * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + + private static final int Linf = (int) 7L; + + /** + * {@snippet lang = c : * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + + private static final int Canberra = (int) 8L; + + /** + * {@snippet lang = c : * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + + private static final int LpUnexpanded = (int) 9L; + + /** + * {@snippet lang = c : * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + + private static final int CorrelationExpanded = (int) 10L; + + /** + * {@snippet lang = c : * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + + private static final int JaccardExpanded = (int) 11L; + + /** + * {@snippet lang = c : * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + + private static final int HellingerExpanded = (int) 12L; + + /** + * {@snippet lang = c : * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + + private static final int Haversine = (int) 13L; + + /** + * {@snippet lang = c : * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + + private static final int BrayCurtis = (int) 14L; + + /** + * {@snippet lang = c : * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + + private static final int JensenShannon = (int) 15L; + + /** + * {@snippet lang = c : * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + + private static final int HammingUnexpanded = (int) 16L; + + /** + * {@snippet lang = c : * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + + private static final int KLDivergence = (int) 17L; + + /** + * {@snippet lang = c : * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + + private static final int RusselRaoExpanded = (int) 18L; + + /** + * {@snippet lang = c : * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + + private static final int DiceExpanded = (int) 19L; + + /** + * {@snippet lang = c : * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + + private static final int Precomputed = (int) 100L; + + /** + * {@snippet lang = c : * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + + /** + * {@snippet lang = c : * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = hnsw_h.C_LONG; + /** + * {@snippet lang = c : * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = hnsw_h.C_INT; + private static final int kDLCPU = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + + private static final int kDLCUDA = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + + private static final int kDLCUDAHost = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + + private static final int kDLOpenCL = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + + private static final int kDLVulkan = (int) 7L; + + /** + * {@snippet lang = c : * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + + private static final int kDLMetal = (int) 8L; + + /** + * {@snippet lang = c : * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + + private static final int kDLVPI = (int) 9L; + + /** + * {@snippet lang = c : * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + + private static final int kDLROCM = (int) 10L; + + /** + * {@snippet lang = c : * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + + private static final int kDLROCMHost = (int) 11L; + + /** + * {@snippet lang = c : * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + + private static final int kDLExtDev = (int) 12L; + + /** + * {@snippet lang = c : * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + + private static final int kDLCUDAManaged = (int) 13L; + + /** + * {@snippet lang = c : * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + + private static final int kDLOneAPI = (int) 14L; + + /** + * {@snippet lang = c : * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + + private static final int kDLWebGPU = (int) 15L; + + /** + * {@snippet lang = c : * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + + private static final int kDLHexagon = (int) 16L; + + /** + * {@snippet lang = c : * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + + private static final int kDLMAIA = (int) 17L; + + /** + * {@snippet lang = c : * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + + private static final int kDLInt = (int) 0L; + + /** + * {@snippet lang = c : * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + + private static final int kDLUInt = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + + private static final int kDLFloat = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + + private static final int kDLOpaqueHandle = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + + private static final int kDLBfloat = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + + private static final int kDLComplex = (int) 5L; + + /** + * {@snippet lang = c : * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + + private static final int kDLBool = (int) 6L; + + /** + * {@snippet lang = c : * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsHnswSearchParams { + * int32_t ef; + * int32_t numThreads; + * } *cuvsHnswSearchParams_t + * } + */ + public static final AddressLayout cuvsHnswSearchParams_t = hnsw_h.C_POINTER; + + private static class cuvsHnswSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsHnswSearchParamsCreate$descriptor() { + return cuvsHnswSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static MethodHandle cuvsHnswSearchParamsCreate$handle() { + return cuvsHnswSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static MemorySegment cuvsHnswSearchParamsCreate$address() { + return cuvsHnswSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsCreate(cuvsHnswSearchParams_t *params) + * } + */ + public static int cuvsHnswSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsHnswSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearchParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsHnswSearchParamsDestroy$descriptor() { + return cuvsHnswSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static MethodHandle cuvsHnswSearchParamsDestroy$handle() { + return cuvsHnswSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static MemorySegment cuvsHnswSearchParamsDestroy$address() { + return cuvsHnswSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearchParamsDestroy(cuvsHnswSearchParams_t params) + * } + */ + public static int cuvsHnswSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsHnswSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearchParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : * typedef cuvsHnswIndex *cuvsHnswIndex_t + * } + */ + public static final AddressLayout cuvsHnswIndex_t = hnsw_h.C_POINTER; + + private static class cuvsHnswIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsHnswIndexCreate$descriptor() { + return cuvsHnswIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static MethodHandle cuvsHnswIndexCreate$handle() { + return cuvsHnswIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static MemorySegment cuvsHnswIndexCreate$address() { + return cuvsHnswIndexCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexCreate(cuvsHnswIndex_t *index) + * } + */ + public static int cuvsHnswIndexCreate(MemorySegment index) { + var mh$ = cuvsHnswIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswIndexCreate", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static FunctionDescriptor cuvsHnswIndexDestroy$descriptor() { + return cuvsHnswIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static MethodHandle cuvsHnswIndexDestroy$handle() { + return cuvsHnswIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static MemorySegment cuvsHnswIndexDestroy$address() { + return cuvsHnswIndexDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswIndexDestroy(cuvsHnswIndex_t index) + * } + */ + public static int cuvsHnswIndexDestroy(MemorySegment index) { + var mh$ = cuvsHnswIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswIndexDestroy", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_LONG, hnsw_h.C_POINTER, + hnsw_h.C_POINTER, hnsw_h.C_POINTER, hnsw_h.C_POINTER, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsHnswSearch$descriptor() { + return cuvsHnswSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsHnswSearch$handle() { + return cuvsHnswSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsHnswSearch$address() { + return cuvsHnswSearch.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswSearch(cuvsResources_t res, cuvsHnswSearchParams_t params, cuvsHnswIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsHnswSearch(long res, MemorySegment params, MemorySegment index, MemorySegment queries, + MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsHnswSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswSearch", res, params, index, queries, neighbors, distances); + } + return (int) mh$.invokeExact(res, params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsHnswDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(hnsw_h.C_INT, hnsw_h.C_LONG, hnsw_h.C_POINTER, + hnsw_h.C_INT, hnsw_h.C_INT, hnsw_h.C_POINTER); + + public static final MemorySegment ADDR = hnsw_h.findOrThrow("cuvsHnswDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static FunctionDescriptor cuvsHnswDeserialize$descriptor() { + return cuvsHnswDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static MethodHandle cuvsHnswDeserialize$handle() { + return cuvsHnswDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static MemorySegment cuvsHnswDeserialize$address() { + return cuvsHnswDeserialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsHnswDeserialize(cuvsResources_t res, const char *filename, int dim, cuvsDistanceType metric, cuvsHnswIndex_t index) + * } + */ + public static int cuvsHnswDeserialize(long res, MemorySegment filename, int dim, int metric, MemorySegment index) { + var mh$ = cuvsHnswDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsHnswDeserialize", res, filename, dim, metric, index); + } + return (int) mh$.invokeExact(res, filename, dim, metric, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static final long _POSIX_C_SOURCE = 200809L; + + /** + * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + + private static final int __TIMESIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + + private static final long __STDC_IEC_60559_BFP__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + + private static final long __STDC_ISO_10646__ = 201706L; + + /** + * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + + private static final int __WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + + private static final int __WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + + private static final int INT8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + + private static final int INT16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + + private static final int INT32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + + private static final long INT64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + + private static final int INT8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + + private static final int INT16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + + private static final int INT32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + + private static final long INT64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + + private static final int UINT8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + + private static final int UINT16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + + private static final int UINT32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + + private static final long UINT64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + + private static final int INT_LEAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + + private static final int INT_LEAST16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + + private static final int INT_LEAST32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + + private static final long INT_LEAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + + private static final int INT_LEAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + + private static final int INT_LEAST16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + + private static final int INT_LEAST32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + + private static final long INT_LEAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + + private static final int UINT_LEAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + + private static final int UINT_LEAST16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + + private static final int UINT_LEAST32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + + private static final long UINT_LEAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + + private static final int INT_FAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + + private static final long INT_FAST16_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + + private static final long INT_FAST32_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + + private static final long INT_FAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + + private static final int INT_FAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + + private static final long INT_FAST16_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + + private static final long INT_FAST32_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + + private static final long INT_FAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + + private static final int UINT_FAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + + private static final long UINT_FAST16_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + + private static final long UINT_FAST32_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + + private static final long UINT_FAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + + private static final long INTPTR_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + + private static final long INTPTR_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + + private static final long UINTPTR_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + + private static final long INTMAX_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + + private static final long INTMAX_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + + private static final long UINTMAX_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + + private static final long PTRDIFF_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + + private static final long PTRDIFF_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + + private static final int SIG_ATOMIC_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + + private static final int SIG_ATOMIC_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + + private static final long SIZE_MAX = -1L; + + /** + * {@snippet lang = c : * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + + private static final int WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + + private static final int WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + + private static final int WINT_MIN = (int) 0L; + + /** + * {@snippet lang = c : * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + + private static final int WINT_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + + /** + * {@snippet lang = c : * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java index 0848589b6..5f74bf223 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java @@ -1,2792 +1,2845 @@ -package com.nvidia.cuvs.panama; +/* + * Copyright (c) 2023-2024, 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. + */ -import java.lang.invoke.*; -import java.lang.foreign.*; -import java.nio.ByteOrder; -import java.util.*; -import java.util.function.*; -import java.util.stream.*; +package com.nvidia.cuvs.panama; -import static java.lang.foreign.ValueLayout.*; -import static java.lang.foreign.MemoryLayout.PathElement.*; +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; public class ivf_flat_h { - ivf_flat_h() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args) - .map(Object::toString) - .collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol) - .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream() - .map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? - MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() - .or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int _STDINT_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - private static final int _FEATURES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - private static final int _DEFAULT_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - private static final int __GLIBC_USE_ISOC2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - private static final int __USE_ISOC11 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - private static final int __USE_ISOC99 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - private static final int __USE_ISOC95 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - private static final int __USE_POSIX_IMPLICITLY = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - private static final int _POSIX_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - private static final int __USE_POSIX = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - private static final int __USE_POSIX2 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - private static final int __USE_POSIX199309 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - private static final int __USE_POSIX199506 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - private static final int __USE_XOPEN2K = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - private static final int __USE_XOPEN2K8 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - private static final int _ATFILE_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - private static final int __WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; - /** - * {@snippet lang=c : - * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - private static final int __SYSCALL_WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - private static final int __USE_MISC = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - private static final int __USE_ATFILE = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - private static final int __USE_FORTIFY_LEVEL = (int)0L; - /** - * {@snippet lang=c : - * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - private static final int _STDC_PREDEF_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - private static final int __STDC_IEC_559__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - private static final int __GNU_LIBRARY__ = (int)6L; - /** - * {@snippet lang=c : - * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - private static final int __GLIBC__ = (int)2L; - /** - * {@snippet lang=c : - * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - private static final int __GLIBC_MINOR__ = (int)35L; - /** - * {@snippet lang=c : - * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - private static final int _SYS_CDEFS_H = (int)1L; - /** - * {@snippet lang=c : - * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - private static final int __glibc_c99_flexarr_available = (int)1L; - /** - * {@snippet lang=c : - * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; - /** - * {@snippet lang=c : - * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - private static final int __HAVE_GENERIC_SELECTION = (int)1L; - /** - * {@snippet lang=c : - * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - private static final int _BITS_TYPES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - private static final int _BITS_TYPESIZES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - private static final int __INO_T_MATCHES_INO64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - private static final int __STATFS_MATCHES_STATFS64 = (int)1L; - /** - * {@snippet lang=c : - * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; - /** - * {@snippet lang=c : - * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - private static final int __FD_SETSIZE = (int)1024L; - /** - * {@snippet lang=c : - * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - private static final int _BITS_TIME64_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - private static final int _BITS_WCHAR_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - private static final int _BITS_STDINT_INTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - private static final int _BITS_STDINT_UINTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - private static final int DLPACK_MAJOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - private static final int DLPACK_MINOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - private static final int true_ = (int)1L; - /** - * {@snippet lang=c : - * #define true 1 - * } - */ - public static int true_() { - return true_; - } - private static final int false_ = (int)0L; - /** - * {@snippet lang=c : - * #define false 0 - * } - */ - public static int false_() { - return false_; - } - private static final int __bool_true_false_are_defined = (int)1L; - /** - * {@snippet lang=c : - * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = ivf_flat_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = ivf_flat_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = ivf_flat_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = ivf_flat_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = ivf_flat_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = ivf_flat_h.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 = ivf_flat_h.C_LONG; - private static final int L2Expanded = (int)0L; - /** - * {@snippet lang=c : - * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - private static final int L2SqrtExpanded = (int)1L; - /** - * {@snippet lang=c : - * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - private static final int CosineExpanded = (int)2L; - /** - * {@snippet lang=c : - * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - private static final int L1 = (int)3L; - /** - * {@snippet lang=c : - * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - private static final int L2Unexpanded = (int)4L; - /** - * {@snippet lang=c : - * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - private static final int L2SqrtUnexpanded = (int)5L; - /** - * {@snippet lang=c : - * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - private static final int InnerProduct = (int)6L; - /** - * {@snippet lang=c : - * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - private static final int Linf = (int)7L; - /** - * {@snippet lang=c : - * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - private static final int Canberra = (int)8L; - /** - * {@snippet lang=c : - * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - private static final int LpUnexpanded = (int)9L; - /** - * {@snippet lang=c : - * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - private static final int CorrelationExpanded = (int)10L; - /** - * {@snippet lang=c : - * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - private static final int JaccardExpanded = (int)11L; - /** - * {@snippet lang=c : - * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - private static final int HellingerExpanded = (int)12L; - /** - * {@snippet lang=c : - * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - private static final int Haversine = (int)13L; - /** - * {@snippet lang=c : - * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - private static final int BrayCurtis = (int)14L; - /** - * {@snippet lang=c : - * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - private static final int JensenShannon = (int)15L; - /** - * {@snippet lang=c : - * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - private static final int HammingUnexpanded = (int)16L; - /** - * {@snippet lang=c : - * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - private static final int KLDivergence = (int)17L; - /** - * {@snippet lang=c : - * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - private static final int RusselRaoExpanded = (int)18L; - /** - * {@snippet lang=c : - * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - private static final int DiceExpanded = (int)19L; - /** - * {@snippet lang=c : - * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - private static final int Precomputed = (int)100L; - /** - * {@snippet lang=c : - * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = ivf_flat_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = ivf_flat_h.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - /** - * {@snippet lang=c : - * typedef struct cuvsIvfFlatIndexParams { - * cuvsDistanceType metric; - * float metric_arg; - * _Bool add_data_on_build; - * uint32_t n_lists; - * uint32_t kmeans_n_iters; - * double kmeans_trainset_fraction; - * _Bool adaptive_centers; - * _Bool conservative_memory_allocation; - * } *cuvsIvfFlatIndexParams_t - * } - */ - public static final AddressLayout cuvsIvfFlatIndexParams_t = ivf_flat_h.C_POINTER; - - private static class cuvsIvfFlatIndexParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexParamsCreate$descriptor() { - return cuvsIvfFlatIndexParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static MethodHandle cuvsIvfFlatIndexParamsCreate$handle() { - return cuvsIvfFlatIndexParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static MemorySegment cuvsIvfFlatIndexParamsCreate$address() { - return cuvsIvfFlatIndexParamsCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) - * } - */ - public static int cuvsIvfFlatIndexParamsCreate(MemorySegment index_params) { - var mh$ = cuvsIvfFlatIndexParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexParamsCreate", index_params); - } - return (int)mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatIndexParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexParamsDestroy$descriptor() { - return cuvsIvfFlatIndexParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static MethodHandle cuvsIvfFlatIndexParamsDestroy$handle() { - return cuvsIvfFlatIndexParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static MemorySegment cuvsIvfFlatIndexParamsDestroy$address() { - return cuvsIvfFlatIndexParamsDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) - * } - */ - public static int cuvsIvfFlatIndexParamsDestroy(MemorySegment index_params) { - var mh$ = cuvsIvfFlatIndexParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexParamsDestroy", index_params); - } - return (int)mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef struct cuvsIvfFlatSearchParams { - * uint32_t n_probes; - * } *cuvsIvfFlatSearchParams_t - * } - */ - public static final AddressLayout cuvsIvfFlatSearchParams_t = ivf_flat_h.C_POINTER; - - private static class cuvsIvfFlatSearchParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSearchParamsCreate$descriptor() { - return cuvsIvfFlatSearchParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static MethodHandle cuvsIvfFlatSearchParamsCreate$handle() { - return cuvsIvfFlatSearchParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static MemorySegment cuvsIvfFlatSearchParamsCreate$address() { - return cuvsIvfFlatSearchParamsCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) - * } - */ - public static int cuvsIvfFlatSearchParamsCreate(MemorySegment params) { - var mh$ = cuvsIvfFlatSearchParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSearchParamsCreate", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatSearchParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSearchParamsDestroy$descriptor() { - return cuvsIvfFlatSearchParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static MethodHandle cuvsIvfFlatSearchParamsDestroy$handle() { - return cuvsIvfFlatSearchParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static MemorySegment cuvsIvfFlatSearchParamsDestroy$address() { - return cuvsIvfFlatSearchParamsDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) - * } - */ - public static int cuvsIvfFlatSearchParamsDestroy(MemorySegment params) { - var mh$ = cuvsIvfFlatSearchParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSearchParamsDestroy", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef cuvsIvfFlatIndex *cuvsIvfFlatIndex_t - * } - */ - public static final AddressLayout cuvsIvfFlatIndex_t = ivf_flat_h.C_POINTER; - - private static class cuvsIvfFlatIndexCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexCreate$descriptor() { - return cuvsIvfFlatIndexCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static MethodHandle cuvsIvfFlatIndexCreate$handle() { - return cuvsIvfFlatIndexCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static MemorySegment cuvsIvfFlatIndexCreate$address() { - return cuvsIvfFlatIndexCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) - * } - */ - public static int cuvsIvfFlatIndexCreate(MemorySegment index) { - var mh$ = cuvsIvfFlatIndexCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexCreate", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatIndexDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatIndexDestroy$descriptor() { - return cuvsIvfFlatIndexDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatIndexDestroy$handle() { - return cuvsIvfFlatIndexDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatIndexDestroy$address() { - return cuvsIvfFlatIndexDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatIndexDestroy(MemorySegment index) { - var mh$ = cuvsIvfFlatIndexDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatIndexDestroy", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatBuild { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatBuild"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatBuild$descriptor() { - return cuvsIvfFlatBuild.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatBuild$handle() { - return cuvsIvfFlatBuild.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatBuild$address() { - return cuvsIvfFlatBuild.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatBuild(long res, MemorySegment index_params, MemorySegment dataset, MemorySegment index) { - var mh$ = cuvsIvfFlatBuild.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatBuild", res, index_params, dataset, index); - } - return (int)mh$.invokeExact(res, index_params, dataset, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatSearch { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearch"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSearch$descriptor() { - return cuvsIvfFlatSearch.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MethodHandle cuvsIvfFlatSearch$handle() { - return cuvsIvfFlatSearch.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MemorySegment cuvsIvfFlatSearch$address() { - return cuvsIvfFlatSearch.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static int cuvsIvfFlatSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { - var mh$ = cuvsIvfFlatSearch.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSearch", res, search_params, index, queries, neighbors, distances); - } - return (int)mh$.invokeExact(res, search_params, index, queries, neighbors, distances); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatSerialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSerialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatSerialize$descriptor() { - return cuvsIvfFlatSerialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatSerialize$handle() { - return cuvsIvfFlatSerialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatSerialize$address() { - return cuvsIvfFlatSerialize.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatSerialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfFlatSerialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatSerialize", res, filename, index); - } - return (int)mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatDeserialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatDeserialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatDeserialize$descriptor() { - return cuvsIvfFlatDeserialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatDeserialize$handle() { - return cuvsIvfFlatDeserialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatDeserialize$address() { - return cuvsIvfFlatDeserialize.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatDeserialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfFlatDeserialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatDeserialize", res, filename, index); - } - return (int)mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfFlatExtend { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_flat_h.C_INT, - ivf_flat_h.C_LONG, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER, - ivf_flat_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatExtend"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfFlatExtend$descriptor() { - return cuvsIvfFlatExtend.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static MethodHandle cuvsIvfFlatExtend$handle() { - return cuvsIvfFlatExtend.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static MemorySegment cuvsIvfFlatExtend$address() { - return cuvsIvfFlatExtend.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) - * } - */ - public static int cuvsIvfFlatExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, MemorySegment index) { - var mh$ = cuvsIvfFlatExtend.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfFlatExtend", res, new_vectors, new_indices, index); - } - return (int)mh$.invokeExact(res, new_vectors, new_indices, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } + ivf_flat_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) + : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + + private static final int _FEATURES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + + private static final int _DEFAULT_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + + private static final int __GLIBC_USE_ISOC2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + + private static final int __USE_ISOC11 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + + private static final int __USE_ISOC99 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + + private static final int __USE_ISOC95 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + + private static final int __USE_POSIX_IMPLICITLY = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + + private static final int _POSIX_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + + private static final int __USE_POSIX = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + + private static final int __USE_POSIX2 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + + private static final int __USE_POSIX199309 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + + private static final int __USE_POSIX199506 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + + private static final int __USE_XOPEN2K = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + + private static final int __USE_XOPEN2K8 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + + private static final int _ATFILE_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + + private static final int __WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + + private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; + + /** + * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + + private static final int __SYSCALL_WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + + private static final int __USE_MISC = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + + private static final int __USE_ATFILE = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + + private static final int __USE_FORTIFY_LEVEL = (int) 0L; + + /** + * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + + private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + + private static final int _STDC_PREDEF_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + + private static final int __STDC_IEC_559__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + + private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + + private static final int __GNU_LIBRARY__ = (int) 6L; + + /** + * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + + private static final int __GLIBC__ = (int) 2L; + + /** + * {@snippet lang = c : * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + + private static final int __GLIBC_MINOR__ = (int) 35L; + + /** + * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + + private static final int _SYS_CDEFS_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + + private static final int __glibc_c99_flexarr_available = (int) 1L; + + /** + * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; + + /** + * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + + private static final int __HAVE_GENERIC_SELECTION = (int) 1L; + + /** + * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + + private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + + private static final int _BITS_TYPES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + + private static final int _BITS_TYPESIZES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + + private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + + private static final int __INO_T_MATCHES_INO64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + + private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + + private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + + private static final int __FD_SETSIZE = (int) 1024L; + + /** + * {@snippet lang = c : * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + + private static final int _BITS_TIME64_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + + private static final int _BITS_WCHAR_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + + private static final int _BITS_STDINT_INTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + + private static final int _BITS_STDINT_UINTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + + private static final int DLPACK_MAJOR_VERSION = (int) 1L; + + /** + * {@snippet lang = c : * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + + private static final int DLPACK_MINOR_VERSION = (int) 0L; + + /** + * {@snippet lang = c : * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + + private static final int true_ = (int) 1L; + + /** + * {@snippet lang = c : * #define true 1 + * } + */ + public static int true_() { + return true_; + } + + private static final int false_ = (int) 0L; + + /** + * {@snippet lang = c : * #define false 0 + * } + */ + public static int false_() { + return false_; + } + + private static final int __bool_true_false_are_defined = (int) 1L; + + /** + * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + + /** + * {@snippet lang = c : * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off_t + * } + */ + public static final OfLong __off_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef long __time_t + * } + */ + public static final OfLong __time_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef int __key_t + * } + */ + public static final OfInt __key_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = ivf_flat_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = ivf_flat_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = ivf_flat_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = ivf_flat_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = ivf_flat_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = ivf_flat_h.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 = ivf_flat_h.C_LONG; + private static final int L2Expanded = (int) 0L; + + /** + * {@snippet lang = c : * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + + private static final int L2SqrtExpanded = (int) 1L; + + /** + * {@snippet lang = c : * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + + private static final int CosineExpanded = (int) 2L; + + /** + * {@snippet lang = c : * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + + private static final int L1 = (int) 3L; + + /** + * {@snippet lang = c : * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + + private static final int L2Unexpanded = (int) 4L; + + /** + * {@snippet lang = c : * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + + private static final int L2SqrtUnexpanded = (int) 5L; + + /** + * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + + private static final int InnerProduct = (int) 6L; + + /** + * {@snippet lang = c : * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + + private static final int Linf = (int) 7L; + + /** + * {@snippet lang = c : * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + + private static final int Canberra = (int) 8L; + + /** + * {@snippet lang = c : * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + + private static final int LpUnexpanded = (int) 9L; + + /** + * {@snippet lang = c : * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + + private static final int CorrelationExpanded = (int) 10L; + + /** + * {@snippet lang = c : * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + + private static final int JaccardExpanded = (int) 11L; + + /** + * {@snippet lang = c : * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + + private static final int HellingerExpanded = (int) 12L; + + /** + * {@snippet lang = c : * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + + private static final int Haversine = (int) 13L; + + /** + * {@snippet lang = c : * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + + private static final int BrayCurtis = (int) 14L; + + /** + * {@snippet lang = c : * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + + private static final int JensenShannon = (int) 15L; + + /** + * {@snippet lang = c : * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + + private static final int HammingUnexpanded = (int) 16L; + + /** + * {@snippet lang = c : * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + + private static final int KLDivergence = (int) 17L; + + /** + * {@snippet lang = c : * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + + private static final int RusselRaoExpanded = (int) 18L; + + /** + * {@snippet lang = c : * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + + private static final int DiceExpanded = (int) 19L; + + /** + * {@snippet lang = c : * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + + private static final int Precomputed = (int) 100L; + + /** + * {@snippet lang = c : * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + + /** + * {@snippet lang = c : * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = ivf_flat_h.C_LONG; + /** + * {@snippet lang = c : * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = ivf_flat_h.C_INT; + private static final int kDLCPU = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + + private static final int kDLCUDA = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + + private static final int kDLCUDAHost = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + + private static final int kDLOpenCL = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + + private static final int kDLVulkan = (int) 7L; + + /** + * {@snippet lang = c : * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + + private static final int kDLMetal = (int) 8L; + + /** + * {@snippet lang = c : * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + + private static final int kDLVPI = (int) 9L; + + /** + * {@snippet lang = c : * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + + private static final int kDLROCM = (int) 10L; + + /** + * {@snippet lang = c : * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + + private static final int kDLROCMHost = (int) 11L; + + /** + * {@snippet lang = c : * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + + private static final int kDLExtDev = (int) 12L; + + /** + * {@snippet lang = c : * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + + private static final int kDLCUDAManaged = (int) 13L; + + /** + * {@snippet lang = c : * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + + private static final int kDLOneAPI = (int) 14L; + + /** + * {@snippet lang = c : * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + + private static final int kDLWebGPU = (int) 15L; + + /** + * {@snippet lang = c : * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + + private static final int kDLHexagon = (int) 16L; + + /** + * {@snippet lang = c : * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + + private static final int kDLMAIA = (int) 17L; + + /** + * {@snippet lang = c : * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + + private static final int kDLInt = (int) 0L; + + /** + * {@snippet lang = c : * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + + private static final int kDLUInt = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + + private static final int kDLFloat = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + + private static final int kDLOpaqueHandle = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + + private static final int kDLBfloat = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + + private static final int kDLComplex = (int) 5L; + + /** + * {@snippet lang = c : * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + + private static final int kDLBool = (int) 6L; + + /** + * {@snippet lang = c : * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsIvfFlatIndexParams { + * cuvsDistanceType metric; + * float metric_arg; + * _Bool add_data_on_build; + * uint32_t n_lists; + * uint32_t kmeans_n_iters; + * double kmeans_trainset_fraction; + * _Bool adaptive_centers; + * _Bool conservative_memory_allocation; + * } *cuvsIvfFlatIndexParams_t + * } + */ + public static final AddressLayout cuvsIvfFlatIndexParams_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexParamsCreate$descriptor() { + return cuvsIvfFlatIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static MethodHandle cuvsIvfFlatIndexParamsCreate$handle() { + return cuvsIvfFlatIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static MemorySegment cuvsIvfFlatIndexParamsCreate$address() { + return cuvsIvfFlatIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsCreate(cuvsIvfFlatIndexParams_t *index_params) + * } + */ + public static int cuvsIvfFlatIndexParamsCreate(MemorySegment index_params) { + var mh$ = cuvsIvfFlatIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexParamsCreate", index_params); + } + return (int) mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexParamsDestroy$descriptor() { + return cuvsIvfFlatIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static MethodHandle cuvsIvfFlatIndexParamsDestroy$handle() { + return cuvsIvfFlatIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static MemorySegment cuvsIvfFlatIndexParamsDestroy$address() { + return cuvsIvfFlatIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexParamsDestroy(cuvsIvfFlatIndexParams_t index_params) + * } + */ + public static int cuvsIvfFlatIndexParamsDestroy(MemorySegment index_params) { + var mh$ = cuvsIvfFlatIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexParamsDestroy", index_params); + } + return (int) mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : + * typedef struct cuvsIvfFlatSearchParams { + * uint32_t n_probes; + * } *cuvsIvfFlatSearchParams_t + * } + */ + public static final AddressLayout cuvsIvfFlatSearchParams_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearchParamsCreate$descriptor() { + return cuvsIvfFlatSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static MethodHandle cuvsIvfFlatSearchParamsCreate$handle() { + return cuvsIvfFlatSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static MemorySegment cuvsIvfFlatSearchParamsCreate$address() { + return cuvsIvfFlatSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsCreate(cuvsIvfFlatSearchParams_t *params) + * } + */ + public static int cuvsIvfFlatSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsIvfFlatSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearchParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearchParamsDestroy$descriptor() { + return cuvsIvfFlatSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static MethodHandle cuvsIvfFlatSearchParamsDestroy$handle() { + return cuvsIvfFlatSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static MemorySegment cuvsIvfFlatSearchParamsDestroy$address() { + return cuvsIvfFlatSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearchParamsDestroy(cuvsIvfFlatSearchParams_t params) + * } + */ + public static int cuvsIvfFlatSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsIvfFlatSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearchParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : * typedef cuvsIvfFlatIndex *cuvsIvfFlatIndex_t + * } + */ + public static final AddressLayout cuvsIvfFlatIndex_t = ivf_flat_h.C_POINTER; + + private static class cuvsIvfFlatIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexCreate$descriptor() { + return cuvsIvfFlatIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static MethodHandle cuvsIvfFlatIndexCreate$handle() { + return cuvsIvfFlatIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static MemorySegment cuvsIvfFlatIndexCreate$address() { + return cuvsIvfFlatIndexCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexCreate(cuvsIvfFlatIndex_t *index) + * } + */ + public static int cuvsIvfFlatIndexCreate(MemorySegment index) { + var mh$ = cuvsIvfFlatIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexCreate", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatIndexDestroy$descriptor() { + return cuvsIvfFlatIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatIndexDestroy$handle() { + return cuvsIvfFlatIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatIndexDestroy$address() { + return cuvsIvfFlatIndexDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatIndexDestroy(cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatIndexDestroy(MemorySegment index) { + var mh$ = cuvsIvfFlatIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatIndexDestroy", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatBuild$descriptor() { + return cuvsIvfFlatBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatBuild$handle() { + return cuvsIvfFlatBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatBuild$address() { + return cuvsIvfFlatBuild.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatBuild(cuvsResources_t res, cuvsIvfFlatIndexParams_t index_params, DLManagedTensor *dataset, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatBuild(long res, MemorySegment index_params, MemorySegment dataset, MemorySegment index) { + var mh$ = cuvsIvfFlatBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatBuild", res, index_params, dataset, index); + } + return (int) mh$.invokeExact(res, index_params, dataset, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSearch$descriptor() { + return cuvsIvfFlatSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsIvfFlatSearch$handle() { + return cuvsIvfFlatSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsIvfFlatSearch$address() { + return cuvsIvfFlatSearch.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSearch(cuvsResources_t res, cuvsIvfFlatSearchParams_t search_params, cuvsIvfFlatIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsIvfFlatSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, + MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsIvfFlatSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSearch", res, search_params, index, queries, neighbors, distances); + } + return (int) mh$.invokeExact(res, search_params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatSerialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatSerialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatSerialize$descriptor() { + return cuvsIvfFlatSerialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatSerialize$handle() { + return cuvsIvfFlatSerialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatSerialize$address() { + return cuvsIvfFlatSerialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatSerialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatSerialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfFlatSerialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatSerialize", res, filename, index); + } + return (int) mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatDeserialize$descriptor() { + return cuvsIvfFlatDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatDeserialize$handle() { + return cuvsIvfFlatDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatDeserialize$address() { + return cuvsIvfFlatDeserialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatDeserialize(cuvsResources_t res, const char *filename, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatDeserialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfFlatDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatDeserialize", res, filename, index); + } + return (int) mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfFlatExtend { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_flat_h.C_INT, ivf_flat_h.C_LONG, + ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER, ivf_flat_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_flat_h.findOrThrow("cuvsIvfFlatExtend"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfFlatExtend$descriptor() { + return cuvsIvfFlatExtend.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static MethodHandle cuvsIvfFlatExtend$handle() { + return cuvsIvfFlatExtend.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static MemorySegment cuvsIvfFlatExtend$address() { + return cuvsIvfFlatExtend.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfFlatExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfFlatIndex_t index) + * } + */ + public static int cuvsIvfFlatExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, + MemorySegment index) { + var mh$ = cuvsIvfFlatExtend.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfFlatExtend", res, new_vectors, new_indices, index); + } + return (int) mh$.invokeExact(res, new_vectors, new_indices, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static final long _POSIX_C_SOURCE = 200809L; + + /** + * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + + private static final int __TIMESIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + + private static final long __STDC_IEC_60559_BFP__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + + private static final long __STDC_ISO_10646__ = 201706L; + + /** + * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + + private static final int __WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + + private static final int __WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + + private static final int INT8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + + private static final int INT16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + + private static final int INT32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + + private static final long INT64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + + private static final int INT8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + + private static final int INT16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + + private static final int INT32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + + private static final long INT64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + + private static final int UINT8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + + private static final int UINT16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + + private static final int UINT32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + + private static final long UINT64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + + private static final int INT_LEAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + + private static final int INT_LEAST16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + + private static final int INT_LEAST32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + + private static final long INT_LEAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + + private static final int INT_LEAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + + private static final int INT_LEAST16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + + private static final int INT_LEAST32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + + private static final long INT_LEAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + + private static final int UINT_LEAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + + private static final int UINT_LEAST16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + + private static final int UINT_LEAST32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + + private static final long UINT_LEAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + + private static final int INT_FAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + + private static final long INT_FAST16_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + + private static final long INT_FAST32_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + + private static final long INT_FAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + + private static final int INT_FAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + + private static final long INT_FAST16_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + + private static final long INT_FAST32_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + + private static final long INT_FAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + + private static final int UINT_FAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + + private static final long UINT_FAST16_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + + private static final long UINT_FAST32_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + + private static final long UINT_FAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + + private static final long INTPTR_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + + private static final long INTPTR_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + + private static final long UINTPTR_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + + private static final long INTMAX_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + + private static final long INTMAX_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + + private static final long UINTMAX_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + + private static final long PTRDIFF_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + + private static final long PTRDIFF_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + + private static final int SIG_ATOMIC_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + + private static final int SIG_ATOMIC_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + + private static final long SIZE_MAX = -1L; + + /** + * {@snippet lang = c : * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + + private static final int WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + + private static final int WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + + private static final int WINT_MIN = (int) 0L; + + /** + * {@snippet lang = c : * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + + private static final int WINT_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + + /** + * {@snippet lang = c : * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } } - diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java index fd57078b6..0d97fabe1 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java @@ -1,3096 +1,3182 @@ -package com.nvidia.cuvs.panama; +/* + * Copyright (c) 2023-2024, 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. + */ -import java.lang.invoke.*; -import java.lang.foreign.*; -import java.nio.ByteOrder; -import java.util.*; -import java.util.function.*; -import java.util.stream.*; +package com.nvidia.cuvs.panama; -import static java.lang.foreign.ValueLayout.*; -import static java.lang.foreign.MemoryLayout.PathElement.*; +import static java.lang.foreign.ValueLayout.JAVA_BYTE; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.PaddingLayout; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.StructLayout; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.foreign.ValueLayout.OfByte; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.foreign.ValueLayout.OfShort; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.stream.Collectors; public class ivf_pq_h { - ivf_pq_h() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args) - .map(Object::toString) - .collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol) - .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream() - .map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? - MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() - .or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - private static final int _STDINT_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - private static final int _FEATURES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - private static final int _DEFAULT_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - private static final int __GLIBC_USE_ISOC2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - private static final int __USE_ISOC11 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - private static final int __USE_ISOC99 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - private static final int __USE_ISOC95 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - private static final int __USE_POSIX_IMPLICITLY = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - private static final int _POSIX_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - private static final int __USE_POSIX = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - private static final int __USE_POSIX2 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - private static final int __USE_POSIX199309 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - private static final int __USE_POSIX199506 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - private static final int __USE_XOPEN2K = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - private static final int __USE_XOPEN2K8 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - private static final int _ATFILE_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - private static final int __WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; - /** - * {@snippet lang=c : - * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - private static final int __SYSCALL_WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - private static final int __USE_MISC = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - private static final int __USE_ATFILE = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - private static final int __USE_FORTIFY_LEVEL = (int)0L; - /** - * {@snippet lang=c : - * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - private static final int _STDC_PREDEF_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - private static final int __STDC_IEC_559__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - private static final int __GNU_LIBRARY__ = (int)6L; - /** - * {@snippet lang=c : - * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - private static final int __GLIBC__ = (int)2L; - /** - * {@snippet lang=c : - * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - private static final int __GLIBC_MINOR__ = (int)35L; - /** - * {@snippet lang=c : - * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - private static final int _SYS_CDEFS_H = (int)1L; - /** - * {@snippet lang=c : - * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - private static final int __glibc_c99_flexarr_available = (int)1L; - /** - * {@snippet lang=c : - * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; - /** - * {@snippet lang=c : - * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - private static final int __HAVE_GENERIC_SELECTION = (int)1L; - /** - * {@snippet lang=c : - * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - private static final int _BITS_TYPES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - private static final int _BITS_TYPESIZES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - private static final int __INO_T_MATCHES_INO64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - private static final int __STATFS_MATCHES_STATFS64 = (int)1L; - /** - * {@snippet lang=c : - * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; - /** - * {@snippet lang=c : - * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - private static final int __FD_SETSIZE = (int)1024L; - /** - * {@snippet lang=c : - * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - private static final int _BITS_TIME64_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - private static final int _BITS_WCHAR_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - private static final int _BITS_STDINT_INTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - private static final int _BITS_STDINT_UINTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - private static final int DLPACK_MAJOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - private static final int DLPACK_MINOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - private static final int true_ = (int)1L; - /** - * {@snippet lang=c : - * #define true 1 - * } - */ - public static int true_() { - return true_; - } - private static final int false_ = (int)0L; - /** - * {@snippet lang=c : - * #define false 0 - * } - */ - public static int false_() { - return false_; - } - private static final int __bool_true_false_are_defined = (int)1L; - /** - * {@snippet lang=c : - * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = ivf_pq_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = ivf_pq_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = ivf_pq_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = ivf_pq_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = ivf_pq_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = ivf_pq_h.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 = ivf_pq_h.C_LONG; - private static final int L2Expanded = (int)0L; - /** - * {@snippet lang=c : - * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - private static final int L2SqrtExpanded = (int)1L; - /** - * {@snippet lang=c : - * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - private static final int CosineExpanded = (int)2L; - /** - * {@snippet lang=c : - * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - private static final int L1 = (int)3L; - /** - * {@snippet lang=c : - * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - private static final int L2Unexpanded = (int)4L; - /** - * {@snippet lang=c : - * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - private static final int L2SqrtUnexpanded = (int)5L; - /** - * {@snippet lang=c : - * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - private static final int InnerProduct = (int)6L; - /** - * {@snippet lang=c : - * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - private static final int Linf = (int)7L; - /** - * {@snippet lang=c : - * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - private static final int Canberra = (int)8L; - /** - * {@snippet lang=c : - * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - private static final int LpUnexpanded = (int)9L; - /** - * {@snippet lang=c : - * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - private static final int CorrelationExpanded = (int)10L; - /** - * {@snippet lang=c : - * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - private static final int JaccardExpanded = (int)11L; - /** - * {@snippet lang=c : - * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - private static final int HellingerExpanded = (int)12L; - /** - * {@snippet lang=c : - * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - private static final int Haversine = (int)13L; - /** - * {@snippet lang=c : - * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - private static final int BrayCurtis = (int)14L; - /** - * {@snippet lang=c : - * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - private static final int JensenShannon = (int)15L; - /** - * {@snippet lang=c : - * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - private static final int HammingUnexpanded = (int)16L; - /** - * {@snippet lang=c : - * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - private static final int KLDivergence = (int)17L; - /** - * {@snippet lang=c : - * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - private static final int RusselRaoExpanded = (int)18L; - /** - * {@snippet lang=c : - * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - private static final int DiceExpanded = (int)19L; - /** - * {@snippet lang=c : - * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - private static final int Precomputed = (int)100L; - /** - * {@snippet lang=c : - * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = ivf_pq_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = ivf_pq_h.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - private static final int CUDA_R_16F = (int)2L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_16F = 2 - * } - */ - public static int CUDA_R_16F() { - return CUDA_R_16F; - } - private static final int CUDA_C_16F = (int)6L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_16F = 6 - * } - */ - public static int CUDA_C_16F() { - return CUDA_C_16F; - } - private static final int CUDA_R_16BF = (int)14L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_16BF = 14 - * } - */ - public static int CUDA_R_16BF() { - return CUDA_R_16BF; - } - private static final int CUDA_C_16BF = (int)15L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_16BF = 15 - * } - */ - public static int CUDA_C_16BF() { - return CUDA_C_16BF; - } - private static final int CUDA_R_32F = (int)0L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_32F = 0 - * } - */ - public static int CUDA_R_32F() { - return CUDA_R_32F; - } - private static final int CUDA_C_32F = (int)4L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_32F = 4 - * } - */ - public static int CUDA_C_32F() { - return CUDA_C_32F; - } - private static final int CUDA_R_64F = (int)1L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_64F = 1 - * } - */ - public static int CUDA_R_64F() { - return CUDA_R_64F; - } - private static final int CUDA_C_64F = (int)5L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_64F = 5 - * } - */ - public static int CUDA_C_64F() { - return CUDA_C_64F; - } - private static final int CUDA_R_4I = (int)16L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_4I = 16 - * } - */ - public static int CUDA_R_4I() { - return CUDA_R_4I; - } - private static final int CUDA_C_4I = (int)17L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_4I = 17 - * } - */ - public static int CUDA_C_4I() { - return CUDA_C_4I; - } - private static final int CUDA_R_4U = (int)18L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_4U = 18 - * } - */ - public static int CUDA_R_4U() { - return CUDA_R_4U; - } - private static final int CUDA_C_4U = (int)19L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_4U = 19 - * } - */ - public static int CUDA_C_4U() { - return CUDA_C_4U; - } - private static final int CUDA_R_8I = (int)3L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_8I = 3 - * } - */ - public static int CUDA_R_8I() { - return CUDA_R_8I; - } - private static final int CUDA_C_8I = (int)7L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_8I = 7 - * } - */ - public static int CUDA_C_8I() { - return CUDA_C_8I; - } - private static final int CUDA_R_8U = (int)8L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_8U = 8 - * } - */ - public static int CUDA_R_8U() { - return CUDA_R_8U; - } - private static final int CUDA_C_8U = (int)9L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_8U = 9 - * } - */ - public static int CUDA_C_8U() { - return CUDA_C_8U; - } - private static final int CUDA_R_16I = (int)20L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_16I = 20 - * } - */ - public static int CUDA_R_16I() { - return CUDA_R_16I; - } - private static final int CUDA_C_16I = (int)21L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_16I = 21 - * } - */ - public static int CUDA_C_16I() { - return CUDA_C_16I; - } - private static final int CUDA_R_16U = (int)22L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_16U = 22 - * } - */ - public static int CUDA_R_16U() { - return CUDA_R_16U; - } - private static final int CUDA_C_16U = (int)23L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_16U = 23 - * } - */ - public static int CUDA_C_16U() { - return CUDA_C_16U; - } - private static final int CUDA_R_32I = (int)10L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_32I = 10 - * } - */ - public static int CUDA_R_32I() { - return CUDA_R_32I; - } - private static final int CUDA_C_32I = (int)11L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_32I = 11 - * } - */ - public static int CUDA_C_32I() { - return CUDA_C_32I; - } - private static final int CUDA_R_32U = (int)12L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_32U = 12 - * } - */ - public static int CUDA_R_32U() { - return CUDA_R_32U; - } - private static final int CUDA_C_32U = (int)13L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_32U = 13 - * } - */ - public static int CUDA_C_32U() { - return CUDA_C_32U; - } - private static final int CUDA_R_64I = (int)24L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_64I = 24 - * } - */ - public static int CUDA_R_64I() { - return CUDA_R_64I; - } - private static final int CUDA_C_64I = (int)25L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_64I = 25 - * } - */ - public static int CUDA_C_64I() { - return CUDA_C_64I; - } - private static final int CUDA_R_64U = (int)26L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_R_64U = 26 - * } - */ - public static int CUDA_R_64U() { - return CUDA_R_64U; - } - private static final int CUDA_C_64U = (int)27L; - /** - * {@snippet lang=c : - * enum cudaDataType_t.CUDA_C_64U = 27 - * } - */ - public static int CUDA_C_64U() { - return CUDA_C_64U; - } - private static final int MAJOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * enum libraryPropertyType_t.MAJOR_VERSION = 0 - * } - */ - public static int MAJOR_VERSION() { - return MAJOR_VERSION; - } - private static final int MINOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * enum libraryPropertyType_t.MINOR_VERSION = 1 - * } - */ - public static int MINOR_VERSION() { - return MINOR_VERSION; - } - private static final int PATCH_LEVEL = (int)2L; - /** - * {@snippet lang=c : - * enum libraryPropertyType_t.PATCH_LEVEL = 2 - * } - */ - public static int PATCH_LEVEL() { - return PATCH_LEVEL; - } - private static final int PER_SUBSPACE = (int)0L; - /** - * {@snippet lang=c : - * enum codebook_gen.PER_SUBSPACE = 0 - * } - */ - public static int PER_SUBSPACE() { - return PER_SUBSPACE; - } - private static final int PER_CLUSTER = (int)1L; - /** - * {@snippet lang=c : - * enum codebook_gen.PER_CLUSTER = 1 - * } - */ - public static int PER_CLUSTER() { - return PER_CLUSTER; - } - /** - * {@snippet lang=c : - * typedef struct cuvsIvfPqIndexParams { - * cuvsDistanceType metric; - * float metric_arg; - * _Bool add_data_on_build; - * uint32_t n_lists; - * uint32_t kmeans_n_iters; - * double kmeans_trainset_fraction; - * uint32_t pq_bits; - * uint32_t pq_dim; - * enum codebook_gen codebook_kind; - * _Bool force_random_rotation; - * _Bool conservative_memory_allocation; - * uint32_t max_train_points_per_pq_code; - * } *cuvsIvfPqIndexParams_t - * } - */ - public static final AddressLayout cuvsIvfPqIndexParams_t = ivf_pq_h.C_POINTER; - - private static class cuvsIvfPqIndexParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexParamsCreate$descriptor() { - return cuvsIvfPqIndexParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static MethodHandle cuvsIvfPqIndexParamsCreate$handle() { - return cuvsIvfPqIndexParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static MemorySegment cuvsIvfPqIndexParamsCreate$address() { - return cuvsIvfPqIndexParamsCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) - * } - */ - public static int cuvsIvfPqIndexParamsCreate(MemorySegment index_params) { - var mh$ = cuvsIvfPqIndexParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexParamsCreate", index_params); - } - return (int)mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqIndexParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexParamsDestroy$descriptor() { - return cuvsIvfPqIndexParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static MethodHandle cuvsIvfPqIndexParamsDestroy$handle() { - return cuvsIvfPqIndexParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static MemorySegment cuvsIvfPqIndexParamsDestroy$address() { - return cuvsIvfPqIndexParamsDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) - * } - */ - public static int cuvsIvfPqIndexParamsDestroy(MemorySegment index_params) { - var mh$ = cuvsIvfPqIndexParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexParamsDestroy", index_params); - } - return (int)mh$.invokeExact(index_params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef struct cuvsIvfPqSearchParams { - * uint32_t n_probes; - * cudaDataType_t lut_dtype; - * cudaDataType_t internal_distance_dtype; - * double preferred_shmem_carveout; - * } *cuvsIvfPqSearchParams_t - * } - */ - public static final AddressLayout cuvsIvfPqSearchParams_t = ivf_pq_h.C_POINTER; - - private static class cuvsIvfPqSearchParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static FunctionDescriptor cuvsIvfPqSearchParamsCreate$descriptor() { - return cuvsIvfPqSearchParamsCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static MethodHandle cuvsIvfPqSearchParamsCreate$handle() { - return cuvsIvfPqSearchParamsCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static MemorySegment cuvsIvfPqSearchParamsCreate$address() { - return cuvsIvfPqSearchParamsCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) - * } - */ - public static int cuvsIvfPqSearchParamsCreate(MemorySegment params) { - var mh$ = cuvsIvfPqSearchParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSearchParamsCreate", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqSearchParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static FunctionDescriptor cuvsIvfPqSearchParamsDestroy$descriptor() { - return cuvsIvfPqSearchParamsDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static MethodHandle cuvsIvfPqSearchParamsDestroy$handle() { - return cuvsIvfPqSearchParamsDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static MemorySegment cuvsIvfPqSearchParamsDestroy$address() { - return cuvsIvfPqSearchParamsDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) - * } - */ - public static int cuvsIvfPqSearchParamsDestroy(MemorySegment params) { - var mh$ = cuvsIvfPqSearchParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSearchParamsDestroy", params); - } - return (int)mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - /** - * {@snippet lang=c : - * typedef cuvsIvfPq *cuvsIvfPqIndex_t - * } - */ - public static final AddressLayout cuvsIvfPqIndex_t = ivf_pq_h.C_POINTER; - - private static class cuvsIvfPqIndexCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexCreate$descriptor() { - return cuvsIvfPqIndexCreate.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static MethodHandle cuvsIvfPqIndexCreate$handle() { - return cuvsIvfPqIndexCreate.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static MemorySegment cuvsIvfPqIndexCreate$address() { - return cuvsIvfPqIndexCreate.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) - * } - */ - public static int cuvsIvfPqIndexCreate(MemorySegment index) { - var mh$ = cuvsIvfPqIndexCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexCreate", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqIndexDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqIndexDestroy$descriptor() { - return cuvsIvfPqIndexDestroy.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqIndexDestroy$handle() { - return cuvsIvfPqIndexDestroy.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqIndexDestroy$address() { - return cuvsIvfPqIndexDestroy.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqIndexDestroy(MemorySegment index) { - var mh$ = cuvsIvfPqIndexDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqIndexDestroy", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqBuild { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqBuild"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqBuild$descriptor() { - return cuvsIvfPqBuild.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqBuild$handle() { - return cuvsIvfPqBuild.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqBuild$address() { - return cuvsIvfPqBuild.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqBuild(long res, MemorySegment params, MemorySegment dataset, MemorySegment index) { - var mh$ = cuvsIvfPqBuild.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqBuild", res, params, dataset, index); - } - return (int)mh$.invokeExact(res, params, dataset, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqSearch { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearch"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static FunctionDescriptor cuvsIvfPqSearch$descriptor() { - return cuvsIvfPqSearch.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MethodHandle cuvsIvfPqSearch$handle() { - return cuvsIvfPqSearch.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static MemorySegment cuvsIvfPqSearch$address() { - return cuvsIvfPqSearch.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) - * } - */ - public static int cuvsIvfPqSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances) { - var mh$ = cuvsIvfPqSearch.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSearch", res, search_params, index, queries, neighbors, distances); - } - return (int)mh$.invokeExact(res, search_params, index, queries, neighbors, distances); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqSerialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSerialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqSerialize$descriptor() { - return cuvsIvfPqSerialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqSerialize$handle() { - return cuvsIvfPqSerialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqSerialize$address() { - return cuvsIvfPqSerialize.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqSerialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfPqSerialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqSerialize", res, filename, index); - } - return (int)mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqDeserialize { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqDeserialize"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqDeserialize$descriptor() { - return cuvsIvfPqDeserialize.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqDeserialize$handle() { - return cuvsIvfPqDeserialize.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqDeserialize$address() { - return cuvsIvfPqDeserialize.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqDeserialize(long res, MemorySegment filename, MemorySegment index) { - var mh$ = cuvsIvfPqDeserialize.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqDeserialize", res, filename, index); - } - return (int)mh$.invokeExact(res, filename, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - - private static class cuvsIvfPqExtend { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - ivf_pq_h.C_INT, - ivf_pq_h.C_LONG, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER, - ivf_pq_h.C_POINTER - ); - - public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqExtend"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static FunctionDescriptor cuvsIvfPqExtend$descriptor() { - return cuvsIvfPqExtend.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static MethodHandle cuvsIvfPqExtend$handle() { - return cuvsIvfPqExtend.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static MemorySegment cuvsIvfPqExtend$address() { - return cuvsIvfPqExtend.ADDR; - } - - /** - * {@snippet lang=c : - * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) - * } - */ - public static int cuvsIvfPqExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, MemorySegment index) { - var mh$ = cuvsIvfPqExtend.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsIvfPqExtend", res, new_vectors, new_indices, index); - } - return (int)mh$.invokeExact(res, new_vectors, new_indices, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } + ivf_pq_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) + : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int _STDINT_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } + + private static final int _FEATURES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } + + private static final int _DEFAULT_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } + + private static final int __GLIBC_USE_ISOC2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } + + private static final int __USE_ISOC11 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } + + private static final int __USE_ISOC99 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } + + private static final int __USE_ISOC95 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } + + private static final int __USE_POSIX_IMPLICITLY = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } + + private static final int _POSIX_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } + + private static final int __USE_POSIX = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } + + private static final int __USE_POSIX2 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX2 1 + * } + */ + public static int __USE_POSIX2() { + return __USE_POSIX2; + } + + private static final int __USE_POSIX199309 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX199309 1 + * } + */ + public static int __USE_POSIX199309() { + return __USE_POSIX199309; + } + + private static final int __USE_POSIX199506 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_POSIX199506 1 + * } + */ + public static int __USE_POSIX199506() { + return __USE_POSIX199506; + } + + private static final int __USE_XOPEN2K = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_XOPEN2K 1 + * } + */ + public static int __USE_XOPEN2K() { + return __USE_XOPEN2K; + } + + private static final int __USE_XOPEN2K8 = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_XOPEN2K8 1 + * } + */ + public static int __USE_XOPEN2K8() { + return __USE_XOPEN2K8; + } + + private static final int _ATFILE_SOURCE = (int) 1L; + + /** + * {@snippet lang = c : * #define _ATFILE_SOURCE 1 + * } + */ + public static int _ATFILE_SOURCE() { + return _ATFILE_SOURCE; + } + + private static final int __WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __WORDSIZE 64 + * } + */ + public static int __WORDSIZE() { + return __WORDSIZE; + } + + private static final int __WORDSIZE_TIME64_COMPAT32 = (int) 1L; + + /** + * {@snippet lang = c : * #define __WORDSIZE_TIME64_COMPAT32 1 + * } + */ + public static int __WORDSIZE_TIME64_COMPAT32() { + return __WORDSIZE_TIME64_COMPAT32; + } + + private static final int __SYSCALL_WORDSIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __SYSCALL_WORDSIZE 64 + * } + */ + public static int __SYSCALL_WORDSIZE() { + return __SYSCALL_WORDSIZE; + } + + private static final int __USE_MISC = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_MISC 1 + * } + */ + public static int __USE_MISC() { + return __USE_MISC; + } + + private static final int __USE_ATFILE = (int) 1L; + + /** + * {@snippet lang = c : * #define __USE_ATFILE 1 + * } + */ + public static int __USE_ATFILE() { + return __USE_ATFILE; + } + + private static final int __USE_FORTIFY_LEVEL = (int) 0L; + + /** + * {@snippet lang = c : * #define __USE_FORTIFY_LEVEL 0 + * } + */ + public static int __USE_FORTIFY_LEVEL() { + return __USE_FORTIFY_LEVEL; + } + + private static final int __GLIBC_USE_DEPRECATED_GETS = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_GETS 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_GETS() { + return __GLIBC_USE_DEPRECATED_GETS; + } + + private static final int __GLIBC_USE_DEPRECATED_SCANF = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_DEPRECATED_SCANF 0 + * } + */ + public static int __GLIBC_USE_DEPRECATED_SCANF() { + return __GLIBC_USE_DEPRECATED_SCANF; + } + + private static final int _STDC_PREDEF_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _STDC_PREDEF_H 1 + * } + */ + public static int _STDC_PREDEF_H() { + return _STDC_PREDEF_H; + } + + private static final int __STDC_IEC_559__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559__ 1 + * } + */ + public static int __STDC_IEC_559__() { + return __STDC_IEC_559__; + } + + private static final int __STDC_IEC_559_COMPLEX__ = (int) 1L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_559_COMPLEX__ 1 + * } + */ + public static int __STDC_IEC_559_COMPLEX__() { + return __STDC_IEC_559_COMPLEX__; + } + + private static final int __GNU_LIBRARY__ = (int) 6L; + + /** + * {@snippet lang = c : * #define __GNU_LIBRARY__ 6 + * } + */ + public static int __GNU_LIBRARY__() { + return __GNU_LIBRARY__; + } + + private static final int __GLIBC__ = (int) 2L; + + /** + * {@snippet lang = c : * #define __GLIBC__ 2 + * } + */ + public static int __GLIBC__() { + return __GLIBC__; + } + + private static final int __GLIBC_MINOR__ = (int) 35L; + + /** + * {@snippet lang = c : * #define __GLIBC_MINOR__ 35 + * } + */ + public static int __GLIBC_MINOR__() { + return __GLIBC_MINOR__; + } + + private static final int _SYS_CDEFS_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _SYS_CDEFS_H 1 + * } + */ + public static int _SYS_CDEFS_H() { + return _SYS_CDEFS_H; + } + + private static final int __glibc_c99_flexarr_available = (int) 1L; + + /** + * {@snippet lang = c : * #define __glibc_c99_flexarr_available 1 + * } + */ + public static int __glibc_c99_flexarr_available() { + return __glibc_c99_flexarr_available; + } + + private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int) 0L; + + /** + * {@snippet lang = c : * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 + * } + */ + public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { + return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; + } + + private static final int __HAVE_GENERIC_SELECTION = (int) 1L; + + /** + * {@snippet lang = c : * #define __HAVE_GENERIC_SELECTION 1 + * } + */ + public static int __HAVE_GENERIC_SELECTION() { + return __HAVE_GENERIC_SELECTION; + } + + private static final int __GLIBC_USE_LIB_EXT2 = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_LIB_EXT2 0 + * } + */ + public static int __GLIBC_USE_LIB_EXT2() { + return __GLIBC_USE_LIB_EXT2; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT() { + return __GLIBC_USE_IEC_60559_BFP_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { + return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_EXT() { + return __GLIBC_USE_IEC_60559_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT; + } + + private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { + return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; + } + + private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int) 0L; + + /** + * {@snippet lang = c : * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 + * } + */ + public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { + return __GLIBC_USE_IEC_60559_TYPES_EXT; + } + + private static final int _BITS_TYPES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPES_H 1 + * } + */ + public static int _BITS_TYPES_H() { + return _BITS_TYPES_H; + } + + private static final int _BITS_TYPESIZES_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TYPESIZES_H 1 + * } + */ + public static int _BITS_TYPESIZES_H() { + return _BITS_TYPESIZES_H; + } + + private static final int __OFF_T_MATCHES_OFF64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __OFF_T_MATCHES_OFF64_T 1 + * } + */ + public static int __OFF_T_MATCHES_OFF64_T() { + return __OFF_T_MATCHES_OFF64_T; + } + + private static final int __INO_T_MATCHES_INO64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __INO_T_MATCHES_INO64_T 1 + * } + */ + public static int __INO_T_MATCHES_INO64_T() { + return __INO_T_MATCHES_INO64_T; + } + + private static final int __RLIM_T_MATCHES_RLIM64_T = (int) 1L; + + /** + * {@snippet lang = c : * #define __RLIM_T_MATCHES_RLIM64_T 1 + * } + */ + public static int __RLIM_T_MATCHES_RLIM64_T() { + return __RLIM_T_MATCHES_RLIM64_T; + } + + private static final int __STATFS_MATCHES_STATFS64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __STATFS_MATCHES_STATFS64 1 + * } + */ + public static int __STATFS_MATCHES_STATFS64() { + return __STATFS_MATCHES_STATFS64; + } + + private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int) 1L; + + /** + * {@snippet lang = c : * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + * } + */ + public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { + return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; + } + + private static final int __FD_SETSIZE = (int) 1024L; + + /** + * {@snippet lang = c : * #define __FD_SETSIZE 1024 + * } + */ + public static int __FD_SETSIZE() { + return __FD_SETSIZE; + } + + private static final int _BITS_TIME64_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_TIME64_H 1 + * } + */ + public static int _BITS_TIME64_H() { + return _BITS_TIME64_H; + } + + private static final int _BITS_WCHAR_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_WCHAR_H 1 + * } + */ + public static int _BITS_WCHAR_H() { + return _BITS_WCHAR_H; + } + + private static final int _BITS_STDINT_INTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_INTN_H 1 + * } + */ + public static int _BITS_STDINT_INTN_H() { + return _BITS_STDINT_INTN_H; + } + + private static final int _BITS_STDINT_UINTN_H = (int) 1L; + + /** + * {@snippet lang = c : * #define _BITS_STDINT_UINTN_H 1 + * } + */ + public static int _BITS_STDINT_UINTN_H() { + return _BITS_STDINT_UINTN_H; + } + + private static final int DLPACK_MAJOR_VERSION = (int) 1L; + + /** + * {@snippet lang = c : * #define DLPACK_MAJOR_VERSION 1 + * } + */ + public static int DLPACK_MAJOR_VERSION() { + return DLPACK_MAJOR_VERSION; + } + + private static final int DLPACK_MINOR_VERSION = (int) 0L; + + /** + * {@snippet lang = c : * #define DLPACK_MINOR_VERSION 0 + * } + */ + public static int DLPACK_MINOR_VERSION() { + return DLPACK_MINOR_VERSION; + } + + private static final int true_ = (int) 1L; + + /** + * {@snippet lang = c : * #define true 1 + * } + */ + public static int true_() { + return true_; + } + + private static final int false_ = (int) 0L; + + /** + * {@snippet lang = c : * #define false 0 + * } + */ + public static int false_() { + return false_; + } + + private static final int __bool_true_false_are_defined = (int) 1L; + + /** + * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + + /** + * {@snippet lang = c : * typedef unsigned char __u_char + * } + */ + public static final OfByte __u_char = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off_t + * } + */ + public static final OfLong __off_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef long __time_t + * } + */ + public static final OfLong __time_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef int __key_t + * } + */ + public static final OfInt __key_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = ivf_pq_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = ivf_pq_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = ivf_pq_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = ivf_pq_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = ivf_pq_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = ivf_pq_h.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 = ivf_pq_h.C_LONG; + private static final int L2Expanded = (int) 0L; + + /** + * {@snippet lang = c : * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + + private static final int L2SqrtExpanded = (int) 1L; + + /** + * {@snippet lang = c : * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + + private static final int CosineExpanded = (int) 2L; + + /** + * {@snippet lang = c : * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + + private static final int L1 = (int) 3L; + + /** + * {@snippet lang = c : * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + + private static final int L2Unexpanded = (int) 4L; + + /** + * {@snippet lang = c : * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + + private static final int L2SqrtUnexpanded = (int) 5L; + + /** + * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + + private static final int InnerProduct = (int) 6L; + + /** + * {@snippet lang = c : * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + + private static final int Linf = (int) 7L; + + /** + * {@snippet lang = c : * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + + private static final int Canberra = (int) 8L; + + /** + * {@snippet lang = c : * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + + private static final int LpUnexpanded = (int) 9L; + + /** + * {@snippet lang = c : * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + + private static final int CorrelationExpanded = (int) 10L; + + /** + * {@snippet lang = c : * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + + private static final int JaccardExpanded = (int) 11L; + + /** + * {@snippet lang = c : * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + + private static final int HellingerExpanded = (int) 12L; + + /** + * {@snippet lang = c : * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + + private static final int Haversine = (int) 13L; + + /** + * {@snippet lang = c : * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + + private static final int BrayCurtis = (int) 14L; + + /** + * {@snippet lang = c : * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + + private static final int JensenShannon = (int) 15L; + + /** + * {@snippet lang = c : * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + + private static final int HammingUnexpanded = (int) 16L; + + /** + * {@snippet lang = c : * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + + private static final int KLDivergence = (int) 17L; + + /** + * {@snippet lang = c : * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + + private static final int RusselRaoExpanded = (int) 18L; + + /** + * {@snippet lang = c : * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + + private static final int DiceExpanded = (int) 19L; + + /** + * {@snippet lang = c : * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + + private static final int Precomputed = (int) 100L; + + /** + * {@snippet lang = c : * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + + /** + * {@snippet lang = c : * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = ivf_pq_h.C_LONG; + /** + * {@snippet lang = c : * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = ivf_pq_h.C_INT; + private static final int kDLCPU = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + + private static final int kDLCUDA = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + + private static final int kDLCUDAHost = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + + private static final int kDLOpenCL = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + + private static final int kDLVulkan = (int) 7L; + + /** + * {@snippet lang = c : * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + + private static final int kDLMetal = (int) 8L; + + /** + * {@snippet lang = c : * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + + private static final int kDLVPI = (int) 9L; + + /** + * {@snippet lang = c : * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + + private static final int kDLROCM = (int) 10L; + + /** + * {@snippet lang = c : * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + + private static final int kDLROCMHost = (int) 11L; + + /** + * {@snippet lang = c : * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + + private static final int kDLExtDev = (int) 12L; + + /** + * {@snippet lang = c : * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + + private static final int kDLCUDAManaged = (int) 13L; + + /** + * {@snippet lang = c : * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + + private static final int kDLOneAPI = (int) 14L; + + /** + * {@snippet lang = c : * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + + private static final int kDLWebGPU = (int) 15L; + + /** + * {@snippet lang = c : * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + + private static final int kDLHexagon = (int) 16L; + + /** + * {@snippet lang = c : * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + + private static final int kDLMAIA = (int) 17L; + + /** + * {@snippet lang = c : * enum .kDLMAIA = 17 + * } + */ + public static int kDLMAIA() { + return kDLMAIA; + } + + private static final int kDLInt = (int) 0L; + + /** + * {@snippet lang = c : * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + + private static final int kDLUInt = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + + private static final int kDLFloat = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + + private static final int kDLOpaqueHandle = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + + private static final int kDLBfloat = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + + private static final int kDLComplex = (int) 5L; + + /** + * {@snippet lang = c : * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + + private static final int kDLBool = (int) 6L; + + /** + * {@snippet lang = c : * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + + private static final int CUDA_R_16F = (int) 2L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16F = 2 + * } + */ + public static int CUDA_R_16F() { + return CUDA_R_16F; + } + + private static final int CUDA_C_16F = (int) 6L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16F = 6 + * } + */ + public static int CUDA_C_16F() { + return CUDA_C_16F; + } + + private static final int CUDA_R_16BF = (int) 14L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16BF = 14 + * } + */ + public static int CUDA_R_16BF() { + return CUDA_R_16BF; + } + + private static final int CUDA_C_16BF = (int) 15L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16BF = 15 + * } + */ + public static int CUDA_C_16BF() { + return CUDA_C_16BF; + } + + private static final int CUDA_R_32F = (int) 0L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_32F = 0 + * } + */ + public static int CUDA_R_32F() { + return CUDA_R_32F; + } + + private static final int CUDA_C_32F = (int) 4L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_32F = 4 + * } + */ + public static int CUDA_C_32F() { + return CUDA_C_32F; + } + + private static final int CUDA_R_64F = (int) 1L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_64F = 1 + * } + */ + public static int CUDA_R_64F() { + return CUDA_R_64F; + } + + private static final int CUDA_C_64F = (int) 5L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_64F = 5 + * } + */ + public static int CUDA_C_64F() { + return CUDA_C_64F; + } + + private static final int CUDA_R_4I = (int) 16L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_4I = 16 + * } + */ + public static int CUDA_R_4I() { + return CUDA_R_4I; + } + + private static final int CUDA_C_4I = (int) 17L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_4I = 17 + * } + */ + public static int CUDA_C_4I() { + return CUDA_C_4I; + } + + private static final int CUDA_R_4U = (int) 18L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_4U = 18 + * } + */ + public static int CUDA_R_4U() { + return CUDA_R_4U; + } + + private static final int CUDA_C_4U = (int) 19L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_4U = 19 + * } + */ + public static int CUDA_C_4U() { + return CUDA_C_4U; + } + + private static final int CUDA_R_8I = (int) 3L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_8I = 3 + * } + */ + public static int CUDA_R_8I() { + return CUDA_R_8I; + } + + private static final int CUDA_C_8I = (int) 7L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_8I = 7 + * } + */ + public static int CUDA_C_8I() { + return CUDA_C_8I; + } + + private static final int CUDA_R_8U = (int) 8L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_8U = 8 + * } + */ + public static int CUDA_R_8U() { + return CUDA_R_8U; + } + + private static final int CUDA_C_8U = (int) 9L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_8U = 9 + * } + */ + public static int CUDA_C_8U() { + return CUDA_C_8U; + } + + private static final int CUDA_R_16I = (int) 20L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16I = 20 + * } + */ + public static int CUDA_R_16I() { + return CUDA_R_16I; + } + + private static final int CUDA_C_16I = (int) 21L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16I = 21 + * } + */ + public static int CUDA_C_16I() { + return CUDA_C_16I; + } + + private static final int CUDA_R_16U = (int) 22L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_16U = 22 + * } + */ + public static int CUDA_R_16U() { + return CUDA_R_16U; + } + + private static final int CUDA_C_16U = (int) 23L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_16U = 23 + * } + */ + public static int CUDA_C_16U() { + return CUDA_C_16U; + } + + private static final int CUDA_R_32I = (int) 10L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_32I = 10 + * } + */ + public static int CUDA_R_32I() { + return CUDA_R_32I; + } + + private static final int CUDA_C_32I = (int) 11L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_32I = 11 + * } + */ + public static int CUDA_C_32I() { + return CUDA_C_32I; + } + + private static final int CUDA_R_32U = (int) 12L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_32U = 12 + * } + */ + public static int CUDA_R_32U() { + return CUDA_R_32U; + } + + private static final int CUDA_C_32U = (int) 13L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_32U = 13 + * } + */ + public static int CUDA_C_32U() { + return CUDA_C_32U; + } + + private static final int CUDA_R_64I = (int) 24L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_64I = 24 + * } + */ + public static int CUDA_R_64I() { + return CUDA_R_64I; + } + + private static final int CUDA_C_64I = (int) 25L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_64I = 25 + * } + */ + public static int CUDA_C_64I() { + return CUDA_C_64I; + } + + private static final int CUDA_R_64U = (int) 26L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_R_64U = 26 + * } + */ + public static int CUDA_R_64U() { + return CUDA_R_64U; + } + + private static final int CUDA_C_64U = (int) 27L; + + /** + * {@snippet lang = c : * enum cudaDataType_t.CUDA_C_64U = 27 + * } + */ + public static int CUDA_C_64U() { + return CUDA_C_64U; + } + + private static final int MAJOR_VERSION = (int) 0L; + + /** + * {@snippet lang = c : * enum libraryPropertyType_t.MAJOR_VERSION = 0 + * } + */ + public static int MAJOR_VERSION() { + return MAJOR_VERSION; + } + + private static final int MINOR_VERSION = (int) 1L; + + /** + * {@snippet lang = c : * enum libraryPropertyType_t.MINOR_VERSION = 1 + * } + */ + public static int MINOR_VERSION() { + return MINOR_VERSION; + } + + private static final int PATCH_LEVEL = (int) 2L; + + /** + * {@snippet lang = c : * enum libraryPropertyType_t.PATCH_LEVEL = 2 + * } + */ + public static int PATCH_LEVEL() { + return PATCH_LEVEL; + } + + private static final int PER_SUBSPACE = (int) 0L; + + /** + * {@snippet lang = c : * enum codebook_gen.PER_SUBSPACE = 0 + * } + */ + public static int PER_SUBSPACE() { + return PER_SUBSPACE; + } + + private static final int PER_CLUSTER = (int) 1L; + + /** + * {@snippet lang = c : * enum codebook_gen.PER_CLUSTER = 1 + * } + */ + public static int PER_CLUSTER() { + return PER_CLUSTER; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsIvfPqIndexParams { + * cuvsDistanceType metric; + * float metric_arg; + * _Bool add_data_on_build; + * uint32_t n_lists; + * uint32_t kmeans_n_iters; + * double kmeans_trainset_fraction; + * uint32_t pq_bits; + * uint32_t pq_dim; + * enum codebook_gen codebook_kind; + * _Bool force_random_rotation; + * _Bool conservative_memory_allocation; + * uint32_t max_train_points_per_pq_code; + * } *cuvsIvfPqIndexParams_t + * } + */ + public static final AddressLayout cuvsIvfPqIndexParams_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexParamsCreate$descriptor() { + return cuvsIvfPqIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static MethodHandle cuvsIvfPqIndexParamsCreate$handle() { + return cuvsIvfPqIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static MemorySegment cuvsIvfPqIndexParamsCreate$address() { + return cuvsIvfPqIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsCreate(cuvsIvfPqIndexParams_t *index_params) + * } + */ + public static int cuvsIvfPqIndexParamsCreate(MemorySegment index_params) { + var mh$ = cuvsIvfPqIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexParamsCreate", index_params); + } + return (int) mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexParamsDestroy$descriptor() { + return cuvsIvfPqIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static MethodHandle cuvsIvfPqIndexParamsDestroy$handle() { + return cuvsIvfPqIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static MemorySegment cuvsIvfPqIndexParamsDestroy$address() { + return cuvsIvfPqIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexParamsDestroy(cuvsIvfPqIndexParams_t index_params) + * } + */ + public static int cuvsIvfPqIndexParamsDestroy(MemorySegment index_params) { + var mh$ = cuvsIvfPqIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexParamsDestroy", index_params); + } + return (int) mh$.invokeExact(index_params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : + * typedef struct cuvsIvfPqSearchParams { + * uint32_t n_probes; + * cudaDataType_t lut_dtype; + * cudaDataType_t internal_distance_dtype; + * double preferred_shmem_carveout; + * } *cuvsIvfPqSearchParams_t + * } + */ + public static final AddressLayout cuvsIvfPqSearchParams_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqSearchParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearchParamsCreate$descriptor() { + return cuvsIvfPqSearchParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static MethodHandle cuvsIvfPqSearchParamsCreate$handle() { + return cuvsIvfPqSearchParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static MemorySegment cuvsIvfPqSearchParamsCreate$address() { + return cuvsIvfPqSearchParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsCreate(cuvsIvfPqSearchParams_t *params) + * } + */ + public static int cuvsIvfPqSearchParamsCreate(MemorySegment params) { + var mh$ = cuvsIvfPqSearchParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearchParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSearchParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearchParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearchParamsDestroy$descriptor() { + return cuvsIvfPqSearchParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static MethodHandle cuvsIvfPqSearchParamsDestroy$handle() { + return cuvsIvfPqSearchParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static MemorySegment cuvsIvfPqSearchParamsDestroy$address() { + return cuvsIvfPqSearchParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearchParamsDestroy(cuvsIvfPqSearchParams_t params) + * } + */ + public static int cuvsIvfPqSearchParamsDestroy(MemorySegment params) { + var mh$ = cuvsIvfPqSearchParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearchParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + /** + * {@snippet lang = c : * typedef cuvsIvfPq *cuvsIvfPqIndex_t + * } + */ + public static final AddressLayout cuvsIvfPqIndex_t = ivf_pq_h.C_POINTER; + + private static class cuvsIvfPqIndexCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexCreate$descriptor() { + return cuvsIvfPqIndexCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static MethodHandle cuvsIvfPqIndexCreate$handle() { + return cuvsIvfPqIndexCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static MemorySegment cuvsIvfPqIndexCreate$address() { + return cuvsIvfPqIndexCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexCreate(cuvsIvfPqIndex_t *index) + * } + */ + public static int cuvsIvfPqIndexCreate(MemorySegment index) { + var mh$ = cuvsIvfPqIndexCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexCreate", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqIndexDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqIndexDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqIndexDestroy$descriptor() { + return cuvsIvfPqIndexDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqIndexDestroy$handle() { + return cuvsIvfPqIndexDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqIndexDestroy$address() { + return cuvsIvfPqIndexDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqIndexDestroy(cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqIndexDestroy(MemorySegment index) { + var mh$ = cuvsIvfPqIndexDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqIndexDestroy", index); + } + return (int) mh$.invokeExact(index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqBuild { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqBuild"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqBuild$descriptor() { + return cuvsIvfPqBuild.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqBuild$handle() { + return cuvsIvfPqBuild.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqBuild$address() { + return cuvsIvfPqBuild.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqBuild(cuvsResources_t res, cuvsIvfPqIndexParams_t params, DLManagedTensor *dataset, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqBuild(long res, MemorySegment params, MemorySegment dataset, MemorySegment index) { + var mh$ = cuvsIvfPqBuild.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqBuild", res, params, dataset, index); + } + return (int) mh$.invokeExact(res, params, dataset, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSearch { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSearch"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static FunctionDescriptor cuvsIvfPqSearch$descriptor() { + return cuvsIvfPqSearch.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MethodHandle cuvsIvfPqSearch$handle() { + return cuvsIvfPqSearch.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static MemorySegment cuvsIvfPqSearch$address() { + return cuvsIvfPqSearch.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSearch(cuvsResources_t res, cuvsIvfPqSearchParams_t search_params, cuvsIvfPqIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances) + * } + */ + public static int cuvsIvfPqSearch(long res, MemorySegment search_params, MemorySegment index, MemorySegment queries, + MemorySegment neighbors, MemorySegment distances) { + var mh$ = cuvsIvfPqSearch.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSearch", res, search_params, index, queries, neighbors, distances); + } + return (int) mh$.invokeExact(res, search_params, index, queries, neighbors, distances); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqSerialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqSerialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqSerialize$descriptor() { + return cuvsIvfPqSerialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqSerialize$handle() { + return cuvsIvfPqSerialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqSerialize$address() { + return cuvsIvfPqSerialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqSerialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqSerialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfPqSerialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqSerialize", res, filename, index); + } + return (int) mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqDeserialize { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqDeserialize"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqDeserialize$descriptor() { + return cuvsIvfPqDeserialize.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqDeserialize$handle() { + return cuvsIvfPqDeserialize.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqDeserialize$address() { + return cuvsIvfPqDeserialize.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqDeserialize(cuvsResources_t res, const char *filename, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqDeserialize(long res, MemorySegment filename, MemorySegment index) { + var mh$ = cuvsIvfPqDeserialize.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqDeserialize", res, filename, index); + } + return (int) mh$.invokeExact(res, filename, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsIvfPqExtend { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(ivf_pq_h.C_INT, ivf_pq_h.C_LONG, + ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER, ivf_pq_h.C_POINTER); + + public static final MemorySegment ADDR = ivf_pq_h.findOrThrow("cuvsIvfPqExtend"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static FunctionDescriptor cuvsIvfPqExtend$descriptor() { + return cuvsIvfPqExtend.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static MethodHandle cuvsIvfPqExtend$handle() { + return cuvsIvfPqExtend.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static MemorySegment cuvsIvfPqExtend$address() { + return cuvsIvfPqExtend.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsIvfPqExtend(cuvsResources_t res, DLManagedTensor *new_vectors, DLManagedTensor *new_indices, cuvsIvfPqIndex_t index) + * } + */ + public static int cuvsIvfPqExtend(long res, MemorySegment new_vectors, MemorySegment new_indices, + MemorySegment index) { + var mh$ = cuvsIvfPqExtend.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsIvfPqExtend", res, new_vectors, new_indices, index); + } + return (int) mh$.invokeExact(res, new_vectors, new_indices, index); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static final long _POSIX_C_SOURCE = 200809L; + + /** + * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + + private static final int __TIMESIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + + private static final long __STDC_IEC_60559_BFP__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + + private static final long __STDC_ISO_10646__ = 201706L; + + /** + * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + + private static final int __WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + + private static final int __WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + + private static final int INT8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + + private static final int INT16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + + private static final int INT32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + + private static final long INT64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + + private static final int INT8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + + private static final int INT16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + + private static final int INT32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + + private static final long INT64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + + private static final int UINT8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + + private static final int UINT16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + + private static final int UINT32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + + private static final long UINT64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + + private static final int INT_LEAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + + private static final int INT_LEAST16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + + private static final int INT_LEAST32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + + private static final long INT_LEAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + + private static final int INT_LEAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + + private static final int INT_LEAST16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + + private static final int INT_LEAST32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + + private static final long INT_LEAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + + private static final int UINT_LEAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + + private static final int UINT_LEAST16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + + private static final int UINT_LEAST32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + + private static final long UINT_LEAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + + private static final int INT_FAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + + private static final long INT_FAST16_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + + private static final long INT_FAST32_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + + private static final long INT_FAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + + private static final int INT_FAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + + private static final long INT_FAST16_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + + private static final long INT_FAST32_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + + private static final long INT_FAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + + private static final int UINT_FAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + + private static final long UINT_FAST16_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + + private static final long UINT_FAST32_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + + private static final long UINT_FAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + + private static final long INTPTR_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + + private static final long INTPTR_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + + private static final long UINTPTR_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + + private static final long INTMAX_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + + private static final long INTMAX_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + + private static final long UINTMAX_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + + private static final long PTRDIFF_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + + private static final long PTRDIFF_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + + private static final int SIG_ATOMIC_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + + private static final int SIG_ATOMIC_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + + private static final long SIZE_MAX = -1L; + + /** + * {@snippet lang = c : * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + + private static final int WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + + private static final int WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + + private static final int WINT_MIN = (int) 0L; + + /** + * {@snippet lang = c : * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + + private static final int WINT_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + + /** + * {@snippet lang = c : * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } + + private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 + * } + */ + public static long DLPACK_FLAG_BITMASK_READ_ONLY() { + return DLPACK_FLAG_BITMASK_READ_ONLY; + } + + private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; + + /** + * {@snippet lang = c : * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 + * } + */ + public static long DLPACK_FLAG_BITMASK_IS_COPIED() { + return DLPACK_FLAG_BITMASK_IS_COPIED; + } } - diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java index 555a4316e..21076f75f 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/max_align_t.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java index 6f4b031bb..78b81f44b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.MemoryLayout.PathElement.groupElement; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java index aabd8b41b..de4a42082 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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.panama; import static java.lang.foreign.ValueLayout.JAVA_BYTE; diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index b5f553108..e4d9df120 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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 static org.junit.jupiter.api.Assertions.assertEquals; @@ -24,7 +40,7 @@ public class CagraBuildAndSearchTest { - private static Logger LOGGER = LoggerFactory.getLogger(CagraBuildAndSearchTest.class); + private static Logger logger = LoggerFactory.getLogger(CagraBuildAndSearchTest.class); /** * A basic test that checks the whole flow - from indexing to search. @@ -47,59 +63,60 @@ public void testIndexingAndSearchingFlow() throws Throwable { Map.of(1, 0.15224178f, 0, 0.59063464f, 3, 0.5986642f)); // Create resource - CuVSResources res = new CuVSResources(); + CuVSResources cuvsResources = new CuVSResources(); // Configure index parameters - CagraIndexParams cagraIndexParams = new CagraIndexParams + CagraIndexParams cagraIndexParameters = new CagraIndexParams .Builder() - .withBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.NN_DESCENT) + .withCuvsCagraGraphBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.NN_DESCENT) .build(); // Create the index with the dataset - CagraIndex index = new CagraIndex - .Builder(res) + CagraIndex cagraIndex = new CagraIndex + .Builder(cuvsResources) .withDataset(dataset) - .withIndexParams(cagraIndexParams) + .withIndexParams(cagraIndexParameters) .build(); // Saving the index on to the disk. - String fileName = UUID.randomUUID().toString() + ".cag"; - index.serialize(new FileOutputStream(fileName)); + String indexFileName = UUID.randomUUID().toString() + ".cag"; + cagraIndex.serialize(new FileOutputStream(indexFileName)); // Loading a CAGRA index from disk. - File testSerializedIndexFile = new File(fileName); - InputStream fin = new FileInputStream(testSerializedIndexFile); - CagraIndex index2 = new CagraIndex.Builder(res) - .from(fin) + File testSerializedIndexFile = new File(indexFileName); + InputStream inputStream = new FileInputStream(testSerializedIndexFile); + CagraIndex deserializedCagraIndex = new CagraIndex + .Builder(cuvsResources) + .from(inputStream) .build(); // Configure search parameters - CagraSearchParams cagraSearchParams = new CagraSearchParams + CagraSearchParams cagraSearchParameters = new CagraSearchParams .Builder() .build(); // Create a query object with the query vectors - CuVSQuery query = new CuVSQuery + CuVSQuery cuvsQuery = new CuVSQuery .Builder() .withTopK(3) - .withSearchParams(cagraSearchParams) + .withSearchParams(cagraSearchParameters) .withQueryVectors(queries) .withMapping(map) .build(); // Perform the search - SearchResult searchResults = index.search(query); + SearchResult searchResults = cagraIndex.search(cuvsQuery); // Check results - LOGGER.info(searchResults.getResults().toString()); + logger.info(searchResults.getResults().toString()); assertEquals(expectedQueryResults, searchResults.getResults(), "Results different than expected"); - // Search from de-serialized index - SearchResult searchResults2 = index2.search(query); + // Search from deserialized index + SearchResult searchResultsFromDeserializedCagraIndex = deserializedCagraIndex.search(cuvsQuery); // Check results - LOGGER.info(searchResults.getResults().toString()); - assertEquals(expectedQueryResults, searchResults2.getResults(), "Results different than expected"); + logger.info(searchResults.getResults().toString()); + assertEquals(expectedQueryResults, searchResultsFromDeserializedCagraIndex.getResults(), "Results different than expected"); // Cleanup if (testSerializedIndexFile.exists()) { diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index db8177e6e..0352e24e3 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023-2024, 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. + */ + #include #include #include @@ -5,10 +21,10 @@ #include #include -cuvsResources_t create_resource(int *rv) { - cuvsResources_t res; - *rv = cuvsResourcesCreate(&res); - return res; +cuvsResources_t create_resource(int *returnValue) { + cuvsResources_t cuvsResources; + *returnValue = cuvsResourcesCreate(&cuvsResources); + return cuvsResources; } DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, long dimensions) { @@ -26,35 +42,35 @@ DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, return tensor; } -cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsResources_t res, int *rv, +cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvsResources, int *returnValue, cuvsCagraIndexParams_t index_params) { - + int64_t dataset_shape[2] = {rows, dimensions}; DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat, dimensions); cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); - *rv = cuvsCagraBuild(res, index_params, &dataset_tensor, index); + *returnValue = cuvsCagraBuild(cuvsResources, index_params, &dataset_tensor, index); return index; } -void serialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, char* filename) { - *rv = cuvsCagraSerialize(res, filename, index, true); +void serialize_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { + *returnValue = cuvsCagraSerialize(cuvsResources, filename, index, true); } -void deserialize_index(cuvsResources_t res, cuvsCagraIndex_t index, int *rv, char* filename) { - *rv = cuvsCagraDeserialize(res, filename, index); +void deserialize_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *rv, char* filename) { + *rv = cuvsCagraDeserialize(cuvsResources, filename, index); } void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, - cuvsResources_t res, int *neighbors_h, float *distances_h, int *rv, cuvsCagraSearchParams_t search_params) { - + cuvsResources_t cuvsResources, int *neighbors_h, float *distances_h, int *returnValue, cuvsCagraSearchParams_t search_params) { + uint32_t *neighbors; float *distances, *queries_d; - cuvsRMMAlloc(res, (void**) &queries_d, sizeof(float) * n_queries * dimensions); - cuvsRMMAlloc(res, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); - cuvsRMMAlloc(res, (void**) &distances, sizeof(float) * n_queries * topk); + cuvsRMMAlloc(cuvsResources, (void**) &queries_d, sizeof(float) * n_queries * dimensions); + cuvsRMMAlloc(cuvsResources, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); + cuvsRMMAlloc(cuvsResources, (void**) &distances, sizeof(float) * n_queries * topk); cudaMemcpy(queries_d, queries, sizeof(float) * n_queries * dimensions, cudaMemcpyDefault); @@ -69,7 +85,7 @@ void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queri cuvsCagraSearchParamsCreate(&search_params); - *rv = cuvsCagraSearch(res, search_params, index, &queries_tensor, &neighbors_tensor, + *returnValue = cuvsCagraSearch(cuvsResources, search_params, index, &queries_tensor, &neighbors_tensor, &distances_tensor); cudaMemcpy(neighbors_h, neighbors, sizeof(uint32_t) * n_queries * topk, cudaMemcpyDefault); From bbcbba1333a23228555d5a2998b5c0c0e1a67188 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Sat, 16 Nov 2024 13:58:17 -0500 Subject: [PATCH 30/53] Javadoc draft 1 --- .../com/nvidia/cuvs/cagra/CagraIndex.java | 191 ++++++++-- .../nvidia/cuvs/cagra/CagraIndexParams.java | 127 ++++++- .../cuvs/cagra/CagraIndexReference.java | 20 + .../nvidia/cuvs/cagra/CagraSearchParams.java | 350 +++++++++++++++--- .../java/com/nvidia/cuvs/cagra/CuVSQuery.java | 91 ++++- .../com/nvidia/cuvs/cagra/CuVSResources.java | 25 +- .../java/com/nvidia/cuvs/cagra/PreFilter.java | 10 +- .../com/nvidia/cuvs/cagra/SearchResult.java | 45 ++- java/internal/src/cuvs_java.c | 8 +- 9 files changed, 761 insertions(+), 106 deletions(-) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 75d12736e..cb617de2b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -40,75 +40,123 @@ *

* CAGRA is a graph-based nearest neighbors algorithm that was built from the * ground up for GPU acceleration. CAGRA demonstrates state-of-the art index - * build and query performance for both small- and large-batch sized search. + * build and query performance for both small and large-batch sized search. Know + * more about this algorithm + * here + * + * @since 24.12 */ public class CagraIndex { private final float[][] dataset; private final CuVSResources cuvsResources; private Arena arena; - private CagraIndexParams cagraIndexParameters; - private CagraIndexReference cagraIndesReference; private Linker linker; private MethodHandle indexMethodHandle; private MethodHandle searchMethodHandle; private MethodHandle serializeMethodHandle; private MethodHandle deserializeMethodHandle; private SymbolLookup symbolLookup; + private CagraIndexParams cagraIndexParameters; + private CagraIndexReference cagraIndesReference; + /** + * Constructor that initializes CagraIndex with an instance of CagraIndexParams, + * dataset, and an instance of CuVSResources + * + * @param indexParameters index parameters + * @param dataset 2D float dataset array + * @param cuvsResources cuVS resources instance + * @throws Throwable exception thrown when native function is invoked + * @see CagraIndexParams + * @see CuVSResources + */ private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources cuvsResources) throws Throwable { this.cagraIndexParameters = indexParameters; this.dataset = dataset; - this.init(); + this.initializeMethodHandles(); this.cuvsResources = cuvsResources; this.cagraIndesReference = build(); } + /** + * Constructs an instance of CagraIndex with an instance of InputStream and + * CuVSResources + * + * @param inputStream an instance of InputStream (eg. FileInputStream) to read + * a persisted CAGRA index. + * @param cuvsResources an instance of CuVSResources. + * @throws Throwable exception thrown when native function is invoked + */ private CagraIndex(InputStream inputStream, CuVSResources cuvsResources) throws Throwable { this.cagraIndexParameters = null; this.dataset = null; this.cuvsResources = cuvsResources; - this.init(); + this.initializeMethodHandles(); this.cagraIndesReference = deserialize(inputStream); } - private void init() throws Throwable { + /** + * Initializes the MethodHandles for invoking native methods. + * + * @see MethodHandle + */ + private void initializeMethodHandles() { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); File workingDirectory = new File(System.getProperty("user.dir")); symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - indexMethodHandle = linker.downcallHandle(symbolLookup.find("build_index").get(), + indexMethodHandle = linker.downcallHandle(symbolLookup.find("build_cagra_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - searchMethodHandle = linker.downcallHandle(symbolLookup.find("search_index").get(), + searchMethodHandle = linker.downcallHandle(symbolLookup.find("search_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMethodHandle = linker.downcallHandle(symbolLookup.find("serialize_index").get(), + serializeMethodHandle = linker.downcallHandle(symbolLookup.find("serialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMethodHandle = linker.downcallHandle(symbolLookup.find("deserialize_index").get(), + deserializeMethodHandle = linker.downcallHandle(symbolLookup.find("deserialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } - public MemorySegment getStringSegment(StringBuilder string) { + /** + * A utility method for getting an instance of MemorySegment for a String. + * + * @param string the string for the expected MemorySegment + * @return an instance of MemorySegment + * @see MemoryLayout + * @see MemorySegment + * @see StringBuilder + */ + public MemorySegment getStringMemorySegment(StringBuilder string) { string.append('\0'); - MemoryLayout sq = MemoryLayout.sequenceLayout(string.length(), linker.canonicalLayouts().get("char")); - MemorySegment fln = arena.allocate(sq); + MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(string.length(), + linker.canonicalLayouts().get("char")); + MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); for (int i = 0; i < string.length(); i++) { - VarHandle flnVH = sq.varHandle(PathElement.sequenceElement(i)); - flnVH.set(fln, 0L, (byte) string.charAt(i)); + VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); + varHandle.set(stringMemorySegment, 0L, (byte) string.charAt(i)); } - return fln; + return stringMemorySegment; } + /** + * A utility method for getting an instance of MemorySegment for a 2D float + * array. + * + * @param data The 2D float array for which the MemorySegment is needed + * @return an instance of MemorySegment + * @see MemoryLayout + * @see MemorySegment + */ private MemorySegment getMemorySegment(float[][] data) { long rows = data.length; long cols = data[0].length; @@ -128,6 +176,15 @@ private MemorySegment getMemorySegment(float[][] data) { return dataMemorySegment; } + /** + * Invokes the native build_index function via the Panama API to build the CAGRA + * index. + * + * @return an instance of CagraIndexReference that holds the pointer to the + * index + * @throws Throwable exception thrown when native function is invoked + * @see CagraIndexReference + */ private CagraIndexReference build() throws Throwable { long rows = dataset.length; long cols = dataset[0].length; @@ -141,6 +198,17 @@ private CagraIndexReference build() throws Throwable { return cagraIndesReference; } + /** + * Invokes the native search_index via the Panama API for searching a CAGRA + * index. + * + * @param cuvsQuery an instance of CuVSQuery holding the query and its + * parameters + * @return an instance of SearchResult containing the results + * @throws Throwable exception thrown when native function is invoked + * @see CuVSQuery + * @see SearchResult + */ public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); @@ -153,19 +221,27 @@ public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { searchMethodHandle.invokeExact(cagraIndesReference.getIndexMemorySegment(), getMemorySegment(cuvsQuery.getQueryVectors()), cuvsQuery.getTopK(), 4L, 2L, cuvsResources.getCuvsResourcesMemorySegment(), neighborsMemorySegment, distancesMemorySegment, - returnValueMemorySegment, cuvsQuery.getCagraSearchParameters().getCagraSearchParamsMS()); + returnValueMemorySegment, cuvsQuery.getCagraSearchParameters().getCagraSearchParamsMemorySegment()); return new SearchResult(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, distancesMemorySegment, cuvsQuery.getTopK(), cuvsQuery.getMapping(), cuvsQuery.getQueryVectors().length); } + /** + * A method to persist a CAGRA index using an instance of OutputStream for + * writing index bytes. + * + * @param outputStream an instance of OutputStream to write the index bytes into + * @throws Throwable exception thrown when native function is invoked + * @see OutputStream + */ public void serialize(OutputStream outputStream) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringSegment(new StringBuilder(tmpIndexFile))); + getStringMemorySegment(new StringBuilder(tmpIndexFile))); File tempFile = new File(tmpIndexFile); FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; @@ -177,12 +253,21 @@ public void serialize(OutputStream outputStream) throws Throwable { tempFile.delete(); } + /** + * A method to persist a CAGRA index using an instance of OutputStream and path + * to the intermediate temporary file. + * + * @param outputStream an instance of OutputStream to write the index bytes to + * @param tmpFilePath path to a temporary file where CAGRA index is written + * @throws Throwable exception thrown when native function is invoked + * @see OutputStream + */ public void serialize(OutputStream outputStream, String tmpFilePath) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringSegment(new StringBuilder(tmpFilePath))); + getStringMemorySegment(new StringBuilder(tmpFilePath))); File tempFile = new File(tmpFilePath); FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; @@ -194,6 +279,17 @@ public void serialize(OutputStream outputStream, String tmpFilePath) throws Thro tempFile.delete(); } + /** + * Gets an instance of CagraIndexReference by deserializing a CAGRA index using + * an input stream. + * + * @param inputStream an instance of InputStream (eg. FileInputStream when + * reading an index file). + * @return an instance of CagraIndexReference. + * @throws Throwable exception thrown when native function is invoked + * @see CagraIndexReference + * @see InputStream + */ private CagraIndexReference deserialize(InputStream inputStream) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); @@ -209,7 +305,7 @@ private CagraIndexReference deserialize(InputStream inputStream) throws Throwabl } deserializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), cagraIndexReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringSegment(new StringBuilder(tmpIndexFile))); + getStringMemorySegment(new StringBuilder(tmpIndexFile))); inputStream.close(); fileOutputStream.close(); @@ -218,40 +314,88 @@ private CagraIndexReference deserialize(InputStream inputStream) throws Throwabl return cagraIndexReference; } - public CagraIndexParams getParams() { + /** + * Gets an instance of CagraIndexParams. + * + * @return an instance of CagraIndexParams + * @see CagraIndexParams + */ + public CagraIndexParams getCagraIndexParameters() { return cagraIndexParameters; } - public CuVSResources getResources() { + /** + * Gets an instance of CuVSResources. + * + * @return an instance of CuVSResources + * @see CuVSResources + */ + public CuVSResources getCuVSResources() { return cuvsResources; } + /** + * Builder helps configure and create an instance of CagraIndex. + */ public static class Builder { - private CagraIndexParams cagraIndexParams; private float[][] dataset; + private CagraIndexParams cagraIndexParams; private CuVSResources cuvsResources; private InputStream inputStream; + /** + * Constructs this Builder with an instance of CuVSResources. + * + * @param cuvsResources an instance of CuVSResources + * @see CuVSResources + */ public Builder(CuVSResources cuvsResources) { this.cuvsResources = cuvsResources; } + /** + * Sets an instance of InputStream typically used when index deserialization is + * needed. + * + * @param inputStream an instance of InputStream + * @return an instance of this Builder + * @see InputStream + */ public Builder from(InputStream inputStream) { this.inputStream = inputStream; return this; } + /** + * Sets the dataset for building the CAGRA index. + * + * @param dataset a two-dimensional float array + * @return an instance of this Builder + */ public Builder withDataset(float[][] dataset) { this.dataset = dataset; return this; } + /** + * Registers an instance of configured CagraIndexParams with this Builder. + * + * @param cagraIndexParameters An instance of CagraIndexParams. + * @return An instance of this Builder. + * @see CagraIndexParams + */ public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { this.cagraIndexParams = cagraIndexParameters; return this; } + /** + * Builds and returns an instance of CagraIndex. + * + * @return an instance of CagraIndex + * @throws Throwable exception thrown when native function is invoked + */ public CagraIndex build() throws Throwable { if (inputStream != null) { return new CagraIndex(inputStream, cuvsResources); @@ -260,5 +404,4 @@ public CagraIndex build() throws Throwable { } } } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index 3030e458f..9a65ca167 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -21,21 +21,40 @@ import com.nvidia.cuvs.panama.cuvsCagraIndexParams; -/* -* Supplemental parameters to build CAGRA Index. -*/ +/** + * Supplemental parameters to build CAGRA Index. + * + * @since 24.12 + */ public class CagraIndexParams { + private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; + private MemorySegment cagraIndexParamsMemorySegment; private Arena arena; private int intermediateGraphDegree; private int graphDegree; - private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; private int nnDescentNiter; - private MemorySegment cagraIndexParamsMemorySegment; + /** + * Enum that denotes which ANN algorithm is used to build CAGRA graph. + */ public enum CuvsCagraGraphBuildAlgo { - AUTO_SELECT(0), IVF_PQ(1), NN_DESCENT(2); - + /** + * AUTO_SELECT + */ + AUTO_SELECT(0), + /** + * IVF_PQ + */ + IVF_PQ(1), + /** + * NN_DESCENT + */ + NN_DESCENT(2); + + /** + * The value for the enum choice. + */ public final int label; private CuvsCagraGraphBuildAlgo(int label) { @@ -43,6 +62,18 @@ private CuvsCagraGraphBuildAlgo(int label) { } } + /** + * Constructor that initializes CagraIndexParams with an instance of Arena, + * intermediateGraphDegree, graphDegree, CuvsCagraGraphBuildAlgo, and + * nnDescentNiter. + * + * @param arena the Arena instance to use + * @param intermediateGraphDegree the degree of input graph for pruning + * @param graphDegree the degree of output graph + * @param CuvsCagraGraphBuildAlgo the CuvsCagraGraphBuildAlgo + * @param nnDescentNiter the number of Iterations to run if building + * with NN_DESCENT + */ public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, CuvsCagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter) { this.arena = arena; @@ -50,10 +81,15 @@ public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegre this.graphDegree = graphDegree; this.cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo; this.nnDescentNiter = nnDescentNiter; - this.set(); + this.setCagraIndexParamsStubValues(); } - private void set() { + /** + * Sets the parameter values in the stub's MemorySegment. + * + * @see MemorySegment + */ + private void setCagraIndexParamsStubValues() { cagraIndexParamsMemorySegment = cuvsCagraIndexParams.allocate(arena); cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMemorySegment, intermediateGraphDegree); cuvsCagraIndexParams.graph_degree(cagraIndexParamsMemorySegment, graphDegree); @@ -61,22 +97,47 @@ private void set() { cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMemorySegment, nnDescentNiter); } + /** + * Gets the degree of input graph for pruning. + * + * @return the degree of input graph + */ public int getIntermediateGraphDegree() { return intermediateGraphDegree; } + /** + * Gets the degree of output graph. + * + * @return the degree of output graph + */ public int getGraphDegree() { return graphDegree; } + /** + * Gets the CuvsCagraGraphBuildAlgo. + * + * @return CuvsCagraGraphBuildAlgo selected + */ public CuvsCagraGraphBuildAlgo getCuvsCagraGraphBuildAlgo() { return cuvsCagraGraphBuildAlgo; } + /** + * Gets the number of Iterations to run if building with NN_DESCENT. + * + * @return the number of Iterations + */ public int getNNDescentNiter() { return nnDescentNiter; } + /** + * Gets the cagraIndexParams MemorySegment. + * + * @return an instance of MemorySegment + */ public MemorySegment getCagraIndexParamsMemorySegment() { return cagraIndexParamsMemorySegment; } @@ -88,45 +149,89 @@ public String toString() { + nnDescentNiter + ", cagraIndexParamsMemorySegment=" + cagraIndexParamsMemorySegment + "]"; } + /** + * Builder configures and creates an instance of CagraIndexParams. + */ public static class Builder { + private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo.NN_DESCENT; private Arena arena; private int intermediateGraphDegree = 128; private int graphDegree = 64; - private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo.NN_DESCENT; private int nnDescentNiter = 20; private int writerThreads = 1; + /** + * Constructor for builder for initializing and instance of Arena. + * + * @see Arena + */ public Builder() { this.arena = Arena.ofConfined(); } + /** + * Sets the degree of input graph for pruning. + * + * @param intermediateGraphDegree degree of input graph for pruning + * @return an instance of Builder + */ public Builder withIntermediateGraphDegree(int intermediateGraphDegree) { this.intermediateGraphDegree = intermediateGraphDegree; return this; } + /** + * Sets the degree of output graph. + * + * @param graphDegree degree of output graph + * @return an instance to Builder + */ public Builder withGraphDegree(int graphDegree) { this.graphDegree = graphDegree; return this; } + /** + * Sets the CuvsCagraGraphBuildAlgo to use. + * + * @param cuvsCagraGraphBuildAlgo the CuvsCagraGraphBuildAlgo to use + * @return an instance of Builder + */ public Builder withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo) { this.cuvsCagraGraphBuildAlgo = cuvsCagraGraphBuildAlgo; return this; } + /** + * Sets the Number of Iterations to run if building with NN_DESCENT. + * + * @param nnDescentNiter number of Iterations to run if building with NN_DESCENT + * @return an instance of Builder + */ public Builder withNNDescentNiter(int nnDescentNiter) { this.nnDescentNiter = nnDescentNiter; return this; } + /** + * Registers the number of writer threads to use for indexing. + * + * @param writerThreads number of writer threads to use + * @return an instance of Builder + */ public Builder withWriterThreads(int writerThreads) { this.writerThreads = writerThreads; return this; } - public CagraIndexParams build() throws Throwable { + /** + * Builds an instance of CagraIndexParams. + * + * @return an instance of CagraIndexParams + * @see CagraIndexParams + */ + public CagraIndexParams build() { return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, nnDescentNiter); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java index 2eab62147..a675ebd76 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java @@ -21,19 +21,39 @@ import com.nvidia.cuvs.panama.cuvsCagraIndex; +/** + * Holds the reference to the index using MemorySegment. + * + * @since 24.12 + */ public class CagraIndexReference { private MemorySegment indexMemorySegment; + /** + * Constructs CagraIndexReference and allocate the MemorySegment. + */ public CagraIndexReference() { Arena arena = Arena.ofConfined(); indexMemorySegment = cuvsCagraIndex.allocate(arena); } + /** + * Constructs CagraIndexReference with an instance of MemorySegment passed as a + * parameter. + * + * @param indexMemorySegment the MemorySegment instance to use for containing + * index reference + */ public CagraIndexReference(MemorySegment indexMemorySegment) { this.indexMemorySegment = indexMemorySegment; } + /** + * Gets the instance of index MemorySegment. + * + * @return index MemorySegment + */ public MemorySegment getIndexMemorySegment() { return indexMemorySegment; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index df4398fd2..1d2cf6ae4 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -21,47 +21,115 @@ import com.nvidia.cuvs.panama.cuvsCagraSearchParams; +/** + * CagraSearchParams encapsulates the logic for configuring and holding search + * parameters. + * + * @since 24.12 + */ public class CagraSearchParams { - private Arena arena; private int maxQueries; private int itopkSize; private int maxIterations; - private CuvsCagraSearchAlgo cuvsCagraSearchAlgo; private int teamSize; private int searchWidth; private int minIterations; private int threadBlockSize; - private CuvsCagraHashMode cuvsCagraHashMode; private int hashmapMinBitlen; - private float hashmapMaxFillRate; private int numRandomSamplings; + private float hashmapMaxFillRate; private long randXorMask; + private Arena arena; private MemorySegment cagraSearchParamsMemorySegment; - - enum CuvsCagraSearchAlgo { - SINGLE_CTA(0), MULTI_CTA(1), MULTI_KERNEL(2), AUTO(3); - - public final int label; - - private CuvsCagraSearchAlgo(int label) { - this.label = label; + private CuvsCagraSearchAlgo cuvsCagraSearchAlgo; + private CuvsCagraHashMapMode cuvsCagraHashMapMode; + + /** + * Enum to denote algorithm used to search CAGRA Index. + */ + public enum CuvsCagraSearchAlgo { + /** + * for large batch sizes + */ + SINGLE_CTA(0), + /** + * for small batch sizes + */ + MULTI_CTA(1), + /** + * MULTI_KERNEL + */ + MULTI_KERNEL(2), + /** + * AUTO + */ + AUTO(3); + + /** + * The value for the enum choice. + */ + public final int value; + + private CuvsCagraSearchAlgo(int value) { + this.value = value; } } - enum CuvsCagraHashMode { - HASH(0), SMALL(1), AUTO_HASH(2); - - public final int label; - - private CuvsCagraHashMode(int label) { - this.label = label; + /** + * Enum to denote Hash Mode used while searching CAGRA index. + */ + public enum CuvsCagraHashMapMode { + /** + * HASH + */ + HASH(0), + /** + * SMALL + */ + SMALL(1), + /** + * AUTO_HASH + */ + AUTO_HASH(2); + + /** + * The value for the enum choice. + */ + public final int value; + + private CuvsCagraHashMapMode(int value) { + this.value = value; } } + /** + * Constructs an instance of CagraSearchParams with passed search parameters. + * + * @param arena the Arena instance to use + * @param maxQueries the maximum number of queries to search at the + * same time (batch size) + * @param itopkSize the number of intermediate search results retained + * during the search + * @param maxIterations the upper limit of search iterations + * @param cuvsCagraSearchAlgo the search implementation is configured + * @param teamSize the number of threads used to calculate a single + * distance + * @param searchWidth the number of graph nodes to select as the + * starting point for the search in each iteration + * @param minIterations the lower limit of search iterations + * @param threadBlockSize the thread block size + * @param hashmapMode the hashmap type configured + * @param hashmapMinBitlen the lower limit of hashmap bit length + * @param hashmapMaxFillRate the upper limit of hashmap fill rate + * @param numRandomSamplings the number of iterations of initial random seed + * node selection + * @param randXorMask the bit mask used for initial random seed node + * selection + */ public CagraSearchParams(Arena arena, int maxQueries, int itopkSize, int maxIterations, CuvsCagraSearchAlgo cuvsCagraSearchAlgo, int teamSize, int searchWidth, int minIterations, int threadBlockSize, - CuvsCagraHashMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, + CuvsCagraHashMapMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, long randXorMask) { super(); this.arena = arena; @@ -73,188 +141,362 @@ public CagraSearchParams(Arena arena, int maxQueries, int itopkSize, int maxIter this.searchWidth = searchWidth; this.minIterations = minIterations; this.threadBlockSize = threadBlockSize; - this.cuvsCagraHashMode = hashmapMode; + this.cuvsCagraHashMapMode = hashmapMode; this.hashmapMinBitlen = hashmapMinBitlen; this.hashmapMaxFillRate = hashmapMaxFillRate; this.numRandomSamplings = numRandomSamplings; this.randXorMask = randXorMask; - this.set(); + this.setSearchParametersInTheStubMemorySegment(); } - public void set() { + /** + * Sets the configured search parameters in the MemorySegment. + */ + public void setSearchParametersInTheStubMemorySegment() { cagraSearchParamsMemorySegment = cuvsCagraSearchParams.allocate(arena); cuvsCagraSearchParams.max_queries(cagraSearchParamsMemorySegment, maxQueries); cuvsCagraSearchParams.itopk_size(cagraSearchParamsMemorySegment, itopkSize); cuvsCagraSearchParams.max_iterations(cagraSearchParamsMemorySegment, maxIterations); - cuvsCagraSearchParams.algo(cagraSearchParamsMemorySegment, cuvsCagraSearchAlgo.label); + cuvsCagraSearchParams.algo(cagraSearchParamsMemorySegment, cuvsCagraSearchAlgo.value); cuvsCagraSearchParams.team_size(cagraSearchParamsMemorySegment, teamSize); cuvsCagraSearchParams.search_width(cagraSearchParamsMemorySegment, searchWidth); cuvsCagraSearchParams.min_iterations(cagraSearchParamsMemorySegment, minIterations); cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMemorySegment, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMemorySegment, cuvsCagraHashMode.label); + cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMemorySegment, cuvsCagraHashMapMode.value); cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMemorySegment, hashmapMinBitlen); cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMemorySegment, hashmapMaxFillRate); cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMemorySegment, numRandomSamplings); cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMemorySegment, randXorMask); } - public int getMax_queries() { + /** + * Gets the maximum number of queries to search at the same time (batch size). + * + * @return the maximum number of queries + */ + public int getMaxQueries() { return maxQueries; } - public int getItopk_size() { + /** + * Gets the number of intermediate search results retained during the search. + * + * @return the number of intermediate search results + */ + public int getItopkSize() { return itopkSize; } - public int getMax_iterations() { + /** + * Gets the upper limit of search iterations. + * + * @return the upper limit value + */ + public int getMaxIterations() { return maxIterations; } - public CuvsCagraSearchAlgo getAlgo() { - return cuvsCagraSearchAlgo; - } - - public int getTeam_size() { + /** + * Gets the number of threads used to calculate a single distance. + * + * @return the number of threads configured + */ + public int getTeamSize() { return teamSize; } - public int getSearch_width() { + /** + * Gets the number of graph nodes to select as the starting point for the search + * in each iteration. + * + * @return the number of graph nodes + */ + public int getSearchWidth() { return searchWidth; } - public int getMin_iterations() { + /** + * Gets the lower limit of search iterations. + * + * @return the lower limit value + */ + public int getMinIterations() { return minIterations; } - public int getThread_block_size() { + /** + * Gets the thread block size. + * + * @return the thread block size + */ + public int getThreadBlockSize() { return threadBlockSize; } - public CuvsCagraHashMode getHashmap_mode() { - return cuvsCagraHashMode; - } - - public int getHashmap_min_bitlen() { + /** + * Gets the lower limit of hashmap bit length. + * + * @return the lower limit value + */ + public int getHashmapMinBitlen() { return hashmapMinBitlen; } - public float getHashmap_max_fill_rate() { - return hashmapMaxFillRate; + /** + * Gets the number of iterations of initial random seed node selection. + * + * @return the number of iterations + */ + public int getNumRandomSamplings() { + return numRandomSamplings; } - public int getNum_random_samplings() { - return numRandomSamplings; + /** + * Gets the upper limit of hashmap fill rate. + * + * @return the upper limit of hashmap fill rate + */ + public float getHashmapMaxFillRate() { + return hashmapMaxFillRate; } - public long getRand_xor_mask() { + /** + * Gets the bit mask used for initial random seed node selection. + * + * @return the bit mask value + */ + public long getRandXorMask() { return randXorMask; } - public MemorySegment getCagraSearchParamsMS() { + /** + * Gets the MemorySegment holding CagraSearchParams. + * + * @return the MemorySegment holding CagraSearchParams + */ + public MemorySegment getCagraSearchParamsMemorySegment() { return cagraSearchParamsMemorySegment; } + /** + * Gets which search implementation is configured. + * + * @return the search implementation configured + * @see CuvsCagraSearchAlgo + */ + public CuvsCagraSearchAlgo getCuvsCagraSearchAlgo() { + return cuvsCagraSearchAlgo; + } + + /** + * Gets the hashmap type configured. + * + * @return the hashmap type configured + * @see CuvsCagraHashMapMode + */ + public CuvsCagraHashMapMode getCuvsCagraHashMapMode() { + return cuvsCagraHashMapMode; + } + @Override public String toString() { return "CagraSearchParams [arena=" + arena + ", maxQueries=" + maxQueries + ", itopkSize=" + itopkSize + ", maxIterations=" + maxIterations + ", cuvsCagraSearchAlgo=" + cuvsCagraSearchAlgo + ", teamSize=" + teamSize + ", searchWidth=" + searchWidth + ", minIterations=" + minIterations + ", threadBlockSize=" + threadBlockSize - + ", cuvsCagraHashMode=" + cuvsCagraHashMode + ", hashmapMinBitlen=" + hashmapMinBitlen + + ", cuvsCagraHashMapMode=" + cuvsCagraHashMapMode + ", hashmapMinBitlen=" + hashmapMinBitlen + ", hashmapMaxFillRate=" + hashmapMaxFillRate + ", numRandomSamplings=" + numRandomSamplings + ", randXorMask=" + randXorMask + ", cagraSearchParamsMemorySegment=" + cagraSearchParamsMemorySegment + "]"; } + /** + * Builder configures and creates an instance of CagraSearchParams. + */ public static class Builder { private Arena arena; private int maxQueries = 1; private int itopkSize = 2; private int maxIterations = 3; - private CuvsCagraSearchAlgo cuvsCagraSearchAlgo = CuvsCagraSearchAlgo.MULTI_KERNEL; private int teamSize = 4; private int searchWidth = 5; private int minIterations = 6; private int threadBlockSize = 7; - private CuvsCagraHashMode cuvsCagraHashMode = CuvsCagraHashMode.AUTO_HASH; private int hashmapMinBitlen = 8; - private float hashmapMaxFillRate = 9.0f; private int numRandomSamplings = 10; + private float hashmapMaxFillRate = 9.0f; private long randXorMask = 11L; + private CuvsCagraSearchAlgo cuvsCagraSearchAlgo = CuvsCagraSearchAlgo.MULTI_KERNEL; + private CuvsCagraHashMapMode cuvsCagraHashMode = CuvsCagraHashMapMode.AUTO_HASH; + /** + * Constructs this Builder with an instance of Arena. + */ public Builder() { this.arena = Arena.ofConfined(); } + /** + * Sets the maximum number of queries to search at the same time (batch size). + * Auto select when 0. + * + * @param maxQueries the maximum number of queries + * @return an instance of this Builder + */ public Builder withMaxQueries(int maxQueries) { this.maxQueries = maxQueries; return this; } + /** + * Sets the number of intermediate search results retained during the search. + * This is the main knob to adjust trade off between accuracy and search speed. + * Higher values improve the search accuracy. + * + * @param itopkSize the number of intermediate search results + * @return an instance of this Builder + */ public Builder withItopkSize(int itopkSize) { this.itopkSize = itopkSize; return this; } + /** + * Sets the upper limit of search iterations. Auto select when 0. + * + * @param maxIterations the upper limit of search iterations + * @return an instance of this Builder + */ public Builder withMaxIterations(int maxIterations) { this.maxIterations = maxIterations; return this; } + /** + * Sets which search implementation to use. + * + * @param cuvsCagraSearchAlgo the search implementation to use + * @return an instance of this Builder + * @see CuvsCagraSearchAlgo + */ public Builder withAlgo(CuvsCagraSearchAlgo cuvsCagraSearchAlgo) { this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; return this; } + /** + * Sets the number of threads used to calculate a single distance. 4, 8, 16, or + * 32. + * + * @param teamSize the number of threads used to calculate a single distance + * @return an instance of this Builder + */ public Builder withTeamSize(int teamSize) { this.teamSize = teamSize; return this; } + /** + * Sets the number of graph nodes to select as the starting point for the search + * in each iteration. + * + * @param searchWidth the number of graph nodes to select + * @return an instance of this Builder + */ public Builder withSearchWidth(int searchWidth) { this.searchWidth = searchWidth; return this; } + /** + * Sets the lower limit of search iterations. + * + * @param minIterations the lower limit of search iterations + * @return an instance of this Builder + */ public Builder withMinIterations(int minIterations) { this.minIterations = minIterations; return this; } + /** + * Sets the thread block size. 0, 64, 128, 256, 512, 1024. Auto selection when + * 0. + * + * @param threadBlockSize the thread block size + * @return an instance of this Builder + */ public Builder withThreadBlockSize(int threadBlockSize) { this.threadBlockSize = threadBlockSize; return this; } - public Builder withHashmapMode(CuvsCagraHashMode cuvsCagraHashMode) { + /** + * Sets the hashmap type. Auto selection when AUTO. + * + * @param cuvsCagraHashMode the hashmap type + * @return an instance of this Builder + * @see CuvsCagraHashMapMode + */ + public Builder withHashmapMode(CuvsCagraHashMapMode cuvsCagraHashMode) { this.cuvsCagraHashMode = cuvsCagraHashMode; return this; } + /** + * Sets the lower limit of hashmap bit length. More than 8. + * + * @param hashmapMinBitlen the lower limit of hashmap bit length + * @return an instance of this Builder + */ public Builder withHashmapMinBitlen(int hashmapMinBitlen) { this.hashmapMinBitlen = hashmapMinBitlen; return this; } + /** + * Sets the upper limit of hashmap fill rate. More than 0.1, less than 0.9. + * + * @param hashmapMaxFillRate the upper limit of hashmap fill rate + * @return an instance of this Builder + */ public Builder withHashmapMaxFillRate(float hashmapMaxFillRate) { this.hashmapMaxFillRate = hashmapMaxFillRate; return this; } + /** + * Sets the number of iterations of initial random seed node selection. 1 or + * more. + * + * @param numRandomSamplings the number of iterations of initial random seed + * node selection + * @return an instance of this Builder + */ public Builder withNumRandomSamplings(int numRandomSamplings) { this.numRandomSamplings = numRandomSamplings; return this; } + /** + * Sets the bit mask used for initial random seed node selection. + * + * @param randXorMask the bit mask used for initial random seed node selection + * @return an instance of this Builder + */ public Builder withRandXorMask(long randXorMask) { this.randXorMask = randXorMask; return this; } - public CagraSearchParams build() throws Throwable { + /** + * Builds an instance of CagraSearchParams with passed search parameters. + * + * @return an instance of CagraSearchParams + */ + public CagraSearchParams build() { return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, cuvsCagraSearchAlgo, teamSize, searchWidth, minIterations, threadBlockSize, cuvsCagraHashMode, hashmapMinBitlen, hashmapMaxFillRate, numRandomSamplings, randXorMask); } - } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java index 1fc3321de..b3260be83 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java @@ -19,14 +19,31 @@ import java.util.Arrays; import java.util.Map; +/** + * CuVSQuery holds the CagraSearchParams and the query vectors to be used while + * invoking search. + * + * @since 24.12 + */ public class CuVSQuery { private CagraSearchParams cagraSearchParameters; private PreFilter preFilter; - private float[][] queryVectors; private Map mapping; + private float[][] queryVectors; private int topK; + /** + * Constructs an instance of CuVSQuery using cagraSearchParameters, preFilter, + * queryVectors, mapping, and topK. + * + * @param cagraSearchParameters an instance of CagraSearchParams holding the + * search parameters + * @param preFilter an instance of PreFilter + * @param queryVectors 2D float query vector array + * @param mapping an instance of ID mapping + * @param topK the top k results to return + */ public CuVSQuery(CagraSearchParams cagraSearchParameters, PreFilter preFilter, float[][] queryVectors, Map mapping, int topK) { super(); @@ -37,22 +54,47 @@ public CuVSQuery(CagraSearchParams cagraSearchParameters, PreFilter preFilter, f this.topK = topK; } + /** + * Gets the instance of CagraSearchParams initially set. + * + * @return an instance CagraSearchParams + */ public CagraSearchParams getCagraSearchParameters() { return cagraSearchParameters; } + /** + * Gets the instance of PreFilter initially set. + * + * @return an instance of PreFilter + */ public PreFilter getPreFilter() { return preFilter; } + /** + * Gets the query vector 2D float array. + * + * @return 2D float array + */ public float[][] getQueryVectors() { return queryVectors; } + /** + * Gets the passed map instance. + * + * @return a map of ID mappings + */ public Map getMapping() { return mapping; } + /** + * Gets the topK value. + * + * @return an integer + */ public int getTopK() { return topK; } @@ -63,6 +105,9 @@ public String toString() { + Arrays.toString(queryVectors) + ", mapping=" + mapping + ", topK=" + topK + "]"; } + /** + * Builder helps configure and create an instance of CuVSQuery. + */ public static class Builder { private CagraSearchParams cagraSearchParams; @@ -71,32 +116,74 @@ public static class Builder { private Map mapping; private int topK = 2; + /** + * Default constructor. + */ + public Builder() { + } + + /** + * Sets the instance of configured CagraSearchParams to be passed for search. + * + * @param cagraSearchParams an instance of the configured CagraSearchParams to + * be used for this query + * @return an instance of this Builder + */ public Builder withSearchParams(CagraSearchParams cagraSearchParams) { this.cagraSearchParams = cagraSearchParams; return this; } + /** + * Registers the query vectors to be passed in the search call. + * + * @param queryVectors 2D float query vector array + * @return an instance of this Builder + */ public Builder withQueryVectors(float[][] queryVectors) { this.queryVectors = queryVectors; return this; } + /** + * Sets the PreFilter to be used with CuVSQuery. + * + * @param preFilter the PreFilter instance to be configured + * @return an instance of this Builder + */ public Builder withPreFilter(PreFilter preFilter) { this.preFilter = preFilter; return this; } + /** + * Sets the instance of mapping to be used for ID mapping. + * + * @param mapping the ID mapping instance + * @return an instance of this Builder + */ public Builder withMapping(Map mapping) { this.mapping = mapping; return this; } + /** + * Registers the topK value. + * + * @param topK the topK value used to retrieve the topK results + * @return an instance of this Builder + */ public Builder withTopK(int topK) { this.topK = topK; return this; } - public CuVSQuery build() throws Throwable { + /** + * Builds an instance of CuVSQuery. + * + * @return an instance of CuVSQuery + */ + public CuVSQuery build() { return new CuVSQuery(cagraSearchParams, preFilter, queryVectors, mapping, topK); } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java index 6ab5b7554..42ed42a1a 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java @@ -26,14 +26,26 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; +/** + * CuVSResources has the logic to initialize and hold the reference to CuVS + * Resources instance. + * + * @since 24.12 + */ public class CuVSResources { private Arena arena; private Linker linker; - private MethodHandle createResourcesMemoryHandler; - private MemorySegment cuvsResourcesMemorySegment; private SymbolLookup symbolLookup; + private MethodHandle createResourcesMethodHandle; + private MemorySegment cuvsResourcesMemorySegment; + /** + * Constructor for CuVSResources that initializes MethodHandle and invokes the + * native create_resource function via Panama API. + * + * @throws Throwable exception thrown when native function is invoked + */ public CuVSResources() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); @@ -41,15 +53,20 @@ public CuVSResources() throws Throwable { File workingDirectory = new File(System.getProperty("user.dir")); symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - createResourcesMemoryHandler = linker.downcallHandle(symbolLookup.find("create_resource").get(), + createResourcesMethodHandle = linker.downcallHandle(symbolLookup.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - cuvsResourcesMemorySegment = (MemorySegment) createResourcesMemoryHandler.invokeExact(returnValueMemorySegment); + cuvsResourcesMemorySegment = (MemorySegment) createResourcesMethodHandle.invokeExact(returnValueMemorySegment); } + /** + * Gets the reference to the cuvsResources MemorySegment. + * + * @return cuvsResources MemorySegment + */ public MemorySegment getCuvsResourcesMemorySegment() { return cuvsResourcesMemorySegment; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java index 5034d2e45..4d985c9d0 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java @@ -17,8 +17,16 @@ package com.nvidia.cuvs.cagra; /** - * TODO: Pending implementation + * Pending Implementation + * + * @since 24.12 */ public class PreFilter { + /** + * Default constructor + */ + public PreFilter() { + } + } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java index 0eea21c9a..911c9f09a 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java @@ -25,6 +25,11 @@ import java.util.List; import java.util.Map; +/** + * SearchResult encapsulates the logic for reading and holding search results. + * + * @since 24.12 + */ public class SearchResult { private List> results; @@ -36,6 +41,22 @@ public class SearchResult { private int topK; private int numberOfQueries; + /** + * Constructor that initializes SearchResult with neighboursSequenceLayout, + * distancesSequenceLayout, neighboursMemorySegment, distancesMemorySegment, + * topK, mapping, and numberOfQueries. + * + * @param neighboursSequenceLayout neighbor SequenceLayout instance + * @param distancesSequenceLayout distance SequenceLayout instance + * @param neighboursMemorySegment neighbor MemorySegment instance + * @param distancesMemorySegment distance MemorySegment instance + * @param topK an integer denoting the topK value + * @param mapping id mapping + * @param numberOfQueries number of queries that were initially + * submitted + * @see SequenceLayout + * @see MemorySegment + */ public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, MemorySegment neighboursMemorySegment, MemorySegment distancesMemorySegment, int topK, Map mapping, int numberOfQueries) { @@ -48,18 +69,25 @@ public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout dist this.distancesMemorySegment = distancesMemorySegment; this.mapping = mapping; results = new LinkedList>(); - this.load(); + this.readResultMemorySegments(); } - private void load() { - VarHandle neighboursVH = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); - VarHandle distancesVH = distancesSequenceLayout.varHandle(PathElement.sequenceElement()); + /** + * Reads neighbors and distances MemorySegments and load values in a List of + * Maps. + * + * @see MemorySegment + * @see VarHandle + */ + private void readResultMemorySegments() { + VarHandle neighboursVarHandle = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); + VarHandle distancesVarHandle = distancesSequenceLayout.varHandle(PathElement.sequenceElement()); Map intermediateResultMap = new LinkedHashMap(); int count = 0; for (long i = 0; i < topK * numberOfQueries; i++) { - int id = (int) neighboursVH.get(neighboursMemorySegment, 0L, i); - float dst = (float) distancesVH.get(distancesMemorySegment, 0L, i); + int id = (int) neighboursVarHandle.get(neighboursMemorySegment, 0L, i); + float dst = (float) distancesVarHandle.get(distancesMemorySegment, 0L, i); intermediateResultMap.put(mapping != null ? mapping.get(id) : id, dst); count += 1; if (count == topK) { @@ -70,6 +98,11 @@ private void load() { } } + /** + * Gets a list of maps containing topK ID and distances. + * + * @return a list of maps + */ public List> getResults() { return results; } diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index 0352e24e3..06fcac6ed 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -42,7 +42,7 @@ DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, return tensor; } -cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvsResources, int *returnValue, +cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvsResources, int *returnValue, cuvsCagraIndexParams_t index_params) { int64_t dataset_shape[2] = {rows, dimensions}; @@ -55,15 +55,15 @@ cuvsCagraIndex_t build_index(float *dataset, long rows, long dimensions, cuvsRes return index; } -void serialize_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { +void serialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { *returnValue = cuvsCagraSerialize(cuvsResources, filename, index, true); } -void deserialize_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *rv, char* filename) { +void deserialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *rv, char* filename) { *rv = cuvsCagraDeserialize(cuvsResources, filename, index); } -void search_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, +void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, cuvsResources_t cuvsResources, int *neighbors_h, float *distances_h, int *returnValue, cuvsCagraSearchParams_t search_params) { uint32_t *neighbors; From 696f0157fef555228462fc530ff4aa69afd6433c Mon Sep 17 00:00:00 2001 From: Ishan Chattopadhyaya Date: Sun, 17 Nov 2024 20:51:27 +0530 Subject: [PATCH 31/53] Fixes for Javadocs, reducing visibility of internals, other refactorings --- java/README.md | 6 +- java/build.sh | 13 +- .../{ExampleApp.java => CagraExample.java} | 67 ++--- .../com/nvidia/cuvs/cagra/CagraIndex.java | 259 +++++++----------- .../nvidia/cuvs/cagra/CagraIndexParams.java | 128 ++++----- .../cuvs/cagra/CagraIndexReference.java | 60 ---- .../cagra/{CuVSQuery.java => CagraQuery.java} | 37 +-- .../nvidia/cuvs/cagra/CagraSearchParams.java | 199 +++++++------- ...rchResult.java => CagraSearchResults.java} | 52 ++-- .../java/com/nvidia/cuvs/cagra/PreFilter.java | 32 --- .../main/java/com/nvidia/cuvs/cagra/Util.java | 72 +++++ .../cuvs/{cagra => common}/CuVSResources.java | 28 +- .../com/nvidia/cuvs/common/SearchResults.java | 14 + ...xParams.java => CuVSCagraIndexParams.java} | 4 +- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 40 ++- 15 files changed, 431 insertions(+), 580 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{ExampleApp.java => CagraExample.java} (52%) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java rename java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/{CuVSQuery.java => CagraQuery.java} (80%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/{SearchResult.java => CagraSearchResults.java} (62%) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => common}/CuVSResources.java (69%) create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java rename java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/{cuvsCagraIndexParams.java => CuVSCagraIndexParams.java} (99%) diff --git a/java/README.md b/java/README.md index 4919578b1..a734273d6 100644 --- a/java/README.md +++ b/java/README.md @@ -1,12 +1,12 @@ Prerequisites ------------- -* JDK 24 +* JDK 22 * Maven 3.9.6 or later -Please build libcuvs (`./build.sh libcuvs` from top level directory) before building the Java API. +Please build libcuvs (`./build.sh libcuvs` from top level directory) before building the Java API with `./build.sh` from this directory. Building -------- -./build.sh will generate the libcuvs_java.so file in internal/ directory, and then build the final jar file for the cuVS Java API in cuvs-java/ directory. +`./build.sh` will generate the libcuvs_java.so file in internal/ directory, and then build the final jar file for the cuVS Java API in cuvs-java/ directory. diff --git a/java/build.sh b/java/build.sh index b06cf2fac..162c9e83f 100755 --- a/java/build.sh +++ b/java/build.sh @@ -1,9 +1,6 @@ export CMAKE_PREFIX_PATH=`pwd`/../cpp/build -cd internal -cmake . -cmake --build . -cd .. -mvn install:install-file -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java-internal -Dversion=0.1 -Dpackaging=so -Dfile=./internal/libcuvs_java.so - -cd cuvs-java -mvn package +cd internal && cmake . && cmake --build . \ + && cd .. \ + && mvn install:install-file -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java-internal -Dversion=0.1 -Dpackaging=so -Dfile=./internal/libcuvs_java.so \ + && cd cuvs-java \ + && mvn package diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java similarity index 52% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java index 592720827..bb8e1d978 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/ExampleApp.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java @@ -20,78 +20,67 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; -import java.util.Map; +import java.lang.invoke.MethodHandles; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; -import com.nvidia.cuvs.cagra.CagraIndexParams.CuvsCagraGraphBuildAlgo; +import com.nvidia.cuvs.cagra.CagraIndexParams.CagraGraphBuildAlgo; +import com.nvidia.cuvs.common.CuVSResources; +import com.nvidia.cuvs.common.SearchResults; import com.nvidia.cuvs.cagra.CagraSearchParams; -import com.nvidia.cuvs.cagra.CuVSQuery; -import com.nvidia.cuvs.cagra.CuVSResources; -import com.nvidia.cuvs.cagra.SearchResult; +import com.nvidia.cuvs.cagra.CagraQuery; -public class ExampleApp { +public class CagraExample { - private static Logger logger = LoggerFactory.getLogger(ExampleApp.class); + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); public static void main(String[] args) throws Throwable { // Sample data and query float[][] dataset = { { 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, { 0.6673192f, 0.10993068f } }; - Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); float[][] queries = { { 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f } }; - CuVSResources cuvsResources = new CuVSResources(); + // Allocate the resources + CuVSResources resources = new CuVSResources(); - CagraIndexParams cagraIndexParameters = new CagraIndexParams - .Builder() + // Building a new CAGRA index + CagraIndexParams indexParams = new CagraIndexParams.Builder() .withIntermediateGraphDegree(10) - .withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo.NN_DESCENT) + .withCagraGraphBuildAlgo(CagraGraphBuildAlgo.NN_DESCENT) .build(); - - // Creating a new CAGRA index - CagraIndex cagraIndex = new CagraIndex - .Builder(cuvsResources) + CagraIndex index = new CagraIndex.Builder(resources) .withDataset(dataset) - .withIndexParams(cagraIndexParameters) + .withIndexParams(indexParams) .build(); - // Saving the CAGRA index on to the disk. - File indexFile = new File("sample_index.cag"); - cagraIndex.serialize(new FileOutputStream(indexFile)); + // Serializing the index to a file + File indexFile = new File("cagra_index.cag"); + index.serialize(new FileOutputStream(indexFile)); - // Loading a CAGRA index from disk. + // Loading a CAGRA index from the file. InputStream fileInputStream = new FileInputStream(indexFile); - CagraIndex deserializedIndex = new CagraIndex - .Builder(cuvsResources) + CagraIndex loadedIndex = new CagraIndex.Builder(resources) .from(fileInputStream) .build(); - CagraSearchParams cagraSearchParameters = new CagraSearchParams - .Builder() - .build(); - - // Query - CuVSQuery cuvsQuery = new CuVSQuery - .Builder() + // Search + CagraSearchParams searchParams = new CagraSearchParams.Builder().build(); + CagraQuery query = new CagraQuery.Builder() .withTopK(3) - .withSearchParams(cagraSearchParameters) + .withSearchParams(searchParams) .withQueryVectors(queries) - .withMapping(map) .build(); + SearchResults results = index.search(query); + log.info(results.getResults().toString()); - // Search - SearchResult searchResult = cagraIndex.search(cuvsQuery); - logger.info(searchResult.getResults().toString()); - - // Search from deserialized index - SearchResult searchResultFromDeserializedIndex = deserializedIndex.search(cuvsQuery); - logger.info(searchResultFromDeserializedIndex.getResults().toString()); + // Search from loaded index + results = loadedIndex.search(query); + log.info(results.getResults().toString()); // Cleanup if (indexFile.exists()) { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index cb617de2b..45cfd86da 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -25,18 +25,18 @@ import java.lang.foreign.FunctionDescriptor; import java.lang.foreign.Linker; import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemoryLayout.PathElement; import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.foreign.SymbolLookup; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; -import java.lang.invoke.VarHandle; import java.util.UUID; +import com.nvidia.cuvs.common.CuVSResources; +import com.nvidia.cuvs.panama.cuvsCagraIndex; + /** - * CagraIndex encapsulates the implementation of crucial methods for interacting - * with the CAGRA index. + * {@link CagraIndex} encapsulates a CAGRA index, along with methods to interact with it. *

* CAGRA is a graph-based nearest neighbors algorithm that was built from the * ground up for GPU acceleration. CAGRA demonstrates state-of-the art index @@ -58,18 +58,10 @@ public class CagraIndex { private MethodHandle deserializeMethodHandle; private SymbolLookup symbolLookup; private CagraIndexParams cagraIndexParameters; - private CagraIndexReference cagraIndesReference; + private IndexReference cagraIndexReference; - /** - * Constructor that initializes CagraIndex with an instance of CagraIndexParams, - * dataset, and an instance of CuVSResources - * - * @param indexParameters index parameters - * @param dataset 2D float dataset array - * @param cuvsResources cuVS resources instance - * @throws Throwable exception thrown when native function is invoked - * @see CagraIndexParams - * @see CuVSResources + /* + * Constructor for building the index using specified dataset */ private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources cuvsResources) throws Throwable { @@ -77,30 +69,22 @@ private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSReso this.dataset = dataset; this.initializeMethodHandles(); this.cuvsResources = cuvsResources; - this.cagraIndesReference = build(); + this.cagraIndexReference = build(); } /** - * Constructs an instance of CagraIndex with an instance of InputStream and - * CuVSResources - * - * @param inputStream an instance of InputStream (eg. FileInputStream) to read - * a persisted CAGRA index. - * @param cuvsResources an instance of CuVSResources. - * @throws Throwable exception thrown when native function is invoked + * Constructor for loading the index from an {@link InputStream} */ private CagraIndex(InputStream inputStream, CuVSResources cuvsResources) throws Throwable { this.cagraIndexParameters = null; this.dataset = null; this.cuvsResources = cuvsResources; this.initializeMethodHandles(); - this.cagraIndesReference = deserialize(inputStream); + this.cagraIndexReference = deserialize(inputStream); } /** - * Initializes the MethodHandles for invoking native methods. - * - * @see MethodHandle + * Initializes the {@link MethodHandles} for invoking native methods. */ private void initializeMethodHandles() { linker = Linker.nativeLinker(); @@ -127,90 +111,33 @@ private void initializeMethodHandles() { } /** - * A utility method for getting an instance of MemorySegment for a String. - * - * @param string the string for the expected MemorySegment - * @return an instance of MemorySegment - * @see MemoryLayout - * @see MemorySegment - * @see StringBuilder - */ - public MemorySegment getStringMemorySegment(StringBuilder string) { - string.append('\0'); - MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(string.length(), - linker.canonicalLayouts().get("char")); - MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); - - for (int i = 0; i < string.length(); i++) { - VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); - varHandle.set(stringMemorySegment, 0L, (byte) string.charAt(i)); - } - return stringMemorySegment; - } - - /** - * A utility method for getting an instance of MemorySegment for a 2D float - * array. - * - * @param data The 2D float array for which the MemorySegment is needed - * @return an instance of MemorySegment - * @see MemoryLayout - * @see MemorySegment - */ - private MemorySegment getMemorySegment(float[][] data) { - long rows = data.length; - long cols = data[0].length; - - MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, - MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); - MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); - - for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), - PathElement.sequenceElement(c)); - element.set(dataMemorySegment, 0, 0, data[r][c]); - } - } - - return dataMemorySegment; - } - - /** - * Invokes the native build_index function via the Panama API to build the CAGRA - * index. + * Invokes the native build_index function via the Panama API to build the {@link CagraIndex} * - * @return an instance of CagraIndexReference that holds the pointer to the + * @return an instance of {@link IndexReference} that holds the pointer to the * index - * @throws Throwable exception thrown when native function is invoked - * @see CagraIndexReference */ - private CagraIndexReference build() throws Throwable { + private IndexReference build() throws Throwable { long rows = dataset.length; long cols = dataset[0].length; - MemoryLayout returnvalueMemoryLayout = linker.canonicalLayouts().get("int"); - MemorySegment returnvalueMemorySegment = arena.allocate(returnvalueMemoryLayout); + MemoryLayout layout = linker.canonicalLayouts().get("int"); + MemorySegment segment = arena.allocate(layout); - cagraIndesReference = new CagraIndexReference((MemorySegment) indexMethodHandle.invokeExact( - getMemorySegment(dataset), rows, cols, cuvsResources.getCuvsResourcesMemorySegment(), returnvalueMemorySegment, - cagraIndexParameters.getCagraIndexParamsMemorySegment())); + cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( + Util.buildMemorySegment(linker, arena, dataset), rows, cols, cuvsResources.getMemorySegment(), segment, + cagraIndexParameters.getMemorySegment())); - return cagraIndesReference; + return cagraIndexReference; } /** * Invokes the native search_index via the Panama API for searching a CAGRA * index. * - * @param cuvsQuery an instance of CuVSQuery holding the query and its + * @param query an instance of {@link CagraQuery} holding the query vectors and other * parameters - * @return an instance of SearchResult containing the results - * @throws Throwable exception thrown when native function is invoked - * @see CuVSQuery - * @see SearchResult + * @return an instance of {@link CagraSearchResults} containing the results */ - public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { - + public CagraSearchResults search(CagraQuery query) throws Throwable { SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); MemorySegment neighborsMemorySegment = arena.allocate(neighborsSequenceLayout); @@ -218,59 +145,40 @@ public SearchResult search(CuVSQuery cuvsQuery) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - searchMethodHandle.invokeExact(cagraIndesReference.getIndexMemorySegment(), - getMemorySegment(cuvsQuery.getQueryVectors()), cuvsQuery.getTopK(), 4L, 2L, - cuvsResources.getCuvsResourcesMemorySegment(), neighborsMemorySegment, distancesMemorySegment, - returnValueMemorySegment, cuvsQuery.getCagraSearchParameters().getCagraSearchParamsMemorySegment()); + searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), + Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), 4L, 2L, + cuvsResources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, + returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); - return new SearchResult(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, - distancesMemorySegment, cuvsQuery.getTopK(), cuvsQuery.getMapping(), cuvsQuery.getQueryVectors().length); + return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, + distancesMemorySegment, query.getTopK(), query.getMapping(), query.getQueryVectors().length); } /** - * A method to persist a CAGRA index using an instance of OutputStream for + * A method to persist a CAGRA index using an instance of {@link OutputStream} for * writing index bytes. * - * @param outputStream an instance of OutputStream to write the index bytes into - * @throws Throwable exception thrown when native function is invoked - * @see OutputStream + * @param outputStream an instance of {@link OutputStream} to write the index bytes into */ public void serialize(OutputStream outputStream) throws Throwable { - MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); - MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), - cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringMemorySegment(new StringBuilder(tmpIndexFile))); - File tempFile = new File(tmpIndexFile); - FileInputStream fileInputStream = new FileInputStream(tempFile); - byte[] chunk = new byte[1024]; - int chunkLength = 0; - while ((chunkLength = fileInputStream.read(chunk)) != -1) { - outputStream.write(chunk, 0, chunkLength); - } - fileInputStream.close(); - tempFile.delete(); + serialize(outputStream, File.createTempFile(UUID.randomUUID().toString(), ".cag")); } /** - * A method to persist a CAGRA index using an instance of OutputStream and path + * A method to persist a CAGRA index using an instance of {@link OutputStream} and path * to the intermediate temporary file. * - * @param outputStream an instance of OutputStream to write the index bytes to - * @param tmpFilePath path to a temporary file where CAGRA index is written - * @throws Throwable exception thrown when native function is invoked - * @see OutputStream + * @param outputStream an instance of {@link OutputStream} to write the index bytes to + * @param tmpFilePath an intermediate {@link File} where CAGRA index is written temporarily */ - public void serialize(OutputStream outputStream, String tmpFilePath) throws Throwable { + public void serialize(OutputStream outputStream, File tempFile) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - serializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), - cagraIndesReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringMemorySegment(new StringBuilder(tmpFilePath))); - File tempFile = new File(tmpFilePath); + serializeMethodHandle.invokeExact(cuvsResources.getMemorySegment(), + cagraIndexReference.getMemorySegment(), returnValueMemorySegment, + Util.buildMemorySegment(linker, arena, tempFile.getAbsolutePath())); FileInputStream fileInputStream = new FileInputStream(tempFile); - byte[] chunk = new byte[1024]; + byte[] chunk = new byte[1024]; // TODO: Make this configurable int chunkLength = 0; while ((chunkLength = fileInputStream.read(chunk)) != -1) { outputStream.write(chunk, 0, chunkLength); @@ -280,21 +188,17 @@ public void serialize(OutputStream outputStream, String tmpFilePath) throws Thro } /** - * Gets an instance of CagraIndexReference by deserializing a CAGRA index using - * an input stream. + * Gets an instance of {@link IndexReference} by deserializing a CAGRA index using + * an {@link InputStream}. * - * @param inputStream an instance of InputStream (eg. FileInputStream when - * reading an index file). - * @return an instance of CagraIndexReference. - * @throws Throwable exception thrown when native function is invoked - * @see CagraIndexReference - * @see InputStream + * @param inputStream an instance of {@link InputStream} + * @return an instance of {@link IndexReference}. */ - private CagraIndexReference deserialize(InputStream inputStream) throws Throwable { + private IndexReference deserialize(InputStream inputStream) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; - CagraIndexReference cagraIndexReference = new CagraIndexReference(); + IndexReference indexReference = new IndexReference(); File tempFile = new File(tmpIndexFile); FileOutputStream fileOutputStream = new FileOutputStream(tempFile); @@ -303,39 +207,37 @@ private CagraIndexReference deserialize(InputStream inputStream) throws Throwabl while ((chunkLength = inputStream.read(chunk)) != -1) { fileOutputStream.write(chunk, 0, chunkLength); } - deserializeMethodHandle.invokeExact(cuvsResources.getCuvsResourcesMemorySegment(), - cagraIndexReference.getIndexMemorySegment(), returnValueMemorySegment, - getStringMemorySegment(new StringBuilder(tmpIndexFile))); + deserializeMethodHandle.invokeExact(cuvsResources.getMemorySegment(), + indexReference.getMemorySegment(), returnValueMemorySegment, + Util.buildMemorySegment(linker, arena, tmpIndexFile)); inputStream.close(); fileOutputStream.close(); tempFile.delete(); - return cagraIndexReference; + return indexReference; } /** - * Gets an instance of CagraIndexParams. + * Gets an instance of {@link CagraIndexParams} * - * @return an instance of CagraIndexParams - * @see CagraIndexParams + * @return an instance of {@link CagraIndexParams} */ public CagraIndexParams getCagraIndexParameters() { return cagraIndexParameters; } /** - * Gets an instance of CuVSResources. + * Gets an instance of {@link CuVSResources} * - * @return an instance of CuVSResources - * @see CuVSResources + * @return an instance of {@link CuVSResources} */ public CuVSResources getCuVSResources() { return cuvsResources; } /** - * Builder helps configure and create an instance of CagraIndex. + * Builder helps configure and create an instance of {@link CagraIndex}. */ public static class Builder { @@ -345,10 +247,9 @@ public static class Builder { private InputStream inputStream; /** - * Constructs this Builder with an instance of CuVSResources. + * Constructs this Builder with an instance of {@link CuVSResources}. * - * @param cuvsResources an instance of CuVSResources - * @see CuVSResources + * @param cuvsResources an instance of {@link CuVSResources} */ public Builder(CuVSResources cuvsResources) { this.cuvsResources = cuvsResources; @@ -358,9 +259,8 @@ public Builder(CuVSResources cuvsResources) { * Sets an instance of InputStream typically used when index deserialization is * needed. * - * @param inputStream an instance of InputStream + * @param inputStream an instance of {@link InputStream} * @return an instance of this Builder - * @see InputStream */ public Builder from(InputStream inputStream) { this.inputStream = inputStream; @@ -368,7 +268,7 @@ public Builder from(InputStream inputStream) { } /** - * Sets the dataset for building the CAGRA index. + * Sets the dataset for building the {@link CagraIndex}. * * @param dataset a two-dimensional float array * @return an instance of this Builder @@ -379,11 +279,10 @@ public Builder withDataset(float[][] dataset) { } /** - * Registers an instance of configured CagraIndexParams with this Builder. + * Registers an instance of configured {@link CagraIndexParams} with this Builder. * * @param cagraIndexParameters An instance of CagraIndexParams. * @return An instance of this Builder. - * @see CagraIndexParams */ public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { this.cagraIndexParams = cagraIndexParameters; @@ -394,7 +293,6 @@ public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { * Builds and returns an instance of CagraIndex. * * @return an instance of CagraIndex - * @throws Throwable exception thrown when native function is invoked */ public CagraIndex build() throws Throwable { if (inputStream != null) { @@ -404,4 +302,41 @@ public CagraIndex build() throws Throwable { } } } + + /** + * Holds the memory reference to an index. + */ + protected static class IndexReference { + + private MemorySegment memorySegment; + + /** + * Constructs CagraIndexReference and allocate the MemorySegment. + */ + protected IndexReference() { + Arena arena = Arena.ofConfined(); + memorySegment = cuvsCagraIndex.allocate(arena); + } + + /** + * Constructs CagraIndexReference with an instance of MemorySegment passed as a + * parameter. + * + * @param indexMemorySegment the MemorySegment instance to use for containing + * index reference + */ + protected IndexReference(MemorySegment indexMemorySegment) { + this.memorySegment = indexMemorySegment; + } + + /** + * Gets the instance of index MemorySegment. + * + * @return index MemorySegment + */ + protected MemorySegment getMemorySegment() { + return memorySegment; + } + } + } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java index 9a65ca167..118f1e387 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java @@ -19,7 +19,7 @@ import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; -import com.nvidia.cuvs.panama.cuvsCagraIndexParams; +import com.nvidia.cuvs.panama.CuVSCagraIndexParams; /** * Supplemental parameters to build CAGRA Index. @@ -28,17 +28,18 @@ */ public class CagraIndexParams { - private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; - private MemorySegment cagraIndexParamsMemorySegment; - private Arena arena; - private int intermediateGraphDegree; - private int graphDegree; - private int nnDescentNiter; + private final CagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; + private final MemorySegment memorySegment; + private final Arena arena; + private final int intermediateGraphDegree; + private final int graphDegree; + private final int nnDescentNiter; + private final int numWriterThreads; /** * Enum that denotes which ANN algorithm is used to build CAGRA graph. */ - public enum CuvsCagraGraphBuildAlgo { + public enum CagraGraphBuildAlgo { /** * AUTO_SELECT */ @@ -57,44 +58,30 @@ public enum CuvsCagraGraphBuildAlgo { */ public final int label; - private CuvsCagraGraphBuildAlgo(int label) { + private CagraGraphBuildAlgo(int label) { this.label = label; } } - /** - * Constructor that initializes CagraIndexParams with an instance of Arena, - * intermediateGraphDegree, graphDegree, CuvsCagraGraphBuildAlgo, and - * nnDescentNiter. - * - * @param arena the Arena instance to use - * @param intermediateGraphDegree the degree of input graph for pruning - * @param graphDegree the degree of output graph - * @param CuvsCagraGraphBuildAlgo the CuvsCagraGraphBuildAlgo - * @param nnDescentNiter the number of Iterations to run if building - * with NN_DESCENT - */ - public CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, - CuvsCagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter) { + private CagraIndexParams(Arena arena, int intermediateGraphDegree, int graphDegree, + CagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter, int writerThreads) { this.arena = arena; this.intermediateGraphDegree = intermediateGraphDegree; this.graphDegree = graphDegree; this.cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo; this.nnDescentNiter = nnDescentNiter; - this.setCagraIndexParamsStubValues(); + this.numWriterThreads = writerThreads; + + this.memorySegment = initMemorySegment(); } - /** - * Sets the parameter values in the stub's MemorySegment. - * - * @see MemorySegment - */ - private void setCagraIndexParamsStubValues() { - cagraIndexParamsMemorySegment = cuvsCagraIndexParams.allocate(arena); - cuvsCagraIndexParams.intermediate_graph_degree(cagraIndexParamsMemorySegment, intermediateGraphDegree); - cuvsCagraIndexParams.graph_degree(cagraIndexParamsMemorySegment, graphDegree); - cuvsCagraIndexParams.build_algo(cagraIndexParamsMemorySegment, cuvsCagraGraphBuildAlgo.label); - cuvsCagraIndexParams.nn_descent_niter(cagraIndexParamsMemorySegment, nnDescentNiter); + private MemorySegment initMemorySegment() { + MemorySegment memorySegment = CuVSCagraIndexParams.allocate(arena); + CuVSCagraIndexParams.intermediate_graph_degree(memorySegment, intermediateGraphDegree); + CuVSCagraIndexParams.graph_degree(memorySegment, graphDegree); + CuVSCagraIndexParams.build_algo(memorySegment, cuvsCagraGraphBuildAlgo.label); + CuVSCagraIndexParams.nn_descent_niter(memorySegment, nnDescentNiter); + return memorySegment; } /** @@ -116,58 +103,51 @@ public int getGraphDegree() { } /** - * Gets the CuvsCagraGraphBuildAlgo. - * - * @return CuvsCagraGraphBuildAlgo selected + * Gets the {@link CagraGraphBuildAlgo} used to build the index. */ - public CuvsCagraGraphBuildAlgo getCuvsCagraGraphBuildAlgo() { + public CagraGraphBuildAlgo getCagraGraphBuildAlgo() { return cuvsCagraGraphBuildAlgo; } /** - * Gets the number of Iterations to run if building with NN_DESCENT. - * - * @return the number of Iterations + * Gets the number of iterations to run if building with {@link CagraGraphBuildAlgo#NN_DESCENT} */ - public int getNNDescentNiter() { + public int getNNDescentNumIterations() { return nnDescentNiter; } - /** - * Gets the cagraIndexParams MemorySegment. - * - * @return an instance of MemorySegment - */ - public MemorySegment getCagraIndexParamsMemorySegment() { - return cagraIndexParamsMemorySegment; + protected MemorySegment getMemorySegment() { + return memorySegment; } @Override public String toString() { return "CagraIndexParams [arena=" + arena + ", intermediateGraphDegree=" + intermediateGraphDegree + ", graphDegree=" + graphDegree + ", cuvsCagraGraphBuildAlgo=" + cuvsCagraGraphBuildAlgo + ", nnDescentNiter=" - + nnDescentNiter + ", cagraIndexParamsMemorySegment=" + cagraIndexParamsMemorySegment + "]"; + + nnDescentNiter + ", cagraIndexParamsMemorySegment=" + memorySegment + "]"; } /** - * Builder configures and creates an instance of CagraIndexParams. + * Gets the number of threads used to build the index. + */ + public int getNumWriterThreads() { + return numWriterThreads; +} + + /** + * Builder configures and creates an instance of {@link CagraIndexParams}. */ public static class Builder { - private CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo.NN_DESCENT; + private CagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CagraGraphBuildAlgo.NN_DESCENT; private Arena arena; private int intermediateGraphDegree = 128; private int graphDegree = 64; - private int nnDescentNiter = 20; - private int writerThreads = 1; + private int nnDescentNumIterations = 20; + private int numWriterThreads = 1; - /** - * Constructor for builder for initializing and instance of Arena. - * - * @see Arena - */ public Builder() { - this.arena = Arena.ofConfined(); + } /** @@ -198,41 +178,41 @@ public Builder withGraphDegree(int graphDegree) { * @param cuvsCagraGraphBuildAlgo the CuvsCagraGraphBuildAlgo to use * @return an instance of Builder */ - public Builder withCuvsCagraGraphBuildAlgo(CuvsCagraGraphBuildAlgo cuvsCagraGraphBuildAlgo) { + public Builder withCagraGraphBuildAlgo(CagraGraphBuildAlgo cuvsCagraGraphBuildAlgo) { this.cuvsCagraGraphBuildAlgo = cuvsCagraGraphBuildAlgo; return this; } /** - * Sets the Number of Iterations to run if building with NN_DESCENT. + * Sets the Number of Iterations to run if building with {@link CagraGraphBuildAlgo#NN_DESCENT}. * - * @param nnDescentNiter number of Iterations to run if building with NN_DESCENT + * @param nnDescentNiter number of Iterations to run if building with {@link CagraGraphBuildAlgo#NN_DESCENT} * @return an instance of Builder */ - public Builder withNNDescentNiter(int nnDescentNiter) { - this.nnDescentNiter = nnDescentNiter; + public Builder withNNDescentNumIterations(int nnDescentNiter) { + this.nnDescentNumIterations = nnDescentNiter; return this; } /** - * Registers the number of writer threads to use for indexing. + * Sets the number of writer threads to use for indexing. * - * @param writerThreads number of writer threads to use + * @param numWriterThreads number of writer threads to use * @return an instance of Builder */ - public Builder withWriterThreads(int writerThreads) { - this.writerThreads = writerThreads; + public Builder withNumWriterThreads(int numWriterThreads) { + this.numWriterThreads = numWriterThreads; return this; } /** - * Builds an instance of CagraIndexParams. + * Builds an instance of {@link CagraIndexParams}. * - * @return an instance of CagraIndexParams - * @see CagraIndexParams + * @return an instance of {@link CagraIndexParams} */ public CagraIndexParams build() { - return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, nnDescentNiter); + this.arena = Arena.ofConfined(); + return new CagraIndexParams(arena, intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, nnDescentNumIterations, numWriterThreads); } } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java deleted file mode 100644 index a675ebd76..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexReference.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023-2024, 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.cagra; - -import java.lang.foreign.Arena; -import java.lang.foreign.MemorySegment; - -import com.nvidia.cuvs.panama.cuvsCagraIndex; - -/** - * Holds the reference to the index using MemorySegment. - * - * @since 24.12 - */ -public class CagraIndexReference { - - private MemorySegment indexMemorySegment; - - /** - * Constructs CagraIndexReference and allocate the MemorySegment. - */ - public CagraIndexReference() { - Arena arena = Arena.ofConfined(); - indexMemorySegment = cuvsCagraIndex.allocate(arena); - } - - /** - * Constructs CagraIndexReference with an instance of MemorySegment passed as a - * parameter. - * - * @param indexMemorySegment the MemorySegment instance to use for containing - * index reference - */ - public CagraIndexReference(MemorySegment indexMemorySegment) { - this.indexMemorySegment = indexMemorySegment; - } - - /** - * Gets the instance of index MemorySegment. - * - * @return index MemorySegment - */ - public MemorySegment getIndexMemorySegment() { - return indexMemorySegment; - } -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java similarity index 80% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java index b3260be83..e5b9d7cff 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java @@ -25,30 +25,28 @@ * * @since 24.12 */ -public class CuVSQuery { +public class CagraQuery { private CagraSearchParams cagraSearchParameters; - private PreFilter preFilter; private Map mapping; private float[][] queryVectors; private int topK; /** - * Constructs an instance of CuVSQuery using cagraSearchParameters, preFilter, + * Constructs an instance of {@link CagraQuery} using cagraSearchParameters, preFilter, * queryVectors, mapping, and topK. * - * @param cagraSearchParameters an instance of CagraSearchParams holding the + * @param cagraSearchParameters an instance of {@link CagraSearchParams} holding the * search parameters * @param preFilter an instance of PreFilter * @param queryVectors 2D float query vector array * @param mapping an instance of ID mapping * @param topK the top k results to return */ - public CuVSQuery(CagraSearchParams cagraSearchParameters, PreFilter preFilter, float[][] queryVectors, + public CagraQuery(CagraSearchParams cagraSearchParameters, float[][] queryVectors, Map mapping, int topK) { super(); this.cagraSearchParameters = cagraSearchParameters; - this.preFilter = preFilter; this.queryVectors = queryVectors; this.mapping = mapping; this.topK = topK; @@ -63,15 +61,6 @@ public CagraSearchParams getCagraSearchParameters() { return cagraSearchParameters; } - /** - * Gets the instance of PreFilter initially set. - * - * @return an instance of PreFilter - */ - public PreFilter getPreFilter() { - return preFilter; - } - /** * Gets the query vector 2D float array. * @@ -101,7 +90,7 @@ public int getTopK() { @Override public String toString() { - return "CuVSQuery [cagraSearchParameters=" + cagraSearchParameters + ", preFilter=" + preFilter + ", queryVectors=" + return "CuVSQuery [cagraSearchParameters=" + cagraSearchParameters + ", queryVectors=" + Arrays.toString(queryVectors) + ", mapping=" + mapping + ", topK=" + topK + "]"; } @@ -111,7 +100,6 @@ public String toString() { public static class Builder { private CagraSearchParams cagraSearchParams; - private PreFilter preFilter; private float[][] queryVectors; private Map mapping; private int topK = 2; @@ -145,17 +133,6 @@ public Builder withQueryVectors(float[][] queryVectors) { return this; } - /** - * Sets the PreFilter to be used with CuVSQuery. - * - * @param preFilter the PreFilter instance to be configured - * @return an instance of this Builder - */ - public Builder withPreFilter(PreFilter preFilter) { - this.preFilter = preFilter; - return this; - } - /** * Sets the instance of mapping to be used for ID mapping. * @@ -183,8 +160,8 @@ public Builder withTopK(int topK) { * * @return an instance of CuVSQuery */ - public CuVSQuery build() { - return new CuVSQuery(cagraSearchParams, preFilter, queryVectors, mapping, topK); + public CagraQuery build() { + return new CagraQuery(cagraSearchParams, queryVectors, mapping, topK); } } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java index 1d2cf6ae4..51ad1b8b2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java @@ -30,7 +30,7 @@ public class CagraSearchParams { private int maxQueries; - private int itopkSize; + private int iTopKSize; private int maxIterations; private int teamSize; private int searchWidth; @@ -38,17 +38,17 @@ public class CagraSearchParams { private int threadBlockSize; private int hashmapMinBitlen; private int numRandomSamplings; - private float hashmapMaxFillRate; - private long randXorMask; + private float hashMapMaxFillRate; + private long randXORMask; private Arena arena; - private MemorySegment cagraSearchParamsMemorySegment; - private CuvsCagraSearchAlgo cuvsCagraSearchAlgo; - private CuvsCagraHashMapMode cuvsCagraHashMapMode; + private MemorySegment memorySegment; + private SearchAlgo searchAlgo; + private HashMapMode hashMapMode; /** * Enum to denote algorithm used to search CAGRA Index. */ - public enum CuvsCagraSearchAlgo { + public enum SearchAlgo { /** * for large batch sizes */ @@ -71,7 +71,7 @@ public enum CuvsCagraSearchAlgo { */ public final int value; - private CuvsCagraSearchAlgo(int value) { + private SearchAlgo(int value) { this.value = value; } } @@ -79,7 +79,7 @@ private CuvsCagraSearchAlgo(int value) { /** * Enum to denote Hash Mode used while searching CAGRA index. */ - public enum CuvsCagraHashMapMode { + public enum HashMapMode { /** * HASH */ @@ -98,7 +98,7 @@ public enum CuvsCagraHashMapMode { */ public final int value; - private CuvsCagraHashMapMode(int value) { + private HashMapMode(int value) { this.value = value; } } @@ -109,64 +109,65 @@ private CuvsCagraHashMapMode(int value) { * @param arena the Arena instance to use * @param maxQueries the maximum number of queries to search at the * same time (batch size) - * @param itopkSize the number of intermediate search results retained + * @param iTopKSize the number of intermediate search results retained * during the search * @param maxIterations the upper limit of search iterations - * @param cuvsCagraSearchAlgo the search implementation is configured + * @param searchAlgo the search implementation is configured * @param teamSize the number of threads used to calculate a single * distance * @param searchWidth the number of graph nodes to select as the * starting point for the search in each iteration * @param minIterations the lower limit of search iterations * @param threadBlockSize the thread block size - * @param hashmapMode the hashmap type configured - * @param hashmapMinBitlen the lower limit of hashmap bit length - * @param hashmapMaxFillRate the upper limit of hashmap fill rate + * @param hashmapMode the hash map type configured + * @param hashmapMinBitlen the lower limit of hash map bit length + * @param hashmapMaxFillRate the upper limit of hash map fill rate * @param numRandomSamplings the number of iterations of initial random seed * node selection - * @param randXorMask the bit mask used for initial random seed node + * @param randXORMask the bit mask used for initial random seed node * selection */ - public CagraSearchParams(Arena arena, int maxQueries, int itopkSize, int maxIterations, - CuvsCagraSearchAlgo cuvsCagraSearchAlgo, int teamSize, int searchWidth, int minIterations, int threadBlockSize, - CuvsCagraHashMapMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, - long randXorMask) { - super(); + private CagraSearchParams(Arena arena, int maxQueries, int iTopKSize, int maxIterations, + SearchAlgo searchAlgo, int teamSize, int searchWidth, int minIterations, int threadBlockSize, + HashMapMode hashmapMode, int hashmapMinBitlen, float hashmapMaxFillRate, int numRandomSamplings, + long randXORMask) { this.arena = arena; this.maxQueries = maxQueries; - this.itopkSize = itopkSize; + this.iTopKSize = iTopKSize; this.maxIterations = maxIterations; - this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; + this.searchAlgo = searchAlgo; this.teamSize = teamSize; this.searchWidth = searchWidth; this.minIterations = minIterations; this.threadBlockSize = threadBlockSize; - this.cuvsCagraHashMapMode = hashmapMode; + this.hashMapMode = hashmapMode; this.hashmapMinBitlen = hashmapMinBitlen; - this.hashmapMaxFillRate = hashmapMaxFillRate; + this.hashMapMaxFillRate = hashmapMaxFillRate; this.numRandomSamplings = numRandomSamplings; - this.randXorMask = randXorMask; - this.setSearchParametersInTheStubMemorySegment(); + this.randXORMask = randXORMask; + + this.memorySegment = allocateMemorySegment(); } /** - * Sets the configured search parameters in the MemorySegment. + * Allocates the configured search parameters in the MemorySegment. */ - public void setSearchParametersInTheStubMemorySegment() { - cagraSearchParamsMemorySegment = cuvsCagraSearchParams.allocate(arena); - cuvsCagraSearchParams.max_queries(cagraSearchParamsMemorySegment, maxQueries); - cuvsCagraSearchParams.itopk_size(cagraSearchParamsMemorySegment, itopkSize); - cuvsCagraSearchParams.max_iterations(cagraSearchParamsMemorySegment, maxIterations); - cuvsCagraSearchParams.algo(cagraSearchParamsMemorySegment, cuvsCagraSearchAlgo.value); - cuvsCagraSearchParams.team_size(cagraSearchParamsMemorySegment, teamSize); - cuvsCagraSearchParams.search_width(cagraSearchParamsMemorySegment, searchWidth); - cuvsCagraSearchParams.min_iterations(cagraSearchParamsMemorySegment, minIterations); - cuvsCagraSearchParams.thread_block_size(cagraSearchParamsMemorySegment, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(cagraSearchParamsMemorySegment, cuvsCagraHashMapMode.value); - cuvsCagraSearchParams.hashmap_min_bitlen(cagraSearchParamsMemorySegment, hashmapMinBitlen); - cuvsCagraSearchParams.hashmap_max_fill_rate(cagraSearchParamsMemorySegment, hashmapMaxFillRate); - cuvsCagraSearchParams.num_random_samplings(cagraSearchParamsMemorySegment, numRandomSamplings); - cuvsCagraSearchParams.rand_xor_mask(cagraSearchParamsMemorySegment, randXorMask); + private MemorySegment allocateMemorySegment() { + MemorySegment memorySegment = cuvsCagraSearchParams.allocate(arena); + cuvsCagraSearchParams.max_queries(memorySegment, maxQueries); + cuvsCagraSearchParams.itopk_size(memorySegment, iTopKSize); + cuvsCagraSearchParams.max_iterations(memorySegment, maxIterations); + cuvsCagraSearchParams.algo(memorySegment, searchAlgo.value); + cuvsCagraSearchParams.team_size(memorySegment, teamSize); + cuvsCagraSearchParams.search_width(memorySegment, searchWidth); + cuvsCagraSearchParams.min_iterations(memorySegment, minIterations); + cuvsCagraSearchParams.thread_block_size(memorySegment, threadBlockSize); + cuvsCagraSearchParams.hashmap_mode(memorySegment, hashMapMode.value); + cuvsCagraSearchParams.hashmap_min_bitlen(memorySegment, hashmapMinBitlen); + cuvsCagraSearchParams.hashmap_max_fill_rate(memorySegment, hashMapMaxFillRate); + cuvsCagraSearchParams.num_random_samplings(memorySegment, numRandomSamplings); + cuvsCagraSearchParams.rand_xor_mask(memorySegment, randXORMask); + return memorySegment; } /** @@ -183,8 +184,8 @@ public int getMaxQueries() { * * @return the number of intermediate search results */ - public int getItopkSize() { - return itopkSize; + public int getITopKSize() { + return iTopKSize; } /** @@ -234,7 +235,7 @@ public int getThreadBlockSize() { } /** - * Gets the lower limit of hashmap bit length. + * Gets the lower limit of hash map bit length. * * @return the lower limit value */ @@ -252,12 +253,12 @@ public int getNumRandomSamplings() { } /** - * Gets the upper limit of hashmap fill rate. + * Gets the upper limit of hash map fill rate. * - * @return the upper limit of hashmap fill rate + * @return the upper limit of hash map fill rate */ - public float getHashmapMaxFillRate() { - return hashmapMaxFillRate; + public float getHashMapMaxFillRate() { + return hashMapMaxFillRate; } /** @@ -265,8 +266,8 @@ public float getHashmapMaxFillRate() { * * @return the bit mask value */ - public long getRandXorMask() { - return randXorMask; + public long getRandXORMask() { + return randXORMask; } /** @@ -274,38 +275,36 @@ public long getRandXorMask() { * * @return the MemorySegment holding CagraSearchParams */ - public MemorySegment getCagraSearchParamsMemorySegment() { - return cagraSearchParamsMemorySegment; + protected MemorySegment getMemorySegment() { + return memorySegment; } /** * Gets which search implementation is configured. * - * @return the search implementation configured - * @see CuvsCagraSearchAlgo + * @return the configured {@link SearchAlgo} */ - public CuvsCagraSearchAlgo getCuvsCagraSearchAlgo() { - return cuvsCagraSearchAlgo; + public SearchAlgo getCagraSearchAlgo() { + return searchAlgo; } /** - * Gets the hashmap type configured. + * Gets the hash map mode configured. * - * @return the hashmap type configured - * @see CuvsCagraHashMapMode + * @return the configured {@link HashMapMode} */ - public CuvsCagraHashMapMode getCuvsCagraHashMapMode() { - return cuvsCagraHashMapMode; + public HashMapMode getHashMapMode() { + return hashMapMode; } @Override public String toString() { - return "CagraSearchParams [arena=" + arena + ", maxQueries=" + maxQueries + ", itopkSize=" + itopkSize - + ", maxIterations=" + maxIterations + ", cuvsCagraSearchAlgo=" + cuvsCagraSearchAlgo + ", teamSize=" + teamSize + return "CagraSearchParams [arena=" + arena + ", maxQueries=" + maxQueries + ", itopkSize=" + iTopKSize + + ", maxIterations=" + maxIterations + ", cuvsCagraSearchAlgo=" + searchAlgo + ", teamSize=" + teamSize + ", searchWidth=" + searchWidth + ", minIterations=" + minIterations + ", threadBlockSize=" + threadBlockSize - + ", cuvsCagraHashMapMode=" + cuvsCagraHashMapMode + ", hashmapMinBitlen=" + hashmapMinBitlen - + ", hashmapMaxFillRate=" + hashmapMaxFillRate + ", numRandomSamplings=" + numRandomSamplings + ", randXorMask=" - + randXorMask + ", cagraSearchParamsMemorySegment=" + cagraSearchParamsMemorySegment + "]"; + + ", hashMapMode=" + hashMapMode + ", hashMapMinBitlen=" + hashmapMinBitlen + + ", hashMapMaxFillRate=" + hashMapMaxFillRate + ", numRandomSamplings=" + numRandomSamplings + ", randXORMask=" + + randXORMask + ", memorySegment=" + memorySegment + "]"; } /** @@ -315,18 +314,18 @@ public static class Builder { private Arena arena; private int maxQueries = 1; - private int itopkSize = 2; + private int iTopKSize = 2; private int maxIterations = 3; private int teamSize = 4; private int searchWidth = 5; private int minIterations = 6; private int threadBlockSize = 7; - private int hashmapMinBitlen = 8; + private int hashMapMinBitlen = 8; private int numRandomSamplings = 10; - private float hashmapMaxFillRate = 9.0f; - private long randXorMask = 11L; - private CuvsCagraSearchAlgo cuvsCagraSearchAlgo = CuvsCagraSearchAlgo.MULTI_KERNEL; - private CuvsCagraHashMapMode cuvsCagraHashMode = CuvsCagraHashMapMode.AUTO_HASH; + private float hashMapMaxFillRate = 9.0f; + private long randXORMask = 11L; + private SearchAlgo searchAlgo = SearchAlgo.MULTI_KERNEL; + private HashMapMode hashMapMode = HashMapMode.AUTO_HASH; /** * Constructs this Builder with an instance of Arena. @@ -352,11 +351,11 @@ public Builder withMaxQueries(int maxQueries) { * This is the main knob to adjust trade off between accuracy and search speed. * Higher values improve the search accuracy. * - * @param itopkSize the number of intermediate search results + * @param iTopKSize the number of intermediate search results * @return an instance of this Builder */ - public Builder withItopkSize(int itopkSize) { - this.itopkSize = itopkSize; + public Builder withItopkSize(int iTopKSize) { + this.iTopKSize = iTopKSize; return this; } @@ -374,12 +373,11 @@ public Builder withMaxIterations(int maxIterations) { /** * Sets which search implementation to use. * - * @param cuvsCagraSearchAlgo the search implementation to use + * @param cuvsCagraSearchAlgo the {@link SearchAlgo} to use * @return an instance of this Builder - * @see CuvsCagraSearchAlgo */ - public Builder withAlgo(CuvsCagraSearchAlgo cuvsCagraSearchAlgo) { - this.cuvsCagraSearchAlgo = cuvsCagraSearchAlgo; + public Builder withAlgo(SearchAlgo cuvsCagraSearchAlgo) { + this.searchAlgo = cuvsCagraSearchAlgo; return this; } @@ -431,36 +429,35 @@ public Builder withThreadBlockSize(int threadBlockSize) { } /** - * Sets the hashmap type. Auto selection when AUTO. + * Sets the hash map type. Auto selection when AUTO. * - * @param cuvsCagraHashMode the hashmap type + * @param hashMapMode the {@link HashMapMode} * @return an instance of this Builder - * @see CuvsCagraHashMapMode */ - public Builder withHashmapMode(CuvsCagraHashMapMode cuvsCagraHashMode) { - this.cuvsCagraHashMode = cuvsCagraHashMode; + public Builder withHashMapMode(HashMapMode hashMapMode) { + this.hashMapMode = hashMapMode; return this; } /** - * Sets the lower limit of hashmap bit length. More than 8. + * Sets the lower limit of hash map bit length. More than 8. * - * @param hashmapMinBitlen the lower limit of hashmap bit length + * @param hashMapMinBitlen the lower limit of hash map bit length * @return an instance of this Builder */ - public Builder withHashmapMinBitlen(int hashmapMinBitlen) { - this.hashmapMinBitlen = hashmapMinBitlen; + public Builder withHashMapMinBitlen(int hashMapMinBitlen) { + this.hashMapMinBitlen = hashMapMinBitlen; return this; } /** - * Sets the upper limit of hashmap fill rate. More than 0.1, less than 0.9. + * Sets the upper limit of hash map fill rate. More than 0.1, less than 0.9. * - * @param hashmapMaxFillRate the upper limit of hashmap fill rate + * @param hashMapMaxFillRate the upper limit of hash map fill rate * @return an instance of this Builder */ - public Builder withHashmapMaxFillRate(float hashmapMaxFillRate) { - this.hashmapMaxFillRate = hashmapMaxFillRate; + public Builder withHashMapMaxFillRate(float hashMapMaxFillRate) { + this.hashMapMaxFillRate = hashMapMaxFillRate; return this; } @@ -480,23 +477,23 @@ public Builder withNumRandomSamplings(int numRandomSamplings) { /** * Sets the bit mask used for initial random seed node selection. * - * @param randXorMask the bit mask used for initial random seed node selection + * @param randXORMask the bit mask used for initial random seed node selection * @return an instance of this Builder */ - public Builder withRandXorMask(long randXorMask) { - this.randXorMask = randXorMask; + public Builder withRandXorMask(long randXORMask) { + this.randXORMask = randXORMask; return this; } /** - * Builds an instance of CagraSearchParams with passed search parameters. + * Builds an instance of {@link CagraSearchParams} with passed search parameters. * * @return an instance of CagraSearchParams */ public CagraSearchParams build() { - return new CagraSearchParams(arena, maxQueries, itopkSize, maxIterations, cuvsCagraSearchAlgo, teamSize, - searchWidth, minIterations, threadBlockSize, cuvsCagraHashMode, hashmapMinBitlen, hashmapMaxFillRate, - numRandomSamplings, randXorMask); + return new CagraSearchParams(arena, maxQueries, iTopKSize, maxIterations, searchAlgo, teamSize, + searchWidth, minIterations, threadBlockSize, hashMapMode, hashMapMinBitlen, hashMapMaxFillRate, + numRandomSamplings, randXORMask); } } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java similarity index 62% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java index 911c9f09a..78b74d3eb 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/SearchResult.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java @@ -25,39 +25,25 @@ import java.util.List; import java.util.Map; +import com.nvidia.cuvs.common.SearchResults; + /** * SearchResult encapsulates the logic for reading and holding search results. * * @since 24.12 */ -public class SearchResult { +public class CagraSearchResults implements SearchResults { - private List> results; - private Map mapping; - private SequenceLayout neighboursSequenceLayout; - private SequenceLayout distancesSequenceLayout; - private MemorySegment neighboursMemorySegment; - private MemorySegment distancesMemorySegment; - private int topK; - private int numberOfQueries; + private final List> results; + private final Map mapping; // TODO: Is this performant in a user application? + private final SequenceLayout neighboursSequenceLayout; + private final SequenceLayout distancesSequenceLayout; + private final MemorySegment neighboursMemorySegment; + private final MemorySegment distancesMemorySegment; + private final int topK; + private final int numberOfQueries; - /** - * Constructor that initializes SearchResult with neighboursSequenceLayout, - * distancesSequenceLayout, neighboursMemorySegment, distancesMemorySegment, - * topK, mapping, and numberOfQueries. - * - * @param neighboursSequenceLayout neighbor SequenceLayout instance - * @param distancesSequenceLayout distance SequenceLayout instance - * @param neighboursMemorySegment neighbor MemorySegment instance - * @param distancesMemorySegment distance MemorySegment instance - * @param topK an integer denoting the topK value - * @param mapping id mapping - * @param numberOfQueries number of queries that were initially - * submitted - * @see SequenceLayout - * @see MemorySegment - */ - public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, + protected CagraSearchResults(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, MemorySegment neighboursMemorySegment, MemorySegment distancesMemorySegment, int topK, Map mapping, int numberOfQueries) { super(); @@ -69,15 +55,12 @@ public SearchResult(SequenceLayout neighboursSequenceLayout, SequenceLayout dist this.distancesMemorySegment = distancesMemorySegment; this.mapping = mapping; results = new LinkedList>(); - this.readResultMemorySegments(); + + readResultMemorySegments(); } /** - * Reads neighbors and distances MemorySegments and load values in a List of - * Maps. - * - * @see MemorySegment - * @see VarHandle + * Reads neighbors and distances {@link MemorySegment} and loads the values internally */ private void readResultMemorySegments() { VarHandle neighboursVarHandle = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); @@ -99,10 +82,11 @@ private void readResultMemorySegments() { } /** - * Gets a list of maps containing topK ID and distances. + * Gets a list results as a map of neighbor IDs to distances. * - * @return a list of maps + * @return a list of results for each query as a map of neighbor IDs to distance */ + @Override public List> getResults() { return results; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java deleted file mode 100644 index 4d985c9d0..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/PreFilter.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023-2024, 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.cagra; - -/** - * Pending Implementation - * - * @since 24.12 - */ -public class PreFilter { - - /** - * Default constructor - */ - public PreFilter() { - } - -} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java new file mode 100644 index 000000000..c2d00091a --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023-2024, 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.cagra; + +import java.lang.foreign.Arena; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.MemoryLayout.PathElement; +import java.lang.invoke.VarHandle; + +public class Util { + /** + * A utility method for getting an instance of {@link MemorySegment} for a {@link String}. + * + * @param str the string for the expected {@link MemorySegment} + * @return an instance of {@link MemorySegment} + */ + protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { + StringBuilder sb = new StringBuilder(str).append('\0'); + MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), + linker.canonicalLayouts().get("char")); + MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); + + for (int i = 0; i < sb.length(); i++) { + VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); + varHandle.set(stringMemorySegment, 0L, (byte) sb.charAt(i)); + } + return stringMemorySegment; + } + + /** + * A utility method for building a {@link MemorySegment} for a 2D float array. + * + * @param data The 2D float array for which the {@link MemorySegment} is needed + * @return an instance of {@link MemorySegment} + */ + protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { + long rows = data.length; + long cols = data[0].length; + + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, + MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); + MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); + + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), + PathElement.sequenceElement(c)); + element.set(dataMemorySegment, 0, 0, data[r][c]); + } + } + + return dataMemorySegment; + } + + +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java similarity index 69% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java index 42ed42a1a..59f7f942e 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs.common; import java.io.File; import java.lang.foreign.Arena; @@ -27,22 +27,20 @@ import java.lang.invoke.MethodHandle; /** - * CuVSResources has the logic to initialize and hold the reference to CuVS - * Resources instance. + * Used for allocating resources for cuVS * * @since 24.12 */ public class CuVSResources { - private Arena arena; - private Linker linker; - private SymbolLookup symbolLookup; - private MethodHandle createResourcesMethodHandle; - private MemorySegment cuvsResourcesMemorySegment; + private final Arena arena; + private final Linker linker; + private final SymbolLookup symbolLookup; + private final MethodHandle createResourceMethodHandle; + private final MemorySegment memorySegment; /** - * Constructor for CuVSResources that initializes MethodHandle and invokes the - * native create_resource function via Panama API. + * Constructor that allocates the resources needed for cuVS * * @throws Throwable exception thrown when native function is invoked */ @@ -51,15 +49,16 @@ public CuVSResources() throws Throwable { arena = Arena.ofConfined(); File workingDirectory = new File(System.getProperty("user.dir")); + // TODO Remove hardcoding, also load from .jar symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - createResourcesMethodHandle = linker.downcallHandle(symbolLookup.find("create_resource").get(), + createResourceMethodHandle = linker.downcallHandle(symbolLookup.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - cuvsResourcesMemorySegment = (MemorySegment) createResourcesMethodHandle.invokeExact(returnValueMemorySegment); + memorySegment = (MemorySegment) createResourceMethodHandle.invokeExact(returnValueMemorySegment); } /** @@ -67,7 +66,8 @@ public CuVSResources() throws Throwable { * * @return cuvsResources MemorySegment */ - public MemorySegment getCuvsResourcesMemorySegment() { - return cuvsResourcesMemorySegment; + public MemorySegment getMemorySegment() { + // TODO: Is there a way to not letting a memory segment leak into the public API? + return memorySegment; } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java new file mode 100644 index 000000000..ae8fa6a23 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java @@ -0,0 +1,14 @@ +package com.nvidia.cuvs.common; + +import java.util.List; +import java.util.Map; + +public interface SearchResults { + + /** + * Gets a list results as a map of neighbor IDs to distances. + * + * @return a list of results for each query as a map of neighbor IDs to distance + */ + public List> getResults(); +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java similarity index 99% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java index 022793289..73b02f40d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java @@ -37,9 +37,9 @@ * } * } */ -public class cuvsCagraIndexParams { +public class CuVSCagraIndexParams { - cuvsCagraIndexParams() { + CuVSCagraIndexParams() { // Should not be called directly } diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index e4d9df120..cdc34c255 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -22,6 +22,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; +import java.lang.invoke.MethodHandles; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -33,14 +34,14 @@ import com.nvidia.cuvs.cagra.CagraIndex; import com.nvidia.cuvs.cagra.CagraIndexParams; +import com.nvidia.cuvs.cagra.CagraQuery; import com.nvidia.cuvs.cagra.CagraSearchParams; -import com.nvidia.cuvs.cagra.CuVSQuery; -import com.nvidia.cuvs.cagra.CuVSResources; -import com.nvidia.cuvs.cagra.SearchResult; +import com.nvidia.cuvs.common.CuVSResources; +import com.nvidia.cuvs.common.SearchResults; public class CagraBuildAndSearchTest { - private static Logger logger = LoggerFactory.getLogger(CagraBuildAndSearchTest.class); + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); /** * A basic test that checks the whole flow - from indexing to search. @@ -63,30 +64,27 @@ public void testIndexingAndSearchingFlow() throws Throwable { Map.of(1, 0.15224178f, 0, 0.59063464f, 3, 0.5986642f)); // Create resource - CuVSResources cuvsResources = new CuVSResources(); + CuVSResources resources = new CuVSResources(); // Configure index parameters - CagraIndexParams cagraIndexParameters = new CagraIndexParams - .Builder() - .withCuvsCagraGraphBuildAlgo(CagraIndexParams.CuvsCagraGraphBuildAlgo.NN_DESCENT) + CagraIndexParams indexParams = new CagraIndexParams.Builder() + .withCagraGraphBuildAlgo(CagraIndexParams.CagraGraphBuildAlgo.NN_DESCENT) .build(); // Create the index with the dataset - CagraIndex cagraIndex = new CagraIndex - .Builder(cuvsResources) + CagraIndex index = new CagraIndex.Builder(resources) .withDataset(dataset) - .withIndexParams(cagraIndexParameters) + .withIndexParams(indexParams) .build(); // Saving the index on to the disk. String indexFileName = UUID.randomUUID().toString() + ".cag"; - cagraIndex.serialize(new FileOutputStream(indexFileName)); + index.serialize(new FileOutputStream(indexFileName)); // Loading a CAGRA index from disk. File testSerializedIndexFile = new File(indexFileName); InputStream inputStream = new FileInputStream(testSerializedIndexFile); - CagraIndex deserializedCagraIndex = new CagraIndex - .Builder(cuvsResources) + CagraIndex loadedIndex = new CagraIndex.Builder(resources) .from(inputStream) .build(); @@ -96,7 +94,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { .build(); // Create a query object with the query vectors - CuVSQuery cuvsQuery = new CuVSQuery + CagraQuery cuvsQuery = new CagraQuery .Builder() .withTopK(3) .withSearchParams(cagraSearchParameters) @@ -105,18 +103,18 @@ public void testIndexingAndSearchingFlow() throws Throwable { .build(); // Perform the search - SearchResult searchResults = cagraIndex.search(cuvsQuery); + SearchResults results = index.search(cuvsQuery); // Check results - logger.info(searchResults.getResults().toString()); - assertEquals(expectedQueryResults, searchResults.getResults(), "Results different than expected"); + log.info(results.getResults().toString()); + assertEquals(expectedQueryResults, results.getResults(), "Results different than expected"); // Search from deserialized index - SearchResult searchResultsFromDeserializedCagraIndex = deserializedCagraIndex.search(cuvsQuery); + results = loadedIndex.search(cuvsQuery); // Check results - logger.info(searchResults.getResults().toString()); - assertEquals(expectedQueryResults, searchResultsFromDeserializedCagraIndex.getResults(), "Results different than expected"); + log.info(results.getResults().toString()); + assertEquals(expectedQueryResults, results.getResults(), "Results different than expected"); // Cleanup if (testSerializedIndexFile.exists()) { From b95bb7fe9a69b9549d3483c35d67575481478852 Mon Sep 17 00:00:00 2001 From: ishan Date: Sun, 17 Nov 2024 21:30:19 +0530 Subject: [PATCH 32/53] Loading the .so file from the jar instead of a hardcoded path --- .../com/nvidia/cuvs/cagra/CagraIndex.java | 46 +++++++++---------- .../com/nvidia/cuvs/common/CuVSResources.java | 16 +++++-- .../nvidia/cuvs/{cagra => common}/Util.java | 43 +++++++++++++++-- 3 files changed, 74 insertions(+), 31 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => common}/Util.java (62%) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java index 45cfd86da..7ff7fc8d2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.foreign.Arena; @@ -33,6 +34,7 @@ import java.util.UUID; import com.nvidia.cuvs.common.CuVSResources; +import com.nvidia.cuvs.common.Util; import com.nvidia.cuvs.panama.cuvsCagraIndex; /** @@ -49,65 +51,63 @@ public class CagraIndex { private final float[][] dataset; - private final CuVSResources cuvsResources; + private final CuVSResources resources; private Arena arena; private Linker linker; private MethodHandle indexMethodHandle; private MethodHandle searchMethodHandle; private MethodHandle serializeMethodHandle; private MethodHandle deserializeMethodHandle; - private SymbolLookup symbolLookup; private CagraIndexParams cagraIndexParameters; private IndexReference cagraIndexReference; /* * Constructor for building the index using specified dataset */ - private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources cuvsResources) + private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources resources) throws Throwable { this.cagraIndexParameters = indexParameters; this.dataset = dataset; - this.initializeMethodHandles(); - this.cuvsResources = cuvsResources; + this.resources = resources; + + initializeMethodHandles(); this.cagraIndexReference = build(); } /** * Constructor for loading the index from an {@link InputStream} */ - private CagraIndex(InputStream inputStream, CuVSResources cuvsResources) throws Throwable { + private CagraIndex(InputStream inputStream, CuVSResources resources) throws Throwable { this.cagraIndexParameters = null; this.dataset = null; - this.cuvsResources = cuvsResources; - this.initializeMethodHandles(); + this.resources = resources; + + initializeMethodHandles(); this.cagraIndexReference = deserialize(inputStream); } /** * Initializes the {@link MethodHandles} for invoking native methods. + * @throws IOException @{@link IOException} is unable to load the native library */ - private void initializeMethodHandles() { + private void initializeMethodHandles() throws IOException { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); - File workingDirectory = new File(System.getProperty("user.dir")); - symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); - - indexMethodHandle = linker.downcallHandle(symbolLookup.find("build_cagra_index").get(), + indexMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("build_cagra_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - searchMethodHandle = linker.downcallHandle(symbolLookup.find("search_cagra_index").get(), + searchMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMethodHandle = linker.downcallHandle(symbolLookup.find("serialize_cagra_index").get(), + serializeMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("serialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMethodHandle = linker.downcallHandle(symbolLookup.find("deserialize_cagra_index").get(), + deserializeMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("deserialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } /** @@ -123,7 +123,7 @@ private IndexReference build() throws Throwable { MemorySegment segment = arena.allocate(layout); cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( - Util.buildMemorySegment(linker, arena, dataset), rows, cols, cuvsResources.getMemorySegment(), segment, + Util.buildMemorySegment(linker, arena, dataset), rows, cols, resources.getMemorySegment(), segment, cagraIndexParameters.getMemorySegment())); return cagraIndexReference; @@ -147,7 +147,7 @@ public CagraSearchResults search(CagraQuery query) throws Throwable { searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), 4L, 2L, - cuvsResources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, + resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, @@ -174,7 +174,7 @@ public void serialize(OutputStream outputStream) throws Throwable { public void serialize(OutputStream outputStream, File tempFile) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - serializeMethodHandle.invokeExact(cuvsResources.getMemorySegment(), + serializeMethodHandle.invokeExact(resources.getMemorySegment(), cagraIndexReference.getMemorySegment(), returnValueMemorySegment, Util.buildMemorySegment(linker, arena, tempFile.getAbsolutePath())); FileInputStream fileInputStream = new FileInputStream(tempFile); @@ -207,7 +207,7 @@ private IndexReference deserialize(InputStream inputStream) throws Throwable { while ((chunkLength = inputStream.read(chunk)) != -1) { fileOutputStream.write(chunk, 0, chunkLength); } - deserializeMethodHandle.invokeExact(cuvsResources.getMemorySegment(), + deserializeMethodHandle.invokeExact(resources.getMemorySegment(), indexReference.getMemorySegment(), returnValueMemorySegment, Util.buildMemorySegment(linker, arena, tmpIndexFile)); @@ -233,7 +233,7 @@ public CagraIndexParams getCagraIndexParameters() { * @return an instance of {@link CuVSResources} */ public CuVSResources getCuVSResources() { - return cuvsResources; + return resources; } /** @@ -308,7 +308,7 @@ public CagraIndex build() throws Throwable { */ protected static class IndexReference { - private MemorySegment memorySegment; + private final MemorySegment memorySegment; /** * Constructs CagraIndexReference and allocate the MemorySegment. diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java index 59f7f942e..b63bac8e0 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java @@ -35,7 +35,7 @@ public class CuVSResources { private final Arena arena; private final Linker linker; - private final SymbolLookup symbolLookup; + private final SymbolLookup libcuvsNativeLibrary; private final MethodHandle createResourceMethodHandle; private final MemorySegment memorySegment; @@ -48,11 +48,10 @@ public CuVSResources() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofConfined(); - File workingDirectory = new File(System.getProperty("user.dir")); - // TODO Remove hardcoding, also load from .jar - symbolLookup = SymbolLookup.libraryLookup(workingDirectory.getParent() + "/internal/libcuvs_java.so", arena); + File nativeLibrary = Util.loadLibraryFromJar("/libcuvs_java.so"); + libcuvsNativeLibrary = SymbolLookup.libraryLookup(nativeLibrary.getAbsolutePath(), arena); - createResourceMethodHandle = linker.downcallHandle(symbolLookup.find("create_resource").get(), + createResourceMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("create_resource").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); @@ -70,4 +69,11 @@ public MemorySegment getMemorySegment() { // TODO: Is there a way to not letting a memory segment leak into the public API? return memorySegment; } + + /** + * Returns the loaded libcuvs_java.so as a {@link SymbolLookup} + */ + public SymbolLookup getLibcuvsNativeLibrary() { + return libcuvsNativeLibrary; + } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java similarity index 62% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java index c2d00091a..23b490abd 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/Util.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java @@ -14,14 +14,25 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs.common; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.lang.foreign.Arena; import java.lang.foreign.Linker; import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemorySegment; import java.lang.foreign.MemoryLayout.PathElement; import java.lang.invoke.VarHandle; +import java.nio.file.FileSystemNotFoundException; +import java.nio.file.FileSystems; +import java.nio.file.ProviderNotFoundException; + +import org.apache.commons.io.IOUtils; public class Util { /** @@ -30,7 +41,7 @@ public class Util { * @param str the string for the expected {@link MemorySegment} * @return an instance of {@link MemorySegment} */ - protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { + public static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { StringBuilder sb = new StringBuilder(str).append('\0'); MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), linker.canonicalLayouts().get("char")); @@ -49,7 +60,7 @@ protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, St * @param data The 2D float array for which the {@link MemorySegment} is needed * @return an instance of {@link MemorySegment} */ - protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { + public static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { long rows = data.length; long cols = data[0].length; @@ -68,5 +79,31 @@ protected static MemorySegment buildMemorySegment(Linker linker, Arena arena, fl return dataMemorySegment; } + /** + * Load a file from the classpath to a temporary file. Suitable for loading .so files from the jar. + */ + public static File loadLibraryFromJar(String path) throws IOException { + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path has to be absolute (start with '/')."); + } + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + + // Split filename to prefix and suffix (extension) + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = (parts.length > 1) ? "." + parts[parts.length - 1] : null; + } + // Prepare temporary file + File temp = File.createTempFile(prefix, suffix); + IOUtils.copy(Util.class.getResourceAsStream(path), new FileOutputStream(temp)); + + return temp; + } + } From 9ab27549861b99f8322cbefe7656316d7a5e0872 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Sun, 17 Nov 2024 15:24:17 -0500 Subject: [PATCH 33/53] package renaming and formatting --- .../nvidia/cuvs/{cagra => }/CagraIndex.java | 78 ++++++----- .../cuvs/{cagra => }/CagraIndexParams.java | 2 +- .../nvidia/cuvs/{cagra => }/CagraQuery.java | 14 +- .../cuvs/{cagra => }/CagraSearchParams.java | 2 +- .../cuvs/{cagra => }/CagraSearchResults.java | 7 +- .../com/nvidia/cuvs/common/CuVSResources.java | 5 +- .../com/nvidia/cuvs/common/SearchResults.java | 12 +- .../java/com/nvidia/cuvs/common/Util.java | 132 +++++++++--------- .../cuvs/{ => examples}/CagraExample.java | 12 +- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 26 ++-- 10 files changed, 143 insertions(+), 147 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraIndex.java (86%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraIndexParams.java (99%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraQuery.java (94%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraSearchParams.java (99%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{cagra => }/CagraSearchResults.java (98%) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{ => examples}/CagraExample.java (91%) diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java similarity index 86% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java index 7ff7fc8d2..0bac413cb 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.io.File; import java.io.FileInputStream; @@ -28,9 +28,9 @@ import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; -import java.lang.foreign.SymbolLookup; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; import java.util.UUID; import com.nvidia.cuvs.common.CuVSResources; @@ -38,7 +38,8 @@ import com.nvidia.cuvs.panama.cuvsCagraIndex; /** - * {@link CagraIndex} encapsulates a CAGRA index, along with methods to interact with it. + * {@link CagraIndex} encapsulates a CAGRA index, along with methods to interact + * with it. *

* CAGRA is a graph-based nearest neighbors algorithm that was built from the * ground up for GPU acceleration. CAGRA demonstrates state-of-the art index @@ -62,10 +63,9 @@ public class CagraIndex { private IndexReference cagraIndexReference; /* - * Constructor for building the index using specified dataset + * Constructor for building the index using specified dataset */ - private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources resources) - throws Throwable { + private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources resources) throws Throwable { this.cagraIndexParameters = indexParameters; this.dataset = dataset; this.resources = resources; @@ -81,14 +81,15 @@ private CagraIndex(InputStream inputStream, CuVSResources resources) throws Thro this.cagraIndexParameters = null; this.dataset = null; this.resources = resources; - + initializeMethodHandles(); this.cagraIndexReference = deserialize(inputStream); } /** * Initializes the {@link MethodHandles} for invoking native methods. - * @throws IOException @{@link IOException} is unable to load the native library + * + * @throws IOException @{@link IOException} is unable to load the native library */ private void initializeMethodHandles() throws IOException { linker = Linker.nativeLinker(); @@ -103,15 +104,18 @@ private void initializeMethodHandles() throws IOException { linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - serializeMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("serialize_cagra_index").get(), + serializeMethodHandle = linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("serialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - deserializeMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("deserialize_cagra_index").get(), + deserializeMethodHandle = linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("deserialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } /** - * Invokes the native build_index function via the Panama API to build the {@link CagraIndex} + * Invokes the native build_index function via the Panama API to build the + * {@link CagraIndex} * * @return an instance of {@link IndexReference} that holds the pointer to the * index @@ -122,9 +126,9 @@ private IndexReference build() throws Throwable { MemoryLayout layout = linker.canonicalLayouts().get("int"); MemorySegment segment = arena.allocate(layout); - cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( - Util.buildMemorySegment(linker, arena, dataset), rows, cols, resources.getMemorySegment(), segment, - cagraIndexParameters.getMemorySegment())); + cagraIndexReference = new IndexReference( + (MemorySegment) indexMethodHandle.invokeExact(Util.buildMemorySegment(linker, arena, dataset), rows, cols, + resources.getMemorySegment(), segment, cagraIndexParameters.getMemorySegment())); return cagraIndexReference; } @@ -133,8 +137,8 @@ private IndexReference build() throws Throwable { * Invokes the native search_index via the Panama API for searching a CAGRA * index. * - * @param query an instance of {@link CagraQuery} holding the query vectors and other - * parameters + * @param query an instance of {@link CagraQuery} holding the query vectors and + * other parameters * @return an instance of {@link CagraSearchResults} containing the results */ public CagraSearchResults search(CagraQuery query) throws Throwable { @@ -147,36 +151,38 @@ public CagraSearchResults search(CagraQuery query) throws Throwable { searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), 4L, 2L, - resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, - returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); + resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, returnValueMemorySegment, + query.getCagraSearchParameters().getMemorySegment()); return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, distancesMemorySegment, query.getTopK(), query.getMapping(), query.getQueryVectors().length); } /** - * A method to persist a CAGRA index using an instance of {@link OutputStream} for - * writing index bytes. + * A method to persist a CAGRA index using an instance of {@link OutputStream} + * for writing index bytes. * - * @param outputStream an instance of {@link OutputStream} to write the index bytes into + * @param outputStream an instance of {@link OutputStream} to write the index + * bytes into */ public void serialize(OutputStream outputStream) throws Throwable { - serialize(outputStream, File.createTempFile(UUID.randomUUID().toString(), ".cag")); + serialize(outputStream, File.createTempFile(UUID.randomUUID().toString(), ".cag")); } /** - * A method to persist a CAGRA index using an instance of {@link OutputStream} and path - * to the intermediate temporary file. + * A method to persist a CAGRA index using an instance of {@link OutputStream} + * and path to the intermediate temporary file. * - * @param outputStream an instance of {@link OutputStream} to write the index bytes to - * @param tmpFilePath an intermediate {@link File} where CAGRA index is written temporarily + * @param outputStream an instance of {@link OutputStream} to write the index + * bytes to + * @param tmpFilePath an intermediate {@link File} where CAGRA index is written + * temporarily */ public void serialize(OutputStream outputStream, File tempFile) throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); - serializeMethodHandle.invokeExact(resources.getMemorySegment(), - cagraIndexReference.getMemorySegment(), returnValueMemorySegment, - Util.buildMemorySegment(linker, arena, tempFile.getAbsolutePath())); + serializeMethodHandle.invokeExact(resources.getMemorySegment(), cagraIndexReference.getMemorySegment(), + returnValueMemorySegment, Util.buildMemorySegment(linker, arena, tempFile.getAbsolutePath())); FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; // TODO: Make this configurable int chunkLength = 0; @@ -188,8 +194,8 @@ public void serialize(OutputStream outputStream, File tempFile) throws Throwable } /** - * Gets an instance of {@link IndexReference} by deserializing a CAGRA index using - * an {@link InputStream}. + * Gets an instance of {@link IndexReference} by deserializing a CAGRA index + * using an {@link InputStream}. * * @param inputStream an instance of {@link InputStream} * @return an instance of {@link IndexReference}. @@ -207,9 +213,8 @@ private IndexReference deserialize(InputStream inputStream) throws Throwable { while ((chunkLength = inputStream.read(chunk)) != -1) { fileOutputStream.write(chunk, 0, chunkLength); } - deserializeMethodHandle.invokeExact(resources.getMemorySegment(), - indexReference.getMemorySegment(), returnValueMemorySegment, - Util.buildMemorySegment(linker, arena, tmpIndexFile)); + deserializeMethodHandle.invokeExact(resources.getMemorySegment(), indexReference.getMemorySegment(), + returnValueMemorySegment, Util.buildMemorySegment(linker, arena, tmpIndexFile)); inputStream.close(); fileOutputStream.close(); @@ -279,7 +284,8 @@ public Builder withDataset(float[][] dataset) { } /** - * Registers an instance of configured {@link CagraIndexParams} with this Builder. + * Registers an instance of configured {@link CagraIndexParams} with this + * Builder. * * @param cagraIndexParameters An instance of CagraIndexParams. * @return An instance of this Builder. @@ -302,7 +308,7 @@ public CagraIndex build() throws Throwable { } } } - + /** * Holds the memory reference to an index. */ diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java similarity index 99% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java index 118f1e387..dd8fa6329 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndexParams.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java similarity index 94% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java index e5b9d7cff..ac42a4559 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.util.Arrays; import java.util.Map; @@ -33,18 +33,18 @@ public class CagraQuery { private int topK; /** - * Constructs an instance of {@link CagraQuery} using cagraSearchParameters, preFilter, - * queryVectors, mapping, and topK. + * Constructs an instance of {@link CagraQuery} using cagraSearchParameters, + * preFilter, queryVectors, mapping, and topK. * - * @param cagraSearchParameters an instance of {@link CagraSearchParams} holding the - * search parameters + * @param cagraSearchParameters an instance of {@link CagraSearchParams} holding + * the search parameters * @param preFilter an instance of PreFilter * @param queryVectors 2D float query vector array * @param mapping an instance of ID mapping * @param topK the top k results to return */ - public CagraQuery(CagraSearchParams cagraSearchParameters, float[][] queryVectors, - Map mapping, int topK) { + public CagraQuery(CagraSearchParams cagraSearchParameters, float[][] queryVectors, Map mapping, + int topK) { super(); this.cagraSearchParameters = cagraSearchParameters; this.queryVectors = queryVectors; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java similarity index 99% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java index 51ad1b8b2..14abd08dd 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java similarity index 98% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java index 78b74d3eb..6fe581964 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/cagra/CagraSearchResults.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.cagra; +package com.nvidia.cuvs; import java.lang.foreign.MemoryLayout.PathElement; import java.lang.foreign.MemorySegment; @@ -55,12 +55,13 @@ protected CagraSearchResults(SequenceLayout neighboursSequenceLayout, SequenceLa this.distancesMemorySegment = distancesMemorySegment; this.mapping = mapping; results = new LinkedList>(); - + readResultMemorySegments(); } /** - * Reads neighbors and distances {@link MemorySegment} and loads the values internally + * Reads neighbors and distances {@link MemorySegment} and loads the values + * internally */ private void readResultMemorySegments() { VarHandle neighboursVarHandle = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java index b63bac8e0..026aa4146 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java @@ -66,7 +66,8 @@ public CuVSResources() throws Throwable { * @return cuvsResources MemorySegment */ public MemorySegment getMemorySegment() { - // TODO: Is there a way to not letting a memory segment leak into the public API? + // TODO: Is there a way to not letting a memory segment leak into the public + // API? return memorySegment; } @@ -74,6 +75,6 @@ public MemorySegment getMemorySegment() { * Returns the loaded libcuvs_java.so as a {@link SymbolLookup} */ public SymbolLookup getLibcuvsNativeLibrary() { - return libcuvsNativeLibrary; + return libcuvsNativeLibrary; } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java index ae8fa6a23..9561e304b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/SearchResults.java @@ -5,10 +5,10 @@ public interface SearchResults { - /** - * Gets a list results as a map of neighbor IDs to distances. - * - * @return a list of results for each query as a map of neighbor IDs to distance - */ - public List> getResults(); + /** + * Gets a list results as a map of neighbor IDs to distances. + * + * @return a list of results for each query as a map of neighbor IDs to distance + */ + public List> getResults(); } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java index 23b490abd..0c47436a0 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java @@ -17,93 +17,87 @@ package com.nvidia.cuvs.common; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.lang.foreign.Arena; import java.lang.foreign.Linker; import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; import java.lang.foreign.MemoryLayout.PathElement; +import java.lang.foreign.MemorySegment; import java.lang.invoke.VarHandle; -import java.nio.file.FileSystemNotFoundException; -import java.nio.file.FileSystems; -import java.nio.file.ProviderNotFoundException; import org.apache.commons.io.IOUtils; public class Util { - /** - * A utility method for getting an instance of {@link MemorySegment} for a {@link String}. - * - * @param str the string for the expected {@link MemorySegment} - * @return an instance of {@link MemorySegment} - */ - public static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { - StringBuilder sb = new StringBuilder(str).append('\0'); - MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), - linker.canonicalLayouts().get("char")); - MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); - - for (int i = 0; i < sb.length(); i++) { - VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); - varHandle.set(stringMemorySegment, 0L, (byte) sb.charAt(i)); - } - return stringMemorySegment; - } + /** + * A utility method for getting an instance of {@link MemorySegment} for a + * {@link String}. + * + * @param str the string for the expected {@link MemorySegment} + * @return an instance of {@link MemorySegment} + */ + public static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { + StringBuilder sb = new StringBuilder(str).append('\0'); + MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), linker.canonicalLayouts().get("char")); + MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); - /** - * A utility method for building a {@link MemorySegment} for a 2D float array. - * - * @param data The 2D float array for which the {@link MemorySegment} is needed - * @return an instance of {@link MemorySegment} - */ - public static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { - long rows = data.length; - long cols = data[0].length; + for (int i = 0; i < sb.length(); i++) { + VarHandle varHandle = stringMemoryLayout.varHandle(PathElement.sequenceElement(i)); + varHandle.set(stringMemorySegment, 0L, (byte) sb.charAt(i)); + } + return stringMemorySegment; + } - MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, - MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); - MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); + /** + * A utility method for building a {@link MemorySegment} for a 2D float array. + * + * @param data The 2D float array for which the {@link MemorySegment} is needed + * @return an instance of {@link MemorySegment} + */ + public static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { + long rows = data.length; + long cols = data[0].length; - for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), - PathElement.sequenceElement(c)); - element.set(dataMemorySegment, 0, 0, data[r][c]); - } - } + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, + MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); + MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); - return dataMemorySegment; - } + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), + PathElement.sequenceElement(c)); + element.set(dataMemorySegment, 0, 0, data[r][c]); + } + } - /** - * Load a file from the classpath to a temporary file. Suitable for loading .so files from the jar. - */ - public static File loadLibraryFromJar(String path) throws IOException { - if (!path.startsWith("/")) { - throw new IllegalArgumentException("The path has to be absolute (start with '/')."); - } - // Obtain filename from path - String[] parts = path.split("/"); - String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + return dataMemorySegment; + } - // Split filename to prefix and suffix (extension) - String prefix = ""; - String suffix = null; - if (filename != null) { - parts = filename.split("\\.", 2); - prefix = parts[0]; - suffix = (parts.length > 1) ? "." + parts[parts.length - 1] : null; - } - // Prepare temporary file - File temp = File.createTempFile(prefix, suffix); - IOUtils.copy(Util.class.getResourceAsStream(path), new FileOutputStream(temp)); + /** + * Load a file from the classpath to a temporary file. Suitable for loading .so + * files from the jar. + */ + public static File loadLibraryFromJar(String path) throws IOException { + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path has to be absolute (start with '/')."); + } + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; - return temp; - } + // Split filename to prefix and suffix (extension) + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = (parts.length > 1) ? "." + parts[parts.length - 1] : null; + } + // Prepare temporary file + File temp = File.createTempFile(prefix, suffix); + IOUtils.copy(Util.class.getResourceAsStream(path), new FileOutputStream(temp)); + return temp; + } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java similarity index 91% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java index bb8e1d978..8fd03777b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraExample.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs; +package com.nvidia.cuvs.examples; import java.io.File; import java.io.FileInputStream; @@ -25,13 +25,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.nvidia.cuvs.cagra.CagraIndex; -import com.nvidia.cuvs.cagra.CagraIndexParams; -import com.nvidia.cuvs.cagra.CagraIndexParams.CagraGraphBuildAlgo; +import com.nvidia.cuvs.CagraIndex; +import com.nvidia.cuvs.CagraIndexParams; +import com.nvidia.cuvs.CagraQuery; +import com.nvidia.cuvs.CagraSearchParams; +import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.SearchResults; -import com.nvidia.cuvs.cagra.CagraSearchParams; -import com.nvidia.cuvs.cagra.CagraQuery; public class CagraExample { diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index cdc34c255..e41f68026 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -32,10 +32,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.nvidia.cuvs.cagra.CagraIndex; -import com.nvidia.cuvs.cagra.CagraIndexParams; -import com.nvidia.cuvs.cagra.CagraQuery; -import com.nvidia.cuvs.cagra.CagraSearchParams; import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.SearchResults; @@ -57,7 +53,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { float[][] queries = {{ 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f }}; // Expected search results - List> expectedQueryResults = Arrays.asList( + List> expectedResults = Arrays.asList( Map.of(3, 0.038782578f, 2, 0.3590463f, 0, 0.83774555f), Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), Map.of(3, 0.047766715f, 2, 0.20332818f, 0, 0.48305473f), @@ -82,22 +78,20 @@ public void testIndexingAndSearchingFlow() throws Throwable { index.serialize(new FileOutputStream(indexFileName)); // Loading a CAGRA index from disk. - File testSerializedIndexFile = new File(indexFileName); - InputStream inputStream = new FileInputStream(testSerializedIndexFile); + File indexFile = new File(indexFileName); + InputStream inputStream = new FileInputStream(indexFile); CagraIndex loadedIndex = new CagraIndex.Builder(resources) .from(inputStream) .build(); // Configure search parameters - CagraSearchParams cagraSearchParameters = new CagraSearchParams - .Builder() + CagraSearchParams searchParams = new CagraSearchParams.Builder() .build(); // Create a query object with the query vectors - CagraQuery cuvsQuery = new CagraQuery - .Builder() + CagraQuery cuvsQuery = new CagraQuery.Builder() .withTopK(3) - .withSearchParams(cagraSearchParameters) + .withSearchParams(searchParams) .withQueryVectors(queries) .withMapping(map) .build(); @@ -107,18 +101,18 @@ public void testIndexingAndSearchingFlow() throws Throwable { // Check results log.info(results.getResults().toString()); - assertEquals(expectedQueryResults, results.getResults(), "Results different than expected"); + assertEquals(expectedResults, results.getResults(), "Results different than expected"); // Search from deserialized index results = loadedIndex.search(cuvsQuery); // Check results log.info(results.getResults().toString()); - assertEquals(expectedQueryResults, results.getResults(), "Results different than expected"); + assertEquals(expectedResults, results.getResults(), "Results different than expected"); // Cleanup - if (testSerializedIndexFile.exists()) { - testSerializedIndexFile.delete(); + if (indexFile.exists()) { + indexFile.delete(); } } } \ No newline at end of file From 638092c5560bbd1dd8e0d02510e08c6b6716aa58 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Mon, 18 Nov 2024 00:14:57 -0500 Subject: [PATCH 34/53] moving CuVSResources + other updates --- .../main/java/com/nvidia/cuvs/CagraIndex.java | 1 - .../com/nvidia/cuvs/CagraIndexParams.java | 14 +- .../main/java/com/nvidia/cuvs/CagraQuery.java | 2 +- .../cuvs/{common => }/CuVSResources.java | 8 +- .../nvidia/cuvs/examples/CagraExample.java | 2 +- .../java/com/nvidia/cuvs/panama/results.java | 227 ------------------ .../com/nvidia/cuvs/panama/results_h.java | 99 -------- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 1 - 8 files changed, 14 insertions(+), 340 deletions(-) rename java/cuvs-java/src/main/java/com/nvidia/cuvs/{common => }/CuVSResources.java (93%) delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java 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 0bac413cb..636771b21 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 @@ -33,7 +33,6 @@ import java.lang.invoke.MethodHandles; import java.util.UUID; -import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.Util; import com.nvidia.cuvs.panama.cuvsCagraIndex; 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 dd8fa6329..ab42b2c9c 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 @@ -41,25 +41,25 @@ public class CagraIndexParams { */ public enum CagraGraphBuildAlgo { /** - * AUTO_SELECT + * Select build algorithm automatically */ AUTO_SELECT(0), /** - * IVF_PQ + * Use IVF-PQ to build all-neighbors knn graph */ IVF_PQ(1), /** - * NN_DESCENT + * Experimental, use NN-Descent to build all-neighbors knn graph */ NN_DESCENT(2); /** * The value for the enum choice. */ - public final int label; + public final int value; - private CagraGraphBuildAlgo(int label) { - this.label = label; + private CagraGraphBuildAlgo(int value) { + this.value = value; } } @@ -79,7 +79,7 @@ private MemorySegment initMemorySegment() { MemorySegment memorySegment = CuVSCagraIndexParams.allocate(arena); CuVSCagraIndexParams.intermediate_graph_degree(memorySegment, intermediateGraphDegree); CuVSCagraIndexParams.graph_degree(memorySegment, graphDegree); - CuVSCagraIndexParams.build_algo(memorySegment, cuvsCagraGraphBuildAlgo.label); + CuVSCagraIndexParams.build_algo(memorySegment, cuvsCagraGraphBuildAlgo.value); CuVSCagraIndexParams.nn_descent_niter(memorySegment, nnDescentNiter); return memorySegment; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java index ac42a4559..f9a8e5884 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java @@ -20,7 +20,7 @@ import java.util.Map; /** - * CuVSQuery holds the CagraSearchParams and the query vectors to be used while + * CagraQuery holds the CagraSearchParams and the query vectors to be used while * invoking search. * * @since 24.12 diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java similarity index 93% rename from java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java rename to java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java index 026aa4146..822f1959d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.nvidia.cuvs.common; +package com.nvidia.cuvs; import java.io.File; import java.lang.foreign.Arena; @@ -26,6 +26,8 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; +import com.nvidia.cuvs.common.Util; + /** * Used for allocating resources for cuVS * @@ -65,7 +67,7 @@ public CuVSResources() throws Throwable { * * @return cuvsResources MemorySegment */ - public MemorySegment getMemorySegment() { + protected MemorySegment getMemorySegment() { // TODO: Is there a way to not letting a memory segment leak into the public // API? return memorySegment; @@ -74,7 +76,7 @@ public MemorySegment getMemorySegment() { /** * Returns the loaded libcuvs_java.so as a {@link SymbolLookup} */ - public SymbolLookup getLibcuvsNativeLibrary() { + protected SymbolLookup getLibcuvsNativeLibrary() { return libcuvsNativeLibrary; } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java index 8fd03777b..bfb9713a4 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/examples/CagraExample.java @@ -29,8 +29,8 @@ import com.nvidia.cuvs.CagraIndexParams; import com.nvidia.cuvs.CagraQuery; import com.nvidia.cuvs.CagraSearchParams; +import com.nvidia.cuvs.CuVSResources; import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; -import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.SearchResults; public class CagraExample { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java deleted file mode 100644 index 78b81f44b..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2023-2024, 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.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang = c : - * struct results { - * int test; - * int *neighbors_h; - * float *distances_h; - * } - * } - */ -public class results { - - results() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout - .structLayout(results_h.C_INT.withName("test"), MemoryLayout.paddingLayout(4), - results_h.C_POINTER.withName("neighbors_h"), results_h.C_POINTER.withName("distances_h")) - .withName("results"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt test$LAYOUT = (OfInt) $LAYOUT.select(groupElement("test")); - - /** - * Layout for field: - * {@snippet lang = c : * int test - * } - */ - public static final OfInt test$layout() { - return test$LAYOUT; - } - - private static final long test$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang = c : * int test - * } - */ - public static final long test$offset() { - return test$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int test - * } - */ - public static int test(MemorySegment struct) { - return struct.get(test$LAYOUT, test$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int test - * } - */ - public static void test(MemorySegment struct, int fieldValue) { - struct.set(test$LAYOUT, test$OFFSET, fieldValue); - } - - private static final AddressLayout neighbors_h$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("neighbors_h")); - - /** - * Layout for field: - * {@snippet lang = c : * int *neighbors_h - * } - */ - public static final AddressLayout neighbors_h$layout() { - return neighbors_h$LAYOUT; - } - - private static final long neighbors_h$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang = c : * int *neighbors_h - * } - */ - public static final long neighbors_h$offset() { - return neighbors_h$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * int *neighbors_h - * } - */ - public static MemorySegment neighbors_h(MemorySegment struct) { - return struct.get(neighbors_h$LAYOUT, neighbors_h$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * int *neighbors_h - * } - */ - public static void neighbors_h(MemorySegment struct, MemorySegment fieldValue) { - struct.set(neighbors_h$LAYOUT, neighbors_h$OFFSET, fieldValue); - } - - private static final AddressLayout distances_h$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("distances_h")); - - /** - * Layout for field: - * {@snippet lang = c : * float *distances_h - * } - */ - public static final AddressLayout distances_h$layout() { - return distances_h$LAYOUT; - } - - private static final long distances_h$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang = c : * float *distances_h - * } - */ - public static final long distances_h$offset() { - return distances_h$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang = c : * float *distances_h - * } - */ - public static MemorySegment distances_h(MemorySegment struct) { - return struct.get(distances_h$LAYOUT, distances_h$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang = c : * float *distances_h - * } - */ - public static void distances_h(MemorySegment struct, MemorySegment fieldValue) { - struct.set(distances_h$LAYOUT, distances_h$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/java/com/nvidia/cuvs/panama/results_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java deleted file mode 100644 index de4a42082..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/results_h.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2023-2024, 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.panama; - -import static java.lang.foreign.ValueLayout.JAVA_BYTE; - -import java.lang.foreign.AddressLayout; -import java.lang.foreign.Arena; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.PaddingLayout; -import java.lang.foreign.SequenceLayout; -import java.lang.foreign.StructLayout; -import java.lang.foreign.SymbolLookup; -import java.lang.foreign.ValueLayout; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class results_h { - - results_h() { - // Should not be called directly - } - - static final Arena LIBRARY_ARENA = Arena.ofAuto(); - static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); - - static void traceDowncall(String name, Object... args) { - String traceArgs = Arrays.stream(args).map(Object::toString).collect(Collectors.joining(", ")); - System.out.printf("%s(%s)\n", name, traceArgs); - } - - static MemorySegment findOrThrow(String symbol) { - return SYMBOL_LOOKUP.find(symbol).orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); - } - - static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { - try { - return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); - } catch (ReflectiveOperationException ex) { - throw new AssertionError(ex); - } - } - - static MemoryLayout align(MemoryLayout layout, long align) { - return switch (layout) { - case PaddingLayout p -> p; - case ValueLayout v -> v.withByteAlignment(align); - case GroupLayout g -> { - MemoryLayout[] alignedMembers = g.memberLayouts().stream().map(m -> align(m, align)).toArray(MemoryLayout[]::new); - yield g instanceof StructLayout ? MemoryLayout.structLayout(alignedMembers) - : MemoryLayout.unionLayout(alignedMembers); - } - case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); - }; - } - - static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - - public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; - public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; - public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; - public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; - public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; - public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; - public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; - public static final AddressLayout C_POINTER = ValueLayout.ADDRESS - .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); - public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; - /** - * {@snippet lang = c : - * typedef struct results { - * int test; - * int *neighbors_h; - * float *distances_h; - * } *rsltp - * } - */ - public static final AddressLayout rsltp = results_h.C_POINTER; -} diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index e41f68026..29b12df1f 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -32,7 +32,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.nvidia.cuvs.common.CuVSResources; import com.nvidia.cuvs.common.SearchResults; public class CagraBuildAndSearchTest { From 51eb3974366b1b263b7f8317167c1c2c35676e05 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Mon, 18 Nov 2024 01:19:09 -0500 Subject: [PATCH 35/53] code refactoring --- .../main/java/com/nvidia/cuvs/CagraIndex.java | 17 +++++++++++------ .../com/nvidia/cuvs/CagraSearchResults.java | 4 ++-- .../java/com/nvidia/cuvs/CuVSResources.java | 2 -- .../main/java/com/nvidia/cuvs/common/Util.java | 1 - java/internal/src/cuvs_java.c | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) 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 636771b21..09d969e59 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 @@ -100,7 +100,7 @@ private void initializeMethodHandles() throws IOException { searchMethodHandle = linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, linker.canonicalLayouts().get("int"), - linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, + linker.canonicalLayouts().get("long"), linker.canonicalLayouts().get("int"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); serializeMethodHandle = linker.downcallHandle( @@ -141,20 +141,26 @@ private IndexReference build() throws Throwable { * @return an instance of {@link CagraSearchResults} containing the results */ public CagraSearchResults search(CagraQuery query) throws Throwable { - SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("int")); - SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(50, linker.canonicalLayouts().get("float")); + long numQueries = query.getQueryVectors().length; + long numBlocks = query.getTopK() * numQueries; + int vectorDimension = numQueries > 0 ? query.getQueryVectors()[0].length : 0; + + SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, + linker.canonicalLayouts().get("int")); + SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, + linker.canonicalLayouts().get("float")); MemorySegment neighborsMemorySegment = arena.allocate(neighborsSequenceLayout); MemorySegment distancesMemorySegment = arena.allocate(distancesSequenceLayout); MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), - Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), 4L, 2L, + Util.buildMemorySegment(linker, arena, query.getQueryVectors()), query.getTopK(), numQueries, vectorDimension, resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, - distancesMemorySegment, query.getTopK(), query.getMapping(), query.getQueryVectors().length); + distancesMemorySegment, query.getTopK(), query.getMapping(), numQueries); } /** @@ -343,5 +349,4 @@ protected MemorySegment getMemorySegment() { return memorySegment; } } - } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java index 6fe581964..372c1965c 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java @@ -41,11 +41,11 @@ public class CagraSearchResults implements SearchResults { private final MemorySegment neighboursMemorySegment; private final MemorySegment distancesMemorySegment; private final int topK; - private final int numberOfQueries; + private final long numberOfQueries; protected CagraSearchResults(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, MemorySegment neighboursMemorySegment, MemorySegment distancesMemorySegment, int topK, - Map mapping, int numberOfQueries) { + Map mapping, long numberOfQueries) { super(); this.topK = topK; this.numberOfQueries = numberOfQueries; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java index 822f1959d..b9fc4ba9b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java @@ -68,8 +68,6 @@ public CuVSResources() throws Throwable { * @return cuvsResources MemorySegment */ protected MemorySegment getMemorySegment() { - // TODO: Is there a way to not letting a memory segment leak into the public - // API? return memorySegment; } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java index 0c47436a0..896253dd7 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java @@ -99,5 +99,4 @@ public static File loadLibraryFromJar(String path) throws IOException { return temp; } - } diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index 06fcac6ed..aac773c1b 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -63,7 +63,7 @@ void deserialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t ind *rv = cuvsCagraDeserialize(cuvsResources, filename, index); } -void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, long dimensions, +void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, int dimensions, cuvsResources_t cuvsResources, int *neighbors_h, float *distances_h, int *returnValue, cuvsCagraSearchParams_t search_params) { uint32_t *neighbors; From fb295dd1587b0c4b99eb66773eba54c48bdc8b54 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Mon, 18 Nov 2024 02:35:13 -0500 Subject: [PATCH 36/53] javadoc maven config update and bug fixes --- java/cuvs-java/pom.xml | 2 +- java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java | 2 +- java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 41ea18ca9..644cd8bb8 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -154,7 +154,7 @@ maven-javadoc-plugin 3.6.2 - com.nvidia.cuvs,com.nvidia.cuvs.panama + com.nvidia.cuvs.examples,com.nvidia.cuvs.panama ${project.build.directory} 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 09d969e59..f9c8b0161 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 @@ -180,7 +180,7 @@ public void serialize(OutputStream outputStream) throws Throwable { * * @param outputStream an instance of {@link OutputStream} to write the index * bytes to - * @param tmpFilePath an intermediate {@link File} where CAGRA index is written + * @param tempFile an intermediate {@link File} where CAGRA index is written * temporarily */ public void serialize(OutputStream outputStream, File tempFile) throws Throwable { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java index f9a8e5884..480f598ee 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java @@ -38,7 +38,6 @@ public class CagraQuery { * * @param cagraSearchParameters an instance of {@link CagraSearchParams} holding * the search parameters - * @param preFilter an instance of PreFilter * @param queryVectors 2D float query vector array * @param mapping an instance of ID mapping * @param topK the top k results to return From 80174d216d8bb20e24411a04c462220673c6a247 Mon Sep 17 00:00:00 2001 From: Ishan Chattopadhyaya Date: Tue, 26 Nov 2024 19:03:14 +0530 Subject: [PATCH 37/53] Consolidating all Arenas and Linkers to CuVSResources, fixing copyright notices --- java/cuvs-java/pom.xml | 6 +- .../main/java/com/nvidia/cuvs/CagraIndex.java | 65 +++++++--------- .../com/nvidia/cuvs/CagraIndexParams.java | 36 +++++---- .../main/java/com/nvidia/cuvs/CagraQuery.java | 2 +- .../com/nvidia/cuvs/CagraSearchParams.java | 77 ++++++++++--------- .../com/nvidia/cuvs/CagraSearchResults.java | 2 +- .../java/com/nvidia/cuvs/CuVSResources.java | 11 +-- .../java/com/nvidia/cuvs/common/Util.java | 2 +- .../nvidia/cuvs/examples/CagraExample.java | 20 ++--- .../cuvs/panama/CuVSCagraIndexParams.java | 2 +- .../com/nvidia/cuvs/panama/DLDataType.java | 2 +- .../java/com/nvidia/cuvs/panama/DLDevice.java | 2 +- .../nvidia/cuvs/panama/DLManagedTensor.java | 2 +- .../cuvs/panama/DLManagedTensorVersioned.java | 2 +- .../com/nvidia/cuvs/panama/DLPackVersion.java | 2 +- .../java/com/nvidia/cuvs/panama/DLTensor.java | 2 +- .../java/com/nvidia/cuvs/panama/__fsid_t.java | 2 +- .../com/nvidia/cuvs/panama/brute_force_h.java | 2 +- .../java/com/nvidia/cuvs/panama/cagra_h.java | 2 +- .../panama/cuvsCagraCompressionParams.java | 2 +- .../nvidia/cuvs/panama/cuvsCagraIndex.java | 2 +- .../cuvs/panama/cuvsCagraSearchParams.java | 2 +- .../com/nvidia/cuvs/panama/cuvsFilter.java | 2 +- .../java/com/nvidia/cuvs/panama/dlpack_h.java | 2 +- .../java/com/nvidia/cuvs/panama/hnsw_h.java | 2 +- .../com/nvidia/cuvs/panama/ivf_flat_h.java | 2 +- .../java/com/nvidia/cuvs/panama/ivf_pq_h.java | 2 +- .../com/nvidia/cuvs/panama/max_align_t.java | 2 +- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 6 +- java/internal/src/cuvs_java.c | 4 +- 30 files changed, 134 insertions(+), 135 deletions(-) diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 644cd8bb8..0f0c4dcb5 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -1,6 +1,6 @@ + + + + maven-clean-plugin + 3.4.0 + + + + maven-resources-plugin + 3.3.1 + + + maven-compiler-plugin + 3.13.0 + + + maven-surefire-plugin + 3.3.0 + + + maven-jar-plugin + 3.4.2 + + + maven-install-plugin + 3.1.2 + + + maven-deploy-plugin + 3.1.2 + + + + maven-site-plugin + 3.12.1 + + + maven-project-info-reports-plugin + 3.6.1 + + + maven-assembly-plugin + + + make-jar-with-dependencies + + package + + + single + + + + + + + com.nvidia.cuvs.examples.CagraExample + + + + jar-with-dependencies + + + + + + + diff --git a/java/examples/cagra-example/src/main/java/com/nvidia/cuvs/examples/CagraExample.java b/java/examples/cagra-example/src/main/java/com/nvidia/cuvs/examples/CagraExample.java new file mode 100644 index 000000000..86c405606 --- /dev/null +++ b/java/examples/cagra-example/src/main/java/com/nvidia/cuvs/examples/CagraExample.java @@ -0,0 +1,58 @@ +package com.nvidia.cuvs.examples; + +import java.lang.invoke.MethodHandles; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.nvidia.cuvs.CagraIndex; +import com.nvidia.cuvs.CagraIndexParams; +import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; +import com.nvidia.cuvs.CagraQuery; +import com.nvidia.cuvs.CagraSearchParams; +import com.nvidia.cuvs.CuVSResources; +import com.nvidia.cuvs.common.SearchResults; + +public class CagraExample { + + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + public static void main(String[] args) throws Throwable { + // Sample dataset and queries + float[][] dataset = { { 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, + { 0.6673192f, 0.10993068f } }; + float[][] queries = { { 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, + { 0.05198065f, 0.5789965f } }; + + // Allocate the resources + CuVSResources resources = new CuVSResources(); + + // Create an index and a searcher + CagraIndexParams indexParams = new CagraIndexParams.Builder(resources) + .withIntermediateGraphDegree(10) + .withCagraGraphBuildAlgo(CagraGraphBuildAlgo.NN_DESCENT) + .build(); + CagraIndex index = new CagraIndex.Builder(resources) + .withDataset(dataset) + .withIndexParams(indexParams) + .build(); + log.info("Indexing done!"); + + // Search + CagraSearchParams searchParams = new CagraSearchParams.Builder(resources).build(); + CagraQuery query = new CagraQuery.Builder() + .withTopK(2) // get only the top 2 items + .withSearchParams(searchParams) + .withQueryVectors(queries) + .build(); + SearchResults results = index.search(query); + + // Print the results + for (int i=0; i + + + + + + + + + + + + + \ No newline at end of file From 1803deee93d17b9f38d463f299afeaabf5dc67d7 Mon Sep 17 00:00:00 2001 From: Vivek Narang Date: Wed, 27 Nov 2024 14:14:29 -0500 Subject: [PATCH 39/53] major performance improvement - reduced creation time for memory segment for data array --- .../main/java/com/nvidia/cuvs/CagraIndex.java | 36 ++++++++++--------- .../com/nvidia/cuvs/CagraSearchParams.java | 1 + .../java/com/nvidia/cuvs/common/Util.java | 14 ++++---- java/internal/src/cuvs_java.c | 14 ++++---- 4 files changed, 34 insertions(+), 31 deletions(-) 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 90b542947..8ad64d7d6 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 @@ -87,15 +87,18 @@ private CagraIndex(InputStream inputStream, CuVSResources resources) throws Thro * @throws IOException @{@link IOException} is unable to load the native library */ private void initializeMethodHandles() throws IOException { - - indexMethodHandle = resources.linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("build_cagra_index").get(), + indexMethodHandle = resources.linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("build_cagra_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("long"), - resources.linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + resources.linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, + ValueLayout.ADDRESS)); - searchMethodHandle = resources.linker.downcallHandle(resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("int"), - resources.linker.canonicalLayouts().get("long"), resources.linker.canonicalLayouts().get("int"), ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + searchMethodHandle = resources.linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, + resources.linker.canonicalLayouts().get("int"), resources.linker.canonicalLayouts().get("long"), + resources.linker.canonicalLayouts().get("int"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, + ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); serializeMethodHandle = resources.linker.downcallHandle( resources.getLibcuvsNativeLibrary().find("serialize_cagra_index").get(), @@ -119,9 +122,9 @@ private IndexReference build() throws Throwable { MemoryLayout layout = resources.linker.canonicalLayouts().get("int"); MemorySegment segment = resources.arena.allocate(layout); - cagraIndexReference = new IndexReference( - (MemorySegment) indexMethodHandle.invokeExact(Util.buildMemorySegment(resources.linker, resources.arena, dataset), rows, cols, - resources.getMemorySegment(), segment, cagraIndexParameters.getMemorySegment())); + cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( + Util.buildMemorySegment(resources.linker, resources.arena, dataset), rows, cols, resources.getMemorySegment(), + segment, cagraIndexParameters.getMemorySegment())); return cagraIndexReference; } @@ -147,11 +150,11 @@ public CagraSearchResults search(CagraQuery query) throws Throwable { MemorySegment distancesMemorySegment = resources.arena.allocate(distancesSequenceLayout); MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); - + searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), - Util.buildMemorySegment(resources.linker, resources.arena, query.getQueryVectors()), query.getTopK(), numQueries, vectorDimension, - resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, returnValueMemorySegment, - query.getCagraSearchParameters().getMemorySegment()); + Util.buildMemorySegment(resources.linker, resources.arena, query.getQueryVectors()), query.getTopK(), + numQueries, vectorDimension, resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, + returnValueMemorySegment, query.getCagraSearchParameters().getMemorySegment()); return new CagraSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, distancesMemorySegment, query.getTopK(), query.getMapping(), numQueries); @@ -174,14 +177,15 @@ public void serialize(OutputStream outputStream) throws Throwable { * * @param outputStream an instance of {@link OutputStream} to write the index * bytes to - * @param tempFile an intermediate {@link File} where CAGRA index is written + * @param tempFile an intermediate {@link File} where CAGRA index is written * temporarily */ public void serialize(OutputStream outputStream, File tempFile) throws Throwable { MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); serializeMethodHandle.invokeExact(resources.getMemorySegment(), cagraIndexReference.getMemorySegment(), - returnValueMemorySegment, Util.buildMemorySegment(resources.linker, resources.arena, tempFile.getAbsolutePath())); + returnValueMemorySegment, + Util.buildMemorySegment(resources.linker, resources.arena, tempFile.getAbsolutePath())); FileInputStream fileInputStream = new FileInputStream(tempFile); byte[] chunk = new byte[1024]; // TODO: Make this configurable int chunkLength = 0; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java index 07f887697..8ea4287b6 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java @@ -328,6 +328,7 @@ public static class Builder { /** * Constructs this Builder with an instance of Arena. + * * @param resources the {@link CuVSResources} instance to use */ public Builder(CuVSResources resources) { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java index 740e8d371..750e49d64 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java @@ -24,6 +24,7 @@ import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemoryLayout.PathElement; import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; import java.lang.invoke.VarHandle; import org.apache.commons.io.IOUtils; @@ -56,18 +57,15 @@ public static MemorySegment buildMemorySegment(Linker linker, Arena arena, Strin */ public static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { long rows = data.length; - long cols = data[0].length; + long cols = rows > 0 ? data[0].length : 0; - MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows, - MemoryLayout.sequenceLayout(cols, linker.canonicalLayouts().get("float"))); + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows * cols, linker.canonicalLayouts().get("float")); MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); + long floatByteSize = linker.canonicalLayouts().get("float").byteSize(); for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - VarHandle element = dataMemoryLayout.arrayElementVarHandle(PathElement.sequenceElement(r), - PathElement.sequenceElement(c)); - element.set(dataMemorySegment, 0, 0, data[r][c]); - } + MemorySegment.copy(data[r], 0, dataMemorySegment, (ValueLayout) linker.canonicalLayouts().get("float"), + (r * cols * floatByteSize), (int) cols); } return dataMemorySegment; diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index 14c8a0112..ec9ecb6af 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -27,7 +27,7 @@ cuvsResources_t create_resource(int *returnValue) { return cuvsResources; } -DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, long dimensions) { +DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) { DLManagedTensor tensor; tensor.dl_tensor.data = data; @@ -46,7 +46,7 @@ cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, c cuvsCagraIndexParams_t index_params) { int64_t dataset_shape[2] = {rows, dimensions}; - DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat, dimensions); + DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat); cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); @@ -59,8 +59,8 @@ void serialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index *returnValue = cuvsCagraSerialize(cuvsResources, filename, index, true); } -void deserialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *rv, char* filename) { - *rv = cuvsCagraDeserialize(cuvsResources, filename, index); +void deserialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { + *returnValue = cuvsCagraDeserialize(cuvsResources, filename, index); } void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, int dimensions, @@ -75,13 +75,13 @@ void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n cudaMemcpy(queries_d, queries, sizeof(float) * n_queries * dimensions, cudaMemcpyDefault); int64_t queries_shape[2] = {n_queries, dimensions}; - DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat, dimensions); + DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat); int64_t neighbors_shape[2] = {n_queries, topk}; - DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt, dimensions); + DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt); int64_t distances_shape[2] = {n_queries, topk}; - DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat, dimensions); + DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat); cuvsCagraSearchParamsCreate(&search_params); From 7cda1e53cd0c2eda9215166e91bfa1a902dd8b69 Mon Sep 17 00:00:00 2001 From: Vivek Narang <123010842+narangvivek10@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:06:17 -0500 Subject: [PATCH 40/53] Adding randomized test, fixes for memory allocation and deallocation, etc. (#6) * Ability to configure CAGRA compression parameters * Enabling indexing threads * Enabling RMM pool resource configuration * Bug fixes for wrong values passed in index and search parameters * Deallocation of resources using Autoclosable * Including a randomized test Co-authored-by: Vivek Narang Co-authored-by: Ishan Chattopadhyaya Co-authored-by: Puneet Ahuja --- java/cuvs-java/pom.xml | 14 +- .../nvidia/cuvs/CagraCompressionParams.java | 266 ++ .../main/java/com/nvidia/cuvs/CagraIndex.java | 54 +- .../com/nvidia/cuvs/CagraIndexParams.java | 14 +- .../main/java/com/nvidia/cuvs/CagraQuery.java | 2 +- .../com/nvidia/cuvs/CagraSearchParams.java | 62 +- .../com/nvidia/cuvs/CagraSearchResults.java | 2 +- .../java/com/nvidia/cuvs/CuVSResources.java | 41 +- .../cuvs/panama/CuVSCagraIndexParams.java | 517 ++- .../panama/CuvsCagraCompressionParams.java | 352 ++ .../cuvs/panama/CuvsCagraSearchParams.java | 644 +++ .../java/com/nvidia/cuvs/panama/__fsid_t.java | 2 +- .../java/com/nvidia/cuvs/panama/cagra_h.java | 4033 +++++++++-------- .../panama/cuvsCagraCompressionParams.java | 372 -- .../cuvs/panama/cuvsCagraSearchParams.java | 697 --- .../nvidia/cuvs/CagraBuildAndSearchTest.java | 142 +- .../com/nvidia/cuvs/CagraRandomizedTest.java | 163 + .../java/com/nvidia/cuvs/CuVSTestCase.java | 19 + java/internal/CMakeLists.txt | 5 +- java/internal/src/cuvs_java.c | 30 +- 20 files changed, 3977 insertions(+), 3454 deletions(-) create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraCompressionParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraCompressionParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraSearchParams.java delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java delete mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java create mode 100644 java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraRandomizedTest.java create mode 100644 java/cuvs-java/src/test/java/com/nvidia/cuvs/CuVSTestCase.java diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index aacbad2ca..95d0afb24 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -59,9 +59,17 @@ - org.junit.jupiter - junit-jupiter-api - 5.10.0 + com.carrotsearch.randomizedtesting + randomizedtesting-runner + 2.8.2 + test + + + + junit + junit + 4.13.1 + test diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraCompressionParams.java new file mode 100644 index 000000000..50df0c64b --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraCompressionParams.java @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2024, 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 java.lang.foreign.MemorySegment; + +import com.nvidia.cuvs.panama.CuvsCagraCompressionParams; + +/** + * Supplemental compression parameters to build CAGRA Index. + * + * @since 25.02 + */ +public class CagraCompressionParams { + + private final MemorySegment memorySegment; + private CuVSResources resources; + private final int pqBits; + private final int pqDim; + private final int vqNCenters; + private final int kmeansNIters; + private final double vqKmeansTrainsetFraction; + private final double pqKmeansTrainsetFraction; + + /** + * Constructs an instance of CagraCompressionParams with passed search + * parameters. + * + * @param resources the resources instance to use + * @param pqBits the bit length of the vector element after + * compression by PQ + * @param pqDim the dimensionality of the vector after + * compression by PQ + * @param vqNCenters the vector quantization (VQ) codebook size - + * number of “coarse cluster centers” + * @param kmeansNIters the number of iterations searching for kmeans + * centers (both VQ and PQ phases) + * @param vqKmeansTrainsetFraction the fraction of data to use during iterative + * kmeans building (VQ phase) + * @param pqKmeansTrainsetFraction the fraction of data to use during iterative + * kmeans building (PQ phase) + */ + private CagraCompressionParams(CuVSResources resources, int pqBits, int pqDim, int vqNCenters, int kmeansNIters, + double vqKmeansTrainsetFraction, double pqKmeansTrainsetFraction) { + this.resources = resources; + this.pqBits = pqBits; + this.pqDim = pqDim; + this.vqNCenters = vqNCenters; + this.kmeansNIters = kmeansNIters; + this.vqKmeansTrainsetFraction = vqKmeansTrainsetFraction; + this.pqKmeansTrainsetFraction = pqKmeansTrainsetFraction; + this.memorySegment = initMemorySegment(); + } + + /** + * Allocates the configured compression parameters in the MemorySegment. + */ + private MemorySegment initMemorySegment() { + MemorySegment compressionParamsMemorySegment = CuvsCagraCompressionParams.allocate(resources.arena); + CuvsCagraCompressionParams.pq_bits(compressionParamsMemorySegment, pqBits); + CuvsCagraCompressionParams.pq_dim(compressionParamsMemorySegment, pqDim); + CuvsCagraCompressionParams.vq_n_centers(compressionParamsMemorySegment, vqNCenters); + CuvsCagraCompressionParams.kmeans_n_iters(compressionParamsMemorySegment, kmeansNIters); + CuvsCagraCompressionParams.vq_kmeans_trainset_fraction(compressionParamsMemorySegment, vqKmeansTrainsetFraction); + CuvsCagraCompressionParams.pq_kmeans_trainset_fraction(compressionParamsMemorySegment, pqKmeansTrainsetFraction); + return compressionParamsMemorySegment; + } + + /** + * Gets the memory segment instance containing the compression parameters. + * + * @return the memory segment instance containing the compression parameters. + */ + protected MemorySegment getMemorySegment() { + return memorySegment; + } + + /** + * 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 the vector quantization (VQ) codebook size - number of “coarse cluster + * centers”. + * + * @return the vector quantization (VQ) codebook size - number of “coarse + * cluster centers”. + */ + public int getVqNCenters() { + return vqNCenters; + } + + /** + * Gets the number of iterations searching for kmeans centers (both VQ and PQ + * phases). + * + * @return the number of iterations searching for kmeans centers (both VQ and PQ + * phases). + */ + public int getKmeansNIters() { + return kmeansNIters; + } + + /** + * Gets the fraction of data to use during iterative kmeans building (VQ phase). + * + * @return the fraction of data to use during iterative kmeans building (VQ + * phase). + */ + public double getVqKmeansTrainsetFraction() { + return vqKmeansTrainsetFraction; + } + + /** + * Gets the fraction of data to use during iterative kmeans building (PQ phase). + * + * @return the fraction of data to use during iterative kmeans building (PQ + * phase). + */ + public double getPqKmeansTrainsetFraction() { + return pqKmeansTrainsetFraction; + } + + @Override + public String toString() { + return "CagraCompressionParams [pqBits=" + pqBits + ", pqDim=" + pqDim + ", vqNCenters=" + vqNCenters + + ", kmeansNIters=" + kmeansNIters + ", vqKmeansTrainsetFraction=" + vqKmeansTrainsetFraction + + ", pqKmeansTrainsetFraction=" + pqKmeansTrainsetFraction + "]"; + } + + /** + * Builder configures and creates an instance of {@link CagraCompressionParams}. + */ + public static class Builder { + + private CuVSResources resources; + private int pqBits = 8; + private int pqDim = 0; + private int vqNCenters = 0; + private int kmeansNIters = 25; + private double vqKmeansTrainsetFraction = 0; + private double pqKmeansTrainsetFraction = 0; + + public Builder(CuVSResources resources) { + this.resources = resources; + } + + /** + * Sets 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. + * + * @param pqBits + * @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. + * + * When zero, an optimal value is selected using a heuristic. + * + * @param pqDim + * @return an instance of Builder + */ + public Builder withPqDim(int pqDim) { + this.pqDim = pqDim; + return this; + } + + /** + * Sets the vector quantization (VQ) codebook size - number of “coarse cluster + * centers”. + * + * When zero, an optimal value is selected using a heuristic. + * + * @param vqNCenters + * @return an instance of Builder + */ + public Builder withVqNCenters(int vqNCenters) { + this.vqNCenters = vqNCenters; + return this; + } + + /** + * Sets the number of iterations searching for kmeans centers (both VQ and PQ + * phases). + * + * @param kmeansNIters + * @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 (VQ phase). + * + * When zero, an optimal value is selected using a heuristic. + * + * @param vqKmeansTrainsetFraction + * @return an instance of Builder + */ + public Builder withVqKmeansTrainsetFraction(double vqKmeansTrainsetFraction) { + this.vqKmeansTrainsetFraction = vqKmeansTrainsetFraction; + return this; + } + + /** + * Sets the fraction of data to use during iterative kmeans building (PQ phase). + * + * When zero, an optimal value is selected using a heuristic. + * + * @param pqKmeansTrainsetFraction + * @return an instance of Builder + */ + public Builder withPqKmeansTrainsetFraction(double pqKmeansTrainsetFraction) { + this.pqKmeansTrainsetFraction = pqKmeansTrainsetFraction; + return this; + } + + /** + * Builds an instance of {@link CagraCompressionParams}. + * + * @return an instance of {@link CagraCompressionParams} + */ + public CagraCompressionParams build() { + return new CagraCompressionParams(resources, pqBits, pqDim, vqNCenters, kmeansNIters, vqKmeansTrainsetFraction, + pqKmeansTrainsetFraction); + } + } +} \ No newline at end of file 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 8ad64d7d6..67394b53b 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 @@ -44,7 +44,7 @@ * more about this algorithm * here * - * @since 24.12 + * @since 25.02 */ public class CagraIndex { @@ -54,14 +54,18 @@ public class CagraIndex { private MethodHandle searchMethodHandle; private MethodHandle serializeMethodHandle; private MethodHandle deserializeMethodHandle; + private MethodHandle destroyIndexMethodHandle; private CagraIndexParams cagraIndexParameters; + private CagraCompressionParams cagraCompressionParams; private IndexReference cagraIndexReference; /* * Constructor for building the index using specified dataset */ - private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSResources resources) throws Throwable { + private CagraIndex(CagraIndexParams indexParameters, CagraCompressionParams cagraCompressionParams, float[][] dataset, + CuVSResources resources) throws Throwable { this.cagraIndexParameters = indexParameters; + this.cagraCompressionParams = cagraCompressionParams; this.dataset = dataset; this.resources = resources; @@ -74,6 +78,7 @@ private CagraIndex(CagraIndexParams indexParameters, float[][] dataset, CuVSReso */ private CagraIndex(InputStream inputStream, CuVSResources resources) throws Throwable { this.cagraIndexParameters = null; + this.cagraCompressionParams = null; this.dataset = null; this.resources = resources; @@ -91,7 +96,7 @@ private void initializeMethodHandles() throws IOException { resources.getLibcuvsNativeLibrary().find("build_cagra_index").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("long"), resources.linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS)); + ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("int"))); searchMethodHandle = resources.linker.downcallHandle( resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), @@ -107,6 +112,16 @@ private void initializeMethodHandles() throws IOException { deserializeMethodHandle = resources.linker.downcallHandle( resources.getLibcuvsNativeLibrary().find("deserialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + destroyIndexMethodHandle = resources.linker.downcallHandle( + resources.getLibcuvsNativeLibrary().find("destroy_cagra_index").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + } + + public void destroyIndex() throws Throwable { + MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); + destroyIndexMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), returnValueMemorySegment); } /** @@ -118,15 +133,25 @@ private void initializeMethodHandles() throws IOException { */ private IndexReference build() throws Throwable { long rows = dataset.length; - long cols = dataset[0].length; + long cols = rows > 0 ? dataset[0].length : 0; + MemoryLayout layout = resources.linker.canonicalLayouts().get("int"); MemorySegment segment = resources.arena.allocate(layout); - cagraIndexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( + MemorySegment indexParamsMemorySegment = cagraIndexParameters != null ? cagraIndexParameters.getMemorySegment() + : MemorySegment.NULL; + + int numWriterThreads = cagraIndexParameters != null ? cagraIndexParameters.getNumWriterThreads() : 1; + + MemorySegment compressionParamsMemorySegment = cagraCompressionParams != null + ? cagraCompressionParams.getMemorySegment() + : MemorySegment.NULL; + + IndexReference indexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( Util.buildMemorySegment(resources.linker, resources.arena, dataset), rows, cols, resources.getMemorySegment(), - segment, cagraIndexParameters.getMemorySegment())); + segment, indexParamsMemorySegment, compressionParamsMemorySegment, numWriterThreads)); - return cagraIndexReference; + return indexReference; } /** @@ -251,6 +276,7 @@ public static class Builder { private float[][] dataset; private CagraIndexParams cagraIndexParams; + private CagraCompressionParams cagraCompressionParams; private CuVSResources cuvsResources; private InputStream inputStream; @@ -298,6 +324,18 @@ public Builder withIndexParams(CagraIndexParams cagraIndexParameters) { return this; } + /** + * Registers an instance of configured {@link CagraCompressionParams} with this + * Builder. + * + * @param cagraCompressionParams An instance of CagraCompressionParams. + * @return An instance of this Builder. + */ + public Builder withCompressionParams(CagraCompressionParams cagraCompressionParams) { + this.cagraCompressionParams = cagraCompressionParams; + return this; + } + /** * Builds and returns an instance of CagraIndex. * @@ -307,7 +345,7 @@ public CagraIndex build() throws Throwable { if (inputStream != null) { return new CagraIndex(inputStream, cuvsResources); } else { - return new CagraIndex(cagraIndexParams, dataset, cuvsResources); + return new CagraIndex(cagraIndexParams, cagraCompressionParams, dataset, cuvsResources); } } } 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 e2ecf513e..66eb235e2 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 @@ -23,7 +23,7 @@ /** * Supplemental parameters to build CAGRA Index. * - * @since 24.12 + * @since 25.02 */ public class CagraIndexParams { @@ -75,12 +75,12 @@ private CagraIndexParams(CuVSResources resources, int intermediateGraphDegree, i } private MemorySegment initMemorySegment() { - MemorySegment memorySegment = CuVSCagraIndexParams.allocate(resources.arena); - CuVSCagraIndexParams.intermediate_graph_degree(memorySegment, intermediateGraphDegree); - CuVSCagraIndexParams.graph_degree(memorySegment, graphDegree); - CuVSCagraIndexParams.build_algo(memorySegment, cuvsCagraGraphBuildAlgo.value); - CuVSCagraIndexParams.nn_descent_niter(memorySegment, nnDescentNiter); - return memorySegment; + MemorySegment indexParamsMemorySegment = CuVSCagraIndexParams.allocate(resources.arena); + CuVSCagraIndexParams.intermediate_graph_degree(indexParamsMemorySegment, intermediateGraphDegree); + CuVSCagraIndexParams.graph_degree(indexParamsMemorySegment, graphDegree); + CuVSCagraIndexParams.build_algo(indexParamsMemorySegment, cuvsCagraGraphBuildAlgo.value); + CuVSCagraIndexParams.nn_descent_niter(indexParamsMemorySegment, nnDescentNiter); + return indexParamsMemorySegment; } /** diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java index 85e31f08a..77cbf33f3 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java @@ -23,7 +23,7 @@ * CagraQuery holds the CagraSearchParams and the query vectors to be used while * invoking search. * - * @since 24.12 + * @since 25.02 */ public class CagraQuery { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java index 8ea4287b6..d7de498c9 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchParams.java @@ -18,13 +18,13 @@ import java.lang.foreign.MemorySegment; -import com.nvidia.cuvs.panama.cuvsCagraSearchParams; +import com.nvidia.cuvs.panama.CuvsCagraSearchParams; /** * CagraSearchParams encapsulates the logic for configuring and holding search * parameters. * - * @since 24.12 + * @since 25.02 */ public class CagraSearchParams { @@ -152,20 +152,24 @@ private CagraSearchParams(CuVSResources resources, int maxQueries, int iTopKSize * Allocates the configured search parameters in the MemorySegment. */ private MemorySegment allocateMemorySegment() { - MemorySegment memorySegment = cuvsCagraSearchParams.allocate(resources.arena); - cuvsCagraSearchParams.max_queries(memorySegment, maxQueries); - cuvsCagraSearchParams.itopk_size(memorySegment, iTopKSize); - cuvsCagraSearchParams.max_iterations(memorySegment, maxIterations); - cuvsCagraSearchParams.algo(memorySegment, searchAlgo.value); - cuvsCagraSearchParams.team_size(memorySegment, teamSize); - cuvsCagraSearchParams.search_width(memorySegment, searchWidth); - cuvsCagraSearchParams.min_iterations(memorySegment, minIterations); - cuvsCagraSearchParams.thread_block_size(memorySegment, threadBlockSize); - cuvsCagraSearchParams.hashmap_mode(memorySegment, hashMapMode.value); - cuvsCagraSearchParams.hashmap_min_bitlen(memorySegment, hashmapMinBitlen); - cuvsCagraSearchParams.hashmap_max_fill_rate(memorySegment, hashMapMaxFillRate); - cuvsCagraSearchParams.num_random_samplings(memorySegment, numRandomSamplings); - cuvsCagraSearchParams.rand_xor_mask(memorySegment, randXORMask); + MemorySegment memorySegment = CuvsCagraSearchParams.allocate(resources.arena); + CuvsCagraSearchParams.max_queries(memorySegment, maxQueries); + CuvsCagraSearchParams.itopk_size(memorySegment, iTopKSize); + CuvsCagraSearchParams.max_iterations(memorySegment, maxIterations); + if (searchAlgo != null) { + CuvsCagraSearchParams.algo(memorySegment, searchAlgo.value); + } + CuvsCagraSearchParams.team_size(memorySegment, teamSize); + CuvsCagraSearchParams.search_width(memorySegment, searchWidth); + CuvsCagraSearchParams.min_iterations(memorySegment, minIterations); + CuvsCagraSearchParams.thread_block_size(memorySegment, threadBlockSize); + if (hashMapMode != null) { + CuvsCagraSearchParams.hashmap_mode(memorySegment, hashMapMode.value); + } + CuvsCagraSearchParams.hashmap_min_bitlen(memorySegment, hashmapMinBitlen); + CuvsCagraSearchParams.hashmap_max_fill_rate(memorySegment, hashMapMaxFillRate); + CuvsCagraSearchParams.num_random_samplings(memorySegment, numRandomSamplings); + CuvsCagraSearchParams.rand_xor_mask(memorySegment, randXORMask); return memorySegment; } @@ -312,19 +316,19 @@ public String toString() { public static class Builder { private CuVSResources resources; - private int maxQueries = 1; - private int iTopKSize = 2; - private int maxIterations = 3; - private int teamSize = 4; - private int searchWidth = 5; - private int minIterations = 6; - private int threadBlockSize = 7; - private int hashMapMinBitlen = 8; - private int numRandomSamplings = 10; - private float hashMapMaxFillRate = 9.0f; - private long randXORMask = 11L; - private SearchAlgo searchAlgo = SearchAlgo.MULTI_KERNEL; - private HashMapMode hashMapMode = HashMapMode.AUTO_HASH; + private int maxQueries; + private int iTopKSize = 64; + private int maxIterations; + private int teamSize; + private int searchWidth = 1; + private int minIterations; + private int threadBlockSize; + private int hashMapMinBitlen; + private int numRandomSamplings = 1; + private float hashMapMaxFillRate = 0.5f; + private long randXORMask = 0x128394; + private SearchAlgo searchAlgo; + private HashMapMode hashMapMode; /** * Constructs this Builder with an instance of Arena. diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java index c601a8539..f4326fde3 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraSearchResults.java @@ -30,7 +30,7 @@ /** * SearchResult encapsulates the logic for reading and holding search results. * - * @since 24.12 + * @since 25.02 */ public class CagraSearchResults implements SearchResults { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java index 5020c0b6d..60f68981b 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java @@ -31,16 +31,18 @@ /** * Used for allocating resources for cuVS * - * @since 24.12 + * @since 25.02 */ -public class CuVSResources { +public class CuVSResources implements AutoCloseable { public final Arena arena; public final Linker linker; public final SymbolLookup libcuvsNativeLibrary; + protected File nativeLibrary; - private final MethodHandle createResourceMethodHandle; - private final MemorySegment memorySegment; + private final MethodHandle createResourcesMethodHandle; + private final MethodHandle destroyResourcesMethodHandle; + private MemorySegment resourcesMemorySegment; /** * Constructor that allocates the resources needed for cuVS @@ -50,17 +52,38 @@ public class CuVSResources { public CuVSResources() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofShared(); - - File nativeLibrary = Util.loadLibraryFromJar("/libcuvs_java.so"); + nativeLibrary = Util.loadLibraryFromJar("/libcuvs_java.so"); libcuvsNativeLibrary = SymbolLookup.libraryLookup(nativeLibrary.getAbsolutePath(), arena); - createResourceMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("create_resource").get(), + createResourcesMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("create_resources").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + destroyResourcesMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("destroy_resources").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + createResources(); + } + + /** + * Creates the resources used internally and returns its reference. + * + * @throws Throwable exception thrown when native function is invoked + */ + public void createResources() throws Throwable { MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); + resourcesMemorySegment = (MemorySegment) createResourcesMethodHandle.invokeExact(returnValueMemorySegment); + } - memorySegment = (MemorySegment) createResourceMethodHandle.invokeExact(returnValueMemorySegment); + @Override + public void close() { + MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); + try { + destroyResourcesMethodHandle.invokeExact(resourcesMemorySegment, returnValueMemorySegment); + } catch (Throwable e) { + e.printStackTrace(); + } + nativeLibrary.delete(); } /** @@ -69,7 +92,7 @@ public CuVSResources() throws Throwable { * @return cuvsResources MemorySegment */ protected MemorySegment getMemorySegment() { - return memorySegment; + return resourcesMemorySegment; } /** diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java index f24be1fd5..72d30e9bb 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java @@ -18,6 +18,7 @@ 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; @@ -28,254 +29,284 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct cuvsCagraIndexParams { - * size_t intermediate_graph_degree; - * size_t graph_degree; + * long intermediate_graph_degree; + * long graph_degree; * enum cuvsCagraGraphBuildAlgo build_algo; - * size_t nn_descent_niter; + * long nn_descent_niter; + * cuvsCagraCompressionParams_t compression; * } * } */ public class CuVSCagraIndexParams { - CuVSCagraIndexParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - cagra_h.C_LONG.withName("intermediate_graph_degree"), - cagra_h.C_LONG.withName("graph_degree"), - cagra_h.C_INT.withName("build_algo"), - MemoryLayout.paddingLayout(4), - cagra_h.C_LONG.withName("nn_descent_niter") - ).withName("cuvsCagraIndexParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong intermediate_graph_degree$LAYOUT = (OfLong)$LAYOUT.select(groupElement("intermediate_graph_degree")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t intermediate_graph_degree - * } - */ - public static final OfLong intermediate_graph_degree$layout() { - return intermediate_graph_degree$LAYOUT; - } - - private static final long intermediate_graph_degree$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t intermediate_graph_degree - * } - */ - public static final long intermediate_graph_degree$offset() { - return intermediate_graph_degree$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t intermediate_graph_degree - * } - */ - public static long intermediate_graph_degree(MemorySegment struct) { - return struct.get(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t intermediate_graph_degree - * } - */ - public static void intermediate_graph_degree(MemorySegment struct, long fieldValue) { - struct.set(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET, fieldValue); - } - - private static final OfLong graph_degree$LAYOUT = (OfLong)$LAYOUT.select(groupElement("graph_degree")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t graph_degree - * } - */ - public static final OfLong graph_degree$layout() { - return graph_degree$LAYOUT; - } - - private static final long graph_degree$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t graph_degree - * } - */ - public static final long graph_degree$offset() { - return graph_degree$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t graph_degree - * } - */ - public static long graph_degree(MemorySegment struct) { - return struct.get(graph_degree$LAYOUT, graph_degree$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t graph_degree - * } - */ - public static void graph_degree(MemorySegment struct, long fieldValue) { - struct.set(graph_degree$LAYOUT, graph_degree$OFFSET, fieldValue); - } - - private static final OfInt build_algo$LAYOUT = (OfInt)$LAYOUT.select(groupElement("build_algo")); - - /** - * Layout for field: - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static final OfInt build_algo$layout() { - return build_algo$LAYOUT; - } - - private static final long build_algo$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static final long build_algo$offset() { - return build_algo$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static int build_algo(MemorySegment struct) { - return struct.get(build_algo$LAYOUT, build_algo$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo build_algo - * } - */ - public static void build_algo(MemorySegment struct, int fieldValue) { - struct.set(build_algo$LAYOUT, build_algo$OFFSET, fieldValue); - } - - private static final OfLong nn_descent_niter$LAYOUT = (OfLong)$LAYOUT.select(groupElement("nn_descent_niter")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t nn_descent_niter - * } - */ - public static final OfLong nn_descent_niter$layout() { - return nn_descent_niter$LAYOUT; - } - - private static final long nn_descent_niter$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t nn_descent_niter - * } - */ - public static final long nn_descent_niter$offset() { - return nn_descent_niter$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t nn_descent_niter - * } - */ - public static long nn_descent_niter(MemorySegment struct) { - return struct.get(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t nn_descent_niter - * } - */ - public static void nn_descent_niter(MemorySegment struct, long fieldValue) { - struct.set(nn_descent_niter$LAYOUT, nn_descent_niter$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); - } + CuVSCagraIndexParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(cagra_h.C_LONG.withName("intermediate_graph_degree"), cagra_h.C_LONG.withName("graph_degree"), + cagra_h.C_INT.withName("build_algo"), MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("nn_descent_niter"), cagra_h.C_POINTER.withName("compression")) + .withName("cuvsCagraIndexParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong intermediate_graph_degree$LAYOUT = (OfLong) $LAYOUT + .select(groupElement("intermediate_graph_degree")); + + /** + * Layout for field: + * {@snippet lang = c : * long intermediate_graph_degree + * } + */ + public static final OfLong intermediate_graph_degree$layout() { + return intermediate_graph_degree$LAYOUT; + } + + private static final long intermediate_graph_degree$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * long intermediate_graph_degree + * } + */ + public static final long intermediate_graph_degree$offset() { + return intermediate_graph_degree$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long intermediate_graph_degree + * } + */ + public static long intermediate_graph_degree(MemorySegment struct) { + return struct.get(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long intermediate_graph_degree + * } + */ + public static void intermediate_graph_degree(MemorySegment struct, long fieldValue) { + struct.set(intermediate_graph_degree$LAYOUT, intermediate_graph_degree$OFFSET, fieldValue); + } + + private static final OfLong graph_degree$LAYOUT = (OfLong) $LAYOUT.select(groupElement("graph_degree")); + + /** + * Layout for field: + * {@snippet lang = c : * long graph_degree + * } + */ + public static final OfLong graph_degree$layout() { + return graph_degree$LAYOUT; + } + + private static final long graph_degree$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * long graph_degree + * } + */ + public static final long graph_degree$offset() { + return graph_degree$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long graph_degree + * } + */ + public static long graph_degree(MemorySegment struct) { + return struct.get(graph_degree$LAYOUT, graph_degree$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long graph_degree + * } + */ + public static void graph_degree(MemorySegment struct, long fieldValue) { + struct.set(graph_degree$LAYOUT, graph_degree$OFFSET, fieldValue); + } + + private static final OfInt build_algo$LAYOUT = (OfInt) $LAYOUT.select(groupElement("build_algo")); + + /** + * Layout for field: + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static final OfInt build_algo$layout() { + return build_algo$LAYOUT; + } + + private static final long build_algo$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static final long build_algo$offset() { + return build_algo$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static int build_algo(MemorySegment struct) { + return struct.get(build_algo$LAYOUT, build_algo$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo build_algo + * } + */ + public static void build_algo(MemorySegment struct, int fieldValue) { + struct.set(build_algo$LAYOUT, build_algo$OFFSET, fieldValue); + } + + private static final OfLong nn_descent_niter$LAYOUT = (OfLong) $LAYOUT.select(groupElement("nn_descent_niter")); + + /** + * Layout for field: + * {@snippet lang = c : * long nn_descent_niter + * } + */ + public static final OfLong nn_descent_niter$layout() { + return nn_descent_niter$LAYOUT; + } + + private static final long nn_descent_niter$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang = c : * long nn_descent_niter + * } + */ + public static final long nn_descent_niter$offset() { + return nn_descent_niter$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long nn_descent_niter + * } + */ + public static long nn_descent_niter(MemorySegment struct) { + return struct.get(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long nn_descent_niter + * } + */ + public static void nn_descent_niter(MemorySegment struct, long fieldValue) { + struct.set(nn_descent_niter$LAYOUT, nn_descent_niter$OFFSET, fieldValue); + } + + private static final AddressLayout compression$LAYOUT = (AddressLayout) $LAYOUT.select(groupElement("compression")); + + /** + * Layout for field: + * {@snippet lang = c : * cuvsCagraCompressionParams_t compression + * } + */ + public static final AddressLayout compression$layout() { + return compression$LAYOUT; + } + + private static final long compression$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang = c : * cuvsCagraCompressionParams_t compression + * } + */ + public static final long compression$offset() { + return compression$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * cuvsCagraCompressionParams_t compression + * } + */ + public static MemorySegment compression(MemorySegment struct) { + return struct.get(compression$LAYOUT, compression$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * cuvsCagraCompressionParams_t compression + * } + */ + public static void compression(MemorySegment struct, MemorySegment fieldValue) { + struct.set(compression$LAYOUT, compression$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } } - diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraCompressionParams.java new file mode 100644 index 000000000..8ee3e7568 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraCompressionParams.java @@ -0,0 +1,352 @@ +/* + * Copyright (c) 2024, 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.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfDouble; +import java.lang.foreign.ValueLayout.OfInt; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct cuvsCagraCompressionParams { + * uint32_t pq_bits; + * uint32_t pq_dim; + * uint32_t vq_n_centers; + * uint32_t kmeans_n_iters; + * double vq_kmeans_trainset_fraction; + * double pq_kmeans_trainset_fraction; + * } + * } + */ +public class CuvsCagraCompressionParams { + + CuvsCagraCompressionParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(cagra_h.C_INT.withName("pq_bits"), + cagra_h.C_INT.withName("pq_dim"), cagra_h.C_INT.withName("vq_n_centers"), + cagra_h.C_INT.withName("kmeans_n_iters"), cagra_h.C_DOUBLE.withName("vq_kmeans_trainset_fraction"), + cagra_h.C_DOUBLE.withName("pq_kmeans_trainset_fraction")).withName("cuvsCagraCompressionParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfInt pq_bits$LAYOUT = (OfInt) $LAYOUT.select(groupElement("pq_bits")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t pq_bits + * } + */ + public static final OfInt pq_bits$layout() { + return pq_bits$LAYOUT; + } + + private static final long pq_bits$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t pq_bits + * } + */ + public static final long pq_bits$offset() { + return pq_bits$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t pq_bits + * } + */ + public static int pq_bits(MemorySegment struct) { + return struct.get(pq_bits$LAYOUT, pq_bits$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t pq_bits + * } + */ + public static void pq_bits(MemorySegment struct, int fieldValue) { + struct.set(pq_bits$LAYOUT, pq_bits$OFFSET, fieldValue); + } + + private static final OfInt pq_dim$LAYOUT = (OfInt) $LAYOUT.select(groupElement("pq_dim")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t pq_dim + * } + */ + public static final OfInt pq_dim$layout() { + return pq_dim$LAYOUT; + } + + private static final long pq_dim$OFFSET = 4; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t pq_dim + * } + */ + public static final long pq_dim$offset() { + return pq_dim$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t pq_dim + * } + */ + public static int pq_dim(MemorySegment struct) { + return struct.get(pq_dim$LAYOUT, pq_dim$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t pq_dim + * } + */ + public static void pq_dim(MemorySegment struct, int fieldValue) { + struct.set(pq_dim$LAYOUT, pq_dim$OFFSET, fieldValue); + } + + private static final OfInt vq_n_centers$LAYOUT = (OfInt) $LAYOUT.select(groupElement("vq_n_centers")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t vq_n_centers + * } + */ + public static final OfInt vq_n_centers$layout() { + return vq_n_centers$LAYOUT; + } + + private static final long vq_n_centers$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t vq_n_centers + * } + */ + public static final long vq_n_centers$offset() { + return vq_n_centers$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t vq_n_centers + * } + */ + public static int vq_n_centers(MemorySegment struct) { + return struct.get(vq_n_centers$LAYOUT, vq_n_centers$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t vq_n_centers + * } + */ + public static void vq_n_centers(MemorySegment struct, int fieldValue) { + struct.set(vq_n_centers$LAYOUT, vq_n_centers$OFFSET, fieldValue); + } + + private static final OfInt kmeans_n_iters$LAYOUT = (OfInt) $LAYOUT.select(groupElement("kmeans_n_iters")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t kmeans_n_iters + * } + */ + public static final OfInt kmeans_n_iters$layout() { + return kmeans_n_iters$LAYOUT; + } + + private static final long kmeans_n_iters$OFFSET = 12; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t kmeans_n_iters + * } + */ + public static final long kmeans_n_iters$offset() { + return kmeans_n_iters$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t kmeans_n_iters + * } + */ + public static int kmeans_n_iters(MemorySegment struct) { + return struct.get(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t kmeans_n_iters + * } + */ + public static void kmeans_n_iters(MemorySegment struct, int fieldValue) { + struct.set(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET, fieldValue); + } + + private static final OfDouble vq_kmeans_trainset_fraction$LAYOUT = (OfDouble) $LAYOUT + .select(groupElement("vq_kmeans_trainset_fraction")); + + /** + * Layout for field: + * {@snippet lang = c : * double vq_kmeans_trainset_fraction + * } + */ + public static final OfDouble vq_kmeans_trainset_fraction$layout() { + return vq_kmeans_trainset_fraction$LAYOUT; + } + + private static final long vq_kmeans_trainset_fraction$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * double vq_kmeans_trainset_fraction + * } + */ + public static final long vq_kmeans_trainset_fraction$offset() { + return vq_kmeans_trainset_fraction$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * double vq_kmeans_trainset_fraction + * } + */ + public static double vq_kmeans_trainset_fraction(MemorySegment struct) { + return struct.get(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * double vq_kmeans_trainset_fraction + * } + */ + public static void vq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { + struct.set(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET, fieldValue); + } + + private static final OfDouble pq_kmeans_trainset_fraction$LAYOUT = (OfDouble) $LAYOUT + .select(groupElement("pq_kmeans_trainset_fraction")); + + /** + * Layout for field: + * {@snippet lang = c : * double pq_kmeans_trainset_fraction + * } + */ + public static final OfDouble pq_kmeans_trainset_fraction$layout() { + return pq_kmeans_trainset_fraction$LAYOUT; + } + + private static final long pq_kmeans_trainset_fraction$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang = c : * double pq_kmeans_trainset_fraction + * } + */ + public static final long pq_kmeans_trainset_fraction$offset() { + return pq_kmeans_trainset_fraction$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * double pq_kmeans_trainset_fraction + * } + */ + public static double pq_kmeans_trainset_fraction(MemorySegment struct) { + return struct.get(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * double pq_kmeans_trainset_fraction + * } + */ + public static void pq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { + struct.set(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraSearchParams.java new file mode 100644 index 000000000..b54b91b5b --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuvsCagraSearchParams.java @@ -0,0 +1,644 @@ +/* + * Copyright (c) 2024, 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.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfFloat; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct cuvsCagraSearchParams { + * long max_queries; + * long itopk_size; + * long max_iterations; + * enum cuvsCagraSearchAlgo algo; + * long team_size; + * long search_width; + * long min_iterations; + * long thread_block_size; + * enum cuvsCagraHashMode hashmap_mode; + * long hashmap_min_bitlen; + * float hashmap_max_fill_rate; + * uint32_t num_random_samplings; + * uint64_t rand_xor_mask; + * } + * } + */ +public class CuvsCagraSearchParams { + + CuvsCagraSearchParams() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout + .structLayout(cagra_h.C_LONG.withName("max_queries"), cagra_h.C_LONG.withName("itopk_size"), + cagra_h.C_LONG.withName("max_iterations"), cagra_h.C_INT.withName("algo"), MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("team_size"), cagra_h.C_LONG.withName("search_width"), + cagra_h.C_LONG.withName("min_iterations"), cagra_h.C_LONG.withName("thread_block_size"), + cagra_h.C_INT.withName("hashmap_mode"), MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("hashmap_min_bitlen"), cagra_h.C_FLOAT.withName("hashmap_max_fill_rate"), + cagra_h.C_INT.withName("num_random_samplings"), cagra_h.C_LONG.withName("rand_xor_mask")) + .withName("cuvsCagraSearchParams"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong max_queries$LAYOUT = (OfLong) $LAYOUT.select(groupElement("max_queries")); + + /** + * Layout for field: + * {@snippet lang = c : * long max_queries + * } + */ + public static final OfLong max_queries$layout() { + return max_queries$LAYOUT; + } + + private static final long max_queries$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * long max_queries + * } + */ + public static final long max_queries$offset() { + return max_queries$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long max_queries + * } + */ + public static long max_queries(MemorySegment struct) { + return struct.get(max_queries$LAYOUT, max_queries$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long max_queries + * } + */ + public static void max_queries(MemorySegment struct, long fieldValue) { + struct.set(max_queries$LAYOUT, max_queries$OFFSET, fieldValue); + } + + private static final OfLong itopk_size$LAYOUT = (OfLong) $LAYOUT.select(groupElement("itopk_size")); + + /** + * Layout for field: + * {@snippet lang = c : * long itopk_size + * } + */ + public static final OfLong itopk_size$layout() { + return itopk_size$LAYOUT; + } + + private static final long itopk_size$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * long itopk_size + * } + */ + public static final long itopk_size$offset() { + return itopk_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long itopk_size + * } + */ + public static long itopk_size(MemorySegment struct) { + return struct.get(itopk_size$LAYOUT, itopk_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long itopk_size + * } + */ + public static void itopk_size(MemorySegment struct, long fieldValue) { + struct.set(itopk_size$LAYOUT, itopk_size$OFFSET, fieldValue); + } + + private static final OfLong max_iterations$LAYOUT = (OfLong) $LAYOUT.select(groupElement("max_iterations")); + + /** + * Layout for field: + * {@snippet lang = c : * long max_iterations + * } + */ + public static final OfLong max_iterations$layout() { + return max_iterations$LAYOUT; + } + + private static final long max_iterations$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang = c : * long max_iterations + * } + */ + public static final long max_iterations$offset() { + return max_iterations$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long max_iterations + * } + */ + public static long max_iterations(MemorySegment struct) { + return struct.get(max_iterations$LAYOUT, max_iterations$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long max_iterations + * } + */ + public static void max_iterations(MemorySegment struct, long fieldValue) { + struct.set(max_iterations$LAYOUT, max_iterations$OFFSET, fieldValue); + } + + private static final OfInt algo$LAYOUT = (OfInt) $LAYOUT.select(groupElement("algo")); + + /** + * Layout for field: + * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo + * } + */ + public static final OfInt algo$layout() { + return algo$LAYOUT; + } + + private static final long algo$OFFSET = 24; + + /** + * Offset for field: + * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo + * } + */ + public static final long algo$offset() { + return algo$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo + * } + */ + public static int algo(MemorySegment struct) { + return struct.get(algo$LAYOUT, algo$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * enum cuvsCagraSearchAlgo algo + * } + */ + public static void algo(MemorySegment struct, int fieldValue) { + struct.set(algo$LAYOUT, algo$OFFSET, fieldValue); + } + + private static final OfLong team_size$LAYOUT = (OfLong) $LAYOUT.select(groupElement("team_size")); + + /** + * Layout for field: + * {@snippet lang = c : * long team_size + * } + */ + public static final OfLong team_size$layout() { + return team_size$LAYOUT; + } + + private static final long team_size$OFFSET = 32; + + /** + * Offset for field: + * {@snippet lang = c : * long team_size + * } + */ + public static final long team_size$offset() { + return team_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long team_size + * } + */ + public static long team_size(MemorySegment struct) { + return struct.get(team_size$LAYOUT, team_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long team_size + * } + */ + public static void team_size(MemorySegment struct, long fieldValue) { + struct.set(team_size$LAYOUT, team_size$OFFSET, fieldValue); + } + + private static final OfLong search_width$LAYOUT = (OfLong) $LAYOUT.select(groupElement("search_width")); + + /** + * Layout for field: + * {@snippet lang = c : * long search_width + * } + */ + public static final OfLong search_width$layout() { + return search_width$LAYOUT; + } + + private static final long search_width$OFFSET = 40; + + /** + * Offset for field: + * {@snippet lang = c : * long search_width + * } + */ + public static final long search_width$offset() { + return search_width$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long search_width + * } + */ + public static long search_width(MemorySegment struct) { + return struct.get(search_width$LAYOUT, search_width$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long search_width + * } + */ + public static void search_width(MemorySegment struct, long fieldValue) { + struct.set(search_width$LAYOUT, search_width$OFFSET, fieldValue); + } + + private static final OfLong min_iterations$LAYOUT = (OfLong) $LAYOUT.select(groupElement("min_iterations")); + + /** + * Layout for field: + * {@snippet lang = c : * long min_iterations + * } + */ + public static final OfLong min_iterations$layout() { + return min_iterations$LAYOUT; + } + + private static final long min_iterations$OFFSET = 48; + + /** + * Offset for field: + * {@snippet lang = c : * long min_iterations + * } + */ + public static final long min_iterations$offset() { + return min_iterations$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long min_iterations + * } + */ + public static long min_iterations(MemorySegment struct) { + return struct.get(min_iterations$LAYOUT, min_iterations$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long min_iterations + * } + */ + public static void min_iterations(MemorySegment struct, long fieldValue) { + struct.set(min_iterations$LAYOUT, min_iterations$OFFSET, fieldValue); + } + + private static final OfLong thread_block_size$LAYOUT = (OfLong) $LAYOUT.select(groupElement("thread_block_size")); + + /** + * Layout for field: + * {@snippet lang = c : * long thread_block_size + * } + */ + public static final OfLong thread_block_size$layout() { + return thread_block_size$LAYOUT; + } + + private static final long thread_block_size$OFFSET = 56; + + /** + * Offset for field: + * {@snippet lang = c : * long thread_block_size + * } + */ + public static final long thread_block_size$offset() { + return thread_block_size$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long thread_block_size + * } + */ + public static long thread_block_size(MemorySegment struct) { + return struct.get(thread_block_size$LAYOUT, thread_block_size$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long thread_block_size + * } + */ + public static void thread_block_size(MemorySegment struct, long fieldValue) { + struct.set(thread_block_size$LAYOUT, thread_block_size$OFFSET, fieldValue); + } + + private static final OfInt hashmap_mode$LAYOUT = (OfInt) $LAYOUT.select(groupElement("hashmap_mode")); + + /** + * Layout for field: + * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static final OfInt hashmap_mode$layout() { + return hashmap_mode$LAYOUT; + } + + private static final long hashmap_mode$OFFSET = 64; + + /** + * Offset for field: + * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static final long hashmap_mode$offset() { + return hashmap_mode$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static int hashmap_mode(MemorySegment struct) { + return struct.get(hashmap_mode$LAYOUT, hashmap_mode$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * enum cuvsCagraHashMode hashmap_mode + * } + */ + public static void hashmap_mode(MemorySegment struct, int fieldValue) { + struct.set(hashmap_mode$LAYOUT, hashmap_mode$OFFSET, fieldValue); + } + + private static final OfLong hashmap_min_bitlen$LAYOUT = (OfLong) $LAYOUT.select(groupElement("hashmap_min_bitlen")); + + /** + * Layout for field: + * {@snippet lang = c : * long hashmap_min_bitlen + * } + */ + public static final OfLong hashmap_min_bitlen$layout() { + return hashmap_min_bitlen$LAYOUT; + } + + private static final long hashmap_min_bitlen$OFFSET = 72; + + /** + * Offset for field: + * {@snippet lang = c : * long hashmap_min_bitlen + * } + */ + public static final long hashmap_min_bitlen$offset() { + return hashmap_min_bitlen$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * long hashmap_min_bitlen + * } + */ + public static long hashmap_min_bitlen(MemorySegment struct) { + return struct.get(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * long hashmap_min_bitlen + * } + */ + public static void hashmap_min_bitlen(MemorySegment struct, long fieldValue) { + struct.set(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET, fieldValue); + } + + private static final OfFloat hashmap_max_fill_rate$LAYOUT = (OfFloat) $LAYOUT + .select(groupElement("hashmap_max_fill_rate")); + + /** + * Layout for field: + * {@snippet lang = c : * float hashmap_max_fill_rate + * } + */ + public static final OfFloat hashmap_max_fill_rate$layout() { + return hashmap_max_fill_rate$LAYOUT; + } + + private static final long hashmap_max_fill_rate$OFFSET = 80; + + /** + * Offset for field: + * {@snippet lang = c : * float hashmap_max_fill_rate + * } + */ + public static final long hashmap_max_fill_rate$offset() { + return hashmap_max_fill_rate$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * float hashmap_max_fill_rate + * } + */ + public static float hashmap_max_fill_rate(MemorySegment struct) { + return struct.get(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * float hashmap_max_fill_rate + * } + */ + public static void hashmap_max_fill_rate(MemorySegment struct, float fieldValue) { + struct.set(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET, fieldValue); + } + + private static final OfInt num_random_samplings$LAYOUT = (OfInt) $LAYOUT.select(groupElement("num_random_samplings")); + + /** + * Layout for field: + * {@snippet lang = c : * uint32_t num_random_samplings + * } + */ + public static final OfInt num_random_samplings$layout() { + return num_random_samplings$LAYOUT; + } + + private static final long num_random_samplings$OFFSET = 84; + + /** + * Offset for field: + * {@snippet lang = c : * uint32_t num_random_samplings + * } + */ + public static final long num_random_samplings$offset() { + return num_random_samplings$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint32_t num_random_samplings + * } + */ + public static int num_random_samplings(MemorySegment struct) { + return struct.get(num_random_samplings$LAYOUT, num_random_samplings$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint32_t num_random_samplings + * } + */ + public static void num_random_samplings(MemorySegment struct, int fieldValue) { + struct.set(num_random_samplings$LAYOUT, num_random_samplings$OFFSET, fieldValue); + } + + private static final OfLong rand_xor_mask$LAYOUT = (OfLong) $LAYOUT.select(groupElement("rand_xor_mask")); + + /** + * Layout for field: + * {@snippet lang = c : * uint64_t rand_xor_mask + * } + */ + public static final OfLong rand_xor_mask$layout() { + return rand_xor_mask$LAYOUT; + } + + private static final long rand_xor_mask$OFFSET = 88; + + /** + * Offset for field: + * {@snippet lang = c : * uint64_t rand_xor_mask + * } + */ + public static final long rand_xor_mask$offset() { + return rand_xor_mask$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uint64_t rand_xor_mask + * } + */ + public static long rand_xor_mask(MemorySegment struct) { + return struct.get(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uint64_t rand_xor_mask + * } + */ + public static void rand_xor_mask(MemorySegment struct, long fieldValue) { + struct.set(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java index 52ebe83ec..66e8dd760 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/__fsid_t.java @@ -42,7 +42,7 @@ public class __fsid_t { } private static final GroupLayout $LAYOUT = MemoryLayout - .structLayout(MemoryLayout.sequenceLayout(2, dlpack_h.C_INT).withName("__val")).withName("$anon$155:12"); + .structLayout(MemoryLayout.sequenceLayout(2, cagra_h.C_INT).withName("__val")).withName("$anon$155:12"); /** * The layout of this struct diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java index a037e2c17..f01afbfbd 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java @@ -41,2027 +41,2028 @@ public class cagra_h { - cagra_h() { - // Should not be called directly - } + cagra_h() { + // 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; - } - private static final int true_ = (int)1L; - /** - * {@snippet lang=c : - * #define true 1 - * } - */ - public static int true_() { - return true_; - } - private static final int false_ = (int)0L; - /** - * {@snippet lang=c : - * #define false 0 - * } - */ - public static int false_() { - return false_; - } - private static final int __bool_true_false_are_defined = (int)1L; - /** - * {@snippet lang=c : - * #define __bool_true_false_are_defined 1 - * } - */ - public static int __bool_true_false_are_defined() { - return __bool_true_false_are_defined; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = cagra_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = cagra_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = cagra_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = cagra_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = cagra_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = cagra_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = cagra_h.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - private static final int AUTO_SELECT = (int)0L; - /** - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 - * } - */ - public static int AUTO_SELECT() { - return AUTO_SELECT; - } - private static final int IVF_PQ = (int)1L; - /** - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 - * } - */ - public static int IVF_PQ() { - return IVF_PQ; - } - private static final int NN_DESCENT = (int)2L; - /** - * {@snippet lang=c : - * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 - * } - */ - public static int NN_DESCENT() { - return NN_DESCENT; - } - /** - * {@snippet lang=c : - * typedef struct cuvsCagraCompressionParams { - * uint32_t pq_bits; - * uint32_t pq_dim; - * uint32_t vq_n_centers; - * uint32_t kmeans_n_iters; - * double vq_kmeans_trainset_fraction; - * double pq_kmeans_trainset_fraction; - * } *cuvsCagraCompressionParams_t - * } - */ - public static final AddressLayout cuvsCagraCompressionParams_t = cagra_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef struct cuvsCagraIndexParams { - * size_t intermediate_graph_degree; - * size_t graph_degree; - * enum cuvsCagraGraphBuildAlgo build_algo; - * size_t nn_descent_niter; - * cuvsCagraCompressionParams_t compression; - * } *cuvsCagraIndexParams_t - * } - */ - public static final AddressLayout cuvsCagraIndexParams_t = cagra_h.C_POINTER; - private static final int SINGLE_CTA = (int)0L; - /** - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo.SINGLE_CTA = 0 - * } - */ - public static int SINGLE_CTA() { - return SINGLE_CTA; - } - private static final int MULTI_CTA = (int)1L; - /** - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo.MULTI_CTA = 1 - * } - */ - public static int MULTI_CTA() { - return MULTI_CTA; - } - private static final int MULTI_KERNEL = (int)2L; - /** - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo.MULTI_KERNEL = 2 - * } - */ - public static int MULTI_KERNEL() { - return MULTI_KERNEL; - } - private static final int AUTO = (int)3L; - /** - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo.AUTO = 3 - * } - */ - public static int AUTO() { - return AUTO; - } - private static final int HASH = (int)0L; - /** - * {@snippet lang=c : - * enum cuvsCagraHashMode.HASH = 0 - * } - */ - public static int HASH() { - return HASH; - } - private static final int SMALL = (int)1L; - /** - * {@snippet lang=c : - * enum cuvsCagraHashMode.SMALL = 1 - * } - */ - public static int SMALL() { - return SMALL; - } - private static final int AUTO_HASH = (int)2L; - /** - * {@snippet lang=c : - * enum cuvsCagraHashMode.AUTO_HASH = 2 - * } - */ - public static int AUTO_HASH() { - return AUTO_HASH; - } - /** - * {@snippet lang=c : - * typedef struct cuvsCagraSearchParams { - * size_t max_queries; - * size_t itopk_size; - * size_t max_iterations; - * enum cuvsCagraSearchAlgo algo; - * size_t team_size; - * size_t search_width; - * size_t min_iterations; - * size_t thread_block_size; - * enum cuvsCagraHashMode hashmap_mode; - * size_t hashmap_min_bitlen; - * float hashmap_max_fill_rate; - * uint32_t num_random_samplings; - * uint64_t rand_xor_mask; - * } *cuvsCagraSearchParams_t - * } - */ - public static final AddressLayout cuvsCagraSearchParams_t = cagra_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef cuvsCagraIndex *cuvsCagraIndex_t - * } - */ - public static final AddressLayout cuvsCagraIndex_t = cagra_h.C_POINTER; - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - 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 true_ = (int) 1L; + + /** + * {@snippet lang = c : * #define true 1 + * } + */ + public static int true_() { + return true_; + } + + private static final int false_ = (int) 0L; + + /** + * {@snippet lang = c : * #define false 0 + * } + */ + public static int false_() { + return false_; + } + + private static final int __bool_true_false_are_defined = (int) 1L; + + /** + * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + + private static final int _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 = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off_t + * } + */ + public static final OfLong __off_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef long __time_t + * } + */ + public static final OfLong __time_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef int __key_t + * } + */ + public static final OfInt __key_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = cagra_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = cagra_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = cagra_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = cagra_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = cagra_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = cagra_h.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; + } + + private static final int AUTO_SELECT = (int) 0L; + + /** + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 + * } + */ + public static int AUTO_SELECT() { + return AUTO_SELECT; + } + + private static final int IVF_PQ = (int) 1L; + + /** + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 + * } + */ + public static int IVF_PQ() { + return IVF_PQ; + } + + private static final int NN_DESCENT = (int) 2L; + + /** + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 + * } + */ + public static int NN_DESCENT() { + return NN_DESCENT; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsCagraCompressionParams { + * uint32_t pq_bits; + * uint32_t pq_dim; + * uint32_t vq_n_centers; + * uint32_t kmeans_n_iters; + * double vq_kmeans_trainset_fraction; + * double pq_kmeans_trainset_fraction; + * } *cuvsCagraCompressionParams_t + * } + */ + public static final AddressLayout cuvsCagraCompressionParams_t = cagra_h.C_POINTER; + /** + * {@snippet lang = c : + * typedef struct cuvsCagraIndexParams { + * unsigned int intermediate_graph_degree; + * unsigned int graph_degree; + * enum cuvsCagraGraphBuildAlgo build_algo; + * unsigned int nn_descent_niter; + * cuvsCagraCompressionParams_t compression; + * } *cuvsCagraIndexParams_t + * } + */ + public static final AddressLayout cuvsCagraIndexParams_t = cagra_h.C_POINTER; + + private static class cuvsCagraIndexParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); + + public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraIndexParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * } + */ + public static FunctionDescriptor cuvsCagraIndexParamsCreate$descriptor() { + return cuvsCagraIndexParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * } + */ + public static MethodHandle cuvsCagraIndexParamsCreate$handle() { + return cuvsCagraIndexParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * } + */ + public static MemorySegment cuvsCagraIndexParamsCreate$address() { + return cuvsCagraIndexParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * } + */ + public static int cuvsCagraIndexParamsCreate(MemorySegment params) { + var mh$ = cuvsCagraIndexParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsCagraIndexParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsCagraIndexParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); + + public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraIndexParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * } + */ + public static FunctionDescriptor cuvsCagraIndexParamsDestroy$descriptor() { + return cuvsCagraIndexParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * } + */ + public static MethodHandle cuvsCagraIndexParamsDestroy$handle() { + return cuvsCagraIndexParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * } + */ + public static MemorySegment cuvsCagraIndexParamsDestroy$address() { + return cuvsCagraIndexParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * } + */ + public static int cuvsCagraIndexParamsDestroy(MemorySegment params) { + var mh$ = cuvsCagraIndexParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsCagraIndexParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsCagraCompressionParamsCreate { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); + + public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraCompressionParamsCreate"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * } + */ + public static FunctionDescriptor cuvsCagraCompressionParamsCreate$descriptor() { + return cuvsCagraCompressionParamsCreate.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * } + */ + public static MethodHandle cuvsCagraCompressionParamsCreate$handle() { + return cuvsCagraCompressionParamsCreate.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * } + */ + public static MemorySegment cuvsCagraCompressionParamsCreate$address() { + return cuvsCagraCompressionParamsCreate.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * } + */ + public static int cuvsCagraCompressionParamsCreate(MemorySegment params) { + var mh$ = cuvsCagraCompressionParamsCreate.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsCagraCompressionParamsCreate", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class cuvsCagraCompressionParamsDestroy { + public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); + + public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraCompressionParamsDestroy"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * } + */ + public static FunctionDescriptor cuvsCagraCompressionParamsDestroy$descriptor() { + return cuvsCagraCompressionParamsDestroy.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * } + */ + public static MethodHandle cuvsCagraCompressionParamsDestroy$handle() { + return cuvsCagraCompressionParamsDestroy.HANDLE; + } + + /** + * Address for: + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * } + */ + public static MemorySegment cuvsCagraCompressionParamsDestroy$address() { + return cuvsCagraCompressionParamsDestroy.ADDR; + } + + /** + * {@snippet lang = c + * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * } + */ + public static int cuvsCagraCompressionParamsDestroy(MemorySegment params) { + var mh$ = cuvsCagraCompressionParamsDestroy.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("cuvsCagraCompressionParamsDestroy", params); + } + return (int) mh$.invokeExact(params); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static final int SINGLE_CTA = (int) 0L; + + /** + * {@snippet lang = c : * enum cuvsCagraSearchAlgo.SINGLE_CTA = 0 + * } + */ + public static int SINGLE_CTA() { + return SINGLE_CTA; + } + + private static final int MULTI_CTA = (int) 1L; + + /** + * {@snippet lang = c : * enum cuvsCagraSearchAlgo.MULTI_CTA = 1 + * } + */ + public static int MULTI_CTA() { + return MULTI_CTA; + } + + private static final int MULTI_KERNEL = (int) 2L; + + /** + * {@snippet lang = c : * enum cuvsCagraSearchAlgo.MULTI_KERNEL = 2 + * } + */ + public static int MULTI_KERNEL() { + return MULTI_KERNEL; + } + + private static final int AUTO = (int) 3L; + + /** + * {@snippet lang = c : * enum cuvsCagraSearchAlgo.AUTO = 3 + * } + */ + public static int AUTO() { + return AUTO; + } + + private static final int HASH = (int) 0L; + + /** + * {@snippet lang = c : * enum cuvsCagraHashMode.HASH = 0 + * } + */ + public static int HASH() { + return HASH; + } + + private static final int SMALL = (int) 1L; + + /** + * {@snippet lang = c : * enum cuvsCagraHashMode.SMALL = 1 + * } + */ + public static int SMALL() { + return SMALL; + } + + private static final int AUTO_HASH = (int) 2L; + + /** + * {@snippet lang = c : * enum cuvsCagraHashMode.AUTO_HASH = 2 + * } + */ + public static int AUTO_HASH() { + return AUTO_HASH; + } + + /** + * {@snippet lang = c : + * typedef struct cuvsCagraSearchParams { + * unsigned int max_queries; + * unsigned int itopk_size; + * unsigned int max_iterations; + * enum cuvsCagraSearchAlgo algo; + * unsigned int team_size; + * unsigned int search_width; + * unsigned int min_iterations; + * unsigned int thread_block_size; + * enum cuvsCagraHashMode hashmap_mode; + * unsigned int hashmap_min_bitlen; + * float hashmap_max_fill_rate; + * uint32_t num_random_samplings; + * uint64_t rand_xor_mask; + * } *cuvsCagraSearchParams_t + * } + */ + public static final AddressLayout cuvsCagraSearchParams_t = cagra_h.C_POINTER; + private static final long _POSIX_C_SOURCE = 200809L; + + /** + * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + + private static final int __TIMESIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + + private static final long __STDC_IEC_60559_BFP__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + + private static final long __STDC_ISO_10646__ = 201706L; + + /** + * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + + private static final int __WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + + private static final int __WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + + private static final int INT8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + + private static final int INT16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + + private static final int INT32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + + private static final long INT64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + + private static final int INT8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + + private static final int INT16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + + private static final int INT32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + + private static final long INT64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + + private static final int UINT8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + + private static final int UINT16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + + private static final int UINT32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + + private static final long UINT64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + + private static final int INT_LEAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + + private static final int INT_LEAST16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + + private static final int INT_LEAST32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + + private static final long INT_LEAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + + private static final int INT_LEAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + + private static final int INT_LEAST16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + + private static final int INT_LEAST32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + + private static final long INT_LEAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + + private static final int UINT_LEAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + + private static final int UINT_LEAST16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + + private static final int UINT_LEAST32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + + private static final long UINT_LEAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + + private static final int INT_FAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + + private static final long INT_FAST16_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + + private static final long INT_FAST32_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + + private static final long INT_FAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + + private static final int INT_FAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + + private static final long INT_FAST16_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + + private static final long INT_FAST32_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + + private static final long INT_FAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + + private static final int UINT_FAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + + private static final long UINT_FAST16_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + + private static final long UINT_FAST32_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + + private static final long UINT_FAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + + private static final long INTPTR_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + + private static final long INTPTR_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + + private static final long UINTPTR_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + + private static final long INTMAX_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + + private static final long INTMAX_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + + private static final long UINTMAX_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + + private static final long PTRDIFF_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + + private static final long PTRDIFF_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + + private static final int SIG_ATOMIC_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + + private static final int SIG_ATOMIC_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + + private static final long SIZE_MAX = -1L; + + /** + * {@snippet lang = c : * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + + private static final int WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + + private static final int WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + + private static final int WINT_MIN = (int) 0L; + + /** + * {@snippet lang = c : * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + + private static final int WINT_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java deleted file mode 100644 index 4bf6f639b..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraCompressionParams.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright (c) 2024, 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.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfDouble; -import java.lang.foreign.ValueLayout.OfInt; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct cuvsCagraCompressionParams { - * uint32_t pq_bits; - * uint32_t pq_dim; - * uint32_t vq_n_centers; - * uint32_t kmeans_n_iters; - * double vq_kmeans_trainset_fraction; - * double pq_kmeans_trainset_fraction; - * } - * } - */ -public class cuvsCagraCompressionParams { - - cuvsCagraCompressionParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - cagra_h.C_INT.withName("pq_bits"), - cagra_h.C_INT.withName("pq_dim"), - cagra_h.C_INT.withName("vq_n_centers"), - cagra_h.C_INT.withName("kmeans_n_iters"), - cagra_h.C_DOUBLE.withName("vq_kmeans_trainset_fraction"), - cagra_h.C_DOUBLE.withName("pq_kmeans_trainset_fraction") - ).withName("cuvsCagraCompressionParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfInt pq_bits$LAYOUT = (OfInt)$LAYOUT.select(groupElement("pq_bits")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t pq_bits - * } - */ - public static final OfInt pq_bits$layout() { - return pq_bits$LAYOUT; - } - - private static final long pq_bits$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t pq_bits - * } - */ - public static final long pq_bits$offset() { - return pq_bits$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t pq_bits - * } - */ - public static int pq_bits(MemorySegment struct) { - return struct.get(pq_bits$LAYOUT, pq_bits$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t pq_bits - * } - */ - public static void pq_bits(MemorySegment struct, int fieldValue) { - struct.set(pq_bits$LAYOUT, pq_bits$OFFSET, fieldValue); - } - - private static final OfInt pq_dim$LAYOUT = (OfInt)$LAYOUT.select(groupElement("pq_dim")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t pq_dim - * } - */ - public static final OfInt pq_dim$layout() { - return pq_dim$LAYOUT; - } - - private static final long pq_dim$OFFSET = 4; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t pq_dim - * } - */ - public static final long pq_dim$offset() { - return pq_dim$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t pq_dim - * } - */ - public static int pq_dim(MemorySegment struct) { - return struct.get(pq_dim$LAYOUT, pq_dim$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t pq_dim - * } - */ - public static void pq_dim(MemorySegment struct, int fieldValue) { - struct.set(pq_dim$LAYOUT, pq_dim$OFFSET, fieldValue); - } - - private static final OfInt vq_n_centers$LAYOUT = (OfInt)$LAYOUT.select(groupElement("vq_n_centers")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t vq_n_centers - * } - */ - public static final OfInt vq_n_centers$layout() { - return vq_n_centers$LAYOUT; - } - - private static final long vq_n_centers$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t vq_n_centers - * } - */ - public static final long vq_n_centers$offset() { - return vq_n_centers$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t vq_n_centers - * } - */ - public static int vq_n_centers(MemorySegment struct) { - return struct.get(vq_n_centers$LAYOUT, vq_n_centers$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t vq_n_centers - * } - */ - public static void vq_n_centers(MemorySegment struct, int fieldValue) { - struct.set(vq_n_centers$LAYOUT, vq_n_centers$OFFSET, fieldValue); - } - - private static final OfInt kmeans_n_iters$LAYOUT = (OfInt)$LAYOUT.select(groupElement("kmeans_n_iters")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t kmeans_n_iters - * } - */ - public static final OfInt kmeans_n_iters$layout() { - return kmeans_n_iters$LAYOUT; - } - - private static final long kmeans_n_iters$OFFSET = 12; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t kmeans_n_iters - * } - */ - public static final long kmeans_n_iters$offset() { - return kmeans_n_iters$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t kmeans_n_iters - * } - */ - public static int kmeans_n_iters(MemorySegment struct) { - return struct.get(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t kmeans_n_iters - * } - */ - public static void kmeans_n_iters(MemorySegment struct, int fieldValue) { - struct.set(kmeans_n_iters$LAYOUT, kmeans_n_iters$OFFSET, fieldValue); - } - - private static final OfDouble vq_kmeans_trainset_fraction$LAYOUT = (OfDouble)$LAYOUT.select(groupElement("vq_kmeans_trainset_fraction")); - - /** - * Layout for field: - * {@snippet lang=c : - * double vq_kmeans_trainset_fraction - * } - */ - public static final OfDouble vq_kmeans_trainset_fraction$layout() { - return vq_kmeans_trainset_fraction$LAYOUT; - } - - private static final long vq_kmeans_trainset_fraction$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang=c : - * double vq_kmeans_trainset_fraction - * } - */ - public static final long vq_kmeans_trainset_fraction$offset() { - return vq_kmeans_trainset_fraction$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * double vq_kmeans_trainset_fraction - * } - */ - public static double vq_kmeans_trainset_fraction(MemorySegment struct) { - return struct.get(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * double vq_kmeans_trainset_fraction - * } - */ - public static void vq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { - struct.set(vq_kmeans_trainset_fraction$LAYOUT, vq_kmeans_trainset_fraction$OFFSET, fieldValue); - } - - private static final OfDouble pq_kmeans_trainset_fraction$LAYOUT = (OfDouble)$LAYOUT.select(groupElement("pq_kmeans_trainset_fraction")); - - /** - * Layout for field: - * {@snippet lang=c : - * double pq_kmeans_trainset_fraction - * } - */ - public static final OfDouble pq_kmeans_trainset_fraction$layout() { - return pq_kmeans_trainset_fraction$LAYOUT; - } - - private static final long pq_kmeans_trainset_fraction$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang=c : - * double pq_kmeans_trainset_fraction - * } - */ - public static final long pq_kmeans_trainset_fraction$offset() { - return pq_kmeans_trainset_fraction$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * double pq_kmeans_trainset_fraction - * } - */ - public static double pq_kmeans_trainset_fraction(MemorySegment struct) { - return struct.get(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * double pq_kmeans_trainset_fraction - * } - */ - public static void pq_kmeans_trainset_fraction(MemorySegment struct, double fieldValue) { - struct.set(pq_kmeans_trainset_fraction$LAYOUT, pq_kmeans_trainset_fraction$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} - diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java deleted file mode 100644 index 9384f587e..000000000 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraSearchParams.java +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Copyright (c) 2024, 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.panama; - -import static java.lang.foreign.MemoryLayout.PathElement.groupElement; - -import java.lang.foreign.Arena; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentAllocator; -import java.lang.foreign.ValueLayout.OfFloat; -import java.lang.foreign.ValueLayout.OfInt; -import java.lang.foreign.ValueLayout.OfLong; -import java.util.function.Consumer; - -/** - * {@snippet lang=c : - * struct cuvsCagraSearchParams { - * size_t max_queries; - * size_t itopk_size; - * size_t max_iterations; - * enum cuvsCagraSearchAlgo algo; - * size_t team_size; - * size_t search_width; - * size_t min_iterations; - * size_t thread_block_size; - * enum cuvsCagraHashMode hashmap_mode; - * size_t hashmap_min_bitlen; - * float hashmap_max_fill_rate; - * uint32_t num_random_samplings; - * uint64_t rand_xor_mask; - * } - * } - */ -public class cuvsCagraSearchParams { - - cuvsCagraSearchParams() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - cagra_h.C_LONG.withName("max_queries"), - cagra_h.C_LONG.withName("itopk_size"), - cagra_h.C_LONG.withName("max_iterations"), - cagra_h.C_INT.withName("algo"), - MemoryLayout.paddingLayout(4), - cagra_h.C_LONG.withName("team_size"), - cagra_h.C_LONG.withName("search_width"), - cagra_h.C_LONG.withName("min_iterations"), - cagra_h.C_LONG.withName("thread_block_size"), - cagra_h.C_INT.withName("hashmap_mode"), - MemoryLayout.paddingLayout(4), - cagra_h.C_LONG.withName("hashmap_min_bitlen"), - cagra_h.C_FLOAT.withName("hashmap_max_fill_rate"), - cagra_h.C_INT.withName("num_random_samplings"), - cagra_h.C_LONG.withName("rand_xor_mask") - ).withName("cuvsCagraSearchParams"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong max_queries$LAYOUT = (OfLong)$LAYOUT.select(groupElement("max_queries")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t max_queries - * } - */ - public static final OfLong max_queries$layout() { - return max_queries$LAYOUT; - } - - private static final long max_queries$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t max_queries - * } - */ - public static final long max_queries$offset() { - return max_queries$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t max_queries - * } - */ - public static long max_queries(MemorySegment struct) { - return struct.get(max_queries$LAYOUT, max_queries$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t max_queries - * } - */ - public static void max_queries(MemorySegment struct, long fieldValue) { - struct.set(max_queries$LAYOUT, max_queries$OFFSET, fieldValue); - } - - private static final OfLong itopk_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("itopk_size")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t itopk_size - * } - */ - public static final OfLong itopk_size$layout() { - return itopk_size$LAYOUT; - } - - private static final long itopk_size$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t itopk_size - * } - */ - public static final long itopk_size$offset() { - return itopk_size$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t itopk_size - * } - */ - public static long itopk_size(MemorySegment struct) { - return struct.get(itopk_size$LAYOUT, itopk_size$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t itopk_size - * } - */ - public static void itopk_size(MemorySegment struct, long fieldValue) { - struct.set(itopk_size$LAYOUT, itopk_size$OFFSET, fieldValue); - } - - private static final OfLong max_iterations$LAYOUT = (OfLong)$LAYOUT.select(groupElement("max_iterations")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t max_iterations - * } - */ - public static final OfLong max_iterations$layout() { - return max_iterations$LAYOUT; - } - - private static final long max_iterations$OFFSET = 16; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t max_iterations - * } - */ - public static final long max_iterations$offset() { - return max_iterations$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t max_iterations - * } - */ - public static long max_iterations(MemorySegment struct) { - return struct.get(max_iterations$LAYOUT, max_iterations$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t max_iterations - * } - */ - public static void max_iterations(MemorySegment struct, long fieldValue) { - struct.set(max_iterations$LAYOUT, max_iterations$OFFSET, fieldValue); - } - - private static final OfInt algo$LAYOUT = (OfInt)$LAYOUT.select(groupElement("algo")); - - /** - * Layout for field: - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo algo - * } - */ - public static final OfInt algo$layout() { - return algo$LAYOUT; - } - - private static final long algo$OFFSET = 24; - - /** - * Offset for field: - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo algo - * } - */ - public static final long algo$offset() { - return algo$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo algo - * } - */ - public static int algo(MemorySegment struct) { - return struct.get(algo$LAYOUT, algo$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * enum cuvsCagraSearchAlgo algo - * } - */ - public static void algo(MemorySegment struct, int fieldValue) { - struct.set(algo$LAYOUT, algo$OFFSET, fieldValue); - } - - private static final OfLong team_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("team_size")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t team_size - * } - */ - public static final OfLong team_size$layout() { - return team_size$LAYOUT; - } - - private static final long team_size$OFFSET = 32; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t team_size - * } - */ - public static final long team_size$offset() { - return team_size$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t team_size - * } - */ - public static long team_size(MemorySegment struct) { - return struct.get(team_size$LAYOUT, team_size$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t team_size - * } - */ - public static void team_size(MemorySegment struct, long fieldValue) { - struct.set(team_size$LAYOUT, team_size$OFFSET, fieldValue); - } - - private static final OfLong search_width$LAYOUT = (OfLong)$LAYOUT.select(groupElement("search_width")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t search_width - * } - */ - public static final OfLong search_width$layout() { - return search_width$LAYOUT; - } - - private static final long search_width$OFFSET = 40; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t search_width - * } - */ - public static final long search_width$offset() { - return search_width$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t search_width - * } - */ - public static long search_width(MemorySegment struct) { - return struct.get(search_width$LAYOUT, search_width$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t search_width - * } - */ - public static void search_width(MemorySegment struct, long fieldValue) { - struct.set(search_width$LAYOUT, search_width$OFFSET, fieldValue); - } - - private static final OfLong min_iterations$LAYOUT = (OfLong)$LAYOUT.select(groupElement("min_iterations")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t min_iterations - * } - */ - public static final OfLong min_iterations$layout() { - return min_iterations$LAYOUT; - } - - private static final long min_iterations$OFFSET = 48; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t min_iterations - * } - */ - public static final long min_iterations$offset() { - return min_iterations$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t min_iterations - * } - */ - public static long min_iterations(MemorySegment struct) { - return struct.get(min_iterations$LAYOUT, min_iterations$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t min_iterations - * } - */ - public static void min_iterations(MemorySegment struct, long fieldValue) { - struct.set(min_iterations$LAYOUT, min_iterations$OFFSET, fieldValue); - } - - private static final OfLong thread_block_size$LAYOUT = (OfLong)$LAYOUT.select(groupElement("thread_block_size")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t thread_block_size - * } - */ - public static final OfLong thread_block_size$layout() { - return thread_block_size$LAYOUT; - } - - private static final long thread_block_size$OFFSET = 56; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t thread_block_size - * } - */ - public static final long thread_block_size$offset() { - return thread_block_size$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t thread_block_size - * } - */ - public static long thread_block_size(MemorySegment struct) { - return struct.get(thread_block_size$LAYOUT, thread_block_size$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t thread_block_size - * } - */ - public static void thread_block_size(MemorySegment struct, long fieldValue) { - struct.set(thread_block_size$LAYOUT, thread_block_size$OFFSET, fieldValue); - } - - private static final OfInt hashmap_mode$LAYOUT = (OfInt)$LAYOUT.select(groupElement("hashmap_mode")); - - /** - * Layout for field: - * {@snippet lang=c : - * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static final OfInt hashmap_mode$layout() { - return hashmap_mode$LAYOUT; - } - - private static final long hashmap_mode$OFFSET = 64; - - /** - * Offset for field: - * {@snippet lang=c : - * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static final long hashmap_mode$offset() { - return hashmap_mode$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static int hashmap_mode(MemorySegment struct) { - return struct.get(hashmap_mode$LAYOUT, hashmap_mode$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * enum cuvsCagraHashMode hashmap_mode - * } - */ - public static void hashmap_mode(MemorySegment struct, int fieldValue) { - struct.set(hashmap_mode$LAYOUT, hashmap_mode$OFFSET, fieldValue); - } - - private static final OfLong hashmap_min_bitlen$LAYOUT = (OfLong)$LAYOUT.select(groupElement("hashmap_min_bitlen")); - - /** - * Layout for field: - * {@snippet lang=c : - * size_t hashmap_min_bitlen - * } - */ - public static final OfLong hashmap_min_bitlen$layout() { - return hashmap_min_bitlen$LAYOUT; - } - - private static final long hashmap_min_bitlen$OFFSET = 72; - - /** - * Offset for field: - * {@snippet lang=c : - * size_t hashmap_min_bitlen - * } - */ - public static final long hashmap_min_bitlen$offset() { - return hashmap_min_bitlen$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * size_t hashmap_min_bitlen - * } - */ - public static long hashmap_min_bitlen(MemorySegment struct) { - return struct.get(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * size_t hashmap_min_bitlen - * } - */ - public static void hashmap_min_bitlen(MemorySegment struct, long fieldValue) { - struct.set(hashmap_min_bitlen$LAYOUT, hashmap_min_bitlen$OFFSET, fieldValue); - } - - private static final OfFloat hashmap_max_fill_rate$LAYOUT = (OfFloat)$LAYOUT.select(groupElement("hashmap_max_fill_rate")); - - /** - * Layout for field: - * {@snippet lang=c : - * float hashmap_max_fill_rate - * } - */ - public static final OfFloat hashmap_max_fill_rate$layout() { - return hashmap_max_fill_rate$LAYOUT; - } - - private static final long hashmap_max_fill_rate$OFFSET = 80; - - /** - * Offset for field: - * {@snippet lang=c : - * float hashmap_max_fill_rate - * } - */ - public static final long hashmap_max_fill_rate$offset() { - return hashmap_max_fill_rate$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * float hashmap_max_fill_rate - * } - */ - public static float hashmap_max_fill_rate(MemorySegment struct) { - return struct.get(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * float hashmap_max_fill_rate - * } - */ - public static void hashmap_max_fill_rate(MemorySegment struct, float fieldValue) { - struct.set(hashmap_max_fill_rate$LAYOUT, hashmap_max_fill_rate$OFFSET, fieldValue); - } - - private static final OfInt num_random_samplings$LAYOUT = (OfInt)$LAYOUT.select(groupElement("num_random_samplings")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint32_t num_random_samplings - * } - */ - public static final OfInt num_random_samplings$layout() { - return num_random_samplings$LAYOUT; - } - - private static final long num_random_samplings$OFFSET = 84; - - /** - * Offset for field: - * {@snippet lang=c : - * uint32_t num_random_samplings - * } - */ - public static final long num_random_samplings$offset() { - return num_random_samplings$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint32_t num_random_samplings - * } - */ - public static int num_random_samplings(MemorySegment struct) { - return struct.get(num_random_samplings$LAYOUT, num_random_samplings$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint32_t num_random_samplings - * } - */ - public static void num_random_samplings(MemorySegment struct, int fieldValue) { - struct.set(num_random_samplings$LAYOUT, num_random_samplings$OFFSET, fieldValue); - } - - private static final OfLong rand_xor_mask$LAYOUT = (OfLong)$LAYOUT.select(groupElement("rand_xor_mask")); - - /** - * Layout for field: - * {@snippet lang=c : - * uint64_t rand_xor_mask - * } - */ - public static final OfLong rand_xor_mask$layout() { - return rand_xor_mask$LAYOUT; - } - - private static final long rand_xor_mask$OFFSET = 88; - - /** - * Offset for field: - * {@snippet lang=c : - * uint64_t rand_xor_mask - * } - */ - public static final long rand_xor_mask$offset() { - return rand_xor_mask$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uint64_t rand_xor_mask - * } - */ - public static long rand_xor_mask(MemorySegment struct) { - return struct.get(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uint64_t rand_xor_mask - * } - */ - public static void rand_xor_mask(MemorySegment struct, long fieldValue) { - struct.set(rand_xor_mask$LAYOUT, rand_xor_mask$OFFSET, fieldValue); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } -} - diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index c5788d342..47e42f2a5 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -16,7 +16,7 @@ package com.nvidia.cuvs; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.Assert.assertEquals; import java.io.File; import java.io.FileInputStream; @@ -28,14 +28,15 @@ import java.util.Map; import java.util.UUID; -import org.junit.jupiter.api.Test; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; import com.nvidia.cuvs.common.SearchResults; public class CagraBuildAndSearchTest { - + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); /** @@ -47,71 +48,88 @@ public class CagraBuildAndSearchTest { public void testIndexingAndSearchingFlow() throws Throwable { // Sample data and query - float[][] dataset = {{ 0.74021935f, 0.9209938f }, { 0.03902049f, 0.9689629f }, { 0.92514056f, 0.4463501f }, { 0.6673192f, 0.10993068f }}; + float[][] dataset = { + { 0.74021935f, 0.9209938f }, + { 0.03902049f, 0.9689629f }, + { 0.92514056f, 0.4463501f }, + { 0.6673192f, 0.10993068f } + }; Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); - float[][] queries = {{ 0.48216683f, 0.0428398f }, { 0.5084142f, 0.6545497f }, { 0.51260436f, 0.2643005f }, { 0.05198065f, 0.5789965f }}; - + float[][] queries = { + { 0.48216683f, 0.0428398f }, + { 0.5084142f, 0.6545497f }, + { 0.51260436f, 0.2643005f }, + { 0.05198065f, 0.5789965f } + }; + // Expected search results List> expectedResults = Arrays.asList( Map.of(3, 0.038782578f, 2, 0.3590463f, 0, 0.83774555f), - Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), - Map.of(3, 0.047766715f, 2, 0.20332818f, 0, 0.48305473f), + Map.of(0, 0.12472608f, 2, 0.21700792f, 1, 0.31918612f), + Map.of(3, 0.047766715f, 2, 0.20332818f, 0, 0.48305473f), Map.of(1, 0.15224178f, 0, 0.59063464f, 3, 0.5986642f)); - // Create resource - CuVSResources resources = new CuVSResources(); - - // Configure index parameters - CagraIndexParams indexParams = new CagraIndexParams.Builder(resources) - .withCagraGraphBuildAlgo(CagraIndexParams.CagraGraphBuildAlgo.NN_DESCENT) - .build(); - - // Create the index with the dataset - CagraIndex index = new CagraIndex.Builder(resources) - .withDataset(dataset) - .withIndexParams(indexParams) - .build(); - - // Saving the index on to the disk. - String indexFileName = UUID.randomUUID().toString() + ".cag"; - index.serialize(new FileOutputStream(indexFileName)); - - // Loading a CAGRA index from disk. - File indexFile = new File(indexFileName); - InputStream inputStream = new FileInputStream(indexFile); - CagraIndex loadedIndex = new CagraIndex.Builder(resources) - .from(inputStream) - .build(); - - // Configure search parameters - CagraSearchParams searchParams = new CagraSearchParams.Builder(resources) - .build(); - - // Create a query object with the query vectors - CagraQuery cuvsQuery = new CagraQuery.Builder() - .withTopK(3) - .withSearchParams(searchParams) - .withQueryVectors(queries) - .withMapping(map) - .build(); - - // Perform the search - SearchResults results = index.search(cuvsQuery); - - // Check results - log.info(results.getResults().toString()); - assertEquals(expectedResults, results.getResults(), "Results different than expected"); - - // Search from deserialized index - results = loadedIndex.search(cuvsQuery); - - // Check results - log.info(results.getResults().toString()); - assertEquals(expectedResults, results.getResults(), "Results different than expected"); - - // Cleanup - if (indexFile.exists()) { - indexFile.delete(); + for (int j = 0; j < 10; j++) { + + try (CuVSResources resources = new CuVSResources()) { + + // Configure index parameters + CagraIndexParams indexParams = new CagraIndexParams.Builder(resources) + .withCagraGraphBuildAlgo(CagraGraphBuildAlgo.NN_DESCENT) + .withGraphDegree(1) + .withIntermediateGraphDegree(2) + .withNumWriterThreads(32) + .build(); + + // Create the index with the dataset + CagraIndex index = new CagraIndex.Builder(resources) + .withDataset(dataset) + .withIndexParams(indexParams) + .build(); + + // Saving the index on to the disk. + String indexFileName = UUID.randomUUID().toString() + ".cag"; + index.serialize(new FileOutputStream(indexFileName)); + + // Loading a CAGRA index from disk. + File indexFile = new File(indexFileName); + InputStream inputStream = new FileInputStream(indexFile); + CagraIndex loadedIndex = new CagraIndex.Builder(resources) + .from(inputStream) + .build(); + + // Configure search parameters + CagraSearchParams searchParams = new CagraSearchParams.Builder(resources) + .build(); + + // Create a query object with the query vectors + CagraQuery cuvsQuery = new CagraQuery.Builder() + .withTopK(3) + .withSearchParams(searchParams) + .withQueryVectors(queries) + .withMapping(map) + .build(); + + // Perform the search + SearchResults results = index.search(cuvsQuery); + + // Check results + log.info(results.getResults().toString()); + assertEquals(expectedResults, results.getResults()); + + // Search from deserialized index + results = loadedIndex.search(cuvsQuery); + + // Check results + log.info(results.getResults().toString()); + assertEquals(expectedResults, results.getResults()); + + // Cleanup + if (indexFile.exists()) { + indexFile.delete(); + } + index.destroyIndex(); + } } } } \ No newline at end of file diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraRandomizedTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraRandomizedTest.java new file mode 100644 index 000000000..0d5ba5c6d --- /dev/null +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraRandomizedTest.java @@ -0,0 +1,163 @@ +package com.nvidia.cuvs; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.carrotsearch.randomizedtesting.RandomizedRunner; +import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; + +@RunWith(RandomizedRunner.class) +public class CagraRandomizedTest extends CuVSTestCase { + + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + @Before + public void setup() { + initializeRandom(); + log.info("Random context initialized for test."); + } + + @Test + public void testResultsTopKWithRandomValues() throws Throwable { + for (int i=0; i<10; i++) { + tmpResultsTopKWithRandomValues(); + } + } + + public void tmpResultsTopKWithRandomValues() throws Throwable { + int DATASET_SIZE_LIMIT = 10_000; + int DIMENSIONS_LIMIT = 2048; + int NUM_QUERIES_LIMIT = 10; + int TOP_K_LIMIT = 64; // nocommit This fails beyond 64 + + int datasetSize = random.nextInt(DATASET_SIZE_LIMIT) + 1; + int dimensions = random.nextInt(DIMENSIONS_LIMIT) + 1; + int numQueries = random.nextInt(NUM_QUERIES_LIMIT) + 1; + int topK = Math.min(random.nextInt(TOP_K_LIMIT) + 1, datasetSize); + + if(datasetSize < topK) datasetSize = topK; + + // Generate a random dataset + float[][] dataset = new float[datasetSize][dimensions]; + for (int i = 0; i < datasetSize; i++) { + for (int j = 0; j < dimensions; j++) { + dataset[i][j] = random.nextFloat() * 100; + } + } + // Generate random query vectors + float[][] queries = new float[numQueries][dimensions]; + for (int i = 0; i < numQueries; i++) { + for (int j = 0; j < dimensions; j++) { + queries[i][j] = random.nextFloat() * 100; + } + } + log.info("Dataset size: {}x{}", datasetSize, dimensions); + log.info("Query size: {}x{}", numQueries, dimensions); + log.info("TopK: {}", topK); + + // Debugging: Log dataset and queries + if (log.isDebugEnabled()) { + log.debug("Dataset:"); + for (float[] row : dataset) { + log.debug(java.util.Arrays.toString(row)); + } + log.debug("Queries:"); + for (float[] query : queries) { + log.debug(java.util.Arrays.toString(query)); + } + } + // Sanity checks + assert dataset.length > 0 : "Dataset is empty."; + assert queries.length > 0 : "Queries are empty."; + assert dimensions > 0 : "Invalid dimensions."; + assert topK > 0 && topK <= datasetSize : "Invalid topK value."; + + // Generate expected results using brute force + List> expected = generateExpectedResults(topK, dataset, queries); + + // Create CuVS index and query + try (CuVSResources resources = new CuVSResources()) { + CagraIndexParams indexParams = new CagraIndexParams.Builder(resources).withCagraGraphBuildAlgo(CagraGraphBuildAlgo.NN_DESCENT).build(); + CagraIndex index = new CagraIndex.Builder(resources).withDataset(dataset).withIndexParams(indexParams).build(); + log.info("Index built successfully."); + + // Execute search and retrieve results + CagraQuery query = new CagraQuery.Builder() + .withQueryVectors(queries) + .withTopK(topK) + .withSearchParams(new CagraSearchParams.Builder(resources).build()) + .build(); + log.info("Query built successfully. Executing search..."); + CagraSearchResults results = index.search(query); + + for (int i=0; i result = results.getResults().get(i); + assertEquals("TopK mismatch for query.", Math.min(topK, datasetSize), result.size()); + + // Sort result by values (distances) and extract keys + List sortedResultKeys = result.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) // Sort by value (distance) + .map(Map.Entry::getKey) // Extract sorted keys + .toList(); + + // Compare using primitive int arrays + /*assertArrayEquals( + "Query " + i + " mismatched", + expected.get(i).stream().mapToInt(Integer::intValue).toArray(), + sortedResultKeys.stream().mapToInt(Integer::intValue).toArray() + );*/ + + // just make sure that the first 5 results are in the expected list (which comprises of 2*topK results) + for (int j = 0; j< Math.min(5, sortedResultKeys.size()); j++) { + assertTrue("Not found in expected list: " + sortedResultKeys.get(j), + expected.get(i).contains(sortedResultKeys.get(j))); + } + + } + } + } + + private List> generateExpectedResults(int topK, float[][] dataset, float[][] queries) { + List> neighborsResult = new ArrayList<>(); + int dimensions = dataset[0].length; + + for (float[] query : queries) { + Map distances = new TreeMap<>(); + for (int j = 0; j < dataset.length; j++) { + double distance = 0; + for (int k = 0; k < dimensions; k++) { + distance += (query[k] - dataset[j][k]) * (query[k] - dataset[j][k]); + } + distances.put(j, Math.sqrt(distance)); + } + + // Sort by distance and select the topK nearest neighbors + List neighbors = distances.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .map(Map.Entry::getKey) + .toList(); + neighborsResult.add(neighbors.subList(0, Math.min(topK * 2, dataset.length))); // generate double the topK results in the expected array + } + + log.info("Expected results generated successfully."); + return neighborsResult; + } +} diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CuVSTestCase.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CuVSTestCase.java new file mode 100644 index 000000000..a07cb4ebf --- /dev/null +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CuVSTestCase.java @@ -0,0 +1,19 @@ +package com.nvidia.cuvs; + +import java.lang.invoke.MethodHandles; +import java.util.Random; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.carrotsearch.randomizedtesting.RandomizedContext; + +public abstract class CuVSTestCase { + protected Random random; + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + protected void initializeRandom() { + random = RandomizedContext.current().getRandom(); + log.info("Test seed: " + RandomizedContext.current().getRunnerSeedAsString()); + } +} diff --git a/java/internal/CMakeLists.txt b/java/internal/CMakeLists.txt index d9a851872..7c1f882f5 100644 --- a/java/internal/CMakeLists.txt +++ b/java/internal/CMakeLists.txt @@ -27,6 +27,9 @@ project( LANGUAGES CXX C ) +find_package(OpenMP) +find_package(Threads) + option(FIND_CUVS_CPP "Search for existing CUVS C++ installations before defaulting to local files" ON ) @@ -53,4 +56,4 @@ include(get_dlpack.cmake) ADD_LIBRARY(cuvs_java SHARED src/cuvs_java.c) target_include_directories(cuvs_java PUBLIC "$") -target_link_libraries(cuvs_java PRIVATE cuvs::c_api $) +target_link_libraries(cuvs_java PRIVATE cuvs::c_api $ OpenMP::OpenMP_CXX Threads::Threads) diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index ec9ecb6af..b6a078e24 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -20,13 +20,22 @@ #include #include #include +#include -cuvsResources_t create_resource(int *returnValue) { +#define try bool __HadError=false; +#define catch(x) ExitJmp:if(__HadError) +#define throw(x) {__HadError=true;goto ExitJmp;} + +cuvsResources_t create_resources(int *returnValue) { cuvsResources_t cuvsResources; *returnValue = cuvsResourcesCreate(&cuvsResources); return cuvsResources; } +void destroy_resources(cuvsResources_t cuvsResources, int *returnValue) { + *returnValue = cuvsResourcesDestroy(cuvsResources); +} + DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) { DLManagedTensor tensor; @@ -43,7 +52,10 @@ DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) } cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvsResources, int *returnValue, - cuvsCagraIndexParams_t index_params) { + cuvsCagraIndexParams_t index_params, cuvsCagraCompressionParams_t compression_params, int numWriterThreads) { + + omp_set_num_threads(numWriterThreads); + cuvsRMMPoolMemoryResourceEnable(95, 95, true); int64_t dataset_shape[2] = {rows, dimensions}; DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat); @@ -51,10 +63,18 @@ cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, c cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); + index_params->compression = compression_params; *returnValue = cuvsCagraBuild(cuvsResources, index_params, &dataset_tensor, index); + + omp_set_num_threads(1); + return index; } +void destroy_cagra_index(cuvsCagraIndex_t index, int *returnValue) { + *returnValue = cuvsCagraIndexDestroy(index); +} + void serialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { *returnValue = cuvsCagraSerialize(cuvsResources, filename, index, true); } @@ -83,11 +103,13 @@ void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n int64_t distances_shape[2] = {n_queries, topk}; DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat); - cuvsCagraSearchParamsCreate(&search_params); - *returnValue = cuvsCagraSearch(cuvsResources, search_params, index, &queries_tensor, &neighbors_tensor, &distances_tensor); cudaMemcpy(neighbors_h, neighbors, sizeof(uint32_t) * n_queries * topk, cudaMemcpyDefault); cudaMemcpy(distances_h, distances, sizeof(float) * n_queries * topk, cudaMemcpyDefault); + + cuvsRMMFree(cuvsResources, distances, sizeof(float) * n_queries * topk); + cuvsRMMFree(cuvsResources, neighbors, sizeof(uint32_t) * n_queries * topk); + cuvsRMMFree(cuvsResources, queries_d, sizeof(float) * n_queries * dimensions); } From 6f708eb1062a114c6a742426c6b7e35c58e5c80a Mon Sep 17 00:00:00 2001 From: Ishan Chattopadhyaya Date: Sat, 14 Dec 2024 00:21:49 +0530 Subject: [PATCH 41/53] Upgrading to 25.02 --- java/build.sh | 4 ++-- java/cuvs-java/pom.xml | 4 ++-- java/examples/cagra-example/pom.xml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/java/build.sh b/java/build.sh index f1d25eef6..3f088172b 100755 --- a/java/build.sh +++ b/java/build.sh @@ -1,7 +1,7 @@ export CMAKE_PREFIX_PATH=`pwd`/../cpp/build cd internal && cmake . && cmake --build . \ && cd .. \ - && mvn install:install-file -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java-internal -Dversion=24.12 -Dpackaging=so -Dfile=./internal/libcuvs_java.so \ + && mvn install:install-file -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java-internal -Dversion=25.02 -Dpackaging=so -Dfile=./internal/libcuvs_java.so \ && cd cuvs-java \ && mvn package \ - && mvn install:install-file -Dfile=./target/cuvs-java-24.12.1-jar-with-dependencies.jar -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java -Dversion=24.12.1 -Dpackaging=jar + && mvn install:install-file -Dfile=./target/cuvs-java-25.02.1-jar-with-dependencies.jar -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java -Dversion=54.02.1 -Dpackaging=jar diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 95d0afb24..f7f69a21a 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.nvidia.cuvs cuvs-java - 24.12.1 + 25.02.1 cuvs-java jar @@ -102,7 +102,7 @@ com.nvidia.cuvs cuvs-java-internal - 24.12 + 25.02 so false diff --git a/java/examples/cagra-example/pom.xml b/java/examples/cagra-example/pom.xml index 8479c5af5..8c04eb3e2 100644 --- a/java/examples/cagra-example/pom.xml +++ b/java/examples/cagra-example/pom.xml @@ -19,11 +19,11 @@ com.nvidia.cuvs cuvs-java - 24.12.1 + 25.02.1 - org.slf4j + org.slf4j slf4j-api 2.0.13 From b98d2bb25d11b387d3159070eb7e5e40b991fcfc Mon Sep 17 00:00:00 2001 From: Vivek Narang <123010842+narangvivek10@users.noreply.github.com> Date: Sat, 21 Dec 2024 11:32:10 -0500 Subject: [PATCH 42/53] Bruteforce API implementation (#8) * Bruteforce API implementation Co-authored-by: Vivek Narang --- java/build.sh | 9 +- java/cuvs-java/pom.xml | 3 +- .../java/com/nvidia/cuvs/BruteForceIndex.java | 255 ++++++++++++++++++ .../nvidia/cuvs/BruteForceIndexParams.java | 71 +++++ .../java/com/nvidia/cuvs/BruteForceQuery.java | 131 +++++++++ .../nvidia/cuvs/BruteForceSearchResults.java | 93 +++++++ .../main/java/com/nvidia/cuvs/CagraIndex.java | 80 +++--- .../com/nvidia/cuvs/CagraIndexParams.java | 2 +- .../main/java/com/nvidia/cuvs/CagraQuery.java | 4 +- .../java/com/nvidia/cuvs/CuVSResources.java | 24 +- .../java/com/nvidia/cuvs/common/Util.java | 29 +- .../nvidia/cuvs/BruteForceAndSearchTest.java | 99 +++++++ java/internal/src/cuvs_java.c | 253 ++++++++++++++--- 13 files changed, 967 insertions(+), 86 deletions(-) create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndex.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndexParams.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceSearchResults.java create mode 100644 java/cuvs-java/src/test/java/com/nvidia/cuvs/BruteForceAndSearchTest.java diff --git a/java/build.sh b/java/build.sh index 3f088172b..3be9f35f0 100755 --- a/java/build.sh +++ b/java/build.sh @@ -1,7 +1,12 @@ export CMAKE_PREFIX_PATH=`pwd`/../cpp/build + +VERSION="25.02" +GROUP_ID="com.nvidia.cuvs" +SO_FILE_PATH="./internal" + cd internal && cmake . && cmake --build . \ && cd .. \ - && mvn install:install-file -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java-internal -Dversion=25.02 -Dpackaging=so -Dfile=./internal/libcuvs_java.so \ + && mvn install:install-file -DgroupId=$GROUP_ID -DartifactId=cuvs-java-internal -Dversion=$VERSION -Dpackaging=so -Dfile=$SO_FILE_PATH/libcuvs_java.so \ && cd cuvs-java \ && mvn package \ - && mvn install:install-file -Dfile=./target/cuvs-java-25.02.1-jar-with-dependencies.jar -DgroupId=com.nvidia.cuvs -DartifactId=cuvs-java -Dversion=54.02.1 -Dpackaging=jar + && mvn install:install-file -Dfile=./target/cuvs-java-$VERSION-jar-with-dependencies.jar -DgroupId=$GROUP_ID -DartifactId=cuvs-java -Dversion=$VERSION -Dpackaging=jar diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index f7f69a21a..9ac634dfb 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.nvidia.cuvs cuvs-java - 25.02.1 + 25.02 cuvs-java jar @@ -114,7 +114,6 @@ - org.apache.maven.plugins maven-assembly-plugin 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 new file mode 100644 index 000000000..443c8df65 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndex.java @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2024, 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 java.io.IOException; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; + +import com.nvidia.cuvs.common.Util; + +/** + * The BRUTEFORCE method is running the KNN algorithm. It performs an extensive + * search, and in contrast to ANN methods produces an exact result. + * + * {@link BruteForceIndex} encapsulates a BRUTEFORCE index, along with methods + * to interact with it. + * + * @since 25.02 + */ +public class BruteForceIndex { + + private final float[][] dataset; + private final long[] prefilterData; + private final CuVSResources resources; + private MethodHandle indexMethodHandle; + private MethodHandle searchMethodHandle; + private MethodHandle destroyIndexMethodHandle; + private IndexReference bruteForceIndexReference; + private BruteForceIndexParams bruteForceIndexParams; + private MemoryLayout longMemoryLayout; + private MemoryLayout intMemoryLayout; + private MemoryLayout floatMemoryLayout; + + /** + * Constructor for building the index using specified dataset + * + * @param dataset the dataset used for creating the BRUTEFORCE + * index + * @param resources an instance of {@link CuVSResources} + * @param bruteForceIndexParams an instance of {@link BruteForceIndexParams} + * holding the index parameters + * @param prefilterData the prefilter data to use while searching the + * BRUTEFORCE index + */ + private BruteForceIndex(float[][] dataset, CuVSResources resources, BruteForceIndexParams bruteForceIndexParams, + long[] prefilterData) throws Throwable { + this.dataset = dataset; + this.prefilterData = prefilterData; + this.resources = resources; + this.bruteForceIndexParams = bruteForceIndexParams; + + longMemoryLayout = resources.linker.canonicalLayouts().get("long"); + intMemoryLayout = resources.linker.canonicalLayouts().get("int"); + floatMemoryLayout = resources.linker.canonicalLayouts().get("float"); + + initializeMethodHandles(); + this.bruteForceIndexReference = build(); + } + + /** + * Initializes the {@link MethodHandles} for invoking native methods. + * + * @throws IOException @{@link IOException} is unable to load the native library + */ + private void initializeMethodHandles() throws IOException { + indexMethodHandle = resources.linker.downcallHandle( + resources.getSymbolLookup().find("build_brute_force_index").get(), + FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, longMemoryLayout, longMemoryLayout, + ValueLayout.ADDRESS, ValueLayout.ADDRESS, intMemoryLayout)); + + searchMethodHandle = resources.linker.downcallHandle( + resources.getSymbolLookup().find("search_brute_force_index").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, intMemoryLayout, longMemoryLayout, + intMemoryLayout, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, + ValueLayout.ADDRESS, longMemoryLayout)); + + destroyIndexMethodHandle = resources.linker.downcallHandle( + resources.getSymbolLookup().find("destroy_brute_force_index").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + } + + /** + * Invokes the native destroy_brute_force_index function to de-allocate + * BRUTEFORCE index + */ + public void destroyIndex() throws Throwable { + MemoryLayout returnValueMemoryLayout = intMemoryLayout; + MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); + destroyIndexMethodHandle.invokeExact(bruteForceIndexReference.getMemorySegment(), returnValueMemorySegment); + } + + /** + * Invokes the native build_brute_force_index function via the Panama API to + * build the {@link BruteForceIndex} + * + * @return an instance of {@link IndexReference} that holds the pointer to the + * index + */ + private IndexReference build() throws Throwable { + long rows = dataset.length; + long cols = rows > 0 ? dataset[0].length : 0; + + MemoryLayout returnValueMemoryLayout = intMemoryLayout; + MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); + + IndexReference indexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( + Util.buildMemorySegment(resources.linker, resources.arena, dataset), rows, cols, resources.getMemorySegment(), + returnValueMemorySegment, bruteForceIndexParams.getNumWriterThreads())); + + return indexReference; + } + + /** + * Invokes the native search_brute_force_index via the Panama API for searching + * a BRUTEFORCE index. + * + * @param cuvsQuery an instance of {@link BruteForceQuery} holding the query + * vectors and other parameters + * @return an instance of {@link BruteForceSearchResults} containing the results + */ + public BruteForceSearchResults 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 prefilterDataLength = prefilterData != null ? prefilterData.length : 0; + + SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, longMemoryLayout); + SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, floatMemoryLayout); + MemorySegment neighborsMemorySegment = resources.arena.allocate(neighborsSequenceLayout); + MemorySegment distancesMemorySegment = resources.arena.allocate(distancesSequenceLayout); + MemoryLayout returnValueMemoryLayout = intMemoryLayout; + MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); + MemorySegment prefilterDataMemorySegment = prefilterData != null + ? Util.buildMemorySegment(resources.linker, resources.arena, prefilterData) + : MemorySegment.NULL; + + searchMethodHandle.invokeExact(bruteForceIndexReference.getMemorySegment(), + Util.buildMemorySegment(resources.linker, resources.arena, cuvsQuery.getQueryVectors()), cuvsQuery.getTopK(), + numQueries, vectorDimension, resources.getMemorySegment(), neighborsMemorySegment, distancesMemorySegment, + returnValueMemorySegment, prefilterDataMemorySegment, prefilterDataLength); + + return new BruteForceSearchResults(neighborsSequenceLayout, distancesSequenceLayout, neighborsMemorySegment, + distancesMemorySegment, cuvsQuery.getTopK(), cuvsQuery.getMapping(), numQueries); + } + + /** + * Builder helps configure and create an instance of {@link BruteForceIndex}. + */ + public static class Builder { + + private float[][] dataset; + private long[] prefilterData; + private CuVSResources cuvsResources; + private BruteForceIndexParams bruteForceIndexParams; + + /** + * Constructs this Builder with an instance of {@link CuVSResources}. + * + * @param cuvsResources an instance of {@link CuVSResources} + */ + public Builder(CuVSResources cuvsResources) { + this.cuvsResources = cuvsResources; + } + + /** + * Registers an instance of configured {@link BruteForceIndexParams} with this + * Builder. + * + * @param bruteForceIndexParams An instance of BruteForceIndexParams + * @return An instance of this Builder + */ + public Builder withIndexParams(BruteForceIndexParams bruteForceIndexParams) { + this.bruteForceIndexParams = bruteForceIndexParams; + return this; + } + + /** + * Sets the dataset for building the {@link BruteForceIndex}. + * + * @param dataset a two-dimensional float array + * @return an instance of this Builder + */ + public Builder withDataset(float[][] dataset) { + this.dataset = dataset; + return this; + } + + /** + * Sets the prefilter data for building the {@link BruteForceIndex}. + * + * @param prefilterData a one-dimensional long array + * @return an instance of this Builder + */ + public Builder withPrefilterData(long[] prefilterData) { + this.prefilterData = prefilterData; + return this; + } + + /** + * Builds and returns an instance of {@link BruteForceIndex}. + * + * @return an instance of {@link BruteForceIndex} + */ + public BruteForceIndex build() throws Throwable { + return new BruteForceIndex(dataset, cuvsResources, bruteForceIndexParams, prefilterData); + } + } + + /** + * Holds the memory reference to a BRUTEFORCE index. + */ + protected static class IndexReference { + + private final MemorySegment memorySegment; + + /** + * Constructs BruteForceIndexReference with an instance of MemorySegment passed + * as a parameter. + * + * @param indexMemorySegment the MemorySegment instance to use for containing + * index reference + */ + protected IndexReference(MemorySegment indexMemorySegment) { + this.memorySegment = indexMemorySegment; + } + + /** + * Gets the instance of index MemorySegment. + * + * @return index MemorySegment + */ + protected MemorySegment getMemorySegment() { + return memorySegment; + } + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndexParams.java new file mode 100644 index 000000000..46d8534c5 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndexParams.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024, 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; + +/** + * Supplemental parameters to build BRUTEFORCE index. + * + * @since 25.02 + */ +public class BruteForceIndexParams { + + private final int numWriterThreads; + + private BruteForceIndexParams(int writerThreads) { + this.numWriterThreads = writerThreads; + } + + @Override + public String toString() { + return "BruteForceIndexParams [numWriterThreads=" + numWriterThreads + "]"; + } + + /** + * Gets the number of threads used to build the index. + */ + public int getNumWriterThreads() { + return numWriterThreads; + } + + /** + * Builder configures and creates an instance of {@link BruteForceIndexParams}. + */ + public static class Builder { + + private int numWriterThreads = 2; + + /** + * Sets the number of writer threads to use for indexing. + * + * @param numWriterThreads number of writer threads to use + * @return an instance of Builder + */ + public Builder withNumWriterThreads(int numWriterThreads) { + this.numWriterThreads = numWriterThreads; + return this; + } + + /** + * Builds an instance of {@link BruteForceIndexParams}. + * + * @return an instance of {@link BruteForceIndexParams} + */ + public BruteForceIndexParams build() { + return new BruteForceIndexParams(numWriterThreads); + } + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..5a9da0515 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2024, 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 java.util.Arrays; +import java.util.Map; + +/** + * BruteForceQuery holds the query vectors to be used while invoking search. + * + * @since 25.02 + */ +public class BruteForceQuery { + + private Map mapping; + private float[][] queryVectors; + private int topK; + + /** + * Constructs an instance of {@link BruteForceQuery} using queryVectors, + * mapping, and topK. + * + * @param queryVectors 2D float query vector array + * @param mapping an instance of ID mapping + * @param topK the top k results to return + */ + public BruteForceQuery(float[][] queryVectors, Map mapping, int topK) { + this.queryVectors = queryVectors; + this.mapping = mapping; + this.topK = topK; + } + + /** + * Gets the query vector 2D float array. + * + * @return 2D float array + */ + public float[][] getQueryVectors() { + return queryVectors; + } + + /** + * Gets the passed map instance. + * + * @return a map of ID mappings + */ + public Map getMapping() { + return mapping; + } + + /** + * Gets the topK value. + * + * @return an integer + */ + public int getTopK() { + return topK; + } + + @Override + public String toString() { + return "BruteForceQuery [mapping=" + mapping + ", queryVectors=" + Arrays.toString(queryVectors) + ", topK=" + topK + + "]"; + } + + /** + * Builder helps configure and create an instance of BruteForceQuery. + */ + public static class Builder { + + private float[][] queryVectors; + private Map mapping; + private int topK = 2; + + /** + * Registers the query vectors to be passed in the search call. + * + * @param queryVectors 2D float query vector array + * @return an instance of this Builder + */ + public Builder withQueryVectors(float[][] queryVectors) { + this.queryVectors = queryVectors; + return this; + } + + /** + * Sets the instance of mapping to be used for ID mapping. + * + * @param mapping the ID mapping instance + * @return an instance of this Builder + */ + public Builder withMapping(Map mapping) { + this.mapping = mapping; + return this; + } + + /** + * Registers the topK value. + * + * @param topK the topK value used to retrieve the topK results + * @return an instance of this Builder + */ + public Builder withTopK(int topK) { + this.topK = topK; + return this; + } + + /** + * Builds an instance of {@link BruteForceQuery} + * + * @return an instance of {@link BruteForceQuery} + */ + public BruteForceQuery build() { + return new BruteForceQuery(queryVectors, mapping, topK); + } + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceSearchResults.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceSearchResults.java new file mode 100644 index 000000000..d53bce751 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceSearchResults.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024, 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 java.lang.foreign.MemoryLayout.PathElement; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SequenceLayout; +import java.lang.invoke.VarHandle; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.nvidia.cuvs.common.SearchResults; + +/** + * SearchResult encapsulates the logic for reading and holding search results. + * + * @since 25.02 + */ +public class BruteForceSearchResults implements SearchResults { + + private final List> results; + private final Map mapping; // TODO: Is this performant in a user application? + private final SequenceLayout neighboursSequenceLayout; + private final SequenceLayout distancesSequenceLayout; + private final MemorySegment neighboursMemorySegment; + private final MemorySegment distancesMemorySegment; + private final int topK; + private final long numberOfQueries; + + protected BruteForceSearchResults(SequenceLayout neighboursSequenceLayout, SequenceLayout distancesSequenceLayout, + MemorySegment neighboursMemorySegment, MemorySegment distancesMemorySegment, int topK, + Map mapping, long numberOfQueries) { + this.topK = topK; + this.numberOfQueries = numberOfQueries; + this.neighboursSequenceLayout = neighboursSequenceLayout; + this.distancesSequenceLayout = distancesSequenceLayout; + this.neighboursMemorySegment = neighboursMemorySegment; + this.distancesMemorySegment = distancesMemorySegment; + this.mapping = mapping; + results = new LinkedList>(); + + readResultMemorySegments(); + } + + /** + * Reads neighbors and distances {@link MemorySegment} and loads the values + * internally + */ + private void readResultMemorySegments() { + VarHandle neighboursVarHandle = neighboursSequenceLayout.varHandle(PathElement.sequenceElement()); + VarHandle distancesVarHandle = distancesSequenceLayout.varHandle(PathElement.sequenceElement()); + + Map intermediateResultMap = new LinkedHashMap(); + int count = 0; + for (long i = 0; i < topK * numberOfQueries; i++) { + long id = (long) neighboursVarHandle.get(neighboursMemorySegment, 0L, i); + float dst = (float) distancesVarHandle.get(distancesMemorySegment, 0L, i); + intermediateResultMap.put(mapping != null ? mapping.get((int) id) : (int) id, dst); + count += 1; + if (count == topK) { + results.add(intermediateResultMap); + intermediateResultMap = new LinkedHashMap(); + count = 0; + } + } + } + + /** + * Gets a list results as a map of neighbor IDs to distances. + * + * @return a list of results for each query as a map of neighbor IDs to distance + */ + @Override + public List> getResults() { + return results; + } +} 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 67394b53b..ca9df5e13 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 @@ -58,9 +58,19 @@ public class CagraIndex { private CagraIndexParams cagraIndexParameters; private CagraCompressionParams cagraCompressionParams; private IndexReference cagraIndexReference; + private MemoryLayout longMemoryLayout; + private MemoryLayout intMemoryLayout; + private MemoryLayout floatMemoryLayout; - /* + /** * Constructor for building the index using specified dataset + * + * @param indexParameters an instance of {@link CagraIndexParams} holding + * the index parameters + * @param cagraCompressionParams an instance of {@link CagraCompressionParams} + * holding the compression parameters + * @param dataset the dataset for indexing + * @param resources an instance of {@link CuVSResources} */ private CagraIndex(CagraIndexParams indexParameters, CagraCompressionParams cagraCompressionParams, float[][] dataset, CuVSResources resources) throws Throwable { @@ -69,12 +79,19 @@ private CagraIndex(CagraIndexParams indexParameters, CagraCompressionParams cagr this.dataset = dataset; this.resources = resources; + longMemoryLayout = resources.linker.canonicalLayouts().get("long"); + intMemoryLayout = resources.linker.canonicalLayouts().get("int"); + floatMemoryLayout = resources.linker.canonicalLayouts().get("float"); + initializeMethodHandles(); this.cagraIndexReference = build(); } /** * Constructor for loading the index from an {@link InputStream} + * + * @param inputStream an instance of stream to read the index bytes from + * @param resources an instance of {@link CuVSResources} */ private CagraIndex(InputStream inputStream, CuVSResources resources) throws Throwable { this.cagraIndexParameters = null; @@ -82,6 +99,10 @@ private CagraIndex(InputStream inputStream, CuVSResources resources) throws Thro this.dataset = null; this.resources = resources; + longMemoryLayout = resources.linker.canonicalLayouts().get("long"); + intMemoryLayout = resources.linker.canonicalLayouts().get("int"); + floatMemoryLayout = resources.linker.canonicalLayouts().get("float"); + initializeMethodHandles(); this.cagraIndexReference = deserialize(inputStream); } @@ -92,40 +113,39 @@ private CagraIndex(InputStream inputStream, CuVSResources resources) throws Thro * @throws IOException @{@link IOException} is unable to load the native library */ private void initializeMethodHandles() throws IOException { - indexMethodHandle = resources.linker.downcallHandle( - resources.getLibcuvsNativeLibrary().find("build_cagra_index").get(), - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("long"), - resources.linker.canonicalLayouts().get("long"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, resources.linker.canonicalLayouts().get("int"))); - - searchMethodHandle = resources.linker.downcallHandle( - resources.getLibcuvsNativeLibrary().find("search_cagra_index").get(), - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, - resources.linker.canonicalLayouts().get("int"), resources.linker.canonicalLayouts().get("long"), - resources.linker.canonicalLayouts().get("int"), ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + indexMethodHandle = resources.linker.downcallHandle(resources.getSymbolLookup().find("build_cagra_index").get(), + FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, longMemoryLayout, longMemoryLayout, + ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, intMemoryLayout)); + + searchMethodHandle = resources.linker.downcallHandle(resources.getSymbolLookup().find("search_cagra_index").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, intMemoryLayout, longMemoryLayout, + intMemoryLayout, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, + ValueLayout.ADDRESS)); serializeMethodHandle = resources.linker.downcallHandle( - resources.getLibcuvsNativeLibrary().find("serialize_cagra_index").get(), + resources.getSymbolLookup().find("serialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); deserializeMethodHandle = resources.linker.downcallHandle( - resources.getLibcuvsNativeLibrary().find("deserialize_cagra_index").get(), + resources.getSymbolLookup().find("deserialize_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); destroyIndexMethodHandle = resources.linker.downcallHandle( - resources.getLibcuvsNativeLibrary().find("destroy_cagra_index").get(), + resources.getSymbolLookup().find("destroy_cagra_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } + /** + * Invokes the native destroy_cagra_index to de-allocate the CAGRA index + */ public void destroyIndex() throws Throwable { - MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); + MemoryLayout returnValueMemoryLayout = intMemoryLayout; MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); destroyIndexMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), returnValueMemorySegment); } /** - * Invokes the native build_index function via the Panama API to build the + * Invokes the native build_cagra_index function via the Panama API to build the * {@link CagraIndex} * * @return an instance of {@link IndexReference} that holds the pointer to the @@ -135,8 +155,8 @@ private IndexReference build() throws Throwable { long rows = dataset.length; long cols = rows > 0 ? dataset[0].length : 0; - MemoryLayout layout = resources.linker.canonicalLayouts().get("int"); - MemorySegment segment = resources.arena.allocate(layout); + MemoryLayout returnValueMemoryLayout = intMemoryLayout; + MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); MemorySegment indexParamsMemorySegment = cagraIndexParameters != null ? cagraIndexParameters.getMemorySegment() : MemorySegment.NULL; @@ -149,14 +169,14 @@ private IndexReference build() throws Throwable { IndexReference indexReference = new IndexReference((MemorySegment) indexMethodHandle.invokeExact( Util.buildMemorySegment(resources.linker, resources.arena, dataset), rows, cols, resources.getMemorySegment(), - segment, indexParamsMemorySegment, compressionParamsMemorySegment, numWriterThreads)); + returnValueMemorySegment, indexParamsMemorySegment, compressionParamsMemorySegment, numWriterThreads)); return indexReference; } /** - * Invokes the native search_index via the Panama API for searching a CAGRA - * index. + * Invokes the native search_cagra_index via the Panama API for searching a + * CAGRA index. * * @param query an instance of {@link CagraQuery} holding the query vectors and * other parameters @@ -167,13 +187,11 @@ public CagraSearchResults search(CagraQuery query) throws Throwable { long numBlocks = query.getTopK() * numQueries; int vectorDimension = numQueries > 0 ? query.getQueryVectors()[0].length : 0; - SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, - resources.linker.canonicalLayouts().get("int")); - SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, - resources.linker.canonicalLayouts().get("float")); + SequenceLayout neighborsSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, intMemoryLayout); + SequenceLayout distancesSequenceLayout = MemoryLayout.sequenceLayout(numBlocks, floatMemoryLayout); MemorySegment neighborsMemorySegment = resources.arena.allocate(neighborsSequenceLayout); MemorySegment distancesMemorySegment = resources.arena.allocate(distancesSequenceLayout); - MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); + MemoryLayout returnValueMemoryLayout = intMemoryLayout; MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); searchMethodHandle.invokeExact(cagraIndexReference.getMemorySegment(), @@ -206,7 +224,7 @@ public void serialize(OutputStream outputStream) throws Throwable { * temporarily */ public void serialize(OutputStream outputStream, File tempFile) throws Throwable { - MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); + MemoryLayout returnValueMemoryLayout = intMemoryLayout; MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); serializeMethodHandle.invokeExact(resources.getMemorySegment(), cagraIndexReference.getMemorySegment(), returnValueMemorySegment, @@ -229,7 +247,7 @@ public void serialize(OutputStream outputStream, File tempFile) throws Throwable * @return an instance of {@link IndexReference}. */ private IndexReference deserialize(InputStream inputStream) throws Throwable { - MemoryLayout returnValueMemoryLayout = resources.linker.canonicalLayouts().get("int"); + MemoryLayout returnValueMemoryLayout = intMemoryLayout; MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".cag"; IndexReference indexReference = new IndexReference(resources); @@ -351,7 +369,7 @@ public CagraIndex build() throws Throwable { } /** - * Holds the memory reference to an index. + * Holds the memory reference to a CAGRA index. */ protected static class IndexReference { 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 66eb235e2..e194575a9 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 @@ -144,7 +144,7 @@ public static class Builder { private int intermediateGraphDegree = 128; private int graphDegree = 64; private int nnDescentNumIterations = 20; - private int numWriterThreads = 1; + private int numWriterThreads = 2; public Builder(CuVSResources resources) { this.resources = resources; diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java index 77cbf33f3..7fb0fdcf1 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java @@ -81,7 +81,7 @@ public Map getMapping() { /** * Gets the topK value. * - * @return an integer + * @return the topK value */ public int getTopK() { return topK; @@ -94,7 +94,7 @@ public String toString() { } /** - * Builder helps configure and create an instance of CuVSQuery. + * Builder helps configure and create an instance of CagraQuery. */ public static class Builder { diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java index 60f68981b..effe81ef2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java @@ -37,12 +37,12 @@ public class CuVSResources implements AutoCloseable { public final Arena arena; public final Linker linker; - public final SymbolLookup libcuvsNativeLibrary; + public final SymbolLookup symbolLookup; protected File nativeLibrary; - private final MethodHandle createResourcesMethodHandle; private final MethodHandle destroyResourcesMethodHandle; private MemorySegment resourcesMemorySegment; + private MemoryLayout intMemoryLayout; /** * Constructor that allocates the resources needed for cuVS @@ -52,14 +52,17 @@ public class CuVSResources implements AutoCloseable { public CuVSResources() throws Throwable { linker = Linker.nativeLinker(); arena = Arena.ofShared(); + nativeLibrary = Util.loadLibraryFromJar("/libcuvs_java.so"); - libcuvsNativeLibrary = SymbolLookup.libraryLookup(nativeLibrary.getAbsolutePath(), arena); + symbolLookup = SymbolLookup.libraryLookup(nativeLibrary.getAbsolutePath(), arena); + intMemoryLayout = linker.canonicalLayouts().get("int"); - createResourcesMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("create_resources").get(), + createResourcesMethodHandle = linker.downcallHandle(symbolLookup.find("create_resources").get(), FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - destroyResourcesMethodHandle = linker.downcallHandle(libcuvsNativeLibrary.find("destroy_resources").get(), + destroyResourcesMethodHandle = linker.downcallHandle(symbolLookup.find("destroy_resources").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + createResources(); } @@ -69,14 +72,14 @@ public CuVSResources() throws Throwable { * @throws Throwable exception thrown when native function is invoked */ public void createResources() throws Throwable { - MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemoryLayout returnValueMemoryLayout = intMemoryLayout; MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); resourcesMemorySegment = (MemorySegment) createResourcesMethodHandle.invokeExact(returnValueMemorySegment); } @Override public void close() { - MemoryLayout returnValueMemoryLayout = linker.canonicalLayouts().get("int"); + MemoryLayout returnValueMemoryLayout = intMemoryLayout; MemorySegment returnValueMemorySegment = arena.allocate(returnValueMemoryLayout); try { destroyResourcesMethodHandle.invokeExact(resourcesMemorySegment, returnValueMemorySegment); @@ -96,9 +99,10 @@ protected MemorySegment getMemorySegment() { } /** - * Returns the loaded libcuvs_java.so as a {@link SymbolLookup} + * Returns the loaded libcuvs_java_cagra.so as a {@link SymbolLookup} */ - protected SymbolLookup getLibcuvsNativeLibrary() { - return libcuvsNativeLibrary; + protected SymbolLookup getSymbolLookup() { + return symbolLookup; } + } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java index 750e49d64..ed2f74c4d 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java @@ -30,6 +30,7 @@ import org.apache.commons.io.IOUtils; public class Util { + /** * A utility method for getting an instance of {@link MemorySegment} for a * {@link String}. @@ -38,8 +39,9 @@ public class Util { * @return an instance of {@link MemorySegment} */ public static MemorySegment buildMemorySegment(Linker linker, Arena arena, String str) { + MemoryLayout charMemoryLayout = linker.canonicalLayouts().get("char"); StringBuilder sb = new StringBuilder(str).append('\0'); - MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), linker.canonicalLayouts().get("char")); + MemoryLayout stringMemoryLayout = MemoryLayout.sequenceLayout(sb.length(), charMemoryLayout); MemorySegment stringMemorySegment = arena.allocate(stringMemoryLayout); for (int i = 0; i < sb.length(); i++) { @@ -49,6 +51,21 @@ public static MemorySegment buildMemorySegment(Linker linker, Arena arena, Strin return stringMemorySegment; } + /** + * A utility method for building a {@link MemorySegment} for a 1D long array. + * + * @param data The 1D long array for which the {@link MemorySegment} is needed + * @return an instance of {@link MemorySegment} + */ + public static MemorySegment buildMemorySegment(Linker linker, Arena arena, long[] data) { + int cells = data.length; + MemoryLayout longMemoryLayout = linker.canonicalLayouts().get("long"); + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(cells, longMemoryLayout); + MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); + MemorySegment.copy(data, 0, dataMemorySegment, (ValueLayout) longMemoryLayout, 0, cells); + return dataMemorySegment; + } + /** * A utility method for building a {@link MemorySegment} for a 2D float array. * @@ -58,14 +75,14 @@ public static MemorySegment buildMemorySegment(Linker linker, Arena arena, Strin public static MemorySegment buildMemorySegment(Linker linker, Arena arena, float[][] data) { long rows = data.length; long cols = rows > 0 ? data[0].length : 0; - - MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows * cols, linker.canonicalLayouts().get("float")); + MemoryLayout floatMemoryLayout = linker.canonicalLayouts().get("float"); + MemoryLayout dataMemoryLayout = MemoryLayout.sequenceLayout(rows * cols, floatMemoryLayout); MemorySegment dataMemorySegment = arena.allocate(dataMemoryLayout); - long floatByteSize = linker.canonicalLayouts().get("float").byteSize(); + long floatByteSize = floatMemoryLayout.byteSize(); for (int r = 0; r < rows; r++) { - MemorySegment.copy(data[r], 0, dataMemorySegment, (ValueLayout) linker.canonicalLayouts().get("float"), - (r * cols * floatByteSize), (int) cols); + MemorySegment.copy(data[r], 0, dataMemorySegment, (ValueLayout) floatMemoryLayout, (r * cols * floatByteSize), + (int) cols); } return dataMemorySegment; diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/BruteForceAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/BruteForceAndSearchTest.java new file mode 100644 index 000000000..00180c633 --- /dev/null +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/BruteForceAndSearchTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024, 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 static org.junit.Assert.assertEquals; + +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.nvidia.cuvs.common.SearchResults; + +public class BruteForceAndSearchTest { + + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + /** + * A basic test that checks the whole flow - from indexing to search. + * + * @throws Throwable + */ + @Test + public void testIndexingAndSearchingFlow() throws Throwable { + + // Sample data and query + float[][] dataset = { + { 0.74021935f, 0.9209938f }, + { 0.03902049f, 0.9689629f }, + { 0.92514056f, 0.4463501f }, + { 0.6673192f, 0.10993068f } + }; + Map map = Map.of(0, 0, 1, 1, 2, 2, 3, 3); + float[][] queries = { + { 0.48216683f, 0.0428398f }, + { 0.5084142f, 0.6545497f }, + { 0.51260436f, 0.2643005f }, + { 0.05198065f, 0.5789965f } + }; + + // Expected search results + List> expectedResults = Arrays.asList( + Map.of(3, 0.59198487f, 1, 0.6283694f, 2, 0.77246666f), + Map.of(1, 0.2534914f, 3, 0.33350062f, 2, 0.8748074f), + Map.of(1, 0.4058035f, 3, 0.43066847f, 2, 0.72249544f), + Map.of(3, 0.11946076f, 1, 0.46753132f, 2, 1.0337032f) + ); + + for (int j = 0; j < 10; j++) { + + try (CuVSResources resources = new CuVSResources()) { + + BruteForceIndexParams indexParams = new BruteForceIndexParams.Builder() + .withNumWriterThreads(32) + .build(); + + // Create the index with the dataset + BruteForceIndex index = new BruteForceIndex.Builder(resources) + .withDataset(dataset) + .withIndexParams(indexParams) + .build(); + + // Create a query object with the query vectors + BruteForceQuery cuvsQuery = new BruteForceQuery.Builder() + .withTopK(3) + .withQueryVectors(queries) + .withMapping(map) + .build(); + + // Perform the search + SearchResults results = index.search(cuvsQuery); + + // Check results + log.info(results.getResults().toString()); + assertEquals(expectedResults, results.getResults()); + + index.destroyIndex(); + } + } + } +} diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index b6a078e24..ee25ab576 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -26,24 +27,44 @@ #define catch(x) ExitJmp:if(__HadError) #define throw(x) {__HadError=true;goto ExitJmp;} -cuvsResources_t create_resources(int *returnValue) { - cuvsResources_t cuvsResources; - *returnValue = cuvsResourcesCreate(&cuvsResources); - return cuvsResources; +/** + * Create an Initialized opaque C handle + * + * @param return_value return value for cuvsResourcesCreate function call + */ +cuvsResources_t create_resources(int *return_value) { + cuvsResources_t cuvs_resources; + *return_value = cuvsResourcesCreate(&cuvs_resources); + return cuvs_resources; } -void destroy_resources(cuvsResources_t cuvsResources, int *returnValue) { - *returnValue = cuvsResourcesDestroy(cuvsResources); +/** + * Destroy and de-allocate opaque C handle + * + * @param cuvs_resources an opaque C handle + * @param return_value return value for cuvsResourcesDestroy function call + */ +void destroy_resources(cuvsResources_t cuvs_resources, int *return_value) { + *return_value = cuvsResourcesDestroy(cuvs_resources); } -DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) { +/** + * Helper function for creating DLManagedTensor instance + * + * @param data the data pointer points to the allocated data + * @param shape the shape of the tensor + * @param code the type code of base types + * @param bits the shape of the tensor + * @param ndim the number of dimensions + */ +DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code, int bits, int ndim) { DLManagedTensor tensor; tensor.dl_tensor.data = data; tensor.dl_tensor.device.device_type = kDLCUDA; - tensor.dl_tensor.ndim = 2; + tensor.dl_tensor.ndim = ndim; tensor.dl_tensor.dtype.code = code; - tensor.dl_tensor.dtype.bits = 32; + tensor.dl_tensor.dtype.bits = bits; tensor.dl_tensor.dtype.lanes = 1; tensor.dl_tensor.shape = shape; tensor.dl_tensor.strides = NULL; @@ -51,65 +72,233 @@ DLManagedTensor prepare_tensor(void *data, int64_t shape[], DLDataTypeCode code) return tensor; } -cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvsResources, int *returnValue, - cuvsCagraIndexParams_t index_params, cuvsCagraCompressionParams_t compression_params, int numWriterThreads) { +/** + * Function for building CAGRA index + * + * @param dataset index dataset + * @param rows number of dataset rows + * @param dimensions vector dimension of the dataset + * @param cuvs_resources reference of the underlying opaque C handle + * @param return_value return value for cuvsCagraBuild function call + * @param index_params a reference to the index parameters + * @param compression_params a reference to the compression parameters + * @param n_writer_threads number of omp threads to use + */ +cuvsCagraIndex_t build_cagra_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvs_resources, int *return_value, + cuvsCagraIndexParams_t index_params, cuvsCagraCompressionParams_t compression_params, int n_writer_threads) { + + cudaStream_t stream; + cuvsStreamGet(cuvs_resources, &stream); - omp_set_num_threads(numWriterThreads); - cuvsRMMPoolMemoryResourceEnable(95, 95, true); + omp_set_num_threads(n_writer_threads); + cuvsRMMPoolMemoryResourceEnable(95, 95, false); int64_t dataset_shape[2] = {rows, dimensions}; - DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat); + DLManagedTensor dataset_tensor = prepare_tensor(dataset, dataset_shape, kDLFloat, 32, 2); cuvsCagraIndex_t index; cuvsCagraIndexCreate(&index); index_params->compression = compression_params; - *returnValue = cuvsCagraBuild(cuvsResources, index_params, &dataset_tensor, index); + cuvsStreamSync(cuvs_resources); + *return_value = cuvsCagraBuild(cuvs_resources, index_params, &dataset_tensor, index); omp_set_num_threads(1); return index; } -void destroy_cagra_index(cuvsCagraIndex_t index, int *returnValue) { - *returnValue = cuvsCagraIndexDestroy(index); +/** + * A function to de-allocate CAGRA index + * + * @param index cuvsCagraIndex_t to de-allocate + * @param return_value return value for cuvsCagraIndexDestroy function call + */ +void destroy_cagra_index(cuvsCagraIndex_t index, int *return_value) { + *return_value = cuvsCagraIndexDestroy(index); } -void serialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { - *returnValue = cuvsCagraSerialize(cuvsResources, filename, index, true); +/** + * A function to serialize a CAGRA index + * + * @param cuvs_resources reference of the underlying opaque C handle + * @param index cuvsCagraIndex_t reference + * @param return_value return value for cuvsCagraSerialize function call + * @param filename the filename of the index file + */ +void serialize_cagra_index(cuvsResources_t cuvs_resources, cuvsCagraIndex_t index, int *return_value, char* filename) { + *return_value = cuvsCagraSerialize(cuvs_resources, filename, index, true); } -void deserialize_cagra_index(cuvsResources_t cuvsResources, cuvsCagraIndex_t index, int *returnValue, char* filename) { - *returnValue = cuvsCagraDeserialize(cuvsResources, filename, index); +/** + * A function to de-serialize a CAGRA index + * + * @param cuvs_resources reference to the underlying opaque C handle + * @param index cuvsCagraIndex_t reference + * @param return_value return value for cuvsCagraDeserialize function call + * @param filename the filename of the index file + */ +void deserialize_cagra_index(cuvsResources_t cuvs_resources, cuvsCagraIndex_t index, int *return_value, char* filename) { + *return_value = cuvsCagraDeserialize(cuvs_resources, filename, index); } +/** + * A function to search a CAGRA index and return results + * + * @param index reference to a CAGRA index to search on + * @param queries query vectors + * @param topk topK results to return + * @param n_queries number of queries + * @param dimensions vector dimension + * @param cuvs_resources reference to the underlying opaque C handle + * @param neighbors_h reference to the neighbor results on the host memory + * @param distances_h reference to the distance results on the host memory + * @param return_value return value for cuvsCagraSearch function call + * @param search_params reference to cuvsCagraSearchParams_t holding the search parameters + */ void search_cagra_index(cuvsCagraIndex_t index, float *queries, int topk, long n_queries, int dimensions, - cuvsResources_t cuvsResources, int *neighbors_h, float *distances_h, int *returnValue, cuvsCagraSearchParams_t search_params) { + cuvsResources_t cuvs_resources, int *neighbors_h, float *distances_h, int *return_value, cuvsCagraSearchParams_t search_params) { + + cudaStream_t stream; + cuvsStreamGet(cuvs_resources, &stream); uint32_t *neighbors; float *distances, *queries_d; - cuvsRMMAlloc(cuvsResources, (void**) &queries_d, sizeof(float) * n_queries * dimensions); - cuvsRMMAlloc(cuvsResources, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); - cuvsRMMAlloc(cuvsResources, (void**) &distances, sizeof(float) * n_queries * topk); + cuvsRMMAlloc(cuvs_resources, (void**) &queries_d, sizeof(float) * n_queries * dimensions); + cuvsRMMAlloc(cuvs_resources, (void**) &neighbors, sizeof(uint32_t) * n_queries * topk); + cuvsRMMAlloc(cuvs_resources, (void**) &distances, sizeof(float) * n_queries * topk); cudaMemcpy(queries_d, queries, sizeof(float) * n_queries * dimensions, cudaMemcpyDefault); int64_t queries_shape[2] = {n_queries, dimensions}; - DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat); + DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat, 32, 2); int64_t neighbors_shape[2] = {n_queries, topk}; - DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt); + DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLUInt, 32, 2); int64_t distances_shape[2] = {n_queries, topk}; - DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat); + DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat, 32, 2); - *returnValue = cuvsCagraSearch(cuvsResources, search_params, index, &queries_tensor, &neighbors_tensor, + cuvsStreamSync(cuvs_resources); + *return_value = cuvsCagraSearch(cuvs_resources, search_params, index, &queries_tensor, &neighbors_tensor, &distances_tensor); cudaMemcpy(neighbors_h, neighbors, sizeof(uint32_t) * n_queries * topk, cudaMemcpyDefault); cudaMemcpy(distances_h, distances, sizeof(float) * n_queries * topk, cudaMemcpyDefault); - cuvsRMMFree(cuvsResources, distances, sizeof(float) * n_queries * topk); - cuvsRMMFree(cuvsResources, neighbors, sizeof(uint32_t) * n_queries * topk); - cuvsRMMFree(cuvsResources, queries_d, sizeof(float) * n_queries * dimensions); + cuvsRMMFree(cuvs_resources, distances, sizeof(float) * n_queries * topk); + cuvsRMMFree(cuvs_resources, neighbors, sizeof(uint32_t) * n_queries * topk); + cuvsRMMFree(cuvs_resources, queries_d, sizeof(float) * n_queries * dimensions); +} + +/** + * De-allocate BRUTEFORCE index + * + * @param index reference to BRUTEFORCE index + * @param return_value return value for cuvsBruteForceIndexDestroy function call + */ +void destroy_brute_force_index(cuvsBruteForceIndex_t index, int *return_value) { + *return_value = cuvsBruteForceIndexDestroy(index); +} + +/** + * A function to build BRUTEFORCE index + * + * @param dataset the dataset to be indexed + * @param rows the number of rows in the dataset + * @param dimensions the vector dimension + * @param cuvs_resources reference to the underlying opaque C handle + * @param return_value return value for cuvsBruteForceBuild function call + * @param n_writer_threads number of threads to use while indexing + */ +cuvsBruteForceIndex_t build_brute_force_index(float *dataset, long rows, long dimensions, cuvsResources_t cuvs_resources, + int *return_value, int n_writer_threads) { + + omp_set_num_threads(n_writer_threads); + cuvsRMMPoolMemoryResourceEnable(95, 95, false); + + cudaStream_t stream; + cuvsStreamGet(cuvs_resources, &stream); + + float *dataset_d; + cuvsRMMAlloc(cuvs_resources, (void**) &dataset_d, sizeof(float) * rows * dimensions); + cudaMemcpy(dataset_d, dataset, sizeof(float) * rows * dimensions, cudaMemcpyDefault); + + int64_t dataset_shape[2] = {rows, dimensions}; + DLManagedTensor dataset_tensor = prepare_tensor(dataset_d, dataset_shape, kDLFloat, 32, 2); + + cuvsBruteForceIndex_t index; + cuvsError_t index_create_status = cuvsBruteForceIndexCreate(&index); + + cuvsStreamSync(cuvs_resources); + *return_value = cuvsBruteForceBuild(cuvs_resources, &dataset_tensor, L2Expanded, 0.f, index); + + cuvsRMMFree(cuvs_resources, dataset_d, sizeof(float) * rows * dimensions); + omp_set_num_threads(1); + + return index; +} + +/** + * A function to search the BRUTEFORCE index + * + * @param index reference to a BRUTEFORCE index to search on + * @param queries reference to query vectors + * @param topk the top k results to return + * @param n_queries number of queries + * @param dimensions vector dimension + * @param cuvs_resources reference to the underlying opaque C handle + * @param neighbors_h reference to the neighbor results on the host memory + * @param distances_h reference to the distance results on the host memory + * @param return_value return value for cuvsBruteForceSearch function call + * @param prefilter_data cuvsFilter input prefilter that can be used to filter queries and neighbors based on the given bitmap + * @param prefilter_data_length prefilter length input + */ +void search_brute_force_index(cuvsBruteForceIndex_t index, float *queries, int topk, long n_queries, int dimensions, + cuvsResources_t cuvs_resources, int64_t *neighbors_h, float *distances_h, int *return_value, long *prefilter_data, + long prefilter_data_length) { + + cudaStream_t stream; + cuvsStreamGet(cuvs_resources, &stream); + + int64_t *neighbors; + float *distances, *queries_d; + long *prefilter_data_d; + cuvsRMMAlloc(cuvs_resources, (void**) &queries_d, sizeof(float) * n_queries * dimensions); + cuvsRMMAlloc(cuvs_resources, (void**) &neighbors, sizeof(int64_t) * n_queries * topk); + cuvsRMMAlloc(cuvs_resources, (void**) &distances, sizeof(float) * n_queries * topk); + cuvsRMMAlloc(cuvs_resources, (void**) &prefilter_data_d, sizeof(long) * prefilter_data_length); + + cudaMemcpy(queries_d, queries, sizeof(float) * n_queries * dimensions, cudaMemcpyDefault); + cudaMemcpy(prefilter_data_d, prefilter_data, sizeof(long) * prefilter_data_length, cudaMemcpyDefault); + + int64_t queries_shape[2] = {n_queries, dimensions}; + DLManagedTensor queries_tensor = prepare_tensor(queries_d, queries_shape, kDLFloat, 32, 2); + + int64_t neighbors_shape[2] = {n_queries, topk}; + DLManagedTensor neighbors_tensor = prepare_tensor(neighbors, neighbors_shape, kDLInt, 64, 2); + + int64_t distances_shape[2] = {n_queries, topk}; + DLManagedTensor distances_tensor = prepare_tensor(distances, distances_shape, kDLFloat, 32, 2); + + cuvsFilter prefilter; + if (prefilter_data == NULL) { + prefilter.type = NO_FILTER; + prefilter.addr = (uintptr_t)NULL; + } else { + int64_t prefilter_shape[1] = {prefilter_data_length}; + DLManagedTensor prefilter_tensor = prepare_tensor(prefilter_data_d, prefilter_shape, kDLUInt, 32, 1); + prefilter.type = BITMAP; + prefilter.addr = (uintptr_t)&prefilter_tensor; + } + + cuvsStreamSync(cuvs_resources); + *return_value = cuvsBruteForceSearch(cuvs_resources, index, &queries_tensor, &neighbors_tensor, &distances_tensor, prefilter); + + cudaMemcpy(neighbors_h, neighbors, sizeof(int64_t) * n_queries * topk, cudaMemcpyDefault); + cudaMemcpy(distances_h, distances, sizeof(float) * n_queries * topk, cudaMemcpyDefault); + + cuvsRMMFree(cuvs_resources, neighbors, sizeof(int64_t) * n_queries * topk); + cuvsRMMFree(cuvs_resources, distances, sizeof(float) * n_queries * topk); + cuvsRMMFree(cuvs_resources, queries_d, sizeof(float) * n_queries * dimensions); } From 81b60f1c479061761dba1ecdf77d3b89e01f6680 Mon Sep 17 00:00:00 2001 From: Vivek Narang <123010842+narangvivek10@users.noreply.github.com> Date: Thu, 26 Dec 2024 14:19:00 -0500 Subject: [PATCH 43/53] Bruteforce serialize and deserialize API implementation (#9) * Bruteforce serialize and deserialize API implementation Co-authored-by: Vivek Narang --- .../java/com/nvidia/cuvs/BruteForceIndex.java | 131 +- .../com/nvidia/cuvs/panama/brute_force_h.java | 4146 ++++++++--------- .../cuvs/panama/cuvsBruteForceIndex.java | 183 + .../nvidia/cuvs/panama/cuvsCagraIndex.java | 295 +- .../nvidia/cuvs/BruteForceAndSearchTest.java | 48 +- java/internal/src/cuvs_java.c | 27 +- 6 files changed, 2356 insertions(+), 2474 deletions(-) create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsBruteForceIndex.java 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 443c8df65..be659d07d 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,7 +16,12 @@ package com.nvidia.cuvs; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.lang.foreign.FunctionDescriptor; import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemorySegment; @@ -24,12 +29,12 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; +import java.util.UUID; import com.nvidia.cuvs.common.Util; +import com.nvidia.cuvs.panama.cuvsBruteForceIndex; /** - * The BRUTEFORCE method is running the KNN algorithm. It performs an extensive - * search, and in contrast to ANN methods produces an exact result. * * {@link BruteForceIndex} encapsulates a BRUTEFORCE index, along with methods * to interact with it. @@ -44,6 +49,8 @@ public class BruteForceIndex { private MethodHandle indexMethodHandle; private MethodHandle searchMethodHandle; private MethodHandle destroyIndexMethodHandle; + private MethodHandle serializeMethodHandle; + private MethodHandle deserializeMethodHandle; private IndexReference bruteForceIndexReference; private BruteForceIndexParams bruteForceIndexParams; private MemoryLayout longMemoryLayout; @@ -76,6 +83,26 @@ private BruteForceIndex(float[][] dataset, CuVSResources resources, BruteForceIn this.bruteForceIndexReference = build(); } + /** + * Constructor for loading the index from an {@link InputStream} + * + * @param inputStream an instance of stream to read the index bytes from + * @param resources an instance of {@link CuVSResources} + */ + private BruteForceIndex(InputStream inputStream, CuVSResources resources) throws Throwable { + this.bruteForceIndexParams = null; + this.dataset = null; + this.prefilterData = null; + this.resources = resources; + + longMemoryLayout = resources.linker.canonicalLayouts().get("long"); + intMemoryLayout = resources.linker.canonicalLayouts().get("int"); + floatMemoryLayout = resources.linker.canonicalLayouts().get("float"); + + initializeMethodHandles(); + this.bruteForceIndexReference = deserialize(inputStream); + } + /** * Initializes the {@link MethodHandles} for invoking native methods. * @@ -96,6 +123,14 @@ private void initializeMethodHandles() throws IOException { destroyIndexMethodHandle = resources.linker.downcallHandle( resources.getSymbolLookup().find("destroy_brute_force_index").get(), FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + serializeMethodHandle = resources.linker.downcallHandle( + resources.getSymbolLookup().find("serialize_brute_force_index").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + + deserializeMethodHandle = resources.linker.downcallHandle( + resources.getSymbolLookup().find("deserialize_brute_force_index").get(), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } /** @@ -162,6 +197,72 @@ public BruteForceSearchResults search(BruteForceQuery cuvsQuery) throws Throwabl distancesMemorySegment, cuvsQuery.getTopK(), cuvsQuery.getMapping(), numQueries); } + /** + * A method to persist a BRUTEFORCE index using an instance of + * {@link OutputStream} for writing index bytes. + * + * @param outputStream an instance of {@link OutputStream} to write the index + * bytes into + */ + public void serialize(OutputStream outputStream) throws Throwable { + serialize(outputStream, File.createTempFile(UUID.randomUUID().toString(), ".bf")); + } + + /** + * A method to persist a BRUTEFORCE index using an instance of + * {@link OutputStream} and path to the intermediate temporary file. + * + * @param outputStream an instance of {@link OutputStream} to write the index + * bytes to + * @param tempFile an intermediate {@link File} where BRUTEFORCE index is + * written temporarily + */ + public void serialize(OutputStream outputStream, File tempFile) throws Throwable { + MemoryLayout returnValueMemoryLayout = intMemoryLayout; + MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); + serializeMethodHandle.invokeExact(resources.getMemorySegment(), bruteForceIndexReference.getMemorySegment(), + returnValueMemorySegment, + Util.buildMemorySegment(resources.linker, resources.arena, tempFile.getAbsolutePath())); + FileInputStream fileInputStream = new FileInputStream(tempFile); + byte[] chunk = new byte[1024]; // TODO: Make this configurable + int chunkLength = 0; + while ((chunkLength = fileInputStream.read(chunk)) != -1) { + outputStream.write(chunk, 0, chunkLength); + } + fileInputStream.close(); + tempFile.delete(); + } + + /** + * Gets an instance of {@link IndexReference} by deserializing a BRUTEFORCE + * index using an {@link InputStream}. + * + * @param inputStream an instance of {@link InputStream} + * @return an instance of {@link IndexReference}. + */ + private IndexReference deserialize(InputStream inputStream) throws Throwable { + MemoryLayout returnValueMemoryLayout = intMemoryLayout; + MemorySegment returnValueMemorySegment = resources.arena.allocate(returnValueMemoryLayout); + String tmpIndexFile = "/tmp/" + UUID.randomUUID().toString() + ".bf"; + IndexReference indexReference = new IndexReference(resources); + + File tempFile = new File(tmpIndexFile); + FileOutputStream fileOutputStream = new FileOutputStream(tempFile); + byte[] chunk = new byte[1024]; + int chunkLength = 0; + while ((chunkLength = inputStream.read(chunk)) != -1) { + fileOutputStream.write(chunk, 0, chunkLength); + } + deserializeMethodHandle.invokeExact(resources.getMemorySegment(), indexReference.getMemorySegment(), + returnValueMemorySegment, Util.buildMemorySegment(resources.linker, resources.arena, tmpIndexFile)); + + inputStream.close(); + fileOutputStream.close(); + tempFile.delete(); + + return indexReference; + } + /** * Builder helps configure and create an instance of {@link BruteForceIndex}. */ @@ -171,6 +272,7 @@ public static class Builder { private long[] prefilterData; private CuVSResources cuvsResources; private BruteForceIndexParams bruteForceIndexParams; + private InputStream inputStream; /** * Constructs this Builder with an instance of {@link CuVSResources}. @@ -193,6 +295,18 @@ public Builder withIndexParams(BruteForceIndexParams bruteForceIndexParams) { return this; } + /** + * Sets an instance of InputStream typically used when index deserialization is + * needed. + * + * @param inputStream an instance of {@link InputStream} + * @return an instance of this Builder + */ + public Builder from(InputStream inputStream) { + this.inputStream = inputStream; + return this; + } + /** * Sets the dataset for building the {@link BruteForceIndex}. * @@ -221,7 +335,11 @@ public Builder withPrefilterData(long[] prefilterData) { * @return an instance of {@link BruteForceIndex} */ public BruteForceIndex build() throws Throwable { - return new BruteForceIndex(dataset, cuvsResources, bruteForceIndexParams, prefilterData); + if (inputStream != null) { + return new BruteForceIndex(inputStream, cuvsResources); + } else { + return new BruteForceIndex(dataset, cuvsResources, bruteForceIndexParams, prefilterData); + } } } @@ -232,6 +350,13 @@ protected static class IndexReference { private final MemorySegment memorySegment; + /** + * Constructs CagraIndexReference and allocate the MemorySegment. + */ + protected IndexReference(CuVSResources resources) { + memorySegment = cuvsBruteForceIndex.allocate(resources.arena); + } + /** * Constructs BruteForceIndexReference with an instance of MemorySegment passed * as a parameter. diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java index 5b73f5444..5761f57b2 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/brute_force_h.java @@ -41,2346 +41,1872 @@ public class brute_force_h { - brute_force_h() { - // Should not be called directly - } + brute_force_h() { + // 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 _STDINT_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDINT_H 1 - * } - */ - public static int _STDINT_H() { - return _STDINT_H; - } - private static final int _FEATURES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _FEATURES_H 1 - * } - */ - public static int _FEATURES_H() { - return _FEATURES_H; - } - private static final int _DEFAULT_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _DEFAULT_SOURCE 1 - * } - */ - public static int _DEFAULT_SOURCE() { - return _DEFAULT_SOURCE; - } - private static final int __GLIBC_USE_ISOC2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_ISOC2X 0 - * } - */ - public static int __GLIBC_USE_ISOC2X() { - return __GLIBC_USE_ISOC2X; - } - private static final int __USE_ISOC11 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC11 1 - * } - */ - public static int __USE_ISOC11() { - return __USE_ISOC11; - } - private static final int __USE_ISOC99 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC99 1 - * } - */ - public static int __USE_ISOC99() { - return __USE_ISOC99; - } - private static final int __USE_ISOC95 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ISOC95 1 - * } - */ - public static int __USE_ISOC95() { - return __USE_ISOC95; - } - private static final int __USE_POSIX_IMPLICITLY = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX_IMPLICITLY 1 - * } - */ - public static int __USE_POSIX_IMPLICITLY() { - return __USE_POSIX_IMPLICITLY; - } - private static final int _POSIX_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _POSIX_SOURCE 1 - * } - */ - public static int _POSIX_SOURCE() { - return _POSIX_SOURCE; - } - private static final int __USE_POSIX = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX 1 - * } - */ - public static int __USE_POSIX() { - return __USE_POSIX; - } - private static final int __USE_POSIX2 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX2 1 - * } - */ - public static int __USE_POSIX2() { - return __USE_POSIX2; - } - private static final int __USE_POSIX199309 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199309 1 - * } - */ - public static int __USE_POSIX199309() { - return __USE_POSIX199309; - } - private static final int __USE_POSIX199506 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_POSIX199506 1 - * } - */ - public static int __USE_POSIX199506() { - return __USE_POSIX199506; - } - private static final int __USE_XOPEN2K = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K 1 - * } - */ - public static int __USE_XOPEN2K() { - return __USE_XOPEN2K; - } - private static final int __USE_XOPEN2K8 = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_XOPEN2K8 1 - * } - */ - public static int __USE_XOPEN2K8() { - return __USE_XOPEN2K8; - } - private static final int _ATFILE_SOURCE = (int)1L; - /** - * {@snippet lang=c : - * #define _ATFILE_SOURCE 1 - * } - */ - public static int _ATFILE_SOURCE() { - return _ATFILE_SOURCE; - } - private static final int __WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __WORDSIZE 64 - * } - */ - public static int __WORDSIZE() { - return __WORDSIZE; - } - private static final int __WORDSIZE_TIME64_COMPAT32 = (int)1L; - /** - * {@snippet lang=c : - * #define __WORDSIZE_TIME64_COMPAT32 1 - * } - */ - public static int __WORDSIZE_TIME64_COMPAT32() { - return __WORDSIZE_TIME64_COMPAT32; - } - private static final int __SYSCALL_WORDSIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __SYSCALL_WORDSIZE 64 - * } - */ - public static int __SYSCALL_WORDSIZE() { - return __SYSCALL_WORDSIZE; - } - private static final int __USE_MISC = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_MISC 1 - * } - */ - public static int __USE_MISC() { - return __USE_MISC; - } - private static final int __USE_ATFILE = (int)1L; - /** - * {@snippet lang=c : - * #define __USE_ATFILE 1 - * } - */ - public static int __USE_ATFILE() { - return __USE_ATFILE; - } - private static final int __USE_FORTIFY_LEVEL = (int)0L; - /** - * {@snippet lang=c : - * #define __USE_FORTIFY_LEVEL 0 - * } - */ - public static int __USE_FORTIFY_LEVEL() { - return __USE_FORTIFY_LEVEL; - } - private static final int __GLIBC_USE_DEPRECATED_GETS = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_GETS 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_GETS() { - return __GLIBC_USE_DEPRECATED_GETS; - } - private static final int __GLIBC_USE_DEPRECATED_SCANF = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_DEPRECATED_SCANF 0 - * } - */ - public static int __GLIBC_USE_DEPRECATED_SCANF() { - return __GLIBC_USE_DEPRECATED_SCANF; - } - private static final int _STDC_PREDEF_H = (int)1L; - /** - * {@snippet lang=c : - * #define _STDC_PREDEF_H 1 - * } - */ - public static int _STDC_PREDEF_H() { - return _STDC_PREDEF_H; - } - private static final int __STDC_IEC_559__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559__ 1 - * } - */ - public static int __STDC_IEC_559__() { - return __STDC_IEC_559__; - } - private static final int __STDC_IEC_559_COMPLEX__ = (int)1L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_559_COMPLEX__ 1 - * } - */ - public static int __STDC_IEC_559_COMPLEX__() { - return __STDC_IEC_559_COMPLEX__; - } - private static final int __GNU_LIBRARY__ = (int)6L; - /** - * {@snippet lang=c : - * #define __GNU_LIBRARY__ 6 - * } - */ - public static int __GNU_LIBRARY__() { - return __GNU_LIBRARY__; - } - private static final int __GLIBC__ = (int)2L; - /** - * {@snippet lang=c : - * #define __GLIBC__ 2 - * } - */ - public static int __GLIBC__() { - return __GLIBC__; - } - private static final int __GLIBC_MINOR__ = (int)35L; - /** - * {@snippet lang=c : - * #define __GLIBC_MINOR__ 35 - * } - */ - public static int __GLIBC_MINOR__() { - return __GLIBC_MINOR__; - } - private static final int _SYS_CDEFS_H = (int)1L; - /** - * {@snippet lang=c : - * #define _SYS_CDEFS_H 1 - * } - */ - public static int _SYS_CDEFS_H() { - return _SYS_CDEFS_H; - } - private static final int __glibc_c99_flexarr_available = (int)1L; - /** - * {@snippet lang=c : - * #define __glibc_c99_flexarr_available 1 - * } - */ - public static int __glibc_c99_flexarr_available() { - return __glibc_c99_flexarr_available; - } - private static final int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = (int)0L; - /** - * {@snippet lang=c : - * #define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 - * } - */ - public static int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI() { - return __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI; - } - private static final int __HAVE_GENERIC_SELECTION = (int)1L; - /** - * {@snippet lang=c : - * #define __HAVE_GENERIC_SELECTION 1 - * } - */ - public static int __HAVE_GENERIC_SELECTION() { - return __HAVE_GENERIC_SELECTION; - } - private static final int __GLIBC_USE_LIB_EXT2 = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_LIB_EXT2 0 - * } - */ - public static int __GLIBC_USE_LIB_EXT2() { - return __GLIBC_USE_LIB_EXT2; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT() { - return __GLIBC_USE_IEC_60559_BFP_EXT; - } - private static final int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_BFP_EXT_C2X() { - return __GLIBC_USE_IEC_60559_BFP_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_EXT() { - return __GLIBC_USE_IEC_60559_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT; - } - private static final int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X() { - return __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X; - } - private static final int __GLIBC_USE_IEC_60559_TYPES_EXT = (int)0L; - /** - * {@snippet lang=c : - * #define __GLIBC_USE_IEC_60559_TYPES_EXT 0 - * } - */ - public static int __GLIBC_USE_IEC_60559_TYPES_EXT() { - return __GLIBC_USE_IEC_60559_TYPES_EXT; - } - private static final int _BITS_TYPES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPES_H 1 - * } - */ - public static int _BITS_TYPES_H() { - return _BITS_TYPES_H; - } - private static final int _BITS_TYPESIZES_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TYPESIZES_H 1 - * } - */ - public static int _BITS_TYPESIZES_H() { - return _BITS_TYPESIZES_H; - } - private static final int __OFF_T_MATCHES_OFF64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __OFF_T_MATCHES_OFF64_T 1 - * } - */ - public static int __OFF_T_MATCHES_OFF64_T() { - return __OFF_T_MATCHES_OFF64_T; - } - private static final int __INO_T_MATCHES_INO64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __INO_T_MATCHES_INO64_T 1 - * } - */ - public static int __INO_T_MATCHES_INO64_T() { - return __INO_T_MATCHES_INO64_T; - } - private static final int __RLIM_T_MATCHES_RLIM64_T = (int)1L; - /** - * {@snippet lang=c : - * #define __RLIM_T_MATCHES_RLIM64_T 1 - * } - */ - public static int __RLIM_T_MATCHES_RLIM64_T() { - return __RLIM_T_MATCHES_RLIM64_T; - } - private static final int __STATFS_MATCHES_STATFS64 = (int)1L; - /** - * {@snippet lang=c : - * #define __STATFS_MATCHES_STATFS64 1 - * } - */ - public static int __STATFS_MATCHES_STATFS64() { - return __STATFS_MATCHES_STATFS64; - } - private static final int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = (int)1L; - /** - * {@snippet lang=c : - * #define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 - * } - */ - public static int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64() { - return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64; - } - private static final int __FD_SETSIZE = (int)1024L; - /** - * {@snippet lang=c : - * #define __FD_SETSIZE 1024 - * } - */ - public static int __FD_SETSIZE() { - return __FD_SETSIZE; - } - private static final int _BITS_TIME64_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_TIME64_H 1 - * } - */ - public static int _BITS_TIME64_H() { - return _BITS_TIME64_H; - } - private static final int _BITS_WCHAR_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_WCHAR_H 1 - * } - */ - public static int _BITS_WCHAR_H() { - return _BITS_WCHAR_H; - } - private static final int _BITS_STDINT_INTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_INTN_H 1 - * } - */ - public static int _BITS_STDINT_INTN_H() { - return _BITS_STDINT_INTN_H; - } - private static final int _BITS_STDINT_UINTN_H = (int)1L; - /** - * {@snippet lang=c : - * #define _BITS_STDINT_UINTN_H 1 - * } - */ - public static int _BITS_STDINT_UINTN_H() { - return _BITS_STDINT_UINTN_H; - } - private static final int DLPACK_MAJOR_VERSION = (int)1L; - /** - * {@snippet lang=c : - * #define DLPACK_MAJOR_VERSION 1 - * } - */ - public static int DLPACK_MAJOR_VERSION() { - return DLPACK_MAJOR_VERSION; - } - private static final int DLPACK_MINOR_VERSION = (int)0L; - /** - * {@snippet lang=c : - * #define DLPACK_MINOR_VERSION 0 - * } - */ - public static int DLPACK_MINOR_VERSION() { - return DLPACK_MINOR_VERSION; - } - /** - * {@snippet lang=c : - * typedef unsigned char __u_char - * } - */ - public static final OfByte __u_char = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned short __u_short - * } - */ - public static final OfShort __u_short = brute_force_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned int __u_int - * } - */ - public static final OfInt __u_int = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __u_long - * } - */ - public static final OfLong __u_long = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char __int8_t - * } - */ - public static final OfByte __int8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned char __uint8_t - * } - */ - public static final OfByte __uint8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef short __int16_t - * } - */ - public static final OfShort __int16_t = brute_force_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef unsigned short __uint16_t - * } - */ - public static final OfShort __uint16_t = brute_force_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef int __int32_t - * } - */ - public static final OfInt __int32_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __uint32_t - * } - */ - public static final OfInt __uint32_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __int64_t - * } - */ - public static final OfLong __int64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uint64_t - * } - */ - public static final OfLong __uint64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int8_t __int_least8_t - * } - */ - public static final OfByte __int_least8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint8_t __uint_least8_t - * } - */ - public static final OfByte __uint_least8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t __int_least16_t - * } - */ - public static final OfShort __int_least16_t = brute_force_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint16_t __uint_least16_t - * } - */ - public static final OfShort __uint_least16_t = brute_force_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t __int_least32_t - * } - */ - public static final OfInt __int_least32_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint32_t __uint_least32_t - * } - */ - public static final OfInt __uint_least32_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t __int_least64_t - * } - */ - public static final OfLong __int_least64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint64_t __uint_least64_t - * } - */ - public static final OfLong __uint_least64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __quad_t - * } - */ - public static final OfLong __quad_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __u_quad_t - * } - */ - public static final OfLong __u_quad_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __intmax_t - * } - */ - public static final OfLong __intmax_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __uintmax_t - * } - */ - public static final OfLong __uintmax_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __dev_t - * } - */ - public static final OfLong __dev_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __uid_t - * } - */ - public static final OfInt __uid_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned int __gid_t - * } - */ - public static final OfInt __gid_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __ino_t - * } - */ - public static final OfLong __ino_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __ino64_t - * } - */ - public static final OfLong __ino64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __mode_t - * } - */ - public static final OfInt __mode_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef unsigned long __nlink_t - * } - */ - public static final OfLong __nlink_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off_t - * } - */ - public static final OfLong __off_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __off64_t - * } - */ - public static final OfLong __off64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __pid_t - * } - */ - public static final OfInt __pid_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __clock_t - * } - */ - public static final OfLong __clock_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim_t - * } - */ - public static final OfLong __rlim_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __rlim64_t - * } - */ - public static final OfLong __rlim64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __id_t - * } - */ - public static final OfInt __id_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __time_t - * } - */ - public static final OfLong __time_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __useconds_t - * } - */ - public static final OfInt __useconds_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef long __suseconds_t - * } - */ - public static final OfLong __suseconds_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __suseconds64_t - * } - */ - public static final OfLong __suseconds64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int __daddr_t - * } - */ - public static final OfInt __daddr_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __key_t - * } - */ - public static final OfInt __key_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __clockid_t - * } - */ - public static final OfInt __clockid_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef void *__timer_t - * } - */ - public static final AddressLayout __timer_t = brute_force_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __blksize_t - * } - */ - public static final OfLong __blksize_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt_t - * } - */ - public static final OfLong __blkcnt_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __blkcnt64_t - * } - */ - public static final OfLong __blkcnt64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt_t - * } - */ - public static final OfLong __fsblkcnt_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsblkcnt64_t - * } - */ - public static final OfLong __fsblkcnt64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt_t - * } - */ - public static final OfLong __fsfilcnt_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __fsfilcnt64_t - * } - */ - public static final OfLong __fsfilcnt64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __fsword_t - * } - */ - public static final OfLong __fsword_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __ssize_t - * } - */ - public static final OfLong __ssize_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long __syscall_slong_t - * } - */ - public static final OfLong __syscall_slong_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long __syscall_ulong_t - * } - */ - public static final OfLong __syscall_ulong_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __off64_t __loff_t - * } - */ - public static final OfLong __loff_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef char *__caddr_t - * } - */ - public static final AddressLayout __caddr_t = brute_force_h.C_POINTER; - /** - * {@snippet lang=c : - * typedef long __intptr_t - * } - */ - public static final OfLong __intptr_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned int __socklen_t - * } - */ - public static final OfInt __socklen_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef int __sig_atomic_t - * } - */ - public static final OfInt __sig_atomic_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int8_t int8_t - * } - */ - public static final OfByte int8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int16_t int16_t - * } - */ - public static final OfShort int16_t = brute_force_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int32_t int32_t - * } - */ - public static final OfInt int32_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int64_t int64_t - * } - */ - public static final OfLong int64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint8_t uint8_t - * } - */ - public static final OfByte uint8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint16_t uint16_t - * } - */ - public static final OfShort uint16_t = brute_force_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint32_t uint32_t - * } - */ - public static final OfInt uint32_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint64_t uint64_t - * } - */ - public static final OfLong uint64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __int_least8_t int_least8_t - * } - */ - public static final OfByte int_least8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __int_least16_t int_least16_t - * } - */ - public static final OfShort int_least16_t = brute_force_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __int_least32_t int_least32_t - * } - */ - public static final OfInt int_least32_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef __int_least64_t int_least64_t - * } - */ - public static final OfLong int_least64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uint_least8_t uint_least8_t - * } - */ - public static final OfByte uint_least8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef __uint_least16_t uint_least16_t - * } - */ - public static final OfShort uint_least16_t = brute_force_h.C_SHORT; - /** - * {@snippet lang=c : - * typedef __uint_least32_t uint_least32_t - * } - */ - public static final OfInt uint_least32_t = brute_force_h.C_INT; - /** - * {@snippet lang=c : - * typedef __uint_least64_t uint_least64_t - * } - */ - public static final OfLong uint_least64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef signed char int_fast8_t - * } - */ - public static final OfByte int_fast8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef long int_fast16_t - * } - */ - public static final OfLong int_fast16_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast32_t - * } - */ - public static final OfLong int_fast32_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long int_fast64_t - * } - */ - public static final OfLong int_fast64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned char uint_fast8_t - * } - */ - public static final OfByte uint_fast8_t = brute_force_h.C_CHAR; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast16_t - * } - */ - public static final OfLong uint_fast16_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast32_t - * } - */ - public static final OfLong uint_fast32_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uint_fast64_t - * } - */ - public static final OfLong uint_fast64_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef long intptr_t - * } - */ - public static final OfLong intptr_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long uintptr_t - * } - */ - public static final OfLong uintptr_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __intmax_t intmax_t - * } - */ - public static final OfLong intmax_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef __uintmax_t uintmax_t - * } - */ - public static final OfLong uintmax_t = brute_force_h.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 = brute_force_h.C_LONG; - private static final int L2Expanded = (int)0L; - /** - * {@snippet lang=c : - * enum .L2Expanded = 0 - * } - */ - public static int L2Expanded() { - return L2Expanded; - } - private static final int L2SqrtExpanded = (int)1L; - /** - * {@snippet lang=c : - * enum .L2SqrtExpanded = 1 - * } - */ - public static int L2SqrtExpanded() { - return L2SqrtExpanded; - } - private static final int CosineExpanded = (int)2L; - /** - * {@snippet lang=c : - * enum .CosineExpanded = 2 - * } - */ - public static int CosineExpanded() { - return CosineExpanded; - } - private static final int L1 = (int)3L; - /** - * {@snippet lang=c : - * enum .L1 = 3 - * } - */ - public static int L1() { - return L1; - } - private static final int L2Unexpanded = (int)4L; - /** - * {@snippet lang=c : - * enum .L2Unexpanded = 4 - * } - */ - public static int L2Unexpanded() { - return L2Unexpanded; - } - private static final int L2SqrtUnexpanded = (int)5L; - /** - * {@snippet lang=c : - * enum .L2SqrtUnexpanded = 5 - * } - */ - public static int L2SqrtUnexpanded() { - return L2SqrtUnexpanded; - } - private static final int InnerProduct = (int)6L; - /** - * {@snippet lang=c : - * enum .InnerProduct = 6 - * } - */ - public static int InnerProduct() { - return InnerProduct; - } - private static final int Linf = (int)7L; - /** - * {@snippet lang=c : - * enum .Linf = 7 - * } - */ - public static int Linf() { - return Linf; - } - private static final int Canberra = (int)8L; - /** - * {@snippet lang=c : - * enum .Canberra = 8 - * } - */ - public static int Canberra() { - return Canberra; - } - private static final int LpUnexpanded = (int)9L; - /** - * {@snippet lang=c : - * enum .LpUnexpanded = 9 - * } - */ - public static int LpUnexpanded() { - return LpUnexpanded; - } - private static final int CorrelationExpanded = (int)10L; - /** - * {@snippet lang=c : - * enum .CorrelationExpanded = 10 - * } - */ - public static int CorrelationExpanded() { - return CorrelationExpanded; - } - private static final int JaccardExpanded = (int)11L; - /** - * {@snippet lang=c : - * enum .JaccardExpanded = 11 - * } - */ - public static int JaccardExpanded() { - return JaccardExpanded; - } - private static final int HellingerExpanded = (int)12L; - /** - * {@snippet lang=c : - * enum .HellingerExpanded = 12 - * } - */ - public static int HellingerExpanded() { - return HellingerExpanded; - } - private static final int Haversine = (int)13L; - /** - * {@snippet lang=c : - * enum .Haversine = 13 - * } - */ - public static int Haversine() { - return Haversine; - } - private static final int BrayCurtis = (int)14L; - /** - * {@snippet lang=c : - * enum .BrayCurtis = 14 - * } - */ - public static int BrayCurtis() { - return BrayCurtis; - } - private static final int JensenShannon = (int)15L; - /** - * {@snippet lang=c : - * enum .JensenShannon = 15 - * } - */ - public static int JensenShannon() { - return JensenShannon; - } - private static final int HammingUnexpanded = (int)16L; - /** - * {@snippet lang=c : - * enum .HammingUnexpanded = 16 - * } - */ - public static int HammingUnexpanded() { - return HammingUnexpanded; - } - private static final int KLDivergence = (int)17L; - /** - * {@snippet lang=c : - * enum .KLDivergence = 17 - * } - */ - public static int KLDivergence() { - return KLDivergence; - } - private static final int RusselRaoExpanded = (int)18L; - /** - * {@snippet lang=c : - * enum .RusselRaoExpanded = 18 - * } - */ - public static int RusselRaoExpanded() { - return RusselRaoExpanded; - } - private static final int DiceExpanded = (int)19L; - /** - * {@snippet lang=c : - * enum .DiceExpanded = 19 - * } - */ - public static int DiceExpanded() { - return DiceExpanded; - } - private static final int Precomputed = (int)100L; - /** - * {@snippet lang=c : - * enum .Precomputed = 100 - * } - */ - public static int Precomputed() { - return Precomputed; - } - /** - * {@snippet lang=c : - * typedef long ptrdiff_t - * } - */ - public static final OfLong ptrdiff_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef unsigned long size_t - * } - */ - public static final OfLong size_t = brute_force_h.C_LONG; - /** - * {@snippet lang=c : - * typedef int wchar_t - * } - */ - public static final OfInt wchar_t = brute_force_h.C_INT; - private static final int kDLCPU = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLCPU = 1 - * } - */ - public static int kDLCPU() { - return kDLCPU; - } - private static final int kDLCUDA = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLCUDA = 2 - * } - */ - public static int kDLCUDA() { - return kDLCUDA; - } - private static final int kDLCUDAHost = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLCUDAHost = 3 - * } - */ - public static int kDLCUDAHost() { - return kDLCUDAHost; - } - private static final int kDLOpenCL = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLOpenCL = 4 - * } - */ - public static int kDLOpenCL() { - return kDLOpenCL; - } - private static final int kDLVulkan = (int)7L; - /** - * {@snippet lang=c : - * enum .kDLVulkan = 7 - * } - */ - public static int kDLVulkan() { - return kDLVulkan; - } - private static final int kDLMetal = (int)8L; - /** - * {@snippet lang=c : - * enum .kDLMetal = 8 - * } - */ - public static int kDLMetal() { - return kDLMetal; - } - private static final int kDLVPI = (int)9L; - /** - * {@snippet lang=c : - * enum .kDLVPI = 9 - * } - */ - public static int kDLVPI() { - return kDLVPI; - } - private static final int kDLROCM = (int)10L; - /** - * {@snippet lang=c : - * enum .kDLROCM = 10 - * } - */ - public static int kDLROCM() { - return kDLROCM; - } - private static final int kDLROCMHost = (int)11L; - /** - * {@snippet lang=c : - * enum .kDLROCMHost = 11 - * } - */ - public static int kDLROCMHost() { - return kDLROCMHost; - } - private static final int kDLExtDev = (int)12L; - /** - * {@snippet lang=c : - * enum .kDLExtDev = 12 - * } - */ - public static int kDLExtDev() { - return kDLExtDev; - } - private static final int kDLCUDAManaged = (int)13L; - /** - * {@snippet lang=c : - * enum .kDLCUDAManaged = 13 - * } - */ - public static int kDLCUDAManaged() { - return kDLCUDAManaged; - } - private static final int kDLOneAPI = (int)14L; - /** - * {@snippet lang=c : - * enum .kDLOneAPI = 14 - * } - */ - public static int kDLOneAPI() { - return kDLOneAPI; - } - private static final int kDLWebGPU = (int)15L; - /** - * {@snippet lang=c : - * enum .kDLWebGPU = 15 - * } - */ - public static int kDLWebGPU() { - return kDLWebGPU; - } - private static final int kDLHexagon = (int)16L; - /** - * {@snippet lang=c : - * enum .kDLHexagon = 16 - * } - */ - public static int kDLHexagon() { - return kDLHexagon; - } - private static final int kDLMAIA = (int)17L; - /** - * {@snippet lang=c : - * enum .kDLMAIA = 17 - * } - */ - public static int kDLMAIA() { - return kDLMAIA; - } - private static final int kDLInt = (int)0L; - /** - * {@snippet lang=c : - * enum .kDLInt = 0 - * } - */ - public static int kDLInt() { - return kDLInt; - } - private static final int kDLUInt = (int)1L; - /** - * {@snippet lang=c : - * enum .kDLUInt = 1 - * } - */ - public static int kDLUInt() { - return kDLUInt; - } - private static final int kDLFloat = (int)2L; - /** - * {@snippet lang=c : - * enum .kDLFloat = 2 - * } - */ - public static int kDLFloat() { - return kDLFloat; - } - private static final int kDLOpaqueHandle = (int)3L; - /** - * {@snippet lang=c : - * enum .kDLOpaqueHandle = 3 - * } - */ - public static int kDLOpaqueHandle() { - return kDLOpaqueHandle; - } - private static final int kDLBfloat = (int)4L; - /** - * {@snippet lang=c : - * enum .kDLBfloat = 4 - * } - */ - public static int kDLBfloat() { - return kDLBfloat; - } - private static final int kDLComplex = (int)5L; - /** - * {@snippet lang=c : - * enum .kDLComplex = 5 - * } - */ - public static int kDLComplex() { - return kDLComplex; - } - private static final int kDLBool = (int)6L; - /** - * {@snippet lang=c : - * enum .kDLBool = 6 - * } - */ - public static int kDLBool() { - return kDLBool; - } - private static final int NO_FILTER = (int)0L; - /** - * {@snippet lang=c : - * enum cuvsFilterType.NO_FILTER = 0 - * } - */ - public static int NO_FILTER() { - return NO_FILTER; - } - private static final int BITSET = (int)1L; - /** - * {@snippet lang=c : - * enum cuvsFilterType.BITSET = 1 - * } - */ - public static int BITSET() { - return BITSET; - } - private static final int BITMAP = (int)2L; - /** - * {@snippet lang=c : - * enum cuvsFilterType.BITMAP = 2 - * } - */ - public static int BITMAP() { - return BITMAP; - } - /** - * {@snippet lang=c : - * typedef cuvsBruteForceIndex *cuvsBruteForceIndex_t - * } - */ - public static final AddressLayout cuvsBruteForceIndex_t = brute_force_h.C_POINTER; - - private static class cuvsBruteForceIndexCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - brute_force_h.C_INT, - brute_force_h.C_POINTER - ); - - public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceIndexCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) - * } - */ - public static FunctionDescriptor cuvsBruteForceIndexCreate$descriptor() { - return cuvsBruteForceIndexCreate.DESC; - } + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int DLPACK_VERSION = (int) 80L; - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) - * } - */ - public static MethodHandle cuvsBruteForceIndexCreate$handle() { - return cuvsBruteForceIndexCreate.HANDLE; - } + /** + * {@snippet lang = c : * #define DLPACK_VERSION 80 + * } + */ + public static int DLPACK_VERSION() { + return DLPACK_VERSION; + } - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) - * } - */ - public static MemorySegment cuvsBruteForceIndexCreate$address() { - return cuvsBruteForceIndexCreate.ADDR; - } + private static final int DLPACK_ABI_VERSION = (int) 1L; - /** - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index) - * } - */ - public static int cuvsBruteForceIndexCreate(MemorySegment index) { - var mh$ = cuvsBruteForceIndexCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsBruteForceIndexCreate", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + /** + * {@snippet lang = c : * #define DLPACK_ABI_VERSION 1 + * } + */ + public static int DLPACK_ABI_VERSION() { + return DLPACK_ABI_VERSION; + } - private static class cuvsBruteForceIndexDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - brute_force_h.C_INT, - brute_force_h.C_POINTER - ); + private static final int _STDINT_H = (int) 1L; - public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceIndexDestroy"); + /** + * {@snippet lang = c : * #define _STDINT_H 1 + * } + */ + public static int _STDINT_H() { + return _STDINT_H; + } - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int _FEATURES_H = (int) 1L; - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) - * } - */ - public static FunctionDescriptor cuvsBruteForceIndexDestroy$descriptor() { - return cuvsBruteForceIndexDestroy.DESC; - } + /** + * {@snippet lang = c : * #define _FEATURES_H 1 + * } + */ + public static int _FEATURES_H() { + return _FEATURES_H; + } - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) - * } - */ - public static MethodHandle cuvsBruteForceIndexDestroy$handle() { - return cuvsBruteForceIndexDestroy.HANDLE; - } + private static final int _DEFAULT_SOURCE = (int) 1L; - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) - * } - */ - public static MemorySegment cuvsBruteForceIndexDestroy$address() { - return cuvsBruteForceIndexDestroy.ADDR; - } + /** + * {@snippet lang = c : * #define _DEFAULT_SOURCE 1 + * } + */ + public static int _DEFAULT_SOURCE() { + return _DEFAULT_SOURCE; + } - /** - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index) - * } - */ - public static int cuvsBruteForceIndexDestroy(MemorySegment index) { - var mh$ = cuvsBruteForceIndexDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsBruteForceIndexDestroy", index); - } - return (int)mh$.invokeExact(index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + private static final int __GLIBC_USE_ISOC2X = (int) 0L; - private static class cuvsBruteForceBuild { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - brute_force_h.C_INT, - brute_force_h.C_LONG, - brute_force_h.C_POINTER, - brute_force_h.C_INT, - brute_force_h.C_FLOAT, - brute_force_h.C_POINTER - ); + /** + * {@snippet lang = c : * #define __GLIBC_USE_ISOC2X 0 + * } + */ + public static int __GLIBC_USE_ISOC2X() { + return __GLIBC_USE_ISOC2X; + } - public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceBuild"); + private static final int __USE_ISOC11 = (int) 1L; - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + /** + * {@snippet lang = c : * #define __USE_ISOC11 1 + * } + */ + public static int __USE_ISOC11() { + return __USE_ISOC11; + } - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) - * } - */ - public static FunctionDescriptor cuvsBruteForceBuild$descriptor() { - return cuvsBruteForceBuild.DESC; - } + private static final int __USE_ISOC99 = (int) 1L; - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) - * } - */ - public static MethodHandle cuvsBruteForceBuild$handle() { - return cuvsBruteForceBuild.HANDLE; - } + /** + * {@snippet lang = c : * #define __USE_ISOC99 1 + * } + */ + public static int __USE_ISOC99() { + return __USE_ISOC99; + } - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) - * } - */ - public static MemorySegment cuvsBruteForceBuild$address() { - return cuvsBruteForceBuild.ADDR; - } + private static final int __USE_ISOC95 = (int) 1L; - /** - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index) - * } - */ - public static int cuvsBruteForceBuild(long res, MemorySegment dataset, int metric, float metric_arg, MemorySegment index) { - var mh$ = cuvsBruteForceBuild.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsBruteForceBuild", res, dataset, metric, metric_arg, index); - } - return (int)mh$.invokeExact(res, dataset, metric, metric_arg, index); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } + /** + * {@snippet lang = c : * #define __USE_ISOC95 1 + * } + */ + public static int __USE_ISOC95() { + return __USE_ISOC95; + } - private static class cuvsBruteForceSearch { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - brute_force_h.C_INT, - brute_force_h.C_LONG, - brute_force_h.C_POINTER, - brute_force_h.C_POINTER, - brute_force_h.C_POINTER, - brute_force_h.C_POINTER, - cuvsFilter.layout() - ); + private static final int __USE_POSIX_IMPLICITLY = (int) 1L; - public static final MemorySegment ADDR = brute_force_h.findOrThrow("cuvsBruteForceSearch"); + /** + * {@snippet lang = c : * #define __USE_POSIX_IMPLICITLY 1 + * } + */ + public static int __USE_POSIX_IMPLICITLY() { + return __USE_POSIX_IMPLICITLY; + } - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int _POSIX_SOURCE = (int) 1L; - /** - * Function descriptor for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) - * } - */ - public static FunctionDescriptor cuvsBruteForceSearch$descriptor() { - return cuvsBruteForceSearch.DESC; - } + /** + * {@snippet lang = c : * #define _POSIX_SOURCE 1 + * } + */ + public static int _POSIX_SOURCE() { + return _POSIX_SOURCE; + } - /** - * Downcall method handle for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) - * } - */ - public static MethodHandle cuvsBruteForceSearch$handle() { - return cuvsBruteForceSearch.HANDLE; - } + private static final int __USE_POSIX = (int) 1L; - /** - * Address for: - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) - * } - */ - public static MemorySegment cuvsBruteForceSearch$address() { - return cuvsBruteForceSearch.ADDR; - } + /** + * {@snippet lang = c : * #define __USE_POSIX 1 + * } + */ + public static int __USE_POSIX() { + return __USE_POSIX; + } - /** - * {@snippet lang=c : - * cuvsError_t cuvsBruteForceSearch(cuvsResources_t res, cuvsBruteForceIndex_t index, DLManagedTensor *queries, DLManagedTensor *neighbors, DLManagedTensor *distances, cuvsFilter prefilter) - * } - */ - public static int cuvsBruteForceSearch(long res, MemorySegment index, MemorySegment queries, MemorySegment neighbors, MemorySegment distances, MemorySegment prefilter) { - var mh$ = cuvsBruteForceSearch.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsBruteForceSearch", res, index, queries, neighbors, distances, prefilter); - } - return (int)mh$.invokeExact(res, index, queries, neighbors, distances, prefilter); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - private static final long _POSIX_C_SOURCE = 200809L; - /** - * {@snippet lang=c : - * #define _POSIX_C_SOURCE 200809 - * } - */ - public static long _POSIX_C_SOURCE() { - return _POSIX_C_SOURCE; - } - private static final int __TIMESIZE = (int)64L; - /** - * {@snippet lang=c : - * #define __TIMESIZE 64 - * } - */ - public static int __TIMESIZE() { - return __TIMESIZE; - } - private static final long __STDC_IEC_60559_BFP__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_BFP__ 201404 - * } - */ - public static long __STDC_IEC_60559_BFP__() { - return __STDC_IEC_60559_BFP__; - } - private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; - /** - * {@snippet lang=c : - * #define __STDC_IEC_60559_COMPLEX__ 201404 - * } - */ - public static long __STDC_IEC_60559_COMPLEX__() { - return __STDC_IEC_60559_COMPLEX__; - } - private static final long __STDC_ISO_10646__ = 201706L; - /** - * {@snippet lang=c : - * #define __STDC_ISO_10646__ 201706 - * } - */ - public static long __STDC_ISO_10646__() { - return __STDC_ISO_10646__; - } - private static final int __WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define __WCHAR_MAX 2147483647 - * } - */ - public static int __WCHAR_MAX() { - return __WCHAR_MAX; - } - private static final int __WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define __WCHAR_MIN -2147483648 - * } - */ - public static int __WCHAR_MIN() { - return __WCHAR_MIN; - } - private static final int INT8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT8_MIN -128 - * } - */ - public static int INT8_MIN() { - return INT8_MIN; - } - private static final int INT16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT16_MIN -32768 - * } - */ - public static int INT16_MIN() { - return INT16_MIN; - } - private static final int INT32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT32_MIN -2147483648 - * } - */ - public static int INT32_MIN() { - return INT32_MIN; - } - private static final long INT64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT64_MIN -9223372036854775808 - * } - */ - public static long INT64_MIN() { - return INT64_MIN; - } - private static final int INT8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT8_MAX 127 - * } - */ - public static int INT8_MAX() { - return INT8_MAX; - } - private static final int INT16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT16_MAX 32767 - * } - */ - public static int INT16_MAX() { - return INT16_MAX; - } - private static final int INT32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT32_MAX 2147483647 - * } - */ - public static int INT32_MAX() { - return INT32_MAX; - } - private static final long INT64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT64_MAX 9223372036854775807 - * } - */ - public static long INT64_MAX() { - return INT64_MAX; - } - private static final int UINT8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT8_MAX 255 - * } - */ - public static int UINT8_MAX() { - return UINT8_MAX; - } - private static final int UINT16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT16_MAX 65535 - * } - */ - public static int UINT16_MAX() { - return UINT16_MAX; - } - private static final int UINT32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT32_MAX 4294967295 - * } - */ - public static int UINT32_MAX() { - return UINT32_MAX; - } - private static final long UINT64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT64_MAX -1 - * } - */ - public static long UINT64_MAX() { - return UINT64_MAX; - } - private static final int INT_LEAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MIN -128 - * } - */ - public static int INT_LEAST8_MIN() { - return INT_LEAST8_MIN; - } - private static final int INT_LEAST16_MIN = (int)-32768L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MIN -32768 - * } - */ - public static int INT_LEAST16_MIN() { - return INT_LEAST16_MIN; - } - private static final int INT_LEAST32_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MIN -2147483648 - * } - */ - public static int INT_LEAST32_MIN() { - return INT_LEAST32_MIN; - } - private static final long INT_LEAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MIN -9223372036854775808 - * } - */ - public static long INT_LEAST64_MIN() { - return INT_LEAST64_MIN; - } - private static final int INT_LEAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_LEAST8_MAX 127 - * } - */ - public static int INT_LEAST8_MAX() { - return INT_LEAST8_MAX; - } - private static final int INT_LEAST16_MAX = (int)32767L; - /** - * {@snippet lang=c : - * #define INT_LEAST16_MAX 32767 - * } - */ - public static int INT_LEAST16_MAX() { - return INT_LEAST16_MAX; - } - private static final int INT_LEAST32_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define INT_LEAST32_MAX 2147483647 - * } - */ - public static int INT_LEAST32_MAX() { - return INT_LEAST32_MAX; - } - private static final long INT_LEAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_LEAST64_MAX 9223372036854775807 - * } - */ - public static long INT_LEAST64_MAX() { - return INT_LEAST64_MAX; - } - private static final int UINT_LEAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_LEAST8_MAX 255 - * } - */ - public static int UINT_LEAST8_MAX() { - return UINT_LEAST8_MAX; - } - private static final int UINT_LEAST16_MAX = (int)65535L; - /** - * {@snippet lang=c : - * #define UINT_LEAST16_MAX 65535 - * } - */ - public static int UINT_LEAST16_MAX() { - return UINT_LEAST16_MAX; - } - private static final int UINT_LEAST32_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define UINT_LEAST32_MAX 4294967295 - * } - */ - public static int UINT_LEAST32_MAX() { - return UINT_LEAST32_MAX; - } - private static final long UINT_LEAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_LEAST64_MAX -1 - * } - */ - public static long UINT_LEAST64_MAX() { - return UINT_LEAST64_MAX; - } - private static final int INT_FAST8_MIN = (int)-128L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MIN -128 - * } - */ - public static int INT_FAST8_MIN() { - return INT_FAST8_MIN; - } - private static final long INT_FAST16_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MIN -9223372036854775808 - * } - */ - public static long INT_FAST16_MIN() { - return INT_FAST16_MIN; - } - private static final long INT_FAST32_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MIN -9223372036854775808 - * } - */ - public static long INT_FAST32_MIN() { - return INT_FAST32_MIN; - } - private static final long INT_FAST64_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MIN -9223372036854775808 - * } - */ - public static long INT_FAST64_MIN() { - return INT_FAST64_MIN; - } - private static final int INT_FAST8_MAX = (int)127L; - /** - * {@snippet lang=c : - * #define INT_FAST8_MAX 127 - * } - */ - public static int INT_FAST8_MAX() { - return INT_FAST8_MAX; - } - private static final long INT_FAST16_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST16_MAX 9223372036854775807 - * } - */ - public static long INT_FAST16_MAX() { - return INT_FAST16_MAX; - } - private static final long INT_FAST32_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST32_MAX 9223372036854775807 - * } - */ - public static long INT_FAST32_MAX() { - return INT_FAST32_MAX; - } - private static final long INT_FAST64_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INT_FAST64_MAX 9223372036854775807 - * } - */ - public static long INT_FAST64_MAX() { - return INT_FAST64_MAX; - } - private static final int UINT_FAST8_MAX = (int)255L; - /** - * {@snippet lang=c : - * #define UINT_FAST8_MAX 255 - * } - */ - public static int UINT_FAST8_MAX() { - return UINT_FAST8_MAX; - } - private static final long UINT_FAST16_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST16_MAX -1 - * } - */ - public static long UINT_FAST16_MAX() { - return UINT_FAST16_MAX; - } - private static final long UINT_FAST32_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST32_MAX -1 - * } - */ - public static long UINT_FAST32_MAX() { - return UINT_FAST32_MAX; - } - private static final long UINT_FAST64_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINT_FAST64_MAX -1 - * } - */ - public static long UINT_FAST64_MAX() { - return UINT_FAST64_MAX; - } - private static final long INTPTR_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTPTR_MIN -9223372036854775808 - * } - */ - public static long INTPTR_MIN() { - return INTPTR_MIN; - } - private static final long INTPTR_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTPTR_MAX 9223372036854775807 - * } - */ - public static long INTPTR_MAX() { - return INTPTR_MAX; - } - private static final long UINTPTR_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTPTR_MAX -1 - * } - */ - public static long UINTPTR_MAX() { - return UINTPTR_MAX; - } - private static final long INTMAX_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define INTMAX_MIN -9223372036854775808 - * } - */ - public static long INTMAX_MIN() { - return INTMAX_MIN; - } - private static final long INTMAX_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define INTMAX_MAX 9223372036854775807 - * } - */ - public static long INTMAX_MAX() { - return INTMAX_MAX; - } - private static final long UINTMAX_MAX = -1L; - /** - * {@snippet lang=c : - * #define UINTMAX_MAX -1 - * } - */ - public static long UINTMAX_MAX() { - return UINTMAX_MAX; - } - private static final long PTRDIFF_MIN = -9223372036854775808L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MIN -9223372036854775808 - * } - */ - public static long PTRDIFF_MIN() { - return PTRDIFF_MIN; - } - private static final long PTRDIFF_MAX = 9223372036854775807L; - /** - * {@snippet lang=c : - * #define PTRDIFF_MAX 9223372036854775807 - * } - */ - public static long PTRDIFF_MAX() { - return PTRDIFF_MAX; - } - private static final int SIG_ATOMIC_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MIN -2147483648 - * } - */ - public static int SIG_ATOMIC_MIN() { - return SIG_ATOMIC_MIN; - } - private static final int SIG_ATOMIC_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define SIG_ATOMIC_MAX 2147483647 - * } - */ - public static int SIG_ATOMIC_MAX() { - return SIG_ATOMIC_MAX; - } - private static final long SIZE_MAX = -1L; - /** - * {@snippet lang=c : - * #define SIZE_MAX -1 - * } - */ - public static long SIZE_MAX() { - return SIZE_MAX; - } - private static final int WCHAR_MIN = (int)-2147483648L; - /** - * {@snippet lang=c : - * #define WCHAR_MIN -2147483648 - * } - */ - public static int WCHAR_MIN() { - return WCHAR_MIN; - } - private static final int WCHAR_MAX = (int)2147483647L; - /** - * {@snippet lang=c : - * #define WCHAR_MAX 2147483647 - * } - */ - public static int WCHAR_MAX() { - return WCHAR_MAX; - } - private static final int WINT_MIN = (int)0L; - /** - * {@snippet lang=c : - * #define WINT_MIN 0 - * } - */ - public static int WINT_MIN() { - return WINT_MIN; - } - private static final int WINT_MAX = (int)4294967295L; - /** - * {@snippet lang=c : - * #define WINT_MAX 4294967295 - * } - */ - public static int WINT_MAX() { - return WINT_MAX; - } - private static final MemorySegment NULL = MemorySegment.ofAddress(0L); - /** - * {@snippet lang=c : - * #define NULL (void*) 0 - * } - */ - public static MemorySegment NULL() { - return NULL; - } - private static final long DLPACK_FLAG_BITMASK_READ_ONLY = 1L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_READ_ONLY 1 - * } - */ - public static long DLPACK_FLAG_BITMASK_READ_ONLY() { - return DLPACK_FLAG_BITMASK_READ_ONLY; - } - private static final long DLPACK_FLAG_BITMASK_IS_COPIED = 2L; - /** - * {@snippet lang=c : - * #define DLPACK_FLAG_BITMASK_IS_COPIED 2 - * } - */ - public static long DLPACK_FLAG_BITMASK_IS_COPIED() { - return DLPACK_FLAG_BITMASK_IS_COPIED; - } -} + 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 = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned short __u_short + * } + */ + public static final OfShort __u_short = brute_force_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned int __u_int + * } + */ + public static final OfInt __u_int = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __u_long + * } + */ + public static final OfLong __u_long = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char __int8_t + * } + */ + public static final OfByte __int8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned char __uint8_t + * } + */ + public static final OfByte __uint8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef short __int16_t + * } + */ + public static final OfShort __int16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang = c : * typedef unsigned short __uint16_t + * } + */ + public static final OfShort __uint16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang = c : * typedef int __int32_t + * } + */ + public static final OfInt __int32_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __uint32_t + * } + */ + public static final OfInt __uint32_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef long __int64_t + * } + */ + public static final OfLong __int64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uint64_t + * } + */ + public static final OfLong __uint64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int8_t __int_least8_t + * } + */ + public static final OfByte __int_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint8_t __uint_least8_t + * } + */ + public static final OfByte __uint_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t __int_least16_t + * } + */ + public static final OfShort __int_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint16_t __uint_least16_t + * } + */ + public static final OfShort __uint_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t __int_least32_t + * } + */ + public static final OfInt __int_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint32_t __uint_least32_t + * } + */ + public static final OfInt __uint_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t __int_least64_t + * } + */ + public static final OfLong __int_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint64_t __uint_least64_t + * } + */ + public static final OfLong __uint_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __quad_t + * } + */ + public static final OfLong __quad_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __u_quad_t + * } + */ + public static final OfLong __u_quad_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __intmax_t + * } + */ + public static final OfLong __intmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __uintmax_t + * } + */ + public static final OfLong __uintmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __dev_t + * } + */ + public static final OfLong __dev_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __uid_t + * } + */ + public static final OfInt __uid_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned int __gid_t + * } + */ + public static final OfInt __gid_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __ino_t + * } + */ + public static final OfLong __ino_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __ino64_t + * } + */ + public static final OfLong __ino64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __mode_t + * } + */ + public static final OfInt __mode_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef unsigned long __nlink_t + * } + */ + public static final OfLong __nlink_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off_t + * } + */ + public static final OfLong __off_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __off64_t + * } + */ + public static final OfLong __off64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __pid_t + * } + */ + public static final OfInt __pid_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef long __clock_t + * } + */ + public static final OfLong __clock_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim_t + * } + */ + public static final OfLong __rlim_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __rlim64_t + * } + */ + public static final OfLong __rlim64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __id_t + * } + */ + public static final OfInt __id_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef long __time_t + * } + */ + public static final OfLong __time_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __useconds_t + * } + */ + public static final OfInt __useconds_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef long __suseconds_t + * } + */ + public static final OfLong __suseconds_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __suseconds64_t + * } + */ + public static final OfLong __suseconds64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef int __daddr_t + * } + */ + public static final OfInt __daddr_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef int __key_t + * } + */ + public static final OfInt __key_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef int __clockid_t + * } + */ + public static final OfInt __clockid_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef void *__timer_t + * } + */ + public static final AddressLayout __timer_t = brute_force_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __blksize_t + * } + */ + public static final OfLong __blksize_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt_t + * } + */ + public static final OfLong __blkcnt_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __blkcnt64_t + * } + */ + public static final OfLong __blkcnt64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt_t + * } + */ + public static final OfLong __fsblkcnt_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsblkcnt64_t + * } + */ + public static final OfLong __fsblkcnt64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt_t + * } + */ + public static final OfLong __fsfilcnt_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __fsfilcnt64_t + * } + */ + public static final OfLong __fsfilcnt64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __fsword_t + * } + */ + public static final OfLong __fsword_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __ssize_t + * } + */ + public static final OfLong __ssize_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long __syscall_slong_t + * } + */ + public static final OfLong __syscall_slong_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long __syscall_ulong_t + * } + */ + public static final OfLong __syscall_ulong_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef __off64_t __loff_t + * } + */ + public static final OfLong __loff_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef char *__caddr_t + * } + */ + public static final AddressLayout __caddr_t = brute_force_h.C_POINTER; + /** + * {@snippet lang = c : * typedef long __intptr_t + * } + */ + public static final OfLong __intptr_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned int __socklen_t + * } + */ + public static final OfInt __socklen_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef int __sig_atomic_t + * } + */ + public static final OfInt __sig_atomic_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef __int8_t int8_t + * } + */ + public static final OfByte int8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int16_t int16_t + * } + */ + public static final OfShort int16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int32_t int32_t + * } + */ + public static final OfInt int32_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef __int64_t int64_t + * } + */ + public static final OfLong int64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint8_t uint8_t + * } + */ + public static final OfByte uint8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint16_t uint16_t + * } + */ + public static final OfShort uint16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint32_t uint32_t + * } + */ + public static final OfInt uint32_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint64_t uint64_t + * } + */ + public static final OfLong uint64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef __int_least8_t int_least8_t + * } + */ + public static final OfByte int_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __int_least16_t int_least16_t + * } + */ + public static final OfShort int_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __int_least32_t int_least32_t + * } + */ + public static final OfInt int_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef __int_least64_t int_least64_t + * } + */ + public static final OfLong int_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uint_least8_t uint_least8_t + * } + */ + public static final OfByte uint_least8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef __uint_least16_t uint_least16_t + * } + */ + public static final OfShort uint_least16_t = brute_force_h.C_SHORT; + /** + * {@snippet lang = c : * typedef __uint_least32_t uint_least32_t + * } + */ + public static final OfInt uint_least32_t = brute_force_h.C_INT; + /** + * {@snippet lang = c : * typedef __uint_least64_t uint_least64_t + * } + */ + public static final OfLong uint_least64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef signed char int_fast8_t + * } + */ + public static final OfByte int_fast8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef long int_fast16_t + * } + */ + public static final OfLong int_fast16_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast32_t + * } + */ + public static final OfLong int_fast32_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long int_fast64_t + * } + */ + public static final OfLong int_fast64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned char uint_fast8_t + * } + */ + public static final OfByte uint_fast8_t = brute_force_h.C_CHAR; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast16_t + * } + */ + public static final OfLong uint_fast16_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast32_t + * } + */ + public static final OfLong uint_fast32_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uint_fast64_t + * } + */ + public static final OfLong uint_fast64_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long intptr_t + * } + */ + public static final OfLong intptr_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long uintptr_t + * } + */ + public static final OfLong uintptr_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef __intmax_t intmax_t + * } + */ + public static final OfLong intmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef __uintmax_t uintmax_t + * } + */ + public static final OfLong uintmax_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = brute_force_h.C_LONG; + /** + * {@snippet lang = c : * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = brute_force_h.C_INT; + private static final int kDLCPU = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLCPU = 1 + * } + */ + public static int kDLCPU() { + return kDLCPU; + } + + private static final int kDLCUDA = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLCUDA = 2 + * } + */ + public static int kDLCUDA() { + return kDLCUDA; + } + + private static final int kDLCUDAHost = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLCUDAHost = 3 + * } + */ + public static int kDLCUDAHost() { + return kDLCUDAHost; + } + + private static final int kDLOpenCL = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLOpenCL = 4 + * } + */ + public static int kDLOpenCL() { + return kDLOpenCL; + } + + private static final int kDLVulkan = (int) 7L; + + /** + * {@snippet lang = c : * enum .kDLVulkan = 7 + * } + */ + public static int kDLVulkan() { + return kDLVulkan; + } + + private static final int kDLMetal = (int) 8L; + + /** + * {@snippet lang = c : * enum .kDLMetal = 8 + * } + */ + public static int kDLMetal() { + return kDLMetal; + } + + private static final int kDLVPI = (int) 9L; + + /** + * {@snippet lang = c : * enum .kDLVPI = 9 + * } + */ + public static int kDLVPI() { + return kDLVPI; + } + + private static final int kDLROCM = (int) 10L; + + /** + * {@snippet lang = c : * enum .kDLROCM = 10 + * } + */ + public static int kDLROCM() { + return kDLROCM; + } + + private static final int kDLROCMHost = (int) 11L; + + /** + * {@snippet lang = c : * enum .kDLROCMHost = 11 + * } + */ + public static int kDLROCMHost() { + return kDLROCMHost; + } + + private static final int kDLExtDev = (int) 12L; + + /** + * {@snippet lang = c : * enum .kDLExtDev = 12 + * } + */ + public static int kDLExtDev() { + return kDLExtDev; + } + + private static final int kDLCUDAManaged = (int) 13L; + + /** + * {@snippet lang = c : * enum .kDLCUDAManaged = 13 + * } + */ + public static int kDLCUDAManaged() { + return kDLCUDAManaged; + } + + private static final int kDLOneAPI = (int) 14L; + + /** + * {@snippet lang = c : * enum .kDLOneAPI = 14 + * } + */ + public static int kDLOneAPI() { + return kDLOneAPI; + } + + private static final int kDLWebGPU = (int) 15L; + + /** + * {@snippet lang = c : * enum .kDLWebGPU = 15 + * } + */ + public static int kDLWebGPU() { + return kDLWebGPU; + } + + private static final int kDLHexagon = (int) 16L; + + /** + * {@snippet lang = c : * enum .kDLHexagon = 16 + * } + */ + public static int kDLHexagon() { + return kDLHexagon; + } + + private static final int kDLInt = (int) 0L; + + /** + * {@snippet lang = c : * enum .kDLInt = 0 + * } + */ + public static int kDLInt() { + return kDLInt; + } + + private static final int kDLUInt = (int) 1L; + + /** + * {@snippet lang = c : * enum .kDLUInt = 1 + * } + */ + public static int kDLUInt() { + return kDLUInt; + } + + private static final int kDLFloat = (int) 2L; + + /** + * {@snippet lang = c : * enum .kDLFloat = 2 + * } + */ + public static int kDLFloat() { + return kDLFloat; + } + + private static final int kDLOpaqueHandle = (int) 3L; + + /** + * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 + * } + */ + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; + } + + private static final int kDLBfloat = (int) 4L; + + /** + * {@snippet lang = c : * enum .kDLBfloat = 4 + * } + */ + public static int kDLBfloat() { + return kDLBfloat; + } + + private static final int kDLComplex = (int) 5L; + + /** + * {@snippet lang = c : * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; + } + + private static final int kDLBool = (int) 6L; + + /** + * {@snippet lang = c : * enum .kDLBool = 6 + * } + */ + public static int kDLBool() { + return kDLBool; + } + + /** + * {@snippet lang = c : * typedef cuvsBruteForceIndex *cuvsBruteForceIndex_t + * } + */ + public static final AddressLayout cuvsBruteForceIndex_t = brute_force_h.C_POINTER; + private static final long _POSIX_C_SOURCE = 200809L; + + /** + * {@snippet lang = c : * #define _POSIX_C_SOURCE 200809 + * } + */ + public static long _POSIX_C_SOURCE() { + return _POSIX_C_SOURCE; + } + + private static final int __TIMESIZE = (int) 64L; + + /** + * {@snippet lang = c : * #define __TIMESIZE 64 + * } + */ + public static int __TIMESIZE() { + return __TIMESIZE; + } + + private static final long __STDC_IEC_60559_BFP__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_BFP__ 201404 + * } + */ + public static long __STDC_IEC_60559_BFP__() { + return __STDC_IEC_60559_BFP__; + } + + private static final long __STDC_IEC_60559_COMPLEX__ = 201404L; + + /** + * {@snippet lang = c : * #define __STDC_IEC_60559_COMPLEX__ 201404 + * } + */ + public static long __STDC_IEC_60559_COMPLEX__() { + return __STDC_IEC_60559_COMPLEX__; + } + + private static final long __STDC_ISO_10646__ = 201706L; + + /** + * {@snippet lang = c : * #define __STDC_ISO_10646__ 201706 + * } + */ + public static long __STDC_ISO_10646__() { + return __STDC_ISO_10646__; + } + + private static final int __WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define __WCHAR_MAX 2147483647 + * } + */ + public static int __WCHAR_MAX() { + return __WCHAR_MAX; + } + + private static final int __WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define __WCHAR_MIN -2147483648 + * } + */ + public static int __WCHAR_MIN() { + return __WCHAR_MIN; + } + + private static final int INT8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT8_MIN -128 + * } + */ + public static int INT8_MIN() { + return INT8_MIN; + } + + private static final int INT16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT16_MIN -32768 + * } + */ + public static int INT16_MIN() { + return INT16_MIN; + } + + private static final int INT32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT32_MIN -2147483648 + * } + */ + public static int INT32_MIN() { + return INT32_MIN; + } + + private static final long INT64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT64_MIN -9223372036854775808 + * } + */ + public static long INT64_MIN() { + return INT64_MIN; + } + + private static final int INT8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT8_MAX 127 + * } + */ + public static int INT8_MAX() { + return INT8_MAX; + } + + private static final int INT16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT16_MAX 32767 + * } + */ + public static int INT16_MAX() { + return INT16_MAX; + } + + private static final int INT32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT32_MAX 2147483647 + * } + */ + public static int INT32_MAX() { + return INT32_MAX; + } + + private static final long INT64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT64_MAX 9223372036854775807 + * } + */ + public static long INT64_MAX() { + return INT64_MAX; + } + + private static final int UINT8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT8_MAX 255 + * } + */ + public static int UINT8_MAX() { + return UINT8_MAX; + } + + private static final int UINT16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT16_MAX 65535 + * } + */ + public static int UINT16_MAX() { + return UINT16_MAX; + } + + private static final int UINT32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT32_MAX 4294967295 + * } + */ + public static int UINT32_MAX() { + return UINT32_MAX; + } + + private static final long UINT64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT64_MAX -1 + * } + */ + public static long UINT64_MAX() { + return UINT64_MAX; + } + + private static final int INT_LEAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MIN -128 + * } + */ + public static int INT_LEAST8_MIN() { + return INT_LEAST8_MIN; + } + + private static final int INT_LEAST16_MIN = (int) -32768L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MIN -32768 + * } + */ + public static int INT_LEAST16_MIN() { + return INT_LEAST16_MIN; + } + + private static final int INT_LEAST32_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MIN -2147483648 + * } + */ + public static int INT_LEAST32_MIN() { + return INT_LEAST32_MIN; + } + + private static final long INT_LEAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MIN -9223372036854775808 + * } + */ + public static long INT_LEAST64_MIN() { + return INT_LEAST64_MIN; + } + + private static final int INT_LEAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_LEAST8_MAX 127 + * } + */ + public static int INT_LEAST8_MAX() { + return INT_LEAST8_MAX; + } + + private static final int INT_LEAST16_MAX = (int) 32767L; + + /** + * {@snippet lang = c : * #define INT_LEAST16_MAX 32767 + * } + */ + public static int INT_LEAST16_MAX() { + return INT_LEAST16_MAX; + } + + private static final int INT_LEAST32_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define INT_LEAST32_MAX 2147483647 + * } + */ + public static int INT_LEAST32_MAX() { + return INT_LEAST32_MAX; + } + + private static final long INT_LEAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_LEAST64_MAX 9223372036854775807 + * } + */ + public static long INT_LEAST64_MAX() { + return INT_LEAST64_MAX; + } + + private static final int UINT_LEAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_LEAST8_MAX 255 + * } + */ + public static int UINT_LEAST8_MAX() { + return UINT_LEAST8_MAX; + } + + private static final int UINT_LEAST16_MAX = (int) 65535L; + + /** + * {@snippet lang = c : * #define UINT_LEAST16_MAX 65535 + * } + */ + public static int UINT_LEAST16_MAX() { + return UINT_LEAST16_MAX; + } + + private static final int UINT_LEAST32_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define UINT_LEAST32_MAX 4294967295 + * } + */ + public static int UINT_LEAST32_MAX() { + return UINT_LEAST32_MAX; + } + + private static final long UINT_LEAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_LEAST64_MAX -1 + * } + */ + public static long UINT_LEAST64_MAX() { + return UINT_LEAST64_MAX; + } + + private static final int INT_FAST8_MIN = (int) -128L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MIN -128 + * } + */ + public static int INT_FAST8_MIN() { + return INT_FAST8_MIN; + } + + private static final long INT_FAST16_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MIN -9223372036854775808 + * } + */ + public static long INT_FAST16_MIN() { + return INT_FAST16_MIN; + } + + private static final long INT_FAST32_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MIN -9223372036854775808 + * } + */ + public static long INT_FAST32_MIN() { + return INT_FAST32_MIN; + } + + private static final long INT_FAST64_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MIN -9223372036854775808 + * } + */ + public static long INT_FAST64_MIN() { + return INT_FAST64_MIN; + } + + private static final int INT_FAST8_MAX = (int) 127L; + + /** + * {@snippet lang = c : * #define INT_FAST8_MAX 127 + * } + */ + public static int INT_FAST8_MAX() { + return INT_FAST8_MAX; + } + + private static final long INT_FAST16_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST16_MAX 9223372036854775807 + * } + */ + public static long INT_FAST16_MAX() { + return INT_FAST16_MAX; + } + + private static final long INT_FAST32_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST32_MAX 9223372036854775807 + * } + */ + public static long INT_FAST32_MAX() { + return INT_FAST32_MAX; + } + + private static final long INT_FAST64_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INT_FAST64_MAX 9223372036854775807 + * } + */ + public static long INT_FAST64_MAX() { + return INT_FAST64_MAX; + } + + private static final int UINT_FAST8_MAX = (int) 255L; + + /** + * {@snippet lang = c : * #define UINT_FAST8_MAX 255 + * } + */ + public static int UINT_FAST8_MAX() { + return UINT_FAST8_MAX; + } + + private static final long UINT_FAST16_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST16_MAX -1 + * } + */ + public static long UINT_FAST16_MAX() { + return UINT_FAST16_MAX; + } + + private static final long UINT_FAST32_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST32_MAX -1 + * } + */ + public static long UINT_FAST32_MAX() { + return UINT_FAST32_MAX; + } + + private static final long UINT_FAST64_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINT_FAST64_MAX -1 + * } + */ + public static long UINT_FAST64_MAX() { + return UINT_FAST64_MAX; + } + + private static final long INTPTR_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTPTR_MIN -9223372036854775808 + * } + */ + public static long INTPTR_MIN() { + return INTPTR_MIN; + } + + private static final long INTPTR_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTPTR_MAX 9223372036854775807 + * } + */ + public static long INTPTR_MAX() { + return INTPTR_MAX; + } + + private static final long UINTPTR_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTPTR_MAX -1 + * } + */ + public static long UINTPTR_MAX() { + return UINTPTR_MAX; + } + + private static final long INTMAX_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define INTMAX_MIN -9223372036854775808 + * } + */ + public static long INTMAX_MIN() { + return INTMAX_MIN; + } + + private static final long INTMAX_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define INTMAX_MAX 9223372036854775807 + * } + */ + public static long INTMAX_MAX() { + return INTMAX_MAX; + } + + private static final long UINTMAX_MAX = -1L; + + /** + * {@snippet lang = c : * #define UINTMAX_MAX -1 + * } + */ + public static long UINTMAX_MAX() { + return UINTMAX_MAX; + } + + private static final long PTRDIFF_MIN = -9223372036854775808L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MIN -9223372036854775808 + * } + */ + public static long PTRDIFF_MIN() { + return PTRDIFF_MIN; + } + + private static final long PTRDIFF_MAX = 9223372036854775807L; + + /** + * {@snippet lang = c : * #define PTRDIFF_MAX 9223372036854775807 + * } + */ + public static long PTRDIFF_MAX() { + return PTRDIFF_MAX; + } + + private static final int SIG_ATOMIC_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MIN -2147483648 + * } + */ + public static int SIG_ATOMIC_MIN() { + return SIG_ATOMIC_MIN; + } + + private static final int SIG_ATOMIC_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define SIG_ATOMIC_MAX 2147483647 + * } + */ + public static int SIG_ATOMIC_MAX() { + return SIG_ATOMIC_MAX; + } + + private static final long SIZE_MAX = -1L; + + /** + * {@snippet lang = c : * #define SIZE_MAX -1 + * } + */ + public static long SIZE_MAX() { + return SIZE_MAX; + } + + private static final int WCHAR_MIN = (int) -2147483648L; + + /** + * {@snippet lang = c : * #define WCHAR_MIN -2147483648 + * } + */ + public static int WCHAR_MIN() { + return WCHAR_MIN; + } + + private static final int WCHAR_MAX = (int) 2147483647L; + + /** + * {@snippet lang = c : * #define WCHAR_MAX 2147483647 + * } + */ + public static int WCHAR_MAX() { + return WCHAR_MAX; + } + + private static final int WINT_MIN = (int) 0L; + + /** + * {@snippet lang = c : * #define WINT_MIN 0 + * } + */ + public static int WINT_MIN() { + return WINT_MIN; + } + + private static final int WINT_MAX = (int) 4294967295L; + + /** + * {@snippet lang = c : * #define WINT_MAX 4294967295 + * } + */ + public static int WINT_MAX() { + return WINT_MAX; + } + + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + + /** + * {@snippet lang = c : * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsBruteForceIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsBruteForceIndex.java new file mode 100644 index 000000000..186f4a4e8 --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsBruteForceIndex.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2024, 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.panama; + +import static java.lang.foreign.MemoryLayout.PathElement.groupElement; + +import java.lang.foreign.Arena; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.function.Consumer; + +/** + * {@snippet lang = c : + * struct { + * uintptr_t addr; + * DLDataType dtype; + * } + * } + */ +public class cuvsBruteForceIndex { + + cuvsBruteForceIndex() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(brute_force_h.C_LONG.withName("addr"), + DLDataType.layout().withName("dtype"), MemoryLayout.paddingLayout(4)).withName("$anon$22:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong addr$LAYOUT = (OfLong) $LAYOUT.select(groupElement("addr")); + + /** + * Layout for field: + * {@snippet lang = c : * uintptr_t addr + * } + */ + public static final OfLong addr$layout() { + return addr$LAYOUT; + } + + private static final long addr$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * uintptr_t addr + * } + */ + public static final long addr$offset() { + return addr$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uintptr_t addr + * } + */ + public static long addr(MemorySegment struct) { + return struct.get(addr$LAYOUT, addr$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uintptr_t addr + * } + */ + public static void addr(MemorySegment struct, long fieldValue) { + struct.set(addr$LAYOUT, addr$OFFSET, fieldValue); + } + + private static final GroupLayout dtype$LAYOUT = (GroupLayout) $LAYOUT.select(groupElement("dtype")); + + /** + * Layout for field: + * {@snippet lang = c : * DLDataType dtype + * } + */ + public static final GroupLayout dtype$layout() { + return dtype$LAYOUT; + } + + private static final long dtype$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * DLDataType dtype + * } + */ + public static final long dtype$offset() { + return dtype$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * DLDataType dtype + * } + */ + public static MemorySegment dtype(MemorySegment struct) { + return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang = c : * DLDataType dtype + * } + */ + public static void dtype(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java index 8fa3a2730..d2cdd4037 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java @@ -27,7 +27,7 @@ import java.util.function.Consumer; /** - * {@snippet lang=c : + * {@snippet lang = c : * struct { * uintptr_t addr; * DLDataType dtype; @@ -36,153 +36,148 @@ */ public class cuvsCagraIndex { - cuvsCagraIndex() { - // Should not be called directly - } - - private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( - cagra_h.C_LONG.withName("addr"), - DLDataType.layout().withName("dtype"), - MemoryLayout.paddingLayout(4) - ).withName("$anon$175:9"); - - /** - * The layout of this struct - */ - public static final GroupLayout layout() { - return $LAYOUT; - } - - private static final OfLong addr$LAYOUT = (OfLong)$LAYOUT.select(groupElement("addr")); - - /** - * Layout for field: - * {@snippet lang=c : - * uintptr_t addr - * } - */ - public static final OfLong addr$layout() { - return addr$LAYOUT; - } - - private static final long addr$OFFSET = 0; - - /** - * Offset for field: - * {@snippet lang=c : - * uintptr_t addr - * } - */ - public static final long addr$offset() { - return addr$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * uintptr_t addr - * } - */ - public static long addr(MemorySegment struct) { - return struct.get(addr$LAYOUT, addr$OFFSET); - } - - /** - * Setter for field: - * {@snippet lang=c : - * uintptr_t addr - * } - */ - public static void addr(MemorySegment struct, long fieldValue) { - struct.set(addr$LAYOUT, addr$OFFSET, fieldValue); - } - - private static final GroupLayout dtype$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("dtype")); - - /** - * Layout for field: - * {@snippet lang=c : - * DLDataType dtype - * } - */ - public static final GroupLayout dtype$layout() { - return dtype$LAYOUT; - } - - private static final long dtype$OFFSET = 8; - - /** - * Offset for field: - * {@snippet lang=c : - * DLDataType dtype - * } - */ - public static final long dtype$offset() { - return dtype$OFFSET; - } - - /** - * Getter for field: - * {@snippet lang=c : - * DLDataType dtype - * } - */ - public static MemorySegment dtype(MemorySegment struct) { - return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - /** - * Setter for field: - * {@snippet lang=c : - * DLDataType dtype - * } - */ - public static void dtype(MemorySegment struct, MemorySegment fieldValue) { - MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); - } - - /** - * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. - * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} - */ - public static MemorySegment asSlice(MemorySegment array, long index) { - return array.asSlice(layout().byteSize() * index); - } - - /** - * The size (in bytes) of this struct - */ - public static long sizeof() { return layout().byteSize(); } - - /** - * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} - */ - public static MemorySegment allocate(SegmentAllocator allocator) { - return allocator.allocate(layout()); - } - - /** - * Allocate an array of size {@code elementCount} using {@code allocator}. - * The returned segment has size {@code elementCount * layout().byteSize()}. - */ - public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { - return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { - return reinterpret(addr, 1, arena, cleanup); - } - - /** - * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). - * The returned segment has size {@code elementCount * layout().byteSize()} - */ - public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { - return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); - } + cuvsCagraIndex() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(cagra_h.C_LONG.withName("addr"), + DLDataType.layout().withName("dtype"), MemoryLayout.paddingLayout(4)).withName("$anon$175:9"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong addr$LAYOUT = (OfLong) $LAYOUT.select(groupElement("addr")); + + /** + * Layout for field: + * {@snippet lang = c : * uintptr_t addr + * } + */ + public static final OfLong addr$layout() { + return addr$LAYOUT; + } + + private static final long addr$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * uintptr_t addr + * } + */ + public static final long addr$offset() { + return addr$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * uintptr_t addr + * } + */ + public static long addr(MemorySegment struct) { + return struct.get(addr$LAYOUT, addr$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * uintptr_t addr + * } + */ + public static void addr(MemorySegment struct, long fieldValue) { + struct.set(addr$LAYOUT, addr$OFFSET, fieldValue); + } + + private static final GroupLayout dtype$LAYOUT = (GroupLayout) $LAYOUT.select(groupElement("dtype")); + + /** + * Layout for field: + * {@snippet lang = c : * DLDataType dtype + * } + */ + public static final GroupLayout dtype$layout() { + return dtype$LAYOUT; + } + + private static final long dtype$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang = c : * DLDataType dtype + * } + */ + public static final long dtype$offset() { + return dtype$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * DLDataType dtype + * } + */ + public static MemorySegment dtype(MemorySegment struct) { + return struct.asSlice(dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang = c : * DLDataType dtype + * } + */ + public static void dtype(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, dtype$OFFSET, dtype$LAYOUT.byteSize()); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at + * {@code index}. The returned segment has address + * {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { + return layout().byteSize(); + } + + /** + * Allocate a segment of size {@code layout().byteSize()} using + * {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. The + * returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and + * {@code cleanupAction} (if any). The returned segment has size + * {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, + Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } } - diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/BruteForceAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/BruteForceAndSearchTest.java index 00180c633..421cf30c8 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/BruteForceAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/BruteForceAndSearchTest.java @@ -18,10 +18,15 @@ import static org.junit.Assert.assertEquals; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; import java.lang.invoke.MethodHandles; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.UUID; import org.junit.Test; import org.slf4j.Logger; @@ -58,16 +63,24 @@ public void testIndexingAndSearchingFlow() throws Throwable { // Expected search results List> expectedResults = Arrays.asList( - Map.of(3, 0.59198487f, 1, 0.6283694f, 2, 0.77246666f), - Map.of(1, 0.2534914f, 3, 0.33350062f, 2, 0.8748074f), - Map.of(1, 0.4058035f, 3, 0.43066847f, 2, 0.72249544f), - Map.of(3, 0.11946076f, 1, 0.46753132f, 2, 1.0337032f) + Map.of(3, 0.038782537f, 2, 0.35904616f, 0, 0.83774555f), + Map.of(0, 0.12472606f, 2, 0.21700788f, 1, 0.3191862f), + Map.of(3, 0.047766685f, 2, 0.20332813f, 0, 0.48305476f), + Map.of(1, 0.15224183f, 0, 0.5906347f, 3, 0.5986643f) ); for (int j = 0; j < 10; j++) { try (CuVSResources resources = new CuVSResources()) { + // Create a query object with the query vectors + BruteForceQuery cuvsQuery = new BruteForceQuery.Builder() + .withTopK(3) + .withQueryVectors(queries) + .withMapping(map) + .build(); + + // Set index parameters BruteForceIndexParams indexParams = new BruteForceIndexParams.Builder() .withNumWriterThreads(32) .build(); @@ -78,13 +91,24 @@ public void testIndexingAndSearchingFlow() throws Throwable { .withIndexParams(indexParams) .build(); - // Create a query object with the query vectors - BruteForceQuery cuvsQuery = new BruteForceQuery.Builder() - .withTopK(3) - .withQueryVectors(queries) - .withMapping(map) + // Saving the index on to the disk. + String indexFileName = UUID.randomUUID().toString() + ".bf"; + index.serialize(new FileOutputStream(indexFileName)); + + // Loading a BRUTEFORCE index from disk. + File indexFile = new File(indexFileName); + InputStream inputStream = new FileInputStream(indexFile); + BruteForceIndex loadedIndex = new BruteForceIndex.Builder(resources) + .from(inputStream) .build(); + // Perform the search + SearchResults resultsFromLoadedIndex = loadedIndex.search(cuvsQuery); + + // Check results + log.info(resultsFromLoadedIndex.getResults().toString()); + assertEquals(expectedResults, resultsFromLoadedIndex.getResults()); + // Perform the search SearchResults results = index.search(cuvsQuery); @@ -92,7 +116,13 @@ public void testIndexingAndSearchingFlow() throws Throwable { log.info(results.getResults().toString()); assertEquals(expectedResults, results.getResults()); + // Cleanup index.destroyIndex(); + loadedIndex.destroyIndex(); + + if (indexFile.exists()) { + indexFile.delete(); + } } } } diff --git a/java/internal/src/cuvs_java.c b/java/internal/src/cuvs_java.c index ee25ab576..b2924aa40 100644 --- a/java/internal/src/cuvs_java.c +++ b/java/internal/src/cuvs_java.c @@ -231,9 +231,8 @@ cuvsBruteForceIndex_t build_brute_force_index(float *dataset, long rows, long di cuvsError_t index_create_status = cuvsBruteForceIndexCreate(&index); cuvsStreamSync(cuvs_resources); - *return_value = cuvsBruteForceBuild(cuvs_resources, &dataset_tensor, L2Expanded, 0.f, index); + *return_value = cuvsBruteForceBuild(cuvs_resources, &dataset_tensor, L2Expanded, 0.0f, index); - cuvsRMMFree(cuvs_resources, dataset_d, sizeof(float) * rows * dimensions); omp_set_num_threads(1); return index; @@ -302,3 +301,27 @@ void search_brute_force_index(cuvsBruteForceIndex_t index, float *queries, int t cuvsRMMFree(cuvs_resources, distances, sizeof(float) * n_queries * topk); cuvsRMMFree(cuvs_resources, queries_d, sizeof(float) * n_queries * dimensions); } + +/** + * A function to serialize a BRUTEFORCE index + * + * @param cuvs_resources reference of the underlying opaque C handle + * @param index cuvsBruteForceIndex_t reference + * @param return_value return value for cuvsBruteForceSerialize function call + * @param filename the filename of the index file + */ +void serialize_brute_force_index(cuvsResources_t cuvs_resources, cuvsBruteForceIndex_t index, int *return_value, char* filename) { + *return_value = cuvsBruteForceSerialize(cuvs_resources, filename, index); +} + +/** + * A function to de-serialize a BRUTEFORCE index + * + * @param cuvs_resources reference to the underlying opaque C handle + * @param index cuvsBruteForceIndex_t reference + * @param return_value return value for cuvsBruteForceDeserialize function call + * @param filename the filename of the index file + */ +void deserialize_brute_force_index(cuvsResources_t cuvs_resources, cuvsBruteForceIndex_t index, int *return_value, char* filename) { + *return_value = cuvsBruteForceDeserialize(cuvs_resources, filename, index); +} From e3757c0ace4ec733b71a269608ef017abdf3aa33 Mon Sep 17 00:00:00 2001 From: Vivek Narang <123010842+narangvivek10@users.noreply.github.com> Date: Tue, 31 Dec 2024 20:15:43 -0500 Subject: [PATCH 44/53] `metric` parameter addition to the CAGRA index parameters (#10) * code updates for the added index parameter Co-authored-by: Vivek Narang --- .../com/nvidia/cuvs/CagraIndexParams.java | 139 +++- .../cuvs/panama/CuVSCagraIndexParams.java | 54 +- .../java/com/nvidia/cuvs/panama/cagra_h.java | 628 ++++++++++++------ .../com/nvidia/cuvs/panama/distance_h.java | 275 ++++++++ .../nvidia/cuvs/CagraBuildAndSearchTest.java | 2 + 5 files changed, 885 insertions(+), 213 deletions(-) create mode 100644 java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/distance_h.java 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 e194575a9..d4964adcf 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 @@ -28,6 +28,7 @@ public class CagraIndexParams { private final CagraGraphBuildAlgo cuvsCagraGraphBuildAlgo; + private final CuvsDistanceType cuvsDistanceType; private final MemorySegment memorySegment; private CuVSResources resources; private final int intermediateGraphDegree; @@ -62,14 +63,116 @@ private CagraGraphBuildAlgo(int value) { } } + /** + * Enum that denotes how to compute distance. + */ + public enum CuvsDistanceType { + + /** + * evaluate as dist_ij = sum(x_ik^2) + sum(y_ij)^2 - 2*sum(x_ik * y_jk) + */ + L2Expanded(0), + /** + * same as above, but inside the epilogue, perform square root operation + */ + L2SqrtExpanded(1), + /** + * cosine distance + */ + CosineExpanded(2), + /** + * L1 distance * + */ + L1(3), + /** + * evaluate as dist_ij += (x_ik - y-jk)^2 * + */ + L2Unexpanded(4), + /** + * same as above, but inside the epilogue, perform square root operation + */ + L2SqrtUnexpanded(5), + /** + * basic inner product + */ + InnerProduct(6), + /** + * Chebyshev (Linf) distance + */ + Linf(7), + /** + * Canberra distance + */ + Canberra(8), + /** + * Generalized Minkowski distance + */ + LpUnexpanded(9), + /** + * Correlation distance + */ + CorrelationExpanded(10), + /** + * Jaccard distance + */ + JaccardExpanded(11), + /** + * Hellinger distance + */ + HellingerExpanded(12), + /** + * Haversine distance + */ + Haversine(13), + /** + * Bray-Curtis distance + */ + BrayCurtis(14), + /** + * Jensen-Shannon distance + */ + JensenShannon(15), + /** + * Hamming distance + */ + HammingUnexpanded(16), + /** + * KLDivergence + */ + KLDivergence(17), + /** + * RusselRao + */ + RusselRaoExpanded(18), + /** + * Dice-Sorensen distance + */ + DiceExpanded(19), + /** + * Precomputed (special value) + */ + Precomputed(100); + + /** + * The value for the enum choice. + */ + public final int value; + + private CuvsDistanceType(int value) { + this.value = value; + } + + } + private CagraIndexParams(CuVSResources resources, int intermediateGraphDegree, int graphDegree, - CagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter, int writerThreads) { + CagraGraphBuildAlgo CuvsCagraGraphBuildAlgo, int nnDescentNiter, int writerThreads, CuvsDistanceType cuvsDistanceType) { this.resources = resources; this.intermediateGraphDegree = intermediateGraphDegree; this.graphDegree = graphDegree; this.cuvsCagraGraphBuildAlgo = CuvsCagraGraphBuildAlgo; this.nnDescentNiter = nnDescentNiter; this.numWriterThreads = writerThreads; + this.cuvsDistanceType = cuvsDistanceType; this.memorySegment = initMemorySegment(); } @@ -80,6 +183,7 @@ private MemorySegment initMemorySegment() { CuVSCagraIndexParams.graph_degree(indexParamsMemorySegment, graphDegree); CuVSCagraIndexParams.build_algo(indexParamsMemorySegment, cuvsCagraGraphBuildAlgo.value); CuVSCagraIndexParams.nn_descent_niter(indexParamsMemorySegment, nnDescentNiter); + CuVSCagraIndexParams.metric(indexParamsMemorySegment, cuvsDistanceType.value); return indexParamsMemorySegment; } @@ -120,13 +224,13 @@ protected MemorySegment getMemorySegment() { return memorySegment; } - @Override - public String toString() { - return "CagraIndexParams [resources=" + resources + ", intermediateGraphDegree=" + intermediateGraphDegree - + ", graphDegree=" + graphDegree + ", cuvsCagraGraphBuildAlgo=" + cuvsCagraGraphBuildAlgo + ", nnDescentNiter=" - + nnDescentNiter + ", cagraIndexParamsMemorySegment=" + memorySegment + "]"; + /** + * Gets the {@link CuvsDistanceType} used to build the index. + */ + public CuvsDistanceType getCuvsDistanceType() { + return cuvsDistanceType; } - + /** * Gets the number of threads used to build the index. */ @@ -134,6 +238,13 @@ public int getNumWriterThreads() { return numWriterThreads; } + @Override + public String toString() { + return "CagraIndexParams [cuvsCagraGraphBuildAlgo=" + cuvsCagraGraphBuildAlgo + ", cuvsDistanceType=" + + cuvsDistanceType + ", intermediateGraphDegree=" + intermediateGraphDegree + ", graphDegree=" + graphDegree + + ", nnDescentNiter=" + nnDescentNiter + ", numWriterThreads=" + numWriterThreads + "]"; + } + /** * Builder configures and creates an instance of {@link CagraIndexParams}. */ @@ -141,6 +252,7 @@ public static class Builder { private CuVSResources resources; private CagraGraphBuildAlgo cuvsCagraGraphBuildAlgo = CagraGraphBuildAlgo.NN_DESCENT; + private CuvsDistanceType cuvsDistanceType = CuvsDistanceType.L2Expanded; private int intermediateGraphDegree = 128; private int graphDegree = 64; private int nnDescentNumIterations = 20; @@ -183,6 +295,17 @@ public Builder withCagraGraphBuildAlgo(CagraGraphBuildAlgo cuvsCagraGraphBuildAl return this; } + /** + * Sets the metric to use. + * + * @param cuvsDistanceType the {@link CuvsDistanceType} to use + * @return an instance of Builder + */ + public Builder withMetric(CuvsDistanceType cuvsDistanceType) { + this.cuvsDistanceType = cuvsDistanceType; + return this; + } + /** * Sets the Number of Iterations to run if building with * {@link CagraGraphBuildAlgo#NN_DESCENT}. @@ -214,7 +337,7 @@ public Builder withNumWriterThreads(int numWriterThreads) { */ public CagraIndexParams build() { return new CagraIndexParams(resources, intermediateGraphDegree, graphDegree, cuvsCagraGraphBuildAlgo, - nnDescentNumIterations, numWriterThreads); + nnDescentNumIterations, numWriterThreads, cuvsDistanceType); } } } \ No newline at end of file diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java index 72d30e9bb..470d4f684 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java @@ -31,6 +31,7 @@ /** * {@snippet lang = c : * struct cuvsCagraIndexParams { + * cuvsDistanceType metric; * long intermediate_graph_degree; * long graph_degree; * enum cuvsCagraGraphBuildAlgo build_algo; @@ -46,7 +47,8 @@ public class CuVSCagraIndexParams { } private static final GroupLayout $LAYOUT = MemoryLayout - .structLayout(cagra_h.C_LONG.withName("intermediate_graph_degree"), cagra_h.C_LONG.withName("graph_degree"), + .structLayout(cagra_h.C_INT.withName("metric"), MemoryLayout.paddingLayout(4), + cagra_h.C_LONG.withName("intermediate_graph_degree"), cagra_h.C_LONG.withName("graph_degree"), cagra_h.C_INT.withName("build_algo"), MemoryLayout.paddingLayout(4), cagra_h.C_LONG.withName("nn_descent_niter"), cagra_h.C_POINTER.withName("compression")) .withName("cuvsCagraIndexParams"); @@ -58,6 +60,46 @@ public static final GroupLayout layout() { return $LAYOUT; } + private static final OfInt metric$LAYOUT = (OfInt) $LAYOUT.select(groupElement("metric")); + + /** + * Layout for field: + * {@snippet lang = c : * cuvsDistanceType metric + * } + */ + public static final OfInt metric$layout() { + return metric$LAYOUT; + } + + private static final long metric$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang = c : * cuvsDistanceType metric + * } + */ + public static final long metric$offset() { + return metric$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang = c : * cuvsDistanceType metric + * } + */ + public static int metric(MemorySegment struct) { + return struct.get(metric$LAYOUT, metric$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang = c : * cuvsDistanceType metric + * } + */ + public static void metric(MemorySegment struct, int fieldValue) { + struct.set(metric$LAYOUT, metric$OFFSET, fieldValue); + } + private static final OfLong intermediate_graph_degree$LAYOUT = (OfLong) $LAYOUT .select(groupElement("intermediate_graph_degree")); @@ -70,7 +112,7 @@ public static final GroupLayout layout() { return intermediate_graph_degree$LAYOUT; } - private static final long intermediate_graph_degree$OFFSET = 0; + private static final long intermediate_graph_degree$OFFSET = 8; /** * Offset for field: @@ -110,7 +152,7 @@ public static void intermediate_graph_degree(MemorySegment struct, long fieldVal return graph_degree$LAYOUT; } - private static final long graph_degree$OFFSET = 8; + private static final long graph_degree$OFFSET = 16; /** * Offset for field: @@ -150,7 +192,7 @@ public static void graph_degree(MemorySegment struct, long fieldValue) { return build_algo$LAYOUT; } - private static final long build_algo$OFFSET = 16; + private static final long build_algo$OFFSET = 24; /** * Offset for field: @@ -190,7 +232,7 @@ public static void build_algo(MemorySegment struct, int fieldValue) { return nn_descent_niter$LAYOUT; } - private static final long nn_descent_niter$OFFSET = 24; + private static final long nn_descent_niter$OFFSET = 32; /** * Offset for field: @@ -230,7 +272,7 @@ public static void nn_descent_niter(MemorySegment struct, long fieldValue) { return compression$LAYOUT; } - private static final long compression$OFFSET = 32; + private static final long compression$OFFSET = 40; /** * Offset for field: diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java index f01afbfbd..d3ad15f58 100644 --- a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java @@ -90,34 +90,24 @@ 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 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_; - } - - 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; + public static int DLPACK_ABI_VERSION() { + return DLPACK_ABI_VERSION; } private static final int _STDINT_H = (int) 1L; @@ -650,6 +640,246 @@ public static int _BITS_STDINT_UINTN_H() { return _BITS_STDINT_UINTN_H; } + private static final int true_ = (int) 1L; + + /** + * {@snippet lang = c : * #define true 1 + * } + */ + public static int true_() { + return true_; + } + + private static final int false_ = (int) 0L; + + /** + * {@snippet lang = c : * #define false 0 + * } + */ + public static int false_() { + return false_; + } + + private static final int __bool_true_false_are_defined = (int) 1L; + + /** + * {@snippet lang = c : * #define __bool_true_false_are_defined 1 + * } + */ + public static int __bool_true_false_are_defined() { + return __bool_true_false_are_defined; + } + + private static final int L2Expanded = (int) 0L; + + /** + * {@snippet lang = c : * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + + private static final int L2SqrtExpanded = (int) 1L; + + /** + * {@snippet lang = c : * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + + private static final int CosineExpanded = (int) 2L; + + /** + * {@snippet lang = c : * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + + private static final int L1 = (int) 3L; + + /** + * {@snippet lang = c : * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + + private static final int L2Unexpanded = (int) 4L; + + /** + * {@snippet lang = c : * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + + private static final int L2SqrtUnexpanded = (int) 5L; + + /** + * {@snippet lang = c : * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + + private static final int InnerProduct = (int) 6L; + + /** + * {@snippet lang = c : * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + + private static final int Linf = (int) 7L; + + /** + * {@snippet lang = c : * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + + private static final int Canberra = (int) 8L; + + /** + * {@snippet lang = c : * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + + private static final int LpUnexpanded = (int) 9L; + + /** + * {@snippet lang = c : * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + + private static final int CorrelationExpanded = (int) 10L; + + /** + * {@snippet lang = c : * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + + private static final int JaccardExpanded = (int) 11L; + + /** + * {@snippet lang = c : * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + + private static final int HellingerExpanded = (int) 12L; + + /** + * {@snippet lang = c : * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + + private static final int Haversine = (int) 13L; + + /** + * {@snippet lang = c : * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + + private static final int BrayCurtis = (int) 14L; + + /** + * {@snippet lang = c : * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + + private static final int JensenShannon = (int) 15L; + + /** + * {@snippet lang = c : * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + + private static final int HammingUnexpanded = (int) 16L; + + /** + * {@snippet lang = c : * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + + private static final int KLDivergence = (int) 17L; + + /** + * {@snippet lang = c : * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + + private static final int RusselRaoExpanded = (int) 18L; + + /** + * {@snippet lang = c : * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + + private static final int DiceExpanded = (int) 19L; + + /** + * {@snippet lang = c : * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + + private static final int Precomputed = (int) 100L; + + /** + * {@snippet lang = c : * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } + /** * {@snippet lang = c : * typedef unsigned char __u_char * } @@ -1100,302 +1330,287 @@ public static int _BITS_STDINT_UINTN_H() { * } */ public static final OfLong uintmax_t = cagra_h.C_LONG; - private static final int CUVS_ERROR = (int) 0L; + /** + * {@snippet lang = c : * typedef long ptrdiff_t + * } + */ + public static final OfLong ptrdiff_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef unsigned long size_t + * } + */ + public static final OfLong size_t = cagra_h.C_LONG; + /** + * {@snippet lang = c : * typedef int wchar_t + * } + */ + public static final OfInt wchar_t = cagra_h.C_INT; + private static final int kDLCPU = (int) 1L; /** - * {@snippet lang = c : * enum .CUVS_ERROR = 0 + * {@snippet lang = c : * enum .kDLCPU = 1 * } */ - public static int CUVS_ERROR() { - return CUVS_ERROR; + public static int kDLCPU() { + return kDLCPU; } - private static final int CUVS_SUCCESS = (int) 1L; + private static final int kDLCUDA = (int) 2L; /** - * {@snippet lang = c : * enum .CUVS_SUCCESS = 1 + * {@snippet lang = c : * enum .kDLCUDA = 2 * } */ - public static int CUVS_SUCCESS() { - return CUVS_SUCCESS; + public static int kDLCUDA() { + return kDLCUDA; } - private static final int AUTO_SELECT = (int) 0L; + private static final int kDLCUDAHost = (int) 3L; /** - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 + * {@snippet lang = c : * enum .kDLCUDAHost = 3 * } */ - public static int AUTO_SELECT() { - return AUTO_SELECT; + public static int kDLCUDAHost() { + return kDLCUDAHost; } - private static final int IVF_PQ = (int) 1L; + private static final int kDLOpenCL = (int) 4L; /** - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 + * {@snippet lang = c : * enum .kDLOpenCL = 4 * } */ - public static int IVF_PQ() { - return IVF_PQ; + public static int kDLOpenCL() { + return kDLOpenCL; } - private static final int NN_DESCENT = (int) 2L; + private static final int kDLVulkan = (int) 7L; /** - * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 + * {@snippet lang = c : * enum .kDLVulkan = 7 * } */ - public static int NN_DESCENT() { - return NN_DESCENT; + public static int kDLVulkan() { + return kDLVulkan; } + private static final int kDLMetal = (int) 8L; + /** - * {@snippet lang = c : - * typedef struct cuvsCagraCompressionParams { - * uint32_t pq_bits; - * uint32_t pq_dim; - * uint32_t vq_n_centers; - * uint32_t kmeans_n_iters; - * double vq_kmeans_trainset_fraction; - * double pq_kmeans_trainset_fraction; - * } *cuvsCagraCompressionParams_t + * {@snippet lang = c : * enum .kDLMetal = 8 * } */ - public static final AddressLayout cuvsCagraCompressionParams_t = cagra_h.C_POINTER; + public static int kDLMetal() { + return kDLMetal; + } + + private static final int kDLVPI = (int) 9L; + /** - * {@snippet lang = c : - * typedef struct cuvsCagraIndexParams { - * unsigned int intermediate_graph_degree; - * unsigned int graph_degree; - * enum cuvsCagraGraphBuildAlgo build_algo; - * unsigned int nn_descent_niter; - * cuvsCagraCompressionParams_t compression; - * } *cuvsCagraIndexParams_t + * {@snippet lang = c : * enum .kDLVPI = 9 * } */ - public static final AddressLayout cuvsCagraIndexParams_t = cagra_h.C_POINTER; - - private static class cuvsCagraIndexParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); - - public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraIndexParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + public static int kDLVPI() { + return kDLVPI; } + private static final int kDLROCM = (int) 10L; + /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * {@snippet lang = c : * enum .kDLROCM = 10 * } */ - public static FunctionDescriptor cuvsCagraIndexParamsCreate$descriptor() { - return cuvsCagraIndexParamsCreate.DESC; + public static int kDLROCM() { + return kDLROCM; } + private static final int kDLROCMHost = (int) 11L; + /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * {@snippet lang = c : * enum .kDLROCMHost = 11 * } */ - public static MethodHandle cuvsCagraIndexParamsCreate$handle() { - return cuvsCagraIndexParamsCreate.HANDLE; + public static int kDLROCMHost() { + return kDLROCMHost; } + private static final int kDLExtDev = (int) 12L; + /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * {@snippet lang = c : * enum .kDLExtDev = 12 * } */ - public static MemorySegment cuvsCagraIndexParamsCreate$address() { - return cuvsCagraIndexParamsCreate.ADDR; + public static int kDLExtDev() { + return kDLExtDev; } + private static final int kDLCUDAManaged = (int) 13L; + /** - * {@snippet lang = c - * : * cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t *params) + * {@snippet lang = c : * enum .kDLCUDAManaged = 13 * } */ - public static int cuvsCagraIndexParamsCreate(MemorySegment params) { - var mh$ = cuvsCagraIndexParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsCagraIndexParamsCreate", params); - } - return (int) mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } + public static int kDLCUDAManaged() { + return kDLCUDAManaged; } - private static class cuvsCagraIndexParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); - - public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraIndexParamsDestroy"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int kDLOneAPI = (int) 14L; /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * {@snippet lang = c : * enum .kDLOneAPI = 14 * } */ - public static FunctionDescriptor cuvsCagraIndexParamsDestroy$descriptor() { - return cuvsCagraIndexParamsDestroy.DESC; + public static int kDLOneAPI() { + return kDLOneAPI; } + private static final int kDLWebGPU = (int) 15L; + /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * {@snippet lang = c : * enum .kDLWebGPU = 15 * } */ - public static MethodHandle cuvsCagraIndexParamsDestroy$handle() { - return cuvsCagraIndexParamsDestroy.HANDLE; + public static int kDLWebGPU() { + return kDLWebGPU; } + private static final int kDLHexagon = (int) 16L; + /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * {@snippet lang = c : * enum .kDLHexagon = 16 * } */ - public static MemorySegment cuvsCagraIndexParamsDestroy$address() { - return cuvsCagraIndexParamsDestroy.ADDR; + public static int kDLHexagon() { + return kDLHexagon; } + private static final int kDLInt = (int) 0L; + /** - * {@snippet lang = c - * : * cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) + * {@snippet lang = c : * enum .kDLInt = 0 * } */ - public static int cuvsCagraIndexParamsDestroy(MemorySegment params) { - var mh$ = cuvsCagraIndexParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsCagraIndexParamsDestroy", params); - } - return (int) mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } + public static int kDLInt() { + return kDLInt; } - private static class cuvsCagraCompressionParamsCreate { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); - - public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraCompressionParamsCreate"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } + private static final int kDLUInt = (int) 1L; /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * {@snippet lang = c : * enum .kDLUInt = 1 * } */ - public static FunctionDescriptor cuvsCagraCompressionParamsCreate$descriptor() { - return cuvsCagraCompressionParamsCreate.DESC; + public static int kDLUInt() { + return kDLUInt; } + private static final int kDLFloat = (int) 2L; + /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * {@snippet lang = c : * enum .kDLFloat = 2 * } */ - public static MethodHandle cuvsCagraCompressionParamsCreate$handle() { - return cuvsCagraCompressionParamsCreate.HANDLE; + public static int kDLFloat() { + return kDLFloat; } + private static final int kDLOpaqueHandle = (int) 3L; + /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * {@snippet lang = c : * enum .kDLOpaqueHandle = 3 * } */ - public static MemorySegment cuvsCagraCompressionParamsCreate$address() { - return cuvsCagraCompressionParamsCreate.ADDR; + public static int kDLOpaqueHandle() { + return kDLOpaqueHandle; } + private static final int kDLBfloat = (int) 4L; + /** - * {@snippet lang = c - * : * cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t *params) + * {@snippet lang = c : * enum .kDLBfloat = 4 * } */ - public static int cuvsCagraCompressionParamsCreate(MemorySegment params) { - var mh$ = cuvsCagraCompressionParamsCreate.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsCagraCompressionParamsCreate", params); - } - return (int) mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } + public static int kDLBfloat() { + return kDLBfloat; } - private static class cuvsCagraCompressionParamsDestroy { - public static final FunctionDescriptor DESC = FunctionDescriptor.of(cagra_h.C_INT, cagra_h.C_POINTER); - - public static final MemorySegment ADDR = cagra_h.findOrThrow("cuvsCagraCompressionParamsDestroy"); + private static final int kDLComplex = (int) 5L; - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + /** + * {@snippet lang = c : * enum .kDLComplex = 5 + * } + */ + public static int kDLComplex() { + return kDLComplex; } + private static final int kDLBool = (int) 6L; + /** - * Function descriptor for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * {@snippet lang = c : * enum .kDLBool = 6 * } */ - public static FunctionDescriptor cuvsCagraCompressionParamsDestroy$descriptor() { - return cuvsCagraCompressionParamsDestroy.DESC; + public static int kDLBool() { + return kDLBool; } + private static final int AUTO_SELECT = (int) 0L; + /** - * Downcall method handle for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.AUTO_SELECT = 0 * } */ - public static MethodHandle cuvsCagraCompressionParamsDestroy$handle() { - return cuvsCagraCompressionParamsDestroy.HANDLE; + public static int AUTO_SELECT() { + return AUTO_SELECT; } + private static final int IVF_PQ = (int) 1L; + /** - * Address for: - * {@snippet lang = c - * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.IVF_PQ = 1 * } */ - public static MemorySegment cuvsCagraCompressionParamsDestroy$address() { - return cuvsCagraCompressionParamsDestroy.ADDR; + public static int IVF_PQ() { + return IVF_PQ; } + private static final int NN_DESCENT = (int) 2L; + /** - * {@snippet lang = c - * : * cuvsError_t cuvsCagraCompressionParamsDestroy(cuvsCagraCompressionParams_t params) + * {@snippet lang = c : * enum cuvsCagraGraphBuildAlgo.NN_DESCENT = 2 * } */ - public static int cuvsCagraCompressionParamsDestroy(MemorySegment params) { - var mh$ = cuvsCagraCompressionParamsDestroy.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("cuvsCagraCompressionParamsDestroy", params); - } - return (int) mh$.invokeExact(params); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } + public static int NN_DESCENT() { + return NN_DESCENT; } + /** + * {@snippet lang = c : + * typedef struct cuvsCagraCompressionParams { + * uint32_t pq_bits; + * uint32_t pq_dim; + * uint32_t vq_n_centers; + * uint32_t kmeans_n_iters; + * double vq_kmeans_trainset_fraction; + * double pq_kmeans_trainset_fraction; + * } *cuvsCagraCompressionParams_t + * } + */ + public static final AddressLayout cuvsCagraCompressionParams_t = cagra_h.C_POINTER; + /** + * {@snippet lang = c : + * typedef struct cuvsCagraIndexParams { + * cuvsDistanceType metric; + * long intermediate_graph_degree; + * long graph_degree; + * enum cuvsCagraGraphBuildAlgo build_algo; + * long nn_descent_niter; + * cuvsCagraCompressionParams_t compression; + * } *cuvsCagraIndexParams_t + * } + */ + public static final AddressLayout cuvsCagraIndexParams_t = cagra_h.C_POINTER; private static final int SINGLE_CTA = (int) 0L; /** @@ -1469,16 +1684,16 @@ public static int AUTO_HASH() { /** * {@snippet lang = c : * typedef struct cuvsCagraSearchParams { - * unsigned int max_queries; - * unsigned int itopk_size; - * unsigned int max_iterations; + * long max_queries; + * long itopk_size; + * long max_iterations; * enum cuvsCagraSearchAlgo algo; - * unsigned int team_size; - * unsigned int search_width; - * unsigned int min_iterations; - * unsigned int thread_block_size; + * long team_size; + * long search_width; + * long min_iterations; + * long thread_block_size; * enum cuvsCagraHashMode hashmap_mode; - * unsigned int hashmap_min_bitlen; + * long hashmap_min_bitlen; * float hashmap_max_fill_rate; * uint32_t num_random_samplings; * uint64_t rand_xor_mask; @@ -1486,6 +1701,11 @@ public static int AUTO_HASH() { * } */ public static final AddressLayout cuvsCagraSearchParams_t = cagra_h.C_POINTER; + /** + * {@snippet lang = c : * typedef cuvsCagraIndex *cuvsCagraIndex_t + * } + */ + public static final AddressLayout cuvsCagraIndex_t = cagra_h.C_POINTER; private static final long _POSIX_C_SOURCE = 200809L; /** @@ -2065,4 +2285,14 @@ public static int WINT_MIN() { public static int WINT_MAX() { return WINT_MAX; } + + private static final MemorySegment NULL = MemorySegment.ofAddress(0L); + + /** + * {@snippet lang = c : * #define NULL (void*) 0 + * } + */ + public static MemorySegment NULL() { + return NULL; + } } diff --git a/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/distance_h.java b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/distance_h.java new file mode 100644 index 000000000..455ab0aba --- /dev/null +++ b/java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/distance_h.java @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2024, 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.panama; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +public class distance_h { + + distance_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MemorySegment findOrThrow(String symbol) { + return SYMBOL_LOOKUP.find(symbol) + .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol)); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; + public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; + public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; + public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; + public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; + public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; + public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; + public static final AddressLayout C_POINTER = ValueLayout.ADDRESS + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); + public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; + private static final int L2Expanded = (int)0L; + /** + * {@snippet lang=c : + * enum .L2Expanded = 0 + * } + */ + public static int L2Expanded() { + return L2Expanded; + } + private static final int L2SqrtExpanded = (int)1L; + /** + * {@snippet lang=c : + * enum .L2SqrtExpanded = 1 + * } + */ + public static int L2SqrtExpanded() { + return L2SqrtExpanded; + } + private static final int CosineExpanded = (int)2L; + /** + * {@snippet lang=c : + * enum .CosineExpanded = 2 + * } + */ + public static int CosineExpanded() { + return CosineExpanded; + } + private static final int L1 = (int)3L; + /** + * {@snippet lang=c : + * enum .L1 = 3 + * } + */ + public static int L1() { + return L1; + } + private static final int L2Unexpanded = (int)4L; + /** + * {@snippet lang=c : + * enum .L2Unexpanded = 4 + * } + */ + public static int L2Unexpanded() { + return L2Unexpanded; + } + private static final int L2SqrtUnexpanded = (int)5L; + /** + * {@snippet lang=c : + * enum .L2SqrtUnexpanded = 5 + * } + */ + public static int L2SqrtUnexpanded() { + return L2SqrtUnexpanded; + } + private static final int InnerProduct = (int)6L; + /** + * {@snippet lang=c : + * enum .InnerProduct = 6 + * } + */ + public static int InnerProduct() { + return InnerProduct; + } + private static final int Linf = (int)7L; + /** + * {@snippet lang=c : + * enum .Linf = 7 + * } + */ + public static int Linf() { + return Linf; + } + private static final int Canberra = (int)8L; + /** + * {@snippet lang=c : + * enum .Canberra = 8 + * } + */ + public static int Canberra() { + return Canberra; + } + private static final int LpUnexpanded = (int)9L; + /** + * {@snippet lang=c : + * enum .LpUnexpanded = 9 + * } + */ + public static int LpUnexpanded() { + return LpUnexpanded; + } + private static final int CorrelationExpanded = (int)10L; + /** + * {@snippet lang=c : + * enum .CorrelationExpanded = 10 + * } + */ + public static int CorrelationExpanded() { + return CorrelationExpanded; + } + private static final int JaccardExpanded = (int)11L; + /** + * {@snippet lang=c : + * enum .JaccardExpanded = 11 + * } + */ + public static int JaccardExpanded() { + return JaccardExpanded; + } + private static final int HellingerExpanded = (int)12L; + /** + * {@snippet lang=c : + * enum .HellingerExpanded = 12 + * } + */ + public static int HellingerExpanded() { + return HellingerExpanded; + } + private static final int Haversine = (int)13L; + /** + * {@snippet lang=c : + * enum .Haversine = 13 + * } + */ + public static int Haversine() { + return Haversine; + } + private static final int BrayCurtis = (int)14L; + /** + * {@snippet lang=c : + * enum .BrayCurtis = 14 + * } + */ + public static int BrayCurtis() { + return BrayCurtis; + } + private static final int JensenShannon = (int)15L; + /** + * {@snippet lang=c : + * enum .JensenShannon = 15 + * } + */ + public static int JensenShannon() { + return JensenShannon; + } + private static final int HammingUnexpanded = (int)16L; + /** + * {@snippet lang=c : + * enum .HammingUnexpanded = 16 + * } + */ + public static int HammingUnexpanded() { + return HammingUnexpanded; + } + private static final int KLDivergence = (int)17L; + /** + * {@snippet lang=c : + * enum .KLDivergence = 17 + * } + */ + public static int KLDivergence() { + return KLDivergence; + } + private static final int RusselRaoExpanded = (int)18L; + /** + * {@snippet lang=c : + * enum .RusselRaoExpanded = 18 + * } + */ + public static int RusselRaoExpanded() { + return RusselRaoExpanded; + } + private static final int DiceExpanded = (int)19L; + /** + * {@snippet lang=c : + * enum .DiceExpanded = 19 + * } + */ + public static int DiceExpanded() { + return DiceExpanded; + } + private static final int Precomputed = (int)100L; + /** + * {@snippet lang=c : + * enum .Precomputed = 100 + * } + */ + public static int Precomputed() { + return Precomputed; + } +} + diff --git a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java index 47e42f2a5..fe89d63e2 100644 --- a/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java +++ b/java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java @@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory; import com.nvidia.cuvs.CagraIndexParams.CagraGraphBuildAlgo; +import com.nvidia.cuvs.CagraIndexParams.CuvsDistanceType; import com.nvidia.cuvs.common.SearchResults; public class CagraBuildAndSearchTest { @@ -79,6 +80,7 @@ public void testIndexingAndSearchingFlow() throws Throwable { .withGraphDegree(1) .withIntermediateGraphDegree(2) .withNumWriterThreads(32) + .withMetric(CuvsDistanceType.L2Expanded) .build(); // Create the index with the dataset From 0aa26653f086e195aa2e86baf1a4475b6b60af1c Mon Sep 17 00:00:00 2001 From: Vivek Narang <123010842+narangvivek10@users.noreply.github.com> Date: Wed, 1 Jan 2025 00:14:34 -0500 Subject: [PATCH 45/53] update year Co-authored-by: Vivek Narang --- java/cuvs-java/pom.xml | 2 +- .../src/main/java/com/nvidia/cuvs/BruteForceIndex.java | 2 +- .../src/main/java/com/nvidia/cuvs/BruteForceIndexParams.java | 2 +- .../src/main/java/com/nvidia/cuvs/BruteForceQuery.java | 2 +- .../src/main/java/com/nvidia/cuvs/BruteForceSearchResults.java | 2 +- .../src/main/java/com/nvidia/cuvs/CagraCompressionParams.java | 2 +- java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java | 2 +- .../src/main/java/com/nvidia/cuvs/CagraIndexParams.java | 2 +- java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraQuery.java | 2 +- .../src/main/java/com/nvidia/cuvs/CagraSearchParams.java | 2 +- .../src/main/java/com/nvidia/cuvs/CagraSearchResults.java | 2 +- java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java | 2 +- java/cuvs-java/src/main/java/com/nvidia/cuvs/common/Util.java | 2 +- .../main/java/com/nvidia/cuvs/panama/CuVSCagraIndexParams.java | 2 +- .../java/com/nvidia/cuvs/panama/CuvsCagraCompressionParams.java | 2 +- .../main/java/com/nvidia/cuvs/panama/CuvsCagraSearchParams.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/DLDataType.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/DLDevice.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/DLManagedTensor.java | 2 +- .../java/com/nvidia/cuvs/panama/DLManagedTensorVersioned.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/DLPackVersion.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/DLTensor.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/__fsid_t.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/brute_force_h.java | 2 +- .../cuvs-java/src/main/java/com/nvidia/cuvs/panama/cagra_h.java | 2 +- .../main/java/com/nvidia/cuvs/panama/cuvsBruteForceIndex.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/cuvsCagraIndex.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/cuvsFilter.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/distance_h.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/dlpack_h.java | 2 +- java/cuvs-java/src/main/java/com/nvidia/cuvs/panama/hnsw_h.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/ivf_flat_h.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/ivf_pq_h.java | 2 +- .../src/main/java/com/nvidia/cuvs/panama/max_align_t.java | 2 +- .../src/test/java/com/nvidia/cuvs/BruteForceAndSearchTest.java | 2 +- .../src/test/java/com/nvidia/cuvs/CagraBuildAndSearchTest.java | 2 +- java/internal/CMakeLists.txt | 2 +- java/internal/src/cuvs_java.c | 2 +- 38 files changed, 38 insertions(+), 38 deletions(-) diff --git a/java/cuvs-java/pom.xml b/java/cuvs-java/pom.xml index 9ac634dfb..67c91543e 100644 --- a/java/cuvs-java/pom.xml +++ b/java/cuvs-java/pom.xml @@ -1,6 +1,6 @@