Skip to navigation

CuVSResources

View as Markdown

Java package: com.nvidia.cuvs

public interface CuVSResources extends AutoCloseable

Used for allocating resources for cuVS

Public Members

handle

long handle()

Gets the opaque CuVSResources handle, to be used whenever we need to pass a cuvsResources_t parameter

Returns

the CuVSResources handle

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:26

access

ScopedAccess access()

Gets scoped access to the native resources object. The native resource object is not thread safe: only a single thread at every time should access concurrently the same native resources. Calling this method from multiple thread is OK, but the returned ScopedAccess object must be closed before calling access() again from a different thread.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:39

deviceId

int deviceId()

Get the logical id of the device associated with this resources object. Information about the device id is immutable, so it is safe to expose it without getting ScopedAccess to the enclosing resources.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:46

close

@Override void close()

Closes this CuVSResources object and releases any resources associated with it.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:51

tempDirectory

Path tempDirectory()

The temporary directory to use for intermediate operations. Defaults to java.io.tmpdir.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:58

setWorkspacePool

void setWorkspacePool(long initialSizeBytes)

Configure the temporary workspace on this resources object as an uncapped pool backed by the current device memory resource. After the initial reservation is allocated on first use, subsequent calls to cuvsRMMAlloc / cuvsRMMFree on this handle hit the pool cache rather than calling cudaMallocAsync / cudaFreeAsync, reducing CUDA context lock contention under concurrent query threads. The pool grows without shrinking: freed allocations are returned to the pool rather than to the device, so the pool’s high-water mark only increases until the resources object is closed.

The pool is per-resources-handle (i.e. per query thread when resources are thread-local), so there is no cross-thread pool mutex contention. Call this once after creating the resources object; calling it again replaces the pool.

Parameters

NameDescription
initialSizeBytesinitial pool reservation in bytes; must be > 0. Size initialSizeBytes to cover the steady-state working set to avoid growth after warmup

Throws

TypeDescription
IllegalArgumentExceptionif initialSizeBytes is not greater than 0

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:78

create

static CuVSResources create() throws Throwable

Creates a new resources. Equivalent to create(CuVSProvider.tempDirectory())

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:87

create

static CuVSResources create(Path tempDirectory) throws Throwable

Creates a new resources.

Parameters

NameDescription
tempDirectorythe temporary directory to use for intermediate operations

Throws

TypeDescription
UnsupportedOperationExceptionif the provider does not cuvs
LibraryExceptionif the native library cannot be loaded

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:98

create

static CuVSResources create( Path tempDirectory, Path memoryTrackingCsvPath, Duration memoryTrackingSampleInterval) throws Throwable

Creates a new resources whose memory allocations are tracked and written as CSV samples from a background thread.

The returned handle wraps all reachable memory resources (host, pinned, managed, device, workspace, large_workspace) with allocation-tracking adaptors and replaces the global host and device memory resources for the lifetime of the handle. It is otherwise indistinguishable from a handle created by #create(Path) and can be used wherever a CuVSResources is accepted. The CSV reporter is stopped and the global memory resources are restored when the handle is closed.

Parameters

NameDescription
tempDirectorythe temporary directory to use for intermediate operations
memoryTrackingCsvPathpath to the output CSV file (created/truncated)
memoryTrackingSampleIntervalminimum interval between successive CSV samples

Throws

TypeDescription
UnsupportedOperationExceptionif the provider does not support cuvs
LibraryExceptionif the native library cannot be loaded

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:123

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java:16