warp-lang 1.0.0b5__py3-none-manylinux2014_x86_64.whl → 1.0.0b6__py3-none-manylinux2014_x86_64.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.
- docs/conf.py +3 -4
- examples/env/env_ant.py +1 -1
- examples/env/env_cartpole.py +1 -1
- examples/env/env_humanoid.py +1 -1
- examples/example_dem.py +28 -26
- examples/example_diffray.py +37 -30
- examples/example_fluid.py +7 -3
- examples/example_jacobian_ik.py +1 -1
- examples/example_mesh_intersect.py +10 -7
- examples/example_nvdb.py +3 -3
- examples/example_render_opengl.py +19 -10
- examples/example_sim_cartpole.py +9 -5
- examples/example_sim_cloth.py +29 -25
- examples/example_sim_fk_grad.py +2 -2
- examples/example_sim_fk_grad_torch.py +3 -3
- examples/example_sim_grad_bounce.py +11 -8
- examples/example_sim_grad_cloth.py +12 -9
- examples/example_sim_granular.py +2 -2
- examples/example_sim_granular_collision_sdf.py +13 -13
- examples/example_sim_neo_hookean.py +3 -3
- examples/example_sim_particle_chain.py +2 -2
- examples/example_sim_quadruped.py +8 -5
- examples/example_sim_rigid_chain.py +8 -5
- examples/example_sim_rigid_contact.py +13 -10
- examples/example_sim_rigid_fem.py +2 -2
- examples/example_sim_rigid_gyroscopic.py +2 -2
- examples/example_sim_rigid_kinematics.py +1 -1
- examples/example_sim_trajopt.py +3 -2
- examples/fem/example_apic_fluid.py +5 -7
- examples/fem/example_diffusion_mgpu.py +18 -16
- warp/__init__.py +3 -2
- warp/bin/warp.so +0 -0
- warp/build_dll.py +29 -9
- warp/builtins.py +206 -7
- warp/codegen.py +58 -38
- warp/config.py +3 -1
- warp/context.py +234 -128
- warp/fem/__init__.py +2 -2
- warp/fem/cache.py +2 -1
- warp/fem/field/nodal_field.py +18 -17
- warp/fem/geometry/hexmesh.py +11 -6
- warp/fem/geometry/quadmesh_2d.py +16 -12
- warp/fem/geometry/tetmesh.py +19 -8
- warp/fem/geometry/trimesh_2d.py +18 -7
- warp/fem/integrate.py +341 -196
- warp/fem/quadrature/__init__.py +1 -1
- warp/fem/quadrature/pic_quadrature.py +138 -53
- warp/fem/quadrature/quadrature.py +81 -9
- warp/fem/space/__init__.py +1 -1
- warp/fem/space/basis_space.py +169 -51
- warp/fem/space/grid_2d_function_space.py +2 -2
- warp/fem/space/grid_3d_function_space.py +2 -2
- warp/fem/space/hexmesh_function_space.py +2 -2
- warp/fem/space/partition.py +9 -6
- warp/fem/space/quadmesh_2d_function_space.py +2 -2
- warp/fem/space/shape/cube_shape_function.py +27 -15
- warp/fem/space/shape/square_shape_function.py +29 -18
- warp/fem/space/tetmesh_function_space.py +2 -2
- warp/fem/space/topology.py +10 -0
- warp/fem/space/trimesh_2d_function_space.py +2 -2
- warp/fem/utils.py +10 -5
- warp/native/array.h +49 -8
- warp/native/builtin.h +31 -14
- warp/native/cuda_util.cpp +8 -3
- warp/native/cuda_util.h +1 -0
- warp/native/exports.h +1177 -1108
- warp/native/intersect.h +4 -4
- warp/native/intersect_adj.h +8 -8
- warp/native/mat.h +65 -6
- warp/native/mesh.h +126 -5
- warp/native/quat.h +28 -4
- warp/native/vec.h +76 -14
- warp/native/warp.cu +1 -6
- warp/render/render_opengl.py +261 -109
- warp/sim/import_mjcf.py +13 -7
- warp/sim/import_urdf.py +14 -14
- warp/sim/inertia.py +17 -18
- warp/sim/model.py +67 -67
- warp/sim/render.py +1 -1
- warp/sparse.py +6 -6
- warp/stubs.py +19 -81
- warp/tape.py +1 -1
- warp/tests/__main__.py +3 -6
- warp/tests/{test_class_kernel.py → aux_test_class_kernel.py} +9 -1
- warp/tests/aux_test_conditional_unequal_types_kernels.py +21 -0
- warp/tests/{test_dependent.py → aux_test_dependent.py} +2 -2
- warp/tests/{test_reference.py → aux_test_reference.py} +1 -1
- warp/tests/aux_test_unresolved_func.py +14 -0
- warp/tests/aux_test_unresolved_symbol.py +14 -0
- warp/tests/{test_kinematics.py → disabled_kinematics.py} +10 -12
- warp/tests/run_coverage_serial.py +31 -0
- warp/tests/test_adam.py +102 -106
- warp/tests/test_arithmetic.py +39 -40
- warp/tests/test_array.py +46 -48
- warp/tests/test_array_reduce.py +25 -19
- warp/tests/test_atomic.py +62 -26
- warp/tests/test_bool.py +16 -11
- warp/tests/test_builtins_resolution.py +1292 -0
- warp/tests/test_bvh.py +9 -12
- warp/tests/test_closest_point_edge_edge.py +53 -57
- warp/tests/test_codegen.py +164 -134
- warp/tests/test_compile_consts.py +13 -19
- warp/tests/test_conditional.py +30 -32
- warp/tests/test_copy.py +9 -12
- warp/tests/test_ctypes.py +90 -98
- warp/tests/test_dense.py +20 -14
- warp/tests/test_devices.py +34 -35
- warp/tests/test_dlpack.py +74 -75
- warp/tests/test_examples.py +215 -97
- warp/tests/test_fabricarray.py +15 -21
- warp/tests/test_fast_math.py +14 -11
- warp/tests/test_fem.py +280 -97
- warp/tests/test_fp16.py +19 -15
- warp/tests/test_func.py +177 -194
- warp/tests/test_generics.py +71 -77
- warp/tests/test_grad.py +83 -32
- warp/tests/test_grad_customs.py +7 -9
- warp/tests/test_hash_grid.py +6 -10
- warp/tests/test_import.py +9 -23
- warp/tests/test_indexedarray.py +19 -21
- warp/tests/test_intersect.py +15 -9
- warp/tests/test_large.py +17 -19
- warp/tests/test_launch.py +14 -17
- warp/tests/test_lerp.py +63 -63
- warp/tests/test_lvalue.py +84 -35
- warp/tests/test_marching_cubes.py +9 -13
- warp/tests/test_mat.py +388 -3004
- warp/tests/test_mat_lite.py +9 -12
- warp/tests/test_mat_scalar_ops.py +2889 -0
- warp/tests/test_math.py +10 -11
- warp/tests/test_matmul.py +104 -100
- warp/tests/test_matmul_lite.py +72 -98
- warp/tests/test_mesh.py +35 -32
- warp/tests/test_mesh_query_aabb.py +18 -25
- warp/tests/test_mesh_query_point.py +39 -23
- warp/tests/test_mesh_query_ray.py +9 -21
- warp/tests/test_mlp.py +8 -9
- warp/tests/test_model.py +89 -93
- warp/tests/test_modules_lite.py +15 -25
- warp/tests/test_multigpu.py +87 -114
- warp/tests/test_noise.py +10 -12
- warp/tests/test_operators.py +14 -21
- warp/tests/test_options.py +10 -11
- warp/tests/test_pinned.py +16 -18
- warp/tests/test_print.py +16 -20
- warp/tests/test_quat.py +121 -88
- warp/tests/test_rand.py +12 -13
- warp/tests/test_reload.py +27 -32
- warp/tests/test_rounding.py +7 -10
- warp/tests/test_runlength_encode.py +105 -106
- warp/tests/test_smoothstep.py +8 -9
- warp/tests/test_snippet.py +13 -22
- warp/tests/test_sparse.py +30 -29
- warp/tests/test_spatial.py +179 -174
- warp/tests/test_streams.py +100 -107
- warp/tests/test_struct.py +98 -67
- warp/tests/test_tape.py +11 -17
- warp/tests/test_torch.py +89 -86
- warp/tests/test_transient_module.py +9 -12
- warp/tests/test_types.py +328 -50
- warp/tests/test_utils.py +217 -218
- warp/tests/test_vec.py +133 -2133
- warp/tests/test_vec_lite.py +8 -11
- warp/tests/test_vec_scalar_ops.py +2099 -0
- warp/tests/test_volume.py +391 -382
- warp/tests/test_volume_write.py +122 -135
- warp/tests/unittest_serial.py +35 -0
- warp/tests/unittest_suites.py +291 -0
- warp/tests/{test_base.py → unittest_utils.py} +138 -25
- warp/tests/{test_misc.py → unused_test_misc.py} +13 -5
- warp/tests/{test_debug.py → walkthough_debug.py} +2 -15
- warp/thirdparty/unittest_parallel.py +257 -54
- warp/types.py +119 -98
- warp/utils.py +14 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/METADATA +2 -1
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/RECORD +182 -178
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/WHEEL +1 -1
- warp/tests/test_all.py +0 -239
- warp/tests/test_conditional_unequal_types_kernels.py +0 -14
- warp/tests/test_coverage.py +0 -38
- warp/tests/test_unresolved_func.py +0 -7
- warp/tests/test_unresolved_symbol.py +0 -7
- /warp/tests/{test_compile_consts_dummy.py → aux_test_compile_consts_dummy.py} +0 -0
- /warp/tests/{test_reference_reference.py → aux_test_reference_reference.py} +0 -0
- /warp/tests/{test_square.py → aux_test_square.py} +0 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/top_level.txt +0 -0
warp/tests/test_spatial.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2023 NVIDIA CORPORATION. All rights reserved.
|
|
2
|
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
|
3
|
+
# and proprietary rights in and to this software, related documentation
|
|
4
|
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
|
5
|
+
# distribution of this software and related documentation without an express
|
|
6
|
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
|
+
|
|
1
8
|
import unittest
|
|
2
9
|
|
|
3
10
|
import numpy as np
|
|
4
11
|
|
|
5
12
|
import warp as wp
|
|
6
|
-
from warp.tests.
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
7
14
|
|
|
8
15
|
wp.init()
|
|
9
16
|
|
|
@@ -1956,188 +1963,186 @@ def test_transform_anon_type_instance(test, device, dtype, register_kernels=Fals
|
|
|
1956
1963
|
tape.zero()
|
|
1957
1964
|
|
|
1958
1965
|
|
|
1959
|
-
|
|
1960
|
-
devices = get_test_devices()
|
|
1966
|
+
devices = get_test_devices()
|
|
1961
1967
|
|
|
1962
|
-
class TestSpatial(parent):
|
|
1963
|
-
pass
|
|
1964
1968
|
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
TestSpatial,
|
|
1968
|
-
f"test_spatial_vector_constructors_{dtype.__name__}",
|
|
1969
|
-
test_spatial_vector_constructors,
|
|
1970
|
-
devices=devices,
|
|
1971
|
-
dtype=dtype,
|
|
1972
|
-
)
|
|
1973
|
-
add_function_test_register_kernel(
|
|
1974
|
-
TestSpatial,
|
|
1975
|
-
f"test_spatial_vector_indexing_{dtype.__name__}",
|
|
1976
|
-
test_spatial_vector_indexing,
|
|
1977
|
-
devices=devices,
|
|
1978
|
-
dtype=dtype,
|
|
1979
|
-
)
|
|
1980
|
-
add_function_test_register_kernel(
|
|
1981
|
-
TestSpatial,
|
|
1982
|
-
f"test_spatial_vector_scalar_multiplication_{dtype.__name__}",
|
|
1983
|
-
test_spatial_vector_scalar_multiplication,
|
|
1984
|
-
devices=devices,
|
|
1985
|
-
dtype=dtype,
|
|
1986
|
-
)
|
|
1987
|
-
add_function_test_register_kernel(
|
|
1988
|
-
TestSpatial,
|
|
1989
|
-
f"test_spatial_vector_add_sub_{dtype.__name__}",
|
|
1990
|
-
test_spatial_vector_add_sub,
|
|
1991
|
-
devices=devices,
|
|
1992
|
-
dtype=dtype,
|
|
1993
|
-
)
|
|
1994
|
-
add_function_test_register_kernel(
|
|
1995
|
-
TestSpatial, f"test_spatial_dot_{dtype.__name__}", test_spatial_dot, devices=devices, dtype=dtype
|
|
1996
|
-
)
|
|
1997
|
-
add_function_test_register_kernel(
|
|
1998
|
-
TestSpatial, f"test_spatial_cross_{dtype.__name__}", test_spatial_cross, devices=devices, dtype=dtype
|
|
1999
|
-
)
|
|
2000
|
-
add_function_test_register_kernel(
|
|
2001
|
-
TestSpatial,
|
|
2002
|
-
f"test_spatial_top_bottom_{dtype.__name__}",
|
|
2003
|
-
test_spatial_top_bottom,
|
|
2004
|
-
devices=devices,
|
|
2005
|
-
dtype=dtype,
|
|
2006
|
-
)
|
|
1969
|
+
class TestSpatial(unittest.TestCase):
|
|
1970
|
+
pass
|
|
2007
1971
|
|
|
2008
|
-
add_function_test_register_kernel(
|
|
2009
|
-
TestSpatial,
|
|
2010
|
-
f"test_transform_constructors_{dtype.__name__}",
|
|
2011
|
-
test_transform_constructors,
|
|
2012
|
-
devices=devices,
|
|
2013
|
-
dtype=dtype,
|
|
2014
|
-
)
|
|
2015
|
-
add_function_test_register_kernel(
|
|
2016
|
-
TestSpatial,
|
|
2017
|
-
f"test_transform_anon_type_instance_{dtype.__name__}",
|
|
2018
|
-
test_transform_anon_type_instance,
|
|
2019
|
-
devices=devices,
|
|
2020
|
-
dtype=dtype,
|
|
2021
|
-
)
|
|
2022
|
-
add_function_test_register_kernel(
|
|
2023
|
-
TestSpatial,
|
|
2024
|
-
f"test_transform_identity_{dtype.__name__}",
|
|
2025
|
-
test_transform_identity,
|
|
2026
|
-
devices=devices,
|
|
2027
|
-
dtype=dtype,
|
|
2028
|
-
)
|
|
2029
|
-
add_function_test_register_kernel(
|
|
2030
|
-
TestSpatial,
|
|
2031
|
-
f"test_transform_indexing_{dtype.__name__}",
|
|
2032
|
-
test_transform_indexing,
|
|
2033
|
-
devices=devices,
|
|
2034
|
-
dtype=dtype,
|
|
2035
|
-
)
|
|
2036
|
-
add_function_test_register_kernel(
|
|
2037
|
-
TestSpatial,
|
|
2038
|
-
f"test_transform_get_trans_rot_{dtype.__name__}",
|
|
2039
|
-
test_transform_get_trans_rot,
|
|
2040
|
-
devices=devices,
|
|
2041
|
-
dtype=dtype,
|
|
2042
|
-
)
|
|
2043
|
-
add_function_test_register_kernel(
|
|
2044
|
-
TestSpatial,
|
|
2045
|
-
f"test_transform_multiply_{dtype.__name__}",
|
|
2046
|
-
test_transform_multiply,
|
|
2047
|
-
devices=devices,
|
|
2048
|
-
dtype=dtype,
|
|
2049
|
-
)
|
|
2050
|
-
add_function_test_register_kernel(
|
|
2051
|
-
TestSpatial,
|
|
2052
|
-
f"test_transform_inverse_{dtype.__name__}",
|
|
2053
|
-
test_transform_inverse,
|
|
2054
|
-
devices=devices,
|
|
2055
|
-
dtype=dtype,
|
|
2056
|
-
)
|
|
2057
|
-
add_function_test_register_kernel(
|
|
2058
|
-
TestSpatial,
|
|
2059
|
-
f"test_transform_point_vector_{dtype.__name__}",
|
|
2060
|
-
test_transform_point_vector,
|
|
2061
|
-
devices=devices,
|
|
2062
|
-
dtype=dtype,
|
|
2063
|
-
)
|
|
2064
1972
|
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
1973
|
+
for dtype in np_float_types:
|
|
1974
|
+
add_function_test_register_kernel(
|
|
1975
|
+
TestSpatial,
|
|
1976
|
+
f"test_spatial_vector_constructors_{dtype.__name__}",
|
|
1977
|
+
test_spatial_vector_constructors,
|
|
1978
|
+
devices=devices,
|
|
1979
|
+
dtype=dtype,
|
|
1980
|
+
)
|
|
1981
|
+
add_function_test_register_kernel(
|
|
1982
|
+
TestSpatial,
|
|
1983
|
+
f"test_spatial_vector_indexing_{dtype.__name__}",
|
|
1984
|
+
test_spatial_vector_indexing,
|
|
1985
|
+
devices=devices,
|
|
1986
|
+
dtype=dtype,
|
|
1987
|
+
)
|
|
1988
|
+
add_function_test_register_kernel(
|
|
1989
|
+
TestSpatial,
|
|
1990
|
+
f"test_spatial_vector_scalar_multiplication_{dtype.__name__}",
|
|
1991
|
+
test_spatial_vector_scalar_multiplication,
|
|
1992
|
+
devices=devices,
|
|
1993
|
+
dtype=dtype,
|
|
1994
|
+
)
|
|
1995
|
+
add_function_test_register_kernel(
|
|
1996
|
+
TestSpatial,
|
|
1997
|
+
f"test_spatial_vector_add_sub_{dtype.__name__}",
|
|
1998
|
+
test_spatial_vector_add_sub,
|
|
1999
|
+
devices=devices,
|
|
2000
|
+
dtype=dtype,
|
|
2001
|
+
)
|
|
2002
|
+
add_function_test_register_kernel(
|
|
2003
|
+
TestSpatial, f"test_spatial_dot_{dtype.__name__}", test_spatial_dot, devices=devices, dtype=dtype
|
|
2004
|
+
)
|
|
2005
|
+
add_function_test_register_kernel(
|
|
2006
|
+
TestSpatial, f"test_spatial_cross_{dtype.__name__}", test_spatial_cross, devices=devices, dtype=dtype
|
|
2007
|
+
)
|
|
2008
|
+
add_function_test_register_kernel(
|
|
2009
|
+
TestSpatial,
|
|
2010
|
+
f"test_spatial_top_bottom_{dtype.__name__}",
|
|
2011
|
+
test_spatial_top_bottom,
|
|
2012
|
+
devices=devices,
|
|
2013
|
+
dtype=dtype,
|
|
2014
|
+
)
|
|
2081
2015
|
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2016
|
+
add_function_test_register_kernel(
|
|
2017
|
+
TestSpatial,
|
|
2018
|
+
f"test_transform_constructors_{dtype.__name__}",
|
|
2019
|
+
test_transform_constructors,
|
|
2020
|
+
devices=devices,
|
|
2021
|
+
dtype=dtype,
|
|
2022
|
+
)
|
|
2023
|
+
add_function_test_register_kernel(
|
|
2024
|
+
TestSpatial,
|
|
2025
|
+
f"test_transform_anon_type_instance_{dtype.__name__}",
|
|
2026
|
+
test_transform_anon_type_instance,
|
|
2027
|
+
devices=devices,
|
|
2028
|
+
dtype=dtype,
|
|
2029
|
+
)
|
|
2030
|
+
add_function_test_register_kernel(
|
|
2031
|
+
TestSpatial,
|
|
2032
|
+
f"test_transform_identity_{dtype.__name__}",
|
|
2033
|
+
test_transform_identity,
|
|
2034
|
+
devices=devices,
|
|
2035
|
+
dtype=dtype,
|
|
2036
|
+
)
|
|
2037
|
+
add_function_test_register_kernel(
|
|
2038
|
+
TestSpatial,
|
|
2039
|
+
f"test_transform_indexing_{dtype.__name__}",
|
|
2040
|
+
test_transform_indexing,
|
|
2041
|
+
devices=devices,
|
|
2042
|
+
dtype=dtype,
|
|
2043
|
+
)
|
|
2044
|
+
add_function_test_register_kernel(
|
|
2045
|
+
TestSpatial,
|
|
2046
|
+
f"test_transform_get_trans_rot_{dtype.__name__}",
|
|
2047
|
+
test_transform_get_trans_rot,
|
|
2048
|
+
devices=devices,
|
|
2049
|
+
dtype=dtype,
|
|
2050
|
+
)
|
|
2051
|
+
add_function_test_register_kernel(
|
|
2052
|
+
TestSpatial,
|
|
2053
|
+
f"test_transform_multiply_{dtype.__name__}",
|
|
2054
|
+
test_transform_multiply,
|
|
2055
|
+
devices=devices,
|
|
2056
|
+
dtype=dtype,
|
|
2057
|
+
)
|
|
2058
|
+
add_function_test_register_kernel(
|
|
2059
|
+
TestSpatial,
|
|
2060
|
+
f"test_transform_inverse_{dtype.__name__}",
|
|
2061
|
+
test_transform_inverse,
|
|
2062
|
+
devices=devices,
|
|
2063
|
+
dtype=dtype,
|
|
2064
|
+
)
|
|
2065
|
+
add_function_test_register_kernel(
|
|
2066
|
+
TestSpatial,
|
|
2067
|
+
f"test_transform_point_vector_{dtype.__name__}",
|
|
2068
|
+
test_transform_point_vector,
|
|
2069
|
+
devices=devices,
|
|
2070
|
+
dtype=dtype,
|
|
2071
|
+
)
|
|
2134
2072
|
|
|
2135
|
-
|
|
2073
|
+
# are these two valid? They don't seem to be doing things you'd want to do,
|
|
2074
|
+
# maybe they should be removed
|
|
2075
|
+
add_function_test_register_kernel(
|
|
2076
|
+
TestSpatial,
|
|
2077
|
+
f"test_transform_scalar_multiplication_{dtype.__name__}",
|
|
2078
|
+
test_transform_scalar_multiplication,
|
|
2079
|
+
devices=devices,
|
|
2080
|
+
dtype=dtype,
|
|
2081
|
+
)
|
|
2082
|
+
add_function_test_register_kernel(
|
|
2083
|
+
TestSpatial,
|
|
2084
|
+
f"test_transform_add_sub_{dtype.__name__}",
|
|
2085
|
+
test_transform_add_sub,
|
|
2086
|
+
devices=devices,
|
|
2087
|
+
dtype=dtype,
|
|
2088
|
+
)
|
|
2089
|
+
|
|
2090
|
+
add_function_test_register_kernel(
|
|
2091
|
+
TestSpatial,
|
|
2092
|
+
f"test_spatial_matrix_constructors_{dtype.__name__}",
|
|
2093
|
+
test_spatial_matrix_constructors,
|
|
2094
|
+
devices=devices,
|
|
2095
|
+
dtype=dtype,
|
|
2096
|
+
)
|
|
2097
|
+
add_function_test_register_kernel(
|
|
2098
|
+
TestSpatial,
|
|
2099
|
+
f"test_spatial_matrix_indexing_{dtype.__name__}",
|
|
2100
|
+
test_spatial_matrix_indexing,
|
|
2101
|
+
devices=devices,
|
|
2102
|
+
dtype=dtype,
|
|
2103
|
+
)
|
|
2104
|
+
add_function_test_register_kernel(
|
|
2105
|
+
TestSpatial,
|
|
2106
|
+
f"test_spatial_matrix_scalar_multiplication_{dtype.__name__}",
|
|
2107
|
+
test_spatial_matrix_scalar_multiplication,
|
|
2108
|
+
devices=devices,
|
|
2109
|
+
dtype=dtype,
|
|
2110
|
+
)
|
|
2111
|
+
add_function_test_register_kernel(
|
|
2112
|
+
TestSpatial,
|
|
2113
|
+
f"test_spatial_matrix_add_sub_{dtype.__name__}",
|
|
2114
|
+
test_spatial_matrix_add_sub,
|
|
2115
|
+
devices=devices,
|
|
2116
|
+
dtype=dtype,
|
|
2117
|
+
)
|
|
2118
|
+
add_function_test_register_kernel(
|
|
2119
|
+
TestSpatial,
|
|
2120
|
+
f"test_spatial_matvec_multiplication_{dtype.__name__}",
|
|
2121
|
+
test_spatial_matvec_multiplication,
|
|
2122
|
+
devices=devices,
|
|
2123
|
+
dtype=dtype,
|
|
2124
|
+
)
|
|
2125
|
+
add_function_test_register_kernel(
|
|
2126
|
+
TestSpatial,
|
|
2127
|
+
f"test_spatial_matmat_multiplication_{dtype.__name__}",
|
|
2128
|
+
test_spatial_matmat_multiplication,
|
|
2129
|
+
devices=devices,
|
|
2130
|
+
dtype=dtype,
|
|
2131
|
+
)
|
|
2132
|
+
add_function_test_register_kernel(
|
|
2133
|
+
TestSpatial,
|
|
2134
|
+
f"test_spatial_outer_product_{dtype.__name__}",
|
|
2135
|
+
test_spatial_outer_product,
|
|
2136
|
+
devices=devices,
|
|
2137
|
+
dtype=dtype,
|
|
2138
|
+
)
|
|
2139
|
+
add_function_test_register_kernel(
|
|
2140
|
+
TestSpatial, f"test_spatial_adjoint_{dtype.__name__}", test_spatial_adjoint, devices=devices, dtype=dtype
|
|
2141
|
+
)
|
|
2136
2142
|
|
|
2137
|
-
|
|
2143
|
+
# \TODO: test spatial_mass and spatial_jacobian
|
|
2138
2144
|
|
|
2139
2145
|
|
|
2140
2146
|
if __name__ == "__main__":
|
|
2141
2147
|
wp.build.clear_kernel_cache()
|
|
2142
|
-
_ = register(unittest.TestCase)
|
|
2143
2148
|
unittest.main(verbosity=2)
|
warp/tests/test_streams.py
CHANGED
|
@@ -10,7 +10,7 @@ import unittest
|
|
|
10
10
|
import numpy as np
|
|
11
11
|
|
|
12
12
|
import warp as wp
|
|
13
|
-
from warp.tests.
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
14
14
|
|
|
15
15
|
wp.init()
|
|
16
16
|
|
|
@@ -284,145 +284,138 @@ def test_stream_scope_wait_stream(test, device):
|
|
|
284
284
|
assert_np_equal(d.numpy(), np.full(N, fill_value=4.0))
|
|
285
285
|
|
|
286
286
|
|
|
287
|
-
|
|
288
|
-
cpu_device = wp.get_device("cpu")
|
|
287
|
+
devices = get_unique_cuda_test_devices()
|
|
289
288
|
|
|
290
|
-
# Can't set the stream on a CPU device
|
|
291
|
-
with test.assertRaises(RuntimeError):
|
|
292
|
-
stream0 = wp.Stream()
|
|
293
|
-
cpu_device.stream = stream0
|
|
294
289
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
wp.
|
|
290
|
+
class TestStreams(unittest.TestCase):
|
|
291
|
+
def test_stream_exceptions(self):
|
|
292
|
+
cpu_device = wp.get_device("cpu")
|
|
298
293
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
294
|
+
# Can't set the stream on a CPU device
|
|
295
|
+
with self.assertRaises(RuntimeError):
|
|
296
|
+
stream0 = wp.Stream()
|
|
297
|
+
cpu_device.stream = stream0
|
|
302
298
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
299
|
+
# Can't create a stream on the CPU
|
|
300
|
+
with self.assertRaises(RuntimeError):
|
|
301
|
+
wp.Stream(device="cpu")
|
|
306
302
|
|
|
303
|
+
# Can't create an event with CPU device
|
|
304
|
+
with self.assertRaises(RuntimeError):
|
|
305
|
+
wp.Event(device=cpu_device)
|
|
307
306
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
a0 = wp.zeros(N, dtype=float, device="cuda:0")
|
|
312
|
-
b0 = wp.empty(N, dtype=float, device="cuda:0")
|
|
313
|
-
c0 = wp.empty(N, dtype=float, device="cuda:0")
|
|
307
|
+
# Can't get the stream on a CPU device
|
|
308
|
+
with self.assertRaises(RuntimeError):
|
|
309
|
+
cpu_stream = cpu_device.stream # noqa: F841
|
|
314
310
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
311
|
+
@unittest.skipUnless(len(wp.get_cuda_devices()) > 1, "Requires at least two CUDA devices")
|
|
312
|
+
def test_stream_arg_graph_mgpu(self):
|
|
313
|
+
wp.load_module(device="cuda:0")
|
|
314
|
+
wp.load_module(device="cuda:1")
|
|
318
315
|
|
|
319
|
-
|
|
320
|
-
|
|
316
|
+
# resources on GPU 0
|
|
317
|
+
stream0 = wp.get_stream("cuda:0")
|
|
318
|
+
a0 = wp.zeros(N, dtype=float, device="cuda:0")
|
|
319
|
+
b0 = wp.empty(N, dtype=float, device="cuda:0")
|
|
320
|
+
c0 = wp.empty(N, dtype=float, device="cuda:0")
|
|
321
321
|
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
# resources on GPU 1
|
|
323
|
+
stream1 = wp.get_stream("cuda:1")
|
|
324
|
+
a1 = wp.zeros(N, dtype=float, device="cuda:1")
|
|
324
325
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
stream0.wait_stream(stream1)
|
|
331
|
-
|
|
332
|
-
# copy values from stream1
|
|
333
|
-
wp.copy(b0, a1, stream=stream0)
|
|
326
|
+
# start recording on stream0
|
|
327
|
+
wp.capture_begin(stream=stream0, force_module_load=False)
|
|
328
|
+
try:
|
|
329
|
+
# branch into stream1
|
|
330
|
+
stream1.wait_stream(stream0)
|
|
334
331
|
|
|
335
|
-
|
|
336
|
-
|
|
332
|
+
# launch concurrent kernels on each stream
|
|
333
|
+
wp.launch(inc, dim=N, inputs=[a0], stream=stream0)
|
|
334
|
+
wp.launch(inc, dim=N, inputs=[a1], stream=stream1)
|
|
337
335
|
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
# wait for stream1 to finish
|
|
337
|
+
stream0.wait_stream(stream1)
|
|
340
338
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
for _ in range(num_iters):
|
|
344
|
-
wp.capture_launch(g, stream=stream0)
|
|
339
|
+
# copy values from stream1
|
|
340
|
+
wp.copy(b0, a1, stream=stream0)
|
|
345
341
|
|
|
346
|
-
|
|
347
|
-
|
|
342
|
+
# compute sum
|
|
343
|
+
wp.launch(sum, dim=N, inputs=[a0, b0, c0], stream=stream0)
|
|
344
|
+
finally:
|
|
345
|
+
# finish recording on stream0
|
|
346
|
+
g = wp.capture_end(stream=stream0)
|
|
348
347
|
|
|
348
|
+
# replay
|
|
349
|
+
num_iters = 10
|
|
350
|
+
for _ in range(num_iters):
|
|
351
|
+
wp.capture_launch(g, stream=stream0)
|
|
349
352
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
with wp.ScopedDevice("cuda:0"):
|
|
353
|
-
stream0 = wp.get_stream()
|
|
354
|
-
a0 = wp.zeros(N, dtype=float)
|
|
355
|
-
b0 = wp.empty(N, dtype=float)
|
|
356
|
-
c0 = wp.empty(N, dtype=float)
|
|
353
|
+
# check results
|
|
354
|
+
assert_np_equal(c0.numpy(), np.full(N, fill_value=2 * num_iters))
|
|
357
355
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
356
|
+
@unittest.skipUnless(len(wp.get_cuda_devices()) > 1, "Requires at least two CUDA devices")
|
|
357
|
+
def test_stream_scope_graph_mgpu(self):
|
|
358
|
+
wp.load_module(device="cuda:0")
|
|
359
|
+
wp.load_module(device="cuda:1")
|
|
362
360
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
361
|
+
# resources on GPU 0
|
|
362
|
+
with wp.ScopedDevice("cuda:0"):
|
|
363
|
+
stream0 = wp.get_stream()
|
|
364
|
+
a0 = wp.zeros(N, dtype=float)
|
|
365
|
+
b0 = wp.empty(N, dtype=float)
|
|
366
|
+
c0 = wp.empty(N, dtype=float)
|
|
367
367
|
|
|
368
|
+
# resources on GPU 1
|
|
368
369
|
with wp.ScopedDevice("cuda:1"):
|
|
369
|
-
|
|
370
|
-
wp.
|
|
370
|
+
stream1 = wp.get_stream()
|
|
371
|
+
a1 = wp.zeros(N, dtype=float)
|
|
371
372
|
|
|
372
|
-
|
|
373
|
+
# capture graph
|
|
374
|
+
with wp.ScopedDevice("cuda:0"):
|
|
375
|
+
# start recording
|
|
376
|
+
wp.capture_begin(force_module_load=False)
|
|
377
|
+
try:
|
|
378
|
+
with wp.ScopedDevice("cuda:1"):
|
|
379
|
+
# branch into stream1
|
|
380
|
+
wp.wait_stream(stream0)
|
|
373
381
|
|
|
374
|
-
|
|
382
|
+
wp.launch(inc, dim=N, inputs=[a1])
|
|
375
383
|
|
|
376
|
-
|
|
377
|
-
wp.wait_stream(stream1)
|
|
384
|
+
wp.launch(inc, dim=N, inputs=[a0])
|
|
378
385
|
|
|
379
|
-
|
|
380
|
-
|
|
386
|
+
# wait for stream1 to finish
|
|
387
|
+
wp.wait_stream(stream1)
|
|
381
388
|
|
|
382
|
-
|
|
383
|
-
|
|
389
|
+
# copy values from stream1
|
|
390
|
+
wp.copy(b0, a1)
|
|
384
391
|
|
|
385
|
-
|
|
386
|
-
|
|
392
|
+
# compute sum
|
|
393
|
+
wp.launch(sum, dim=N, inputs=[a0, b0, c0])
|
|
394
|
+
finally:
|
|
395
|
+
# finish recording
|
|
396
|
+
g = wp.capture_end()
|
|
387
397
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
# check results
|
|
395
|
-
assert_np_equal(c0.numpy(), np.full(N, fill_value=2 * num_iters))
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
def register(parent):
|
|
399
|
-
devices = wp.get_cuda_devices()
|
|
398
|
+
# replay
|
|
399
|
+
with wp.ScopedDevice("cuda:0"):
|
|
400
|
+
num_iters = 10
|
|
401
|
+
for _ in range(num_iters):
|
|
402
|
+
wp.capture_launch(g)
|
|
400
403
|
|
|
401
|
-
|
|
402
|
-
|
|
404
|
+
# check results
|
|
405
|
+
assert_np_equal(c0.numpy(), np.full(N, fill_value=2 * num_iters))
|
|
403
406
|
|
|
404
|
-
add_function_test(TestStreams, "test_stream_arg_implicit_sync", test_stream_arg_implicit_sync, devices=devices)
|
|
405
|
-
add_function_test(TestStreams, "test_stream_scope_implicit_sync", test_stream_scope_implicit_sync, devices=devices)
|
|
406
407
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
add_function_test(TestStreams, "test_stream_arg_wait_stream", test_stream_arg_wait_stream, devices=devices)
|
|
410
|
-
add_function_test(TestStreams, "test_stream_scope_synchronize", test_stream_scope_synchronize, devices=devices)
|
|
411
|
-
add_function_test(TestStreams, "test_stream_scope_wait_event", test_stream_scope_wait_event, devices=devices)
|
|
412
|
-
add_function_test(TestStreams, "test_stream_scope_wait_stream", test_stream_scope_wait_stream, devices=devices)
|
|
413
|
-
add_function_test(TestStreams, "test_stream_exceptions", test_stream_exceptions, devices=devices)
|
|
408
|
+
add_function_test(TestStreams, "test_stream_arg_implicit_sync", test_stream_arg_implicit_sync, devices=devices)
|
|
409
|
+
add_function_test(TestStreams, "test_stream_scope_implicit_sync", test_stream_scope_implicit_sync, devices=devices)
|
|
414
410
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
411
|
+
add_function_test(TestStreams, "test_stream_arg_synchronize", test_stream_arg_synchronize, devices=devices)
|
|
412
|
+
add_function_test(TestStreams, "test_stream_arg_wait_event", test_stream_arg_wait_event, devices=devices)
|
|
413
|
+
add_function_test(TestStreams, "test_stream_arg_wait_stream", test_stream_arg_wait_stream, devices=devices)
|
|
414
|
+
add_function_test(TestStreams, "test_stream_scope_synchronize", test_stream_scope_synchronize, devices=devices)
|
|
415
|
+
add_function_test(TestStreams, "test_stream_scope_wait_event", test_stream_scope_wait_event, devices=devices)
|
|
416
|
+
add_function_test(TestStreams, "test_stream_scope_wait_stream", test_stream_scope_wait_stream, devices=devices)
|
|
420
417
|
|
|
421
418
|
|
|
422
419
|
if __name__ == "__main__":
|
|
423
420
|
wp.build.clear_kernel_cache()
|
|
424
|
-
_ = register(unittest.TestCase)
|
|
425
|
-
|
|
426
|
-
wp.force_load(wp.get_cuda_devices())
|
|
427
|
-
|
|
428
421
|
unittest.main(verbosity=2)
|