warp-lang 1.10.0__py3-none-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of warp-lang might be problematic. Click here for more details.
- warp/__init__.py +334 -0
- warp/__init__.pyi +5856 -0
- warp/_src/__init__.py +14 -0
- warp/_src/autograd.py +1077 -0
- warp/_src/build.py +620 -0
- warp/_src/build_dll.py +642 -0
- warp/_src/builtins.py +10555 -0
- warp/_src/codegen.py +4361 -0
- warp/_src/config.py +178 -0
- warp/_src/constants.py +59 -0
- warp/_src/context.py +8352 -0
- warp/_src/dlpack.py +464 -0
- warp/_src/fabric.py +362 -0
- warp/_src/fem/__init__.py +14 -0
- warp/_src/fem/adaptivity.py +510 -0
- warp/_src/fem/cache.py +689 -0
- warp/_src/fem/dirichlet.py +190 -0
- warp/_src/fem/domain.py +553 -0
- warp/_src/fem/field/__init__.py +131 -0
- warp/_src/fem/field/field.py +703 -0
- warp/_src/fem/field/nodal_field.py +403 -0
- warp/_src/fem/field/restriction.py +39 -0
- warp/_src/fem/field/virtual.py +1021 -0
- warp/_src/fem/geometry/__init__.py +32 -0
- warp/_src/fem/geometry/adaptive_nanogrid.py +782 -0
- warp/_src/fem/geometry/closest_point.py +99 -0
- warp/_src/fem/geometry/deformed_geometry.py +277 -0
- warp/_src/fem/geometry/element.py +854 -0
- warp/_src/fem/geometry/geometry.py +693 -0
- warp/_src/fem/geometry/grid_2d.py +478 -0
- warp/_src/fem/geometry/grid_3d.py +539 -0
- warp/_src/fem/geometry/hexmesh.py +956 -0
- warp/_src/fem/geometry/nanogrid.py +660 -0
- warp/_src/fem/geometry/partition.py +483 -0
- warp/_src/fem/geometry/quadmesh.py +597 -0
- warp/_src/fem/geometry/tetmesh.py +762 -0
- warp/_src/fem/geometry/trimesh.py +588 -0
- warp/_src/fem/integrate.py +2507 -0
- warp/_src/fem/linalg.py +385 -0
- warp/_src/fem/operator.py +398 -0
- warp/_src/fem/polynomial.py +231 -0
- warp/_src/fem/quadrature/__init__.py +17 -0
- warp/_src/fem/quadrature/pic_quadrature.py +318 -0
- warp/_src/fem/quadrature/quadrature.py +665 -0
- warp/_src/fem/space/__init__.py +248 -0
- warp/_src/fem/space/basis_function_space.py +499 -0
- warp/_src/fem/space/basis_space.py +681 -0
- warp/_src/fem/space/dof_mapper.py +253 -0
- warp/_src/fem/space/function_space.py +312 -0
- warp/_src/fem/space/grid_2d_function_space.py +179 -0
- warp/_src/fem/space/grid_3d_function_space.py +229 -0
- warp/_src/fem/space/hexmesh_function_space.py +255 -0
- warp/_src/fem/space/nanogrid_function_space.py +199 -0
- warp/_src/fem/space/partition.py +435 -0
- warp/_src/fem/space/quadmesh_function_space.py +222 -0
- warp/_src/fem/space/restriction.py +221 -0
- warp/_src/fem/space/shape/__init__.py +152 -0
- warp/_src/fem/space/shape/cube_shape_function.py +1107 -0
- warp/_src/fem/space/shape/shape_function.py +134 -0
- warp/_src/fem/space/shape/square_shape_function.py +928 -0
- warp/_src/fem/space/shape/tet_shape_function.py +829 -0
- warp/_src/fem/space/shape/triangle_shape_function.py +674 -0
- warp/_src/fem/space/tetmesh_function_space.py +270 -0
- warp/_src/fem/space/topology.py +461 -0
- warp/_src/fem/space/trimesh_function_space.py +193 -0
- warp/_src/fem/types.py +114 -0
- warp/_src/fem/utils.py +488 -0
- warp/_src/jax.py +188 -0
- warp/_src/jax_experimental/__init__.py +14 -0
- warp/_src/jax_experimental/custom_call.py +389 -0
- warp/_src/jax_experimental/ffi.py +1286 -0
- warp/_src/jax_experimental/xla_ffi.py +658 -0
- warp/_src/marching_cubes.py +710 -0
- warp/_src/math.py +416 -0
- warp/_src/optim/__init__.py +14 -0
- warp/_src/optim/adam.py +165 -0
- warp/_src/optim/linear.py +1608 -0
- warp/_src/optim/sgd.py +114 -0
- warp/_src/paddle.py +408 -0
- warp/_src/render/__init__.py +14 -0
- warp/_src/render/imgui_manager.py +291 -0
- warp/_src/render/render_opengl.py +3638 -0
- warp/_src/render/render_usd.py +939 -0
- warp/_src/render/utils.py +162 -0
- warp/_src/sparse.py +2718 -0
- warp/_src/tape.py +1208 -0
- warp/_src/thirdparty/__init__.py +0 -0
- warp/_src/thirdparty/appdirs.py +598 -0
- warp/_src/thirdparty/dlpack.py +145 -0
- warp/_src/thirdparty/unittest_parallel.py +676 -0
- warp/_src/torch.py +393 -0
- warp/_src/types.py +5888 -0
- warp/_src/utils.py +1695 -0
- warp/autograd.py +33 -0
- warp/bin/libwarp-clang.dylib +0 -0
- warp/bin/libwarp.dylib +0 -0
- warp/build.py +29 -0
- warp/build_dll.py +24 -0
- warp/codegen.py +24 -0
- warp/constants.py +24 -0
- warp/context.py +33 -0
- warp/dlpack.py +24 -0
- warp/examples/__init__.py +24 -0
- warp/examples/assets/bear.usd +0 -0
- warp/examples/assets/bunny.usd +0 -0
- warp/examples/assets/cube.usd +0 -0
- warp/examples/assets/nonuniform.usd +0 -0
- warp/examples/assets/nvidia_logo.png +0 -0
- warp/examples/assets/pixel.jpg +0 -0
- warp/examples/assets/rocks.nvdb +0 -0
- warp/examples/assets/rocks.usd +0 -0
- warp/examples/assets/sphere.usd +0 -0
- warp/examples/assets/square_cloth.usd +0 -0
- warp/examples/benchmarks/benchmark_api.py +389 -0
- warp/examples/benchmarks/benchmark_cloth.py +296 -0
- warp/examples/benchmarks/benchmark_cloth_cupy.py +96 -0
- warp/examples/benchmarks/benchmark_cloth_jax.py +105 -0
- warp/examples/benchmarks/benchmark_cloth_numba.py +161 -0
- warp/examples/benchmarks/benchmark_cloth_numpy.py +85 -0
- warp/examples/benchmarks/benchmark_cloth_paddle.py +94 -0
- warp/examples/benchmarks/benchmark_cloth_pytorch.py +94 -0
- warp/examples/benchmarks/benchmark_cloth_taichi.py +120 -0
- warp/examples/benchmarks/benchmark_cloth_warp.py +153 -0
- warp/examples/benchmarks/benchmark_gemm.py +164 -0
- warp/examples/benchmarks/benchmark_interop_paddle.py +166 -0
- warp/examples/benchmarks/benchmark_interop_torch.py +166 -0
- warp/examples/benchmarks/benchmark_launches.py +301 -0
- warp/examples/benchmarks/benchmark_tile_load_store.py +103 -0
- warp/examples/benchmarks/benchmark_tile_sort.py +155 -0
- warp/examples/browse.py +37 -0
- warp/examples/core/example_cupy.py +86 -0
- warp/examples/core/example_dem.py +241 -0
- warp/examples/core/example_fluid.py +299 -0
- warp/examples/core/example_graph_capture.py +150 -0
- warp/examples/core/example_marching_cubes.py +195 -0
- warp/examples/core/example_mesh.py +180 -0
- warp/examples/core/example_mesh_intersect.py +211 -0
- warp/examples/core/example_nvdb.py +182 -0
- warp/examples/core/example_raycast.py +111 -0
- warp/examples/core/example_raymarch.py +205 -0
- warp/examples/core/example_render_opengl.py +290 -0
- warp/examples/core/example_sample_mesh.py +300 -0
- warp/examples/core/example_sph.py +411 -0
- warp/examples/core/example_spin_lock.py +93 -0
- warp/examples/core/example_torch.py +211 -0
- warp/examples/core/example_wave.py +269 -0
- warp/examples/core/example_work_queue.py +118 -0
- warp/examples/distributed/example_jacobi_mpi.py +506 -0
- warp/examples/fem/example_adaptive_grid.py +286 -0
- warp/examples/fem/example_apic_fluid.py +469 -0
- warp/examples/fem/example_burgers.py +261 -0
- warp/examples/fem/example_convection_diffusion.py +181 -0
- warp/examples/fem/example_convection_diffusion_dg.py +225 -0
- warp/examples/fem/example_darcy_ls_optimization.py +489 -0
- warp/examples/fem/example_deformed_geometry.py +172 -0
- warp/examples/fem/example_diffusion.py +196 -0
- warp/examples/fem/example_diffusion_3d.py +225 -0
- warp/examples/fem/example_diffusion_mgpu.py +225 -0
- warp/examples/fem/example_distortion_energy.py +228 -0
- warp/examples/fem/example_elastic_shape_optimization.py +387 -0
- warp/examples/fem/example_magnetostatics.py +242 -0
- warp/examples/fem/example_mixed_elasticity.py +293 -0
- warp/examples/fem/example_navier_stokes.py +263 -0
- warp/examples/fem/example_nonconforming_contact.py +300 -0
- warp/examples/fem/example_stokes.py +213 -0
- warp/examples/fem/example_stokes_transfer.py +262 -0
- warp/examples/fem/example_streamlines.py +357 -0
- warp/examples/fem/utils.py +1047 -0
- warp/examples/interop/example_jax_callable.py +146 -0
- warp/examples/interop/example_jax_ffi_callback.py +132 -0
- warp/examples/interop/example_jax_kernel.py +232 -0
- warp/examples/optim/example_diffray.py +561 -0
- warp/examples/optim/example_fluid_checkpoint.py +497 -0
- warp/examples/tile/example_tile_block_cholesky.py +502 -0
- warp/examples/tile/example_tile_cholesky.py +88 -0
- warp/examples/tile/example_tile_convolution.py +66 -0
- warp/examples/tile/example_tile_fft.py +55 -0
- warp/examples/tile/example_tile_filtering.py +113 -0
- warp/examples/tile/example_tile_matmul.py +85 -0
- warp/examples/tile/example_tile_mcgp.py +191 -0
- warp/examples/tile/example_tile_mlp.py +385 -0
- warp/examples/tile/example_tile_nbody.py +199 -0
- warp/fabric.py +24 -0
- warp/fem/__init__.py +173 -0
- warp/fem/adaptivity.py +26 -0
- warp/fem/cache.py +30 -0
- warp/fem/dirichlet.py +24 -0
- warp/fem/field/__init__.py +24 -0
- warp/fem/field/field.py +26 -0
- warp/fem/geometry/__init__.py +21 -0
- warp/fem/geometry/closest_point.py +31 -0
- warp/fem/linalg.py +38 -0
- warp/fem/operator.py +32 -0
- warp/fem/polynomial.py +29 -0
- warp/fem/space/__init__.py +22 -0
- warp/fem/space/basis_space.py +24 -0
- warp/fem/space/shape/__init__.py +68 -0
- warp/fem/space/topology.py +24 -0
- warp/fem/types.py +24 -0
- warp/fem/utils.py +32 -0
- warp/jax.py +29 -0
- warp/jax_experimental/__init__.py +29 -0
- warp/jax_experimental/custom_call.py +29 -0
- warp/jax_experimental/ffi.py +39 -0
- warp/jax_experimental/xla_ffi.py +24 -0
- warp/marching_cubes.py +24 -0
- warp/math.py +37 -0
- warp/native/array.h +1687 -0
- warp/native/builtin.h +2327 -0
- warp/native/bvh.cpp +562 -0
- warp/native/bvh.cu +826 -0
- warp/native/bvh.h +555 -0
- warp/native/clang/clang.cpp +541 -0
- warp/native/coloring.cpp +622 -0
- warp/native/crt.cpp +51 -0
- warp/native/crt.h +568 -0
- warp/native/cuda_crt.h +1058 -0
- warp/native/cuda_util.cpp +677 -0
- warp/native/cuda_util.h +313 -0
- warp/native/error.cpp +77 -0
- warp/native/error.h +36 -0
- warp/native/exports.h +2023 -0
- warp/native/fabric.h +246 -0
- warp/native/hashgrid.cpp +311 -0
- warp/native/hashgrid.cu +89 -0
- warp/native/hashgrid.h +240 -0
- warp/native/initializer_array.h +41 -0
- warp/native/intersect.h +1253 -0
- warp/native/intersect_adj.h +375 -0
- warp/native/intersect_tri.h +348 -0
- warp/native/mat.h +5189 -0
- warp/native/mathdx.cpp +93 -0
- warp/native/matnn.h +221 -0
- warp/native/mesh.cpp +266 -0
- warp/native/mesh.cu +406 -0
- warp/native/mesh.h +2097 -0
- warp/native/nanovdb/GridHandle.h +533 -0
- warp/native/nanovdb/HostBuffer.h +591 -0
- warp/native/nanovdb/NanoVDB.h +6246 -0
- warp/native/nanovdb/NodeManager.h +323 -0
- warp/native/nanovdb/PNanoVDB.h +3390 -0
- warp/native/noise.h +859 -0
- warp/native/quat.h +1664 -0
- warp/native/rand.h +342 -0
- warp/native/range.h +145 -0
- warp/native/reduce.cpp +174 -0
- warp/native/reduce.cu +363 -0
- warp/native/runlength_encode.cpp +79 -0
- warp/native/runlength_encode.cu +61 -0
- warp/native/scan.cpp +47 -0
- warp/native/scan.cu +55 -0
- warp/native/scan.h +23 -0
- warp/native/solid_angle.h +466 -0
- warp/native/sort.cpp +251 -0
- warp/native/sort.cu +286 -0
- warp/native/sort.h +35 -0
- warp/native/sparse.cpp +241 -0
- warp/native/sparse.cu +435 -0
- warp/native/spatial.h +1306 -0
- warp/native/svd.h +727 -0
- warp/native/temp_buffer.h +46 -0
- warp/native/tile.h +4124 -0
- warp/native/tile_radix_sort.h +1112 -0
- warp/native/tile_reduce.h +838 -0
- warp/native/tile_scan.h +240 -0
- warp/native/tuple.h +189 -0
- warp/native/vec.h +2199 -0
- warp/native/version.h +23 -0
- warp/native/volume.cpp +501 -0
- warp/native/volume.cu +68 -0
- warp/native/volume.h +970 -0
- warp/native/volume_builder.cu +483 -0
- warp/native/volume_builder.h +52 -0
- warp/native/volume_impl.h +70 -0
- warp/native/warp.cpp +1143 -0
- warp/native/warp.cu +4604 -0
- warp/native/warp.h +358 -0
- warp/optim/__init__.py +20 -0
- warp/optim/adam.py +24 -0
- warp/optim/linear.py +35 -0
- warp/optim/sgd.py +24 -0
- warp/paddle.py +24 -0
- warp/py.typed +0 -0
- warp/render/__init__.py +22 -0
- warp/render/imgui_manager.py +29 -0
- warp/render/render_opengl.py +24 -0
- warp/render/render_usd.py +24 -0
- warp/render/utils.py +24 -0
- warp/sparse.py +51 -0
- warp/tape.py +24 -0
- warp/tests/__init__.py +1 -0
- warp/tests/__main__.py +4 -0
- warp/tests/assets/curlnoise_golden.npy +0 -0
- warp/tests/assets/mlp_golden.npy +0 -0
- warp/tests/assets/pixel.npy +0 -0
- warp/tests/assets/pnoise_golden.npy +0 -0
- warp/tests/assets/spiky.usd +0 -0
- warp/tests/assets/test_grid.nvdb +0 -0
- warp/tests/assets/test_index_grid.nvdb +0 -0
- warp/tests/assets/test_int32_grid.nvdb +0 -0
- warp/tests/assets/test_vec_grid.nvdb +0 -0
- warp/tests/assets/torus.nvdb +0 -0
- warp/tests/assets/torus.usda +105 -0
- warp/tests/aux_test_class_kernel.py +34 -0
- warp/tests/aux_test_compile_consts_dummy.py +18 -0
- warp/tests/aux_test_conditional_unequal_types_kernels.py +29 -0
- warp/tests/aux_test_dependent.py +29 -0
- warp/tests/aux_test_grad_customs.py +29 -0
- warp/tests/aux_test_instancing_gc.py +26 -0
- warp/tests/aux_test_module_aot.py +7 -0
- warp/tests/aux_test_module_unload.py +23 -0
- warp/tests/aux_test_name_clash1.py +40 -0
- warp/tests/aux_test_name_clash2.py +40 -0
- warp/tests/aux_test_reference.py +9 -0
- warp/tests/aux_test_reference_reference.py +8 -0
- warp/tests/aux_test_square.py +16 -0
- warp/tests/aux_test_unresolved_func.py +22 -0
- warp/tests/aux_test_unresolved_symbol.py +22 -0
- warp/tests/cuda/__init__.py +0 -0
- warp/tests/cuda/test_async.py +676 -0
- warp/tests/cuda/test_conditional_captures.py +1147 -0
- warp/tests/cuda/test_ipc.py +124 -0
- warp/tests/cuda/test_mempool.py +233 -0
- warp/tests/cuda/test_multigpu.py +169 -0
- warp/tests/cuda/test_peer.py +139 -0
- warp/tests/cuda/test_pinned.py +84 -0
- warp/tests/cuda/test_streams.py +691 -0
- warp/tests/geometry/__init__.py +0 -0
- warp/tests/geometry/test_bvh.py +335 -0
- warp/tests/geometry/test_hash_grid.py +259 -0
- warp/tests/geometry/test_marching_cubes.py +294 -0
- warp/tests/geometry/test_mesh.py +318 -0
- warp/tests/geometry/test_mesh_query_aabb.py +392 -0
- warp/tests/geometry/test_mesh_query_point.py +935 -0
- warp/tests/geometry/test_mesh_query_ray.py +323 -0
- warp/tests/geometry/test_volume.py +1103 -0
- warp/tests/geometry/test_volume_write.py +346 -0
- warp/tests/interop/__init__.py +0 -0
- warp/tests/interop/test_dlpack.py +730 -0
- warp/tests/interop/test_jax.py +1673 -0
- warp/tests/interop/test_paddle.py +800 -0
- warp/tests/interop/test_torch.py +1001 -0
- warp/tests/run_coverage_serial.py +39 -0
- warp/tests/test_adam.py +162 -0
- warp/tests/test_arithmetic.py +1096 -0
- warp/tests/test_array.py +3756 -0
- warp/tests/test_array_reduce.py +156 -0
- warp/tests/test_assert.py +303 -0
- warp/tests/test_atomic.py +336 -0
- warp/tests/test_atomic_bitwise.py +209 -0
- warp/tests/test_atomic_cas.py +312 -0
- warp/tests/test_bool.py +220 -0
- warp/tests/test_builtins_resolution.py +732 -0
- warp/tests/test_closest_point_edge_edge.py +327 -0
- warp/tests/test_codegen.py +974 -0
- warp/tests/test_codegen_instancing.py +1495 -0
- warp/tests/test_compile_consts.py +215 -0
- warp/tests/test_conditional.py +298 -0
- warp/tests/test_context.py +35 -0
- warp/tests/test_copy.py +319 -0
- warp/tests/test_ctypes.py +618 -0
- warp/tests/test_dense.py +73 -0
- warp/tests/test_devices.py +127 -0
- warp/tests/test_enum.py +136 -0
- warp/tests/test_examples.py +424 -0
- warp/tests/test_fabricarray.py +998 -0
- warp/tests/test_fast_math.py +72 -0
- warp/tests/test_fem.py +2204 -0
- warp/tests/test_fixedarray.py +229 -0
- warp/tests/test_fp16.py +136 -0
- warp/tests/test_func.py +501 -0
- warp/tests/test_future_annotations.py +100 -0
- warp/tests/test_generics.py +656 -0
- warp/tests/test_grad.py +893 -0
- warp/tests/test_grad_customs.py +339 -0
- warp/tests/test_grad_debug.py +341 -0
- warp/tests/test_implicit_init.py +411 -0
- warp/tests/test_import.py +45 -0
- warp/tests/test_indexedarray.py +1140 -0
- warp/tests/test_intersect.py +103 -0
- warp/tests/test_iter.py +76 -0
- warp/tests/test_large.py +177 -0
- warp/tests/test_launch.py +411 -0
- warp/tests/test_lerp.py +151 -0
- warp/tests/test_linear_solvers.py +223 -0
- warp/tests/test_lvalue.py +427 -0
- warp/tests/test_map.py +526 -0
- warp/tests/test_mat.py +3515 -0
- warp/tests/test_mat_assign_copy.py +178 -0
- warp/tests/test_mat_constructors.py +573 -0
- warp/tests/test_mat_lite.py +122 -0
- warp/tests/test_mat_scalar_ops.py +2913 -0
- warp/tests/test_math.py +212 -0
- warp/tests/test_module_aot.py +287 -0
- warp/tests/test_module_hashing.py +258 -0
- warp/tests/test_modules_lite.py +70 -0
- warp/tests/test_noise.py +252 -0
- warp/tests/test_operators.py +299 -0
- warp/tests/test_options.py +129 -0
- warp/tests/test_overwrite.py +551 -0
- warp/tests/test_print.py +408 -0
- warp/tests/test_quat.py +2653 -0
- warp/tests/test_quat_assign_copy.py +145 -0
- warp/tests/test_rand.py +339 -0
- warp/tests/test_reload.py +303 -0
- warp/tests/test_rounding.py +157 -0
- warp/tests/test_runlength_encode.py +196 -0
- warp/tests/test_scalar_ops.py +133 -0
- warp/tests/test_smoothstep.py +108 -0
- warp/tests/test_snippet.py +318 -0
- warp/tests/test_sparse.py +845 -0
- warp/tests/test_spatial.py +2859 -0
- warp/tests/test_spatial_assign_copy.py +160 -0
- warp/tests/test_special_values.py +361 -0
- warp/tests/test_static.py +640 -0
- warp/tests/test_struct.py +901 -0
- warp/tests/test_tape.py +242 -0
- warp/tests/test_transient_module.py +93 -0
- warp/tests/test_triangle_closest_point.py +192 -0
- warp/tests/test_tuple.py +361 -0
- warp/tests/test_types.py +615 -0
- warp/tests/test_utils.py +594 -0
- warp/tests/test_vec.py +1408 -0
- warp/tests/test_vec_assign_copy.py +143 -0
- warp/tests/test_vec_constructors.py +325 -0
- warp/tests/test_vec_lite.py +80 -0
- warp/tests/test_vec_scalar_ops.py +2327 -0
- warp/tests/test_verify_fp.py +100 -0
- warp/tests/test_version.py +75 -0
- warp/tests/tile/__init__.py +0 -0
- warp/tests/tile/test_tile.py +1519 -0
- warp/tests/tile/test_tile_atomic_bitwise.py +403 -0
- warp/tests/tile/test_tile_cholesky.py +608 -0
- warp/tests/tile/test_tile_load.py +724 -0
- warp/tests/tile/test_tile_mathdx.py +156 -0
- warp/tests/tile/test_tile_matmul.py +179 -0
- warp/tests/tile/test_tile_mlp.py +400 -0
- warp/tests/tile/test_tile_reduce.py +950 -0
- warp/tests/tile/test_tile_shared_memory.py +376 -0
- warp/tests/tile/test_tile_sort.py +121 -0
- warp/tests/tile/test_tile_view.py +173 -0
- warp/tests/unittest_serial.py +47 -0
- warp/tests/unittest_suites.py +430 -0
- warp/tests/unittest_utils.py +469 -0
- warp/tests/walkthrough_debug.py +95 -0
- warp/torch.py +24 -0
- warp/types.py +51 -0
- warp/utils.py +31 -0
- warp_lang-1.10.0.dist-info/METADATA +459 -0
- warp_lang-1.10.0.dist-info/RECORD +468 -0
- warp_lang-1.10.0.dist-info/WHEEL +5 -0
- warp_lang-1.10.0.dist-info/licenses/LICENSE.md +176 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/Gaia-LICENSE.txt +6 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/appdirs-LICENSE.txt +22 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/asset_pixel_jpg-LICENSE.txt +3 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/cuda-LICENSE.txt +1582 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/dlpack-LICENSE.txt +201 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/fp16-LICENSE.txt +28 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/libmathdx-LICENSE.txt +220 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/llvm-LICENSE.txt +279 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/moller-LICENSE.txt +16 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/nanovdb-LICENSE.txt +2 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/nvrtc-LICENSE.txt +1592 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/svd-LICENSE.txt +23 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/unittest_parallel-LICENSE.txt +21 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/usd-LICENSE.txt +213 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/windingnumber-LICENSE.txt +21 -0
- warp_lang-1.10.0.dist-info/top_level.txt +1 -0
warp/native/warp.cpp
ADDED
|
@@ -0,0 +1,1143 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include "warp.h"
|
|
19
|
+
#include "scan.h"
|
|
20
|
+
#include "array.h"
|
|
21
|
+
#include "exports.h"
|
|
22
|
+
#include "error.h"
|
|
23
|
+
#include "version.h"
|
|
24
|
+
|
|
25
|
+
#include <stdlib.h>
|
|
26
|
+
#include <string.h>
|
|
27
|
+
|
|
28
|
+
// MSVC provides _aligned_malloc() instead of the standard aligned_alloc()
|
|
29
|
+
#if defined(_MSC_VER)
|
|
30
|
+
#include <malloc.h>
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
uint16_t wp_float_to_half_bits(float x)
|
|
34
|
+
{
|
|
35
|
+
// adapted from Fabien Giesen's post: https://gist.github.com/rygorous/2156668
|
|
36
|
+
union fp32
|
|
37
|
+
{
|
|
38
|
+
uint32_t u;
|
|
39
|
+
float f;
|
|
40
|
+
|
|
41
|
+
struct
|
|
42
|
+
{
|
|
43
|
+
unsigned int mantissa : 23;
|
|
44
|
+
unsigned int exponent : 8;
|
|
45
|
+
unsigned int sign : 1;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
fp32 f;
|
|
50
|
+
f.f = x;
|
|
51
|
+
|
|
52
|
+
fp32 f32infty = { 255 << 23 };
|
|
53
|
+
fp32 f16infty = { 31 << 23 };
|
|
54
|
+
fp32 magic = { 15 << 23 };
|
|
55
|
+
uint32_t sign_mask = 0x80000000u;
|
|
56
|
+
uint32_t round_mask = ~0xfffu;
|
|
57
|
+
uint16_t u;
|
|
58
|
+
|
|
59
|
+
uint32_t sign = f.u & sign_mask;
|
|
60
|
+
f.u ^= sign;
|
|
61
|
+
|
|
62
|
+
// NOTE all the integer compares in this function can be safely
|
|
63
|
+
// compiled into signed compares since all operands are below
|
|
64
|
+
// 0x80000000. Important if you want fast straight SSE2 code
|
|
65
|
+
// (since there's no unsigned PCMPGTD).
|
|
66
|
+
|
|
67
|
+
if (f.u >= f32infty.u) // Inf or NaN (all exponent bits set)
|
|
68
|
+
u = (f.u > f32infty.u) ? 0x7e00 : 0x7c00; // NaN->qNaN and Inf->Inf
|
|
69
|
+
else // (De)normalized number or zero
|
|
70
|
+
{
|
|
71
|
+
f.u &= round_mask;
|
|
72
|
+
f.f *= magic.f;
|
|
73
|
+
f.u -= round_mask;
|
|
74
|
+
if (f.u > f16infty.u) f.u = f16infty.u; // Clamp to signed infinity if overflowed
|
|
75
|
+
|
|
76
|
+
u = f.u >> 13; // Take the bits!
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
u |= sign >> 16;
|
|
80
|
+
return u;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
float wp_half_bits_to_float(uint16_t u)
|
|
84
|
+
{
|
|
85
|
+
// adapted from Fabien Giesen's post: https://gist.github.com/rygorous/2156668
|
|
86
|
+
union fp32
|
|
87
|
+
{
|
|
88
|
+
uint32_t u;
|
|
89
|
+
float f;
|
|
90
|
+
|
|
91
|
+
struct
|
|
92
|
+
{
|
|
93
|
+
unsigned int mantissa : 23;
|
|
94
|
+
unsigned int exponent : 8;
|
|
95
|
+
unsigned int sign : 1;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
static const fp32 magic = { 113 << 23 };
|
|
100
|
+
static const uint32_t shifted_exp = 0x7c00 << 13; // exponent mask after shift
|
|
101
|
+
fp32 o;
|
|
102
|
+
|
|
103
|
+
o.u = (u & 0x7fff) << 13; // exponent/mantissa bits
|
|
104
|
+
uint32_t exp = shifted_exp & o.u; // just the exponent
|
|
105
|
+
o.u += (127 - 15) << 23; // exponent adjust
|
|
106
|
+
|
|
107
|
+
// handle exponent special cases
|
|
108
|
+
if (exp == shifted_exp) // Inf/NaN?
|
|
109
|
+
o.u += (128 - 16) << 23; // extra exp adjust
|
|
110
|
+
else if (exp == 0) // Zero/Denormal?
|
|
111
|
+
{
|
|
112
|
+
o.u += 1 << 23; // extra exp adjust
|
|
113
|
+
o.f -= magic.f; // renormalize
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
o.u |= (u & 0x8000) << 16; // sign bit
|
|
117
|
+
return o.f;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
int wp_init(const char* expected_version)
|
|
121
|
+
{
|
|
122
|
+
// Check version mismatch (guard against NULL expected_version)
|
|
123
|
+
if (expected_version != NULL && strcmp(expected_version, WP_VERSION_STRING) != 0)
|
|
124
|
+
{
|
|
125
|
+
fprintf(stderr,
|
|
126
|
+
"Warp Warning: Version mismatch detected in Warp native library.\n"
|
|
127
|
+
" Expected Warp version: %s\n"
|
|
128
|
+
" Loaded native library version: %s\n"
|
|
129
|
+
" This may occur due to environment variables or multiple Warp installations.\n",
|
|
130
|
+
expected_version,
|
|
131
|
+
WP_VERSION_STRING);
|
|
132
|
+
}
|
|
133
|
+
else if (expected_version == NULL)
|
|
134
|
+
{
|
|
135
|
+
fprintf(stderr,
|
|
136
|
+
"Warp Warning: Version check skipped (NULL version provided).\n"
|
|
137
|
+
" Loaded native library version: %s\n",
|
|
138
|
+
WP_VERSION_STRING);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#if WP_ENABLE_CUDA
|
|
142
|
+
int cuda_init(void);
|
|
143
|
+
// note: it's safe to proceed even if CUDA initialization failed
|
|
144
|
+
cuda_init();
|
|
145
|
+
#endif
|
|
146
|
+
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
void wp_shutdown()
|
|
151
|
+
{
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const char* wp_version()
|
|
155
|
+
{
|
|
156
|
+
return WP_VERSION_STRING;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const char* wp_get_error_string()
|
|
160
|
+
{
|
|
161
|
+
return wp::get_error_string();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
void wp_set_error_output_enabled(int enable)
|
|
165
|
+
{
|
|
166
|
+
wp::set_error_output_enabled(bool(enable));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
int wp_is_error_output_enabled()
|
|
170
|
+
{
|
|
171
|
+
return int(wp::is_error_output_enabled());
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
int wp_is_cuda_enabled()
|
|
175
|
+
{
|
|
176
|
+
return int(WP_ENABLE_CUDA);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
int wp_is_cuda_compatibility_enabled()
|
|
180
|
+
{
|
|
181
|
+
return int(WP_ENABLE_CUDA_COMPATIBILITY);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
int wp_is_mathdx_enabled()
|
|
185
|
+
{
|
|
186
|
+
return int(WP_ENABLE_MATHDX);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
int wp_is_debug_enabled()
|
|
190
|
+
{
|
|
191
|
+
return int(WP_ENABLE_DEBUG);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
void* wp_alloc_host(size_t s)
|
|
195
|
+
{
|
|
196
|
+
// increase CPU array alignment for compatibility with other libs, e.g., JAX, XLA, Eigen.
|
|
197
|
+
size_t alignment = 64;
|
|
198
|
+
|
|
199
|
+
// msvc does not provide the standard aligned_alloc()
|
|
200
|
+
#if defined(_MSC_VER)
|
|
201
|
+
return _aligned_malloc(s, alignment);
|
|
202
|
+
#else
|
|
203
|
+
// ensure that the size is a multiple of alignment
|
|
204
|
+
size_t remainder = s % alignment;
|
|
205
|
+
if (remainder != 0)
|
|
206
|
+
s += alignment - remainder;
|
|
207
|
+
return aligned_alloc(alignment, s);
|
|
208
|
+
#endif
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
void wp_free_host(void* ptr)
|
|
212
|
+
{
|
|
213
|
+
#if defined(_MSC_VER)
|
|
214
|
+
_aligned_free(ptr);
|
|
215
|
+
#else
|
|
216
|
+
free(ptr);
|
|
217
|
+
#endif
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
bool wp_memcpy_h2h(void* dest, void* src, size_t n)
|
|
221
|
+
{
|
|
222
|
+
memcpy(dest, src, n);
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
void wp_memset_host(void* dest, int value, size_t n)
|
|
227
|
+
{
|
|
228
|
+
if ((n%4) > 0)
|
|
229
|
+
{
|
|
230
|
+
memset(dest, value, n);
|
|
231
|
+
}
|
|
232
|
+
else
|
|
233
|
+
{
|
|
234
|
+
const size_t num_words = n/4;
|
|
235
|
+
for (size_t i=0; i < num_words; ++i)
|
|
236
|
+
((int*)dest)[i] = value;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// fill memory buffer with a value: this is a faster memtile variant
|
|
241
|
+
// for types bigger than one byte, but requires proper alignment of dst
|
|
242
|
+
template <typename T>
|
|
243
|
+
void memtile_value_host(T* dst, T value, size_t n)
|
|
244
|
+
{
|
|
245
|
+
while (n--)
|
|
246
|
+
*dst++ = value;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
void wp_memtile_host(void* dst, const void* src, size_t srcsize, size_t n)
|
|
250
|
+
{
|
|
251
|
+
size_t dst_addr = reinterpret_cast<size_t>(dst);
|
|
252
|
+
size_t src_addr = reinterpret_cast<size_t>(src);
|
|
253
|
+
|
|
254
|
+
// try memtile_value first because it should be faster, but we need to ensure proper alignment
|
|
255
|
+
if (srcsize == 8 && (dst_addr & 7) == 0 && (src_addr & 7) == 0)
|
|
256
|
+
memtile_value_host(reinterpret_cast<int64_t*>(dst), *reinterpret_cast<const int64_t*>(src), n);
|
|
257
|
+
else if (srcsize == 4 && (dst_addr & 3) == 0 && (src_addr & 3) == 0)
|
|
258
|
+
memtile_value_host(reinterpret_cast<int32_t*>(dst), *reinterpret_cast<const int32_t*>(src), n);
|
|
259
|
+
else if (srcsize == 2 && (dst_addr & 1) == 0 && (src_addr & 1) == 0)
|
|
260
|
+
memtile_value_host(reinterpret_cast<int16_t*>(dst), *reinterpret_cast<const int16_t*>(src), n);
|
|
261
|
+
else if (srcsize == 1)
|
|
262
|
+
memset(dst, *reinterpret_cast<const int8_t*>(src), n);
|
|
263
|
+
else
|
|
264
|
+
{
|
|
265
|
+
// generic version
|
|
266
|
+
while (n--)
|
|
267
|
+
{
|
|
268
|
+
memcpy(dst, src, srcsize);
|
|
269
|
+
dst = (int8_t*)dst + srcsize;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
void wp_array_scan_int_host(uint64_t in, uint64_t out, int len, bool inclusive)
|
|
275
|
+
{
|
|
276
|
+
scan_host((const int*)in, (int*)out, len, inclusive);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
void wp_array_scan_float_host(uint64_t in, uint64_t out, int len, bool inclusive)
|
|
280
|
+
{
|
|
281
|
+
scan_host((const float*)in, (float*)out, len, inclusive);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
static void array_copy_nd(void* dst, const void* src,
|
|
286
|
+
const int* dst_strides, const int* src_strides,
|
|
287
|
+
const int*const* dst_indices, const int*const* src_indices,
|
|
288
|
+
const int* shape, int ndim, size_t elem_size)
|
|
289
|
+
{
|
|
290
|
+
if (ndim == 1)
|
|
291
|
+
{
|
|
292
|
+
for (int i = 0; i < shape[0]; i++)
|
|
293
|
+
{
|
|
294
|
+
size_t src_idx = src_indices[0] ? src_indices[0][i] : i;
|
|
295
|
+
size_t dst_idx = dst_indices[0] ? dst_indices[0][i] : i;
|
|
296
|
+
const char* p = (const char*)src + src_idx * src_strides[0];
|
|
297
|
+
char* q = (char*)dst + dst_idx * dst_strides[0];
|
|
298
|
+
// copy element
|
|
299
|
+
memcpy(q, p, elem_size);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else
|
|
303
|
+
{
|
|
304
|
+
for (int i = 0; i < shape[0]; i++)
|
|
305
|
+
{
|
|
306
|
+
size_t src_idx = src_indices[0] ? src_indices[0][i] : i;
|
|
307
|
+
size_t dst_idx = dst_indices[0] ? dst_indices[0][i] : i;
|
|
308
|
+
const char* p = (const char*)src + src_idx * src_strides[0];
|
|
309
|
+
char* q = (char*)dst + dst_idx * dst_strides[0];
|
|
310
|
+
// recurse on next inner dimension
|
|
311
|
+
array_copy_nd(q, p, dst_strides + 1, src_strides + 1, dst_indices + 1, src_indices + 1, shape + 1, ndim - 1, elem_size);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
static void array_copy_to_fabric(wp::fabricarray_t<void>& dst, const void* src_data,
|
|
318
|
+
size_t src_stride, const int* src_indices, size_t elem_size)
|
|
319
|
+
{
|
|
320
|
+
const int8_t* src_ptr = static_cast<const int8_t*>(src_data);
|
|
321
|
+
|
|
322
|
+
if (src_indices)
|
|
323
|
+
{
|
|
324
|
+
// copy from indexed array
|
|
325
|
+
for (size_t i = 0; i < dst.nbuckets; i++)
|
|
326
|
+
{
|
|
327
|
+
const wp::fabricbucket_t& bucket = dst.buckets[i];
|
|
328
|
+
int8_t* dst_ptr = static_cast<int8_t*>(bucket.ptr);
|
|
329
|
+
size_t bucket_size = bucket.index_end - bucket.index_start;
|
|
330
|
+
for (size_t j = 0; j < bucket_size; j++)
|
|
331
|
+
{
|
|
332
|
+
size_t idx = *src_indices;
|
|
333
|
+
memcpy(dst_ptr, src_ptr + idx * elem_size, elem_size);
|
|
334
|
+
dst_ptr += elem_size;
|
|
335
|
+
++src_indices;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else
|
|
340
|
+
{
|
|
341
|
+
if (src_stride == elem_size)
|
|
342
|
+
{
|
|
343
|
+
// copy from contiguous array
|
|
344
|
+
for (size_t i = 0; i < dst.nbuckets; i++)
|
|
345
|
+
{
|
|
346
|
+
const wp::fabricbucket_t& bucket = dst.buckets[i];
|
|
347
|
+
size_t num_bytes = (bucket.index_end - bucket.index_start) * elem_size;
|
|
348
|
+
memcpy(bucket.ptr, src_ptr, num_bytes);
|
|
349
|
+
src_ptr += num_bytes;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else
|
|
353
|
+
{
|
|
354
|
+
// copy from strided array
|
|
355
|
+
for (size_t i = 0; i < dst.nbuckets; i++)
|
|
356
|
+
{
|
|
357
|
+
const wp::fabricbucket_t& bucket = dst.buckets[i];
|
|
358
|
+
int8_t* dst_ptr = static_cast<int8_t*>(bucket.ptr);
|
|
359
|
+
size_t bucket_size = bucket.index_end - bucket.index_start;
|
|
360
|
+
for (size_t j = 0; j < bucket_size; j++)
|
|
361
|
+
{
|
|
362
|
+
memcpy(dst_ptr, src_ptr, elem_size);
|
|
363
|
+
src_ptr += src_stride;
|
|
364
|
+
dst_ptr += elem_size;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
static void array_copy_from_fabric(const wp::fabricarray_t<void>& src, void* dst_data,
|
|
372
|
+
size_t dst_stride, const int* dst_indices, size_t elem_size)
|
|
373
|
+
{
|
|
374
|
+
int8_t* dst_ptr = static_cast<int8_t*>(dst_data);
|
|
375
|
+
|
|
376
|
+
if (dst_indices)
|
|
377
|
+
{
|
|
378
|
+
// copy to indexed array
|
|
379
|
+
for (size_t i = 0; i < src.nbuckets; i++)
|
|
380
|
+
{
|
|
381
|
+
const wp::fabricbucket_t& bucket = src.buckets[i];
|
|
382
|
+
const int8_t* src_ptr = static_cast<const int8_t*>(bucket.ptr);
|
|
383
|
+
size_t bucket_size = bucket.index_end - bucket.index_start;
|
|
384
|
+
for (size_t j = 0; j < bucket_size; j++)
|
|
385
|
+
{
|
|
386
|
+
int idx = *dst_indices;
|
|
387
|
+
memcpy(dst_ptr + idx * elem_size, src_ptr, elem_size);
|
|
388
|
+
src_ptr += elem_size;
|
|
389
|
+
++dst_indices;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
else
|
|
394
|
+
{
|
|
395
|
+
if (dst_stride == elem_size)
|
|
396
|
+
{
|
|
397
|
+
// copy to contiguous array
|
|
398
|
+
for (size_t i = 0; i < src.nbuckets; i++)
|
|
399
|
+
{
|
|
400
|
+
const wp::fabricbucket_t& bucket = src.buckets[i];
|
|
401
|
+
size_t num_bytes = (bucket.index_end - bucket.index_start) * elem_size;
|
|
402
|
+
memcpy(dst_ptr, bucket.ptr, num_bytes);
|
|
403
|
+
dst_ptr += num_bytes;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
else
|
|
407
|
+
{
|
|
408
|
+
// copy to strided array
|
|
409
|
+
for (size_t i = 0; i < src.nbuckets; i++)
|
|
410
|
+
{
|
|
411
|
+
const wp::fabricbucket_t& bucket = src.buckets[i];
|
|
412
|
+
const int8_t* src_ptr = static_cast<const int8_t*>(bucket.ptr);
|
|
413
|
+
size_t bucket_size = bucket.index_end - bucket.index_start;
|
|
414
|
+
for (size_t j = 0; j < bucket_size; j++)
|
|
415
|
+
{
|
|
416
|
+
memcpy(dst_ptr, src_ptr, elem_size);
|
|
417
|
+
dst_ptr += dst_stride;
|
|
418
|
+
src_ptr += elem_size;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
static void array_copy_fabric_to_fabric(wp::fabricarray_t<void>& dst, const wp::fabricarray_t<void>& src, size_t elem_size)
|
|
426
|
+
{
|
|
427
|
+
wp::fabricbucket_t* dst_bucket = dst.buckets;
|
|
428
|
+
const wp::fabricbucket_t* src_bucket = src.buckets;
|
|
429
|
+
int8_t* dst_ptr = static_cast<int8_t*>(dst_bucket->ptr);
|
|
430
|
+
const int8_t* src_ptr = static_cast<const int8_t*>(src_bucket->ptr);
|
|
431
|
+
size_t dst_remaining = dst_bucket->index_end - dst_bucket->index_start;
|
|
432
|
+
size_t src_remaining = src_bucket->index_end - src_bucket->index_start;
|
|
433
|
+
size_t total_copied = 0;
|
|
434
|
+
|
|
435
|
+
while (total_copied < dst.size)
|
|
436
|
+
{
|
|
437
|
+
if (dst_remaining <= src_remaining)
|
|
438
|
+
{
|
|
439
|
+
// copy to destination bucket
|
|
440
|
+
size_t num_elems = dst_remaining;
|
|
441
|
+
size_t num_bytes = num_elems * elem_size;
|
|
442
|
+
memcpy(dst_ptr, src_ptr, num_bytes);
|
|
443
|
+
|
|
444
|
+
// advance to next destination bucket
|
|
445
|
+
++dst_bucket;
|
|
446
|
+
dst_ptr = static_cast<int8_t*>(dst_bucket->ptr);
|
|
447
|
+
dst_remaining = dst_bucket->index_end - dst_bucket->index_start;
|
|
448
|
+
|
|
449
|
+
// advance source offset
|
|
450
|
+
src_ptr += num_bytes;
|
|
451
|
+
src_remaining -= num_elems;
|
|
452
|
+
|
|
453
|
+
total_copied += num_elems;
|
|
454
|
+
}
|
|
455
|
+
else
|
|
456
|
+
{
|
|
457
|
+
// copy to destination bucket
|
|
458
|
+
size_t num_elems = src_remaining;
|
|
459
|
+
size_t num_bytes = num_elems * elem_size;
|
|
460
|
+
memcpy(dst_ptr, src_ptr, num_bytes);
|
|
461
|
+
|
|
462
|
+
// advance to next source bucket
|
|
463
|
+
++src_bucket;
|
|
464
|
+
src_ptr = static_cast<const int8_t*>(src_bucket->ptr);
|
|
465
|
+
src_remaining = src_bucket->index_end - src_bucket->index_start;
|
|
466
|
+
|
|
467
|
+
// advance destination offset
|
|
468
|
+
dst_ptr += num_bytes;
|
|
469
|
+
dst_remaining -= num_elems;
|
|
470
|
+
|
|
471
|
+
total_copied += num_elems;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
static void array_copy_to_fabric_indexed(wp::indexedfabricarray_t<void>& dst, const void* src_data,
|
|
478
|
+
size_t src_stride, const int* src_indices, size_t elem_size)
|
|
479
|
+
{
|
|
480
|
+
const int8_t* src_ptr = static_cast<const int8_t*>(src_data);
|
|
481
|
+
|
|
482
|
+
if (src_indices)
|
|
483
|
+
{
|
|
484
|
+
// copy from indexed array
|
|
485
|
+
for (size_t i = 0; i < dst.size; i++)
|
|
486
|
+
{
|
|
487
|
+
size_t src_idx = src_indices[i];
|
|
488
|
+
size_t dst_idx = dst.indices[i];
|
|
489
|
+
void* dst_ptr = fabricarray_element_ptr(dst.fa, dst_idx, elem_size);
|
|
490
|
+
memcpy(dst_ptr, src_ptr + dst_idx * elem_size, elem_size);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
else
|
|
494
|
+
{
|
|
495
|
+
// copy from contiguous/strided array
|
|
496
|
+
for (size_t i = 0; i < dst.size; i++)
|
|
497
|
+
{
|
|
498
|
+
size_t dst_idx = dst.indices[i];
|
|
499
|
+
void* dst_ptr = fabricarray_element_ptr(dst.fa, dst_idx, elem_size);
|
|
500
|
+
if (dst_ptr)
|
|
501
|
+
{
|
|
502
|
+
memcpy(dst_ptr, src_ptr, elem_size);
|
|
503
|
+
src_ptr += src_stride;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
static void array_copy_fabric_indexed_to_fabric(wp::fabricarray_t<void>& dst, const wp::indexedfabricarray_t<void>& src, size_t elem_size)
|
|
511
|
+
{
|
|
512
|
+
wp::fabricbucket_t* dst_bucket = dst.buckets;
|
|
513
|
+
int8_t* dst_ptr = static_cast<int8_t*>(dst_bucket->ptr);
|
|
514
|
+
int8_t* dst_end = dst_ptr + elem_size * (dst_bucket->index_end - dst_bucket->index_start);
|
|
515
|
+
|
|
516
|
+
for (size_t i = 0; i < src.size; i++)
|
|
517
|
+
{
|
|
518
|
+
size_t src_idx = src.indices[i];
|
|
519
|
+
const void* src_ptr = fabricarray_element_ptr(src.fa, src_idx, elem_size);
|
|
520
|
+
|
|
521
|
+
if (dst_ptr >= dst_end)
|
|
522
|
+
{
|
|
523
|
+
// advance to next destination bucket
|
|
524
|
+
++dst_bucket;
|
|
525
|
+
dst_ptr = static_cast<int8_t*>(dst_bucket->ptr);
|
|
526
|
+
dst_end = dst_ptr + elem_size * (dst_bucket->index_end - dst_bucket->index_start);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
memcpy(dst_ptr, src_ptr, elem_size);
|
|
530
|
+
|
|
531
|
+
dst_ptr += elem_size;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
static void array_copy_fabric_indexed_to_fabric_indexed(wp::indexedfabricarray_t<void>& dst, const wp::indexedfabricarray_t<void>& src, size_t elem_size)
|
|
537
|
+
{
|
|
538
|
+
for (size_t i = 0; i < src.size; i++)
|
|
539
|
+
{
|
|
540
|
+
size_t src_idx = src.indices[i];
|
|
541
|
+
size_t dst_idx = dst.indices[i];
|
|
542
|
+
|
|
543
|
+
const void* src_ptr = fabricarray_element_ptr(src.fa, src_idx, elem_size);
|
|
544
|
+
void* dst_ptr = fabricarray_element_ptr(dst.fa, dst_idx, elem_size);
|
|
545
|
+
|
|
546
|
+
memcpy(dst_ptr, src_ptr, elem_size);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
static void array_copy_fabric_to_fabric_indexed(wp::indexedfabricarray_t<void>& dst, const wp::fabricarray_t<void>& src, size_t elem_size)
|
|
552
|
+
{
|
|
553
|
+
wp::fabricbucket_t* src_bucket = src.buckets;
|
|
554
|
+
const int8_t* src_ptr = static_cast<const int8_t*>(src_bucket->ptr);
|
|
555
|
+
const int8_t* src_end = src_ptr + elem_size * (src_bucket->index_end - src_bucket->index_start);
|
|
556
|
+
|
|
557
|
+
for (size_t i = 0; i < dst.size; i++)
|
|
558
|
+
{
|
|
559
|
+
size_t dst_idx = dst.indices[i];
|
|
560
|
+
void* dst_ptr = fabricarray_element_ptr(dst.fa, dst_idx, elem_size);
|
|
561
|
+
|
|
562
|
+
if (src_ptr >= src_end)
|
|
563
|
+
{
|
|
564
|
+
// advance to next source bucket
|
|
565
|
+
++src_bucket;
|
|
566
|
+
src_ptr = static_cast<int8_t*>(src_bucket->ptr);
|
|
567
|
+
src_end = src_ptr + elem_size * (src_bucket->index_end - src_bucket->index_start);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
memcpy(dst_ptr, src_ptr, elem_size);
|
|
571
|
+
|
|
572
|
+
src_ptr += elem_size;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
static void array_copy_from_fabric_indexed(const wp::indexedfabricarray_t<void>& src, void* dst_data,
|
|
578
|
+
size_t dst_stride, const int* dst_indices, size_t elem_size)
|
|
579
|
+
{
|
|
580
|
+
int8_t* dst_ptr = static_cast<int8_t*>(dst_data);
|
|
581
|
+
|
|
582
|
+
if (dst_indices)
|
|
583
|
+
{
|
|
584
|
+
// copy to indexed array
|
|
585
|
+
for (size_t i = 0; i < src.size; i++)
|
|
586
|
+
{
|
|
587
|
+
size_t idx = src.indices[i];
|
|
588
|
+
if (idx < src.fa.size)
|
|
589
|
+
{
|
|
590
|
+
const void* src_ptr = fabricarray_element_ptr(src.fa, idx, elem_size);
|
|
591
|
+
size_t dst_idx = dst_indices[i];
|
|
592
|
+
memcpy(dst_ptr + dst_idx * elem_size, src_ptr, elem_size);
|
|
593
|
+
}
|
|
594
|
+
else
|
|
595
|
+
{
|
|
596
|
+
fprintf(stderr, "Warp copy error: Source index %llu is out of bounds for fabric array of size %llu",
|
|
597
|
+
(unsigned long long)idx, (unsigned long long)src.fa.size);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
else
|
|
602
|
+
{
|
|
603
|
+
// copy to contiguous/strided array
|
|
604
|
+
for (size_t i = 0; i < src.size; i++)
|
|
605
|
+
{
|
|
606
|
+
size_t idx = src.indices[i];
|
|
607
|
+
if (idx < src.fa.size)
|
|
608
|
+
{
|
|
609
|
+
const void* src_ptr = fabricarray_element_ptr(src.fa, idx, elem_size);
|
|
610
|
+
memcpy(dst_ptr, src_ptr, elem_size);
|
|
611
|
+
dst_ptr += dst_stride;
|
|
612
|
+
}
|
|
613
|
+
else
|
|
614
|
+
{
|
|
615
|
+
fprintf(stderr, "Warp copy error: Source index %llu is out of bounds for fabric array of size %llu",
|
|
616
|
+
(unsigned long long)idx, (unsigned long long)src.fa.size);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
WP_API bool wp_array_copy_host(void* dst, void* src, int dst_type, int src_type, int elem_size)
|
|
624
|
+
{
|
|
625
|
+
if (!src || !dst)
|
|
626
|
+
return false;
|
|
627
|
+
|
|
628
|
+
const void* src_data = NULL;
|
|
629
|
+
void* dst_data = NULL;
|
|
630
|
+
int src_ndim = 0;
|
|
631
|
+
int dst_ndim = 0;
|
|
632
|
+
const int* src_shape = NULL;
|
|
633
|
+
const int* dst_shape = NULL;
|
|
634
|
+
const int* src_strides = NULL;
|
|
635
|
+
const int* dst_strides = NULL;
|
|
636
|
+
const int*const* src_indices = NULL;
|
|
637
|
+
const int*const* dst_indices = NULL;
|
|
638
|
+
|
|
639
|
+
const wp::fabricarray_t<void>* src_fabricarray = NULL;
|
|
640
|
+
wp::fabricarray_t<void>* dst_fabricarray = NULL;
|
|
641
|
+
|
|
642
|
+
const wp::indexedfabricarray_t<void>* src_indexedfabricarray = NULL;
|
|
643
|
+
wp::indexedfabricarray_t<void>* dst_indexedfabricarray = NULL;
|
|
644
|
+
|
|
645
|
+
const int* null_indices[wp::ARRAY_MAX_DIMS] = { NULL };
|
|
646
|
+
|
|
647
|
+
if (src_type == wp::ARRAY_TYPE_REGULAR)
|
|
648
|
+
{
|
|
649
|
+
const wp::array_t<void>& src_arr = *static_cast<const wp::array_t<void>*>(src);
|
|
650
|
+
src_data = src_arr.data;
|
|
651
|
+
src_ndim = src_arr.ndim;
|
|
652
|
+
src_shape = src_arr.shape.dims;
|
|
653
|
+
src_strides = src_arr.strides;
|
|
654
|
+
src_indices = null_indices;
|
|
655
|
+
}
|
|
656
|
+
else if (src_type == wp::ARRAY_TYPE_INDEXED)
|
|
657
|
+
{
|
|
658
|
+
const wp::indexedarray_t<void>& src_arr = *static_cast<const wp::indexedarray_t<void>*>(src);
|
|
659
|
+
src_data = src_arr.arr.data;
|
|
660
|
+
src_ndim = src_arr.arr.ndim;
|
|
661
|
+
src_shape = src_arr.shape.dims;
|
|
662
|
+
src_strides = src_arr.arr.strides;
|
|
663
|
+
src_indices = src_arr.indices;
|
|
664
|
+
}
|
|
665
|
+
else if (src_type == wp::ARRAY_TYPE_FABRIC)
|
|
666
|
+
{
|
|
667
|
+
src_fabricarray = static_cast<const wp::fabricarray_t<void>*>(src);
|
|
668
|
+
src_ndim = 1;
|
|
669
|
+
}
|
|
670
|
+
else if (src_type == wp::ARRAY_TYPE_FABRIC_INDEXED)
|
|
671
|
+
{
|
|
672
|
+
src_indexedfabricarray = static_cast<const wp::indexedfabricarray_t<void>*>(src);
|
|
673
|
+
src_ndim = 1;
|
|
674
|
+
}
|
|
675
|
+
else
|
|
676
|
+
{
|
|
677
|
+
fprintf(stderr, "Warp copy error: Invalid source array type (%d)\n", src_type);
|
|
678
|
+
return false;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (dst_type == wp::ARRAY_TYPE_REGULAR)
|
|
682
|
+
{
|
|
683
|
+
const wp::array_t<void>& dst_arr = *static_cast<const wp::array_t<void>*>(dst);
|
|
684
|
+
dst_data = dst_arr.data;
|
|
685
|
+
dst_ndim = dst_arr.ndim;
|
|
686
|
+
dst_shape = dst_arr.shape.dims;
|
|
687
|
+
dst_strides = dst_arr.strides;
|
|
688
|
+
dst_indices = null_indices;
|
|
689
|
+
}
|
|
690
|
+
else if (dst_type == wp::ARRAY_TYPE_INDEXED)
|
|
691
|
+
{
|
|
692
|
+
const wp::indexedarray_t<void>& dst_arr = *static_cast<const wp::indexedarray_t<void>*>(dst);
|
|
693
|
+
dst_data = dst_arr.arr.data;
|
|
694
|
+
dst_ndim = dst_arr.arr.ndim;
|
|
695
|
+
dst_shape = dst_arr.shape.dims;
|
|
696
|
+
dst_strides = dst_arr.arr.strides;
|
|
697
|
+
dst_indices = dst_arr.indices;
|
|
698
|
+
}
|
|
699
|
+
else if (dst_type == wp::ARRAY_TYPE_FABRIC)
|
|
700
|
+
{
|
|
701
|
+
dst_fabricarray = static_cast<wp::fabricarray_t<void>*>(dst);
|
|
702
|
+
dst_ndim = 1;
|
|
703
|
+
}
|
|
704
|
+
else if (dst_type == wp::ARRAY_TYPE_FABRIC_INDEXED)
|
|
705
|
+
{
|
|
706
|
+
dst_indexedfabricarray = static_cast<wp::indexedfabricarray_t<void>*>(dst);
|
|
707
|
+
dst_ndim = 1;
|
|
708
|
+
}
|
|
709
|
+
else
|
|
710
|
+
{
|
|
711
|
+
fprintf(stderr, "Warp copy error: Invalid destination array type (%d)\n", dst_type);
|
|
712
|
+
return false;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
if (src_ndim != dst_ndim)
|
|
716
|
+
{
|
|
717
|
+
fprintf(stderr, "Warp copy error: Incompatible array dimensionalities (%d and %d)\n", src_ndim, dst_ndim);
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// handle fabric arrays
|
|
722
|
+
if (dst_fabricarray)
|
|
723
|
+
{
|
|
724
|
+
size_t n = dst_fabricarray->size;
|
|
725
|
+
if (src_fabricarray)
|
|
726
|
+
{
|
|
727
|
+
// copy from fabric to fabric
|
|
728
|
+
if (src_fabricarray->size != n)
|
|
729
|
+
{
|
|
730
|
+
fprintf(stderr, "Warp copy error: Incompatible array sizes\n");
|
|
731
|
+
return false;
|
|
732
|
+
}
|
|
733
|
+
array_copy_fabric_to_fabric(*dst_fabricarray, *src_fabricarray, elem_size);
|
|
734
|
+
return true;
|
|
735
|
+
}
|
|
736
|
+
else if (src_indexedfabricarray)
|
|
737
|
+
{
|
|
738
|
+
// copy from fabric indexed to fabric
|
|
739
|
+
if (src_indexedfabricarray->size != n)
|
|
740
|
+
{
|
|
741
|
+
fprintf(stderr, "Warp copy error: Incompatible array sizes\n");
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
array_copy_fabric_indexed_to_fabric(*dst_fabricarray, *src_indexedfabricarray, elem_size);
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
else
|
|
748
|
+
{
|
|
749
|
+
// copy to fabric
|
|
750
|
+
if (size_t(src_shape[0]) != n)
|
|
751
|
+
{
|
|
752
|
+
fprintf(stderr, "Warp copy error: Incompatible array sizes\n");
|
|
753
|
+
return false;
|
|
754
|
+
}
|
|
755
|
+
array_copy_to_fabric(*dst_fabricarray, src_data, src_strides[0], src_indices[0], elem_size);
|
|
756
|
+
return true;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
else if (dst_indexedfabricarray)
|
|
760
|
+
{
|
|
761
|
+
size_t n = dst_indexedfabricarray->size;
|
|
762
|
+
if (src_fabricarray)
|
|
763
|
+
{
|
|
764
|
+
// copy from fabric to fabric indexed
|
|
765
|
+
if (src_fabricarray->size != n)
|
|
766
|
+
{
|
|
767
|
+
fprintf(stderr, "Warp copy error: Incompatible array sizes\n");
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
array_copy_fabric_to_fabric_indexed(*dst_indexedfabricarray, *src_fabricarray, elem_size);
|
|
771
|
+
return true;
|
|
772
|
+
}
|
|
773
|
+
else if (src_indexedfabricarray)
|
|
774
|
+
{
|
|
775
|
+
// copy from fabric indexed to fabric indexed
|
|
776
|
+
if (src_indexedfabricarray->size != n)
|
|
777
|
+
{
|
|
778
|
+
fprintf(stderr, "Warp copy error: Incompatible array sizes\n");
|
|
779
|
+
return false;
|
|
780
|
+
}
|
|
781
|
+
array_copy_fabric_indexed_to_fabric_indexed(*dst_indexedfabricarray, *src_indexedfabricarray, elem_size);
|
|
782
|
+
return true;
|
|
783
|
+
}
|
|
784
|
+
else
|
|
785
|
+
{
|
|
786
|
+
// copy to fabric indexed
|
|
787
|
+
if (size_t(src_shape[0]) != n)
|
|
788
|
+
{
|
|
789
|
+
fprintf(stderr, "Warp copy error: Incompatible array sizes\n");
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
array_copy_to_fabric_indexed(*dst_indexedfabricarray, src_data, src_strides[0], src_indices[0], elem_size);
|
|
793
|
+
return true;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
else if (src_fabricarray)
|
|
797
|
+
{
|
|
798
|
+
// copy from fabric
|
|
799
|
+
size_t n = src_fabricarray->size;
|
|
800
|
+
if (size_t(dst_shape[0]) != n)
|
|
801
|
+
{
|
|
802
|
+
fprintf(stderr, "Warp copy error: Incompatible array sizes\n");
|
|
803
|
+
return false;
|
|
804
|
+
}
|
|
805
|
+
array_copy_from_fabric(*src_fabricarray, dst_data, dst_strides[0], dst_indices[0], elem_size);
|
|
806
|
+
return true;
|
|
807
|
+
}
|
|
808
|
+
else if (src_indexedfabricarray)
|
|
809
|
+
{
|
|
810
|
+
// copy from fabric indexed
|
|
811
|
+
size_t n = src_indexedfabricarray->size;
|
|
812
|
+
if (size_t(dst_shape[0]) != n)
|
|
813
|
+
{
|
|
814
|
+
fprintf(stderr, "Warp copy error: Incompatible array sizes\n");
|
|
815
|
+
return false;
|
|
816
|
+
}
|
|
817
|
+
array_copy_from_fabric_indexed(*src_indexedfabricarray, dst_data, dst_strides[0], dst_indices[0], elem_size);
|
|
818
|
+
return true;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
for (int i = 0; i < src_ndim; i++)
|
|
822
|
+
{
|
|
823
|
+
if (src_shape[i] != dst_shape[i])
|
|
824
|
+
{
|
|
825
|
+
fprintf(stderr, "Warp copy error: Incompatible array shapes\n");
|
|
826
|
+
return 0;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
array_copy_nd(dst_data, src_data,
|
|
831
|
+
dst_strides, src_strides,
|
|
832
|
+
dst_indices, src_indices,
|
|
833
|
+
src_shape, src_ndim, elem_size);
|
|
834
|
+
|
|
835
|
+
return true;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
static void array_fill_strided(void* data, const int* shape, const int* strides, int ndim, const void* value, size_t value_size)
|
|
840
|
+
{
|
|
841
|
+
size_t stride = strides[0];
|
|
842
|
+
if (ndim == 1)
|
|
843
|
+
{
|
|
844
|
+
char* p = (char*)data;
|
|
845
|
+
for (int i = 0; i < shape[0]; i++)
|
|
846
|
+
{
|
|
847
|
+
memcpy(p, value, value_size);
|
|
848
|
+
p += stride;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
else
|
|
852
|
+
{
|
|
853
|
+
for (int i = 0; i < shape[0]; i++)
|
|
854
|
+
{
|
|
855
|
+
char* p = (char*)data + i * stride;
|
|
856
|
+
// recurse on next inner dimension
|
|
857
|
+
array_fill_strided(p, shape + 1, strides + 1, ndim - 1, value, value_size);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
static void array_fill_indexed(void* data, const int* shape, const int* strides, const int*const* indices, int ndim, const void* value, size_t value_size)
|
|
864
|
+
{
|
|
865
|
+
size_t stride = strides[0];
|
|
866
|
+
if (ndim == 1)
|
|
867
|
+
{
|
|
868
|
+
for (int i = 0; i < shape[0]; i++)
|
|
869
|
+
{
|
|
870
|
+
size_t idx = indices[0] ? indices[0][i] : i;
|
|
871
|
+
char* p = (char*)data + idx * stride;
|
|
872
|
+
memcpy(p, value, value_size);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
else
|
|
876
|
+
{
|
|
877
|
+
for (int i = 0; i < shape[0]; i++)
|
|
878
|
+
{
|
|
879
|
+
size_t idx = indices[0] ? indices[0][i] : i;
|
|
880
|
+
char* p = (char*)data + idx * stride;
|
|
881
|
+
// recurse on next inner dimension
|
|
882
|
+
array_fill_indexed(p, shape + 1, strides + 1, indices + 1, ndim - 1, value, value_size);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
static void array_fill_fabric(wp::fabricarray_t<void>& fa, const void* value_ptr, size_t value_size)
|
|
889
|
+
{
|
|
890
|
+
for (size_t i = 0; i < fa.nbuckets; i++)
|
|
891
|
+
{
|
|
892
|
+
const wp::fabricbucket_t& bucket = fa.buckets[i];
|
|
893
|
+
size_t bucket_size = bucket.index_end - bucket.index_start;
|
|
894
|
+
wp_memtile_host(bucket.ptr, value_ptr, value_size, bucket_size);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
static void array_fill_fabric_indexed(wp::indexedfabricarray_t<void>& ifa, const void* value_ptr, size_t value_size)
|
|
900
|
+
{
|
|
901
|
+
for (size_t i = 0; i < ifa.size; i++)
|
|
902
|
+
{
|
|
903
|
+
size_t idx = size_t(ifa.indices[i]);
|
|
904
|
+
if (idx < ifa.fa.size)
|
|
905
|
+
{
|
|
906
|
+
void* p = fabricarray_element_ptr(ifa.fa, idx, value_size);
|
|
907
|
+
memcpy(p, value_ptr, value_size);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
WP_API void wp_array_fill_host(void* arr_ptr, int arr_type, const void* value_ptr, int value_size)
|
|
914
|
+
{
|
|
915
|
+
if (!arr_ptr || !value_ptr)
|
|
916
|
+
return;
|
|
917
|
+
|
|
918
|
+
if (arr_type == wp::ARRAY_TYPE_REGULAR)
|
|
919
|
+
{
|
|
920
|
+
wp::array_t<void>& arr = *static_cast<wp::array_t<void>*>(arr_ptr);
|
|
921
|
+
array_fill_strided(arr.data, arr.shape.dims, arr.strides, arr.ndim, value_ptr, value_size);
|
|
922
|
+
}
|
|
923
|
+
else if (arr_type == wp::ARRAY_TYPE_INDEXED)
|
|
924
|
+
{
|
|
925
|
+
wp::indexedarray_t<void>& ia = *static_cast<wp::indexedarray_t<void>*>(arr_ptr);
|
|
926
|
+
array_fill_indexed(ia.arr.data, ia.shape.dims, ia.arr.strides, ia.indices, ia.arr.ndim, value_ptr, value_size);
|
|
927
|
+
}
|
|
928
|
+
else if (arr_type == wp::ARRAY_TYPE_FABRIC)
|
|
929
|
+
{
|
|
930
|
+
wp::fabricarray_t<void>& fa = *static_cast<wp::fabricarray_t<void>*>(arr_ptr);
|
|
931
|
+
array_fill_fabric(fa, value_ptr, value_size);
|
|
932
|
+
}
|
|
933
|
+
else if (arr_type == wp::ARRAY_TYPE_FABRIC_INDEXED)
|
|
934
|
+
{
|
|
935
|
+
wp::indexedfabricarray_t<void>& ifa = *static_cast<wp::indexedfabricarray_t<void>*>(arr_ptr);
|
|
936
|
+
array_fill_fabric_indexed(ifa, value_ptr, value_size);
|
|
937
|
+
}
|
|
938
|
+
else
|
|
939
|
+
{
|
|
940
|
+
fprintf(stderr, "Warp fill error: Invalid array type id %d\n", arr_type);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
// impl. files
|
|
946
|
+
// TODO: compile as separate translation units
|
|
947
|
+
#include "bvh.cpp"
|
|
948
|
+
#include "scan.cpp"
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
// stubs for platforms where there is no CUDA
|
|
952
|
+
#if !WP_ENABLE_CUDA
|
|
953
|
+
|
|
954
|
+
void* wp_alloc_pinned(size_t s)
|
|
955
|
+
{
|
|
956
|
+
// CUDA is not available, fall back on system allocator
|
|
957
|
+
return wp_alloc_host(s);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
void wp_free_pinned(void* ptr)
|
|
961
|
+
{
|
|
962
|
+
// CUDA is not available, fall back on system allocator
|
|
963
|
+
wp_free_host(ptr);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
void* wp_alloc_device(void* context, size_t s)
|
|
967
|
+
{
|
|
968
|
+
return NULL;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
void* wp_alloc_device_default(void* context, size_t s)
|
|
972
|
+
{
|
|
973
|
+
return NULL;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
void* wp_alloc_device_async(void* context, size_t s)
|
|
977
|
+
{
|
|
978
|
+
return NULL;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
void wp_free_device(void* context, void* ptr)
|
|
982
|
+
{
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
void wp_free_device_default(void* context, void* ptr)
|
|
986
|
+
{
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
void wp_free_device_async(void* context, void* ptr)
|
|
990
|
+
{
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
bool wp_memcpy_h2d(void* context, void* dest, void* src, size_t n, void* stream)
|
|
994
|
+
{
|
|
995
|
+
return false;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
bool wp_memcpy_d2h(void* context, void* dest, void* src, size_t n, void* stream)
|
|
999
|
+
{
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
bool wp_memcpy_d2d(void* context, void* dest, void* src, size_t n, void* stream)
|
|
1004
|
+
{
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
bool wp_memcpy_p2p(void* dst_context, void* dst, void* src_context, void* src, size_t n, void* stream)
|
|
1009
|
+
{
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
void wp_memset_device(void* context, void* dest, int value, size_t n)
|
|
1014
|
+
{
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
void wp_memtile_device(void* context, void* dest, const void* src, size_t srcsize, size_t n)
|
|
1018
|
+
{
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
bool wp_array_copy_device(void* context, void* dst, void* src, int dst_type, int src_type, int elem_size)
|
|
1022
|
+
{
|
|
1023
|
+
return false;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
void wp_array_fill_device(void* context, void* arr, int arr_type, const void* value, int value_size)
|
|
1027
|
+
{
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
WP_API int wp_cuda_driver_version() { return 0; }
|
|
1031
|
+
WP_API int wp_cuda_toolkit_version() { return 0; }
|
|
1032
|
+
|
|
1033
|
+
WP_API bool wp_cuda_driver_is_initialized() { return false; }
|
|
1034
|
+
|
|
1035
|
+
WP_API int wp_nvrtc_supported_arch_count() { return 0; }
|
|
1036
|
+
WP_API void wp_nvrtc_supported_archs(int* archs) {}
|
|
1037
|
+
|
|
1038
|
+
WP_API int wp_cuda_device_get_count() { return 0; }
|
|
1039
|
+
WP_API void* wp_cuda_device_get_primary_context(int ordinal) { return NULL; }
|
|
1040
|
+
WP_API const char* wp_cuda_device_get_name(int ordinal) { return NULL; }
|
|
1041
|
+
WP_API int wp_cuda_device_get_arch(int ordinal) { return 0; }
|
|
1042
|
+
WP_API int wp_cuda_device_get_sm_count(int ordinal) { return 0; }
|
|
1043
|
+
WP_API void wp_cuda_device_get_uuid(int ordinal, char uuid[16]) {}
|
|
1044
|
+
WP_API int wp_cuda_device_get_pci_domain_id(int ordinal) { return -1; }
|
|
1045
|
+
WP_API int wp_cuda_device_get_pci_bus_id(int ordinal) { return -1; }
|
|
1046
|
+
WP_API int wp_cuda_device_get_pci_device_id(int ordinal) { return -1; }
|
|
1047
|
+
WP_API int wp_cuda_device_is_uva(int ordinal) { return 0; }
|
|
1048
|
+
WP_API int wp_cuda_device_is_mempool_supported(int ordinal) { return 0; }
|
|
1049
|
+
WP_API int wp_cuda_device_is_ipc_supported(int ordinal) { return 0; }
|
|
1050
|
+
WP_API int wp_cuda_device_set_mempool_release_threshold(int ordinal, uint64_t threshold) { return 0; }
|
|
1051
|
+
WP_API uint64_t wp_cuda_device_get_mempool_release_threshold(int ordinal) { return 0; }
|
|
1052
|
+
WP_API uint64_t wp_cuda_device_get_mempool_used_mem_current(int ordinal) { return 0; }
|
|
1053
|
+
WP_API uint64_t wp_cuda_device_get_mempool_used_mem_high(int ordinal) { return 0; }
|
|
1054
|
+
WP_API void wp_cuda_device_get_memory_info(int ordinal, size_t* free_mem, size_t* total_mem) {}
|
|
1055
|
+
|
|
1056
|
+
WP_API void* wp_cuda_context_get_current() { return NULL; }
|
|
1057
|
+
WP_API void wp_cuda_context_set_current(void* ctx) {}
|
|
1058
|
+
WP_API void wp_cuda_context_push_current(void* context) {}
|
|
1059
|
+
WP_API void wp_cuda_context_pop_current() {}
|
|
1060
|
+
WP_API void* wp_cuda_context_create(int device_ordinal) { return NULL; }
|
|
1061
|
+
WP_API void wp_cuda_context_destroy(void* context) {}
|
|
1062
|
+
WP_API void wp_cuda_context_synchronize(void* context) {}
|
|
1063
|
+
WP_API uint64_t wp_cuda_context_check(void* context) { return 0; }
|
|
1064
|
+
WP_API int wp_cuda_context_get_device_ordinal(void* context) { return -1; }
|
|
1065
|
+
WP_API int wp_cuda_context_is_primary(void* context) { return 0; }
|
|
1066
|
+
WP_API void* wp_cuda_context_get_stream(void* context) { return NULL; }
|
|
1067
|
+
WP_API void wp_cuda_context_set_stream(void* context, void* stream, int sync) {}
|
|
1068
|
+
|
|
1069
|
+
WP_API int wp_cuda_is_peer_access_supported(int target_ordinal, int peer_ordinal) { return 0; }
|
|
1070
|
+
WP_API int wp_cuda_is_peer_access_enabled(void* target_context, void* peer_context) { return 0; }
|
|
1071
|
+
WP_API int wp_cuda_set_peer_access_enabled(void* target_context, void* peer_context, int enable) { return 0; }
|
|
1072
|
+
WP_API int wp_cuda_is_mempool_access_enabled(int target_ordinal, int peer_ordinal) { return 0; }
|
|
1073
|
+
WP_API int wp_cuda_set_mempool_access_enabled(int target_ordinal, int peer_ordinal, int enable) { return 0; }
|
|
1074
|
+
|
|
1075
|
+
WP_API void wp_cuda_ipc_get_mem_handle(void* ptr, char* out_buffer) {}
|
|
1076
|
+
WP_API void* wp_cuda_ipc_open_mem_handle(void* context, char* handle) { return NULL; }
|
|
1077
|
+
WP_API void wp_cuda_ipc_close_mem_handle(void* ptr) {}
|
|
1078
|
+
WP_API void wp_cuda_ipc_get_event_handle(void* context, void* event, char* out_buffer) {}
|
|
1079
|
+
WP_API void* wp_cuda_ipc_open_event_handle(void* context, char* handle) { return NULL; }
|
|
1080
|
+
|
|
1081
|
+
WP_API void* wp_cuda_stream_create(void* context, int priority) { return NULL; }
|
|
1082
|
+
WP_API void wp_cuda_stream_destroy(void* context, void* stream) {}
|
|
1083
|
+
WP_API int wp_cuda_stream_query(void* stream) { return 0; }
|
|
1084
|
+
WP_API void wp_cuda_stream_register(void* context, void* stream) {}
|
|
1085
|
+
WP_API void wp_cuda_stream_unregister(void* context, void* stream) {}
|
|
1086
|
+
WP_API void* wp_cuda_stream_get_current() { return NULL; }
|
|
1087
|
+
WP_API void wp_cuda_stream_synchronize(void* stream) {}
|
|
1088
|
+
WP_API void wp_cuda_stream_wait_event(void* stream, void* event, bool external) {}
|
|
1089
|
+
WP_API void wp_cuda_stream_wait_stream(void* stream, void* other_stream, void* event, bool external) {}
|
|
1090
|
+
WP_API int wp_cuda_stream_is_capturing(void* stream) { return 0; }
|
|
1091
|
+
WP_API uint64_t wp_cuda_stream_get_capture_id(void* stream) { return 0; }
|
|
1092
|
+
WP_API int wp_cuda_stream_get_priority(void* stream) { return 0; }
|
|
1093
|
+
|
|
1094
|
+
WP_API void* wp_cuda_event_create(void* context, unsigned flags) { return NULL; }
|
|
1095
|
+
WP_API void wp_cuda_event_destroy(void* event) {}
|
|
1096
|
+
WP_API int wp_cuda_event_query(void* event) { return 0; }
|
|
1097
|
+
WP_API void wp_cuda_event_record(void* event, void* stream, bool external) {}
|
|
1098
|
+
WP_API void wp_cuda_event_synchronize(void* event) {}
|
|
1099
|
+
WP_API float wp_cuda_event_elapsed_time(void* start_event, void* end_event) { return 0.0f; }
|
|
1100
|
+
|
|
1101
|
+
WP_API bool wp_cuda_graph_begin_capture(void* context, void* stream, int external) { return false; }
|
|
1102
|
+
WP_API bool wp_cuda_graph_end_capture(void* context, void* stream, void** graph_ret) { return false; }
|
|
1103
|
+
WP_API bool wp_cuda_graph_create_exec(void* context, void* stream, void* graph, void** graph_exec_ret) { return false; }
|
|
1104
|
+
WP_API bool wp_cuda_graph_launch(void* graph, void* stream) { return false; }
|
|
1105
|
+
WP_API bool wp_cuda_graph_destroy(void* context, void* graph) { return false; }
|
|
1106
|
+
WP_API bool wp_cuda_graph_exec_destroy(void* context, void* graph_exec) { return false; }
|
|
1107
|
+
WP_API bool wp_capture_debug_dot_print(void* graph, const char *path, uint32_t flags) { return false; }
|
|
1108
|
+
|
|
1109
|
+
WP_API bool wp_cuda_graph_insert_if_else(void* context, void* stream, int arch, bool use_ptx, int* condition, void** if_graph_ret, void** else_graph_ret) { return false; }
|
|
1110
|
+
WP_API bool wp_cuda_graph_insert_while(void* context, void* stream, int arch, bool use_ptx, int* condition, void** body_graph_ret, uint64_t* handle_ret) { return false; }
|
|
1111
|
+
WP_API bool wp_cuda_graph_set_condition(void* context, void* stream, int arch, bool use_ptx, int* condition, uint64_t handle) { return false; }
|
|
1112
|
+
WP_API bool wp_cuda_graph_pause_capture(void* context, void* stream, void** graph_ret) { return false; }
|
|
1113
|
+
WP_API bool wp_cuda_graph_resume_capture(void* context, void* stream, void* graph) { return false; }
|
|
1114
|
+
WP_API bool wp_cuda_graph_insert_child_graph(void* context, void* stream, void* child_graph) { return false; }
|
|
1115
|
+
WP_API bool wp_cuda_graph_check_conditional_body(void* body_graph) { return false; }
|
|
1116
|
+
|
|
1117
|
+
WP_API size_t wp_cuda_compile_program(const char* cuda_src, const char* program_name, int arch, const char* include_dir, int num_cuda_include_dirs, const char** cuda_include_dirs, bool debug, bool verbose, bool verify_fp, bool fast_math, bool fuse_fp, bool lineinfo, bool compile_time_trace, const char* output_path, size_t num_ltoirs, char** ltoirs, size_t* ltoir_sizes, int* ltoir_input_types) { return 0; }
|
|
1118
|
+
|
|
1119
|
+
WP_API void* wp_cuda_load_module(void* context, const char* ptx) { return NULL; }
|
|
1120
|
+
WP_API void wp_cuda_unload_module(void* context, void* module) {}
|
|
1121
|
+
WP_API void* wp_cuda_get_kernel(void* context, void* module, const char* name) { return NULL; }
|
|
1122
|
+
WP_API size_t wp_cuda_launch_kernel(void* context, void* kernel, size_t dim, int max_blocks, int block_dim, int shared_memory_bytes, void** args, void* stream) { return 0; }
|
|
1123
|
+
|
|
1124
|
+
WP_API int wp_cuda_get_max_shared_memory(void* context) { return 0; }
|
|
1125
|
+
WP_API bool wp_cuda_configure_kernel_shared_memory(void* kernel, int size) { return false; }
|
|
1126
|
+
|
|
1127
|
+
WP_API void wp_cuda_set_context_restore_policy(bool always_restore) {}
|
|
1128
|
+
WP_API int wp_cuda_get_context_restore_policy() { return false; }
|
|
1129
|
+
|
|
1130
|
+
WP_API void wp_array_scan_int_device(uint64_t in, uint64_t out, int len, bool inclusive) {}
|
|
1131
|
+
WP_API void wp_array_scan_float_device(uint64_t in, uint64_t out, int len, bool inclusive) {}
|
|
1132
|
+
|
|
1133
|
+
WP_API void wp_cuda_graphics_map(void* context, void* resource) {}
|
|
1134
|
+
WP_API void wp_cuda_graphics_unmap(void* context, void* resource) {}
|
|
1135
|
+
WP_API void wp_cuda_graphics_device_ptr_and_size(void* context, void* resource, uint64_t* ptr, size_t* size) {}
|
|
1136
|
+
WP_API void* wp_cuda_graphics_register_gl_buffer(void* context, uint32_t gl_buffer, unsigned int flags) { return NULL; }
|
|
1137
|
+
WP_API void wp_cuda_graphics_unregister_resource(void* context, void* resource) {}
|
|
1138
|
+
|
|
1139
|
+
WP_API void wp_cuda_timing_begin(int flags) {}
|
|
1140
|
+
WP_API int wp_cuda_timing_get_result_count() { return 0; }
|
|
1141
|
+
WP_API void wp_cuda_timing_end(timing_result_t* results, int size) {}
|
|
1142
|
+
|
|
1143
|
+
#endif // !WP_ENABLE_CUDA
|