Native API and device interchange#

Use the public headers and Rust exports as the declaration and signature authority. The C ABI version is 12. The interfaces below share the execution and ownership contracts on this page.

Operation

C

C++

Rust

CRS construction, preparation and metadata

crs.h: create and prepare, identify, inspect, compare, export and release. cugeo_proj_crs_is_geographic writes 0 or 1, initializes a supplied output to 0 on failure, and rejects a null handle or output

The umbrella header exposes the owning interfaces

Crs, CrsRuntime, CrsInfo, CrsFamily, AxisInfo, AuthorityMatch, WktVersion, PreparationInfo, PreparationOptions

Selection, records and execution

resolution.h: create or load a resolution record, explain, inspect axes, dimensions and executor, derive plans, and create forward or inverse host transforms. Prepare and execute typed CUDA routes

transform.hpp: owning and borrowed resolution, plan, prepared transform, workspace and execution wrappers

resolve, candidates, Resolution, ResolutionRequest, HostTransform, Plan, Direction, Explain, RowStatus, RowFailure

Buffers and CUDA resources

proj.h: device resources, preparation, workspaces, bindings and execution

buffers.hpp, cuda.hpp, and cuda_driver.hpp

Buffer, BufferMut, Validity, ValidityMut

Arrow device interchange

arrow.h

arrow.hpp: retained arrow_binding

—

Projected frames, geocentric, Helmert and local ENU

frame.h, geocentric.h, helmert.h, local_frame.h

frame.hpp, geocentric.hpp, helmert.hpp, local_frame.hpp

Wgs84EnuAnchor, Wgs84EnuFrame, Helmert parameter and rate types

UTM and convergence

convergence.h: host and CUDA convergence

Shared C semantics

utm_forward, utm_inverse, utm_convergence, UtmProfile

Grids, routes, candidates, pins, epochs and records

resolution.h

Resolution and plan wrappers

Grid, route, choice, candidate, pin, epoch, record, rejection and capability exports in lib.rs

Experimental device exports

device_utm_experimental.h: fixed single-stage WGS84 UTM. device_route_experimental.h: leased prepared-route view

—

The experimental-plan-export feature exposes an unstable, nondefault wire plan and geocentric helpers in lib.rs.

The linked owning headers contain the complete declarations, C++ members and defaults. The Rust pub use surface also includes operation stages and steps, grid geometry and digests, database identity, instantiated CRSs, record differences, rejections and capability registry entries. Use those declarations for exact types and signatures.

CRS string exports use a sizing call so the caller can allocate the required storage. CRS preparation can admit caller-retained storage. Serialize calls that share a CRS value. Equality preserves declared axis order, and export formats have different semantic-loss boundaries. See Coordinate systems and operation selection. For the meaning of a numeric batch or row code, see Errors and per-point statuses.

Which resources does enqueue borrow?#

Stage

Resources and obligations

Plan

Create or derive the selected plan. Keep borrowed owners alive for any borrowed views.

Prepare

Prepare on the required CUDA context and stream with a device resource. Retain caller-owned preparation storage for its documented lifetime. Preparation can allocate. Enqueue does not.

Size and create workspace

Size for the intended maximum row count and create on the compatible context and stream. A workspace is exclusive to one live execution.

Bind

Supply typed 2D or 3D input and output buffers, counts and strides, validity bitmaps, and any status and cause storage. Observe the descriptor extents and mutable alias restrictions in proj.h. Device allocations require CUGEO_PROJ_DEVICE_ALIGNMENT, 256 bytes.

Enqueue

Keep the prepared transform, workspace, buffers, bindings and their owners live through completion. Native enqueue allocates nothing and transfers no coordinates. Use a compatible caller stream and context. Follow the capture conditions in the declaration for the selected route.

Query or wait

The execution owns workspace occupancy until completion and release. Observe asynchronous errors before consuming outputs. During capture, retain the execution and its borrowed resources as required by the header.

Release

Release the execution, including a non-NULL cleanup handle returned on failure, before reusing the workspace or borrowed resources. Release owning handles according to their lifetime dependencies.

Keep these quantities distinct. The host preparation capacity is the admission budget. Caller-retained storage is memory supplied and kept by the caller. Requested device bytes describe the exact retained payload requested by the prepared object or workspace. Allocator reservation is a separate, potentially larger footprint. Requested bytes do not measure the allocator’s reservation.

C++ owning wrappers release their handles. Borrowed references and borrowed_execution do not replace the caller’s lifetime obligations. cuda_context_ref and cuda_stream_ref borrow native handles. When cuda.h is visible, context_ref(CUcontext) and stream_ref(CUstream) adapt driver handles. A device-resource callback lease extends allocator lifetime across prepared execution. Typed frame and geocentric wrappers follow their respective owned or borrowed lifecycles. Helmert provides both managed and borrowed completion through managed_helmert_execution, helmert_execution, and cuda_event_ref. Consult their owning header for the chosen mode.

Output validity padding#

CUDA updates a partially written output validity byte through its aligned 4-byte word. The entire word must fit in the bitmap extent or enqueue returns a buffer error. Use a bitmap padded to whole words. Slices aligned at both ends to byte boundaries and host or input bitmaps need no additional padding.

Arrow Device bindings use the CUDA allocation’s extent. Python allocates its output bitmaps with the required padding.

Who releases the Arrow arrays and schemas?#

Coordinates use a nullable struct with exactly two nonnullable float64 children. Status uses uint8. On successful binding, the input, output and status array roots and their three schemas move into the binding. All six client release callbacks are cleared, and releasing the binding invokes each callback once. The C++ arrow_binding retains shared binding state for this ownership and completion contract. See arrow.h and the runtime test.

The caller stream must wait on the input synchronization event, including when the input was produced on another stream. Keep the location, prepared transform, workspace, buffers and binding live through completion. In the checked cross-stream case, an empty event handle returns CUGEO_PROJ_CUDA_ERROR with no execution. A same-thread retry with the valid event succeeds: EPSG:4326 to EPSG:32631 at the central meridian produces 500000 m easting and OK status.

Specialist operations and host metadata#

Projected frame plans compose projected-frame stages and use the shared device-resource and execution lifecycle. Geocentric interfaces provide typed host and CUDA conversion in the declared direction, including height promotion. Helmert interfaces distinguish 7- and 15-parameter conventions and epoch modes. Select profile IDs from the registry. WGS84 local ENU helpers prepare an anchor from longitude, latitude and height and convert in the requested local or ECEF direction. Use the linked headers for parameter conventions, direction and units.

UTM meridian convergence is a separate C host/CUDA and Rust scalar operation. It accepts zones 1–60, hemisphere 0 or 1, longitude in [−180°, 180°] and latitude in [−80°, 84°]. The result uses the [−180°, 180°] angle branch and is NaN on failure. The checked tolerance against PROJ factors is 1e−7°. CUDA requires a single prepared WGS84 UTM stage and a caller-owned nondefault stream. Graph capture is admitted.

Rectangle continuity#

cugeo_proj_host_transform_certify_rectangle is a host metadata query over the selected executor’s input axes and units. It certifies continuity across a closed rectangle for admitted noop, regular WGS84 UTM or spherical Web Mercator stages and supported surrounding axis and unit steps. An inverse handle reuses the same selection. The query produces no envelope or transformed rows and performs no GPU work. It returns INVALID_ARGUMENT for 3D or malformed bounds and UNSUPPORTED for an unknown domain or per-row selection. See resolution.h.

The experimental fixed UTM export carries direction, coefficients and arithmetic version for a single WGS84 UTM stage. The experimental route view requires a lease to retain the prepared route identity and steps. Neither is a promise of the regular execution interface.