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.
Files changed (187) hide show
  1. docs/conf.py +3 -4
  2. examples/env/env_ant.py +1 -1
  3. examples/env/env_cartpole.py +1 -1
  4. examples/env/env_humanoid.py +1 -1
  5. examples/example_dem.py +28 -26
  6. examples/example_diffray.py +37 -30
  7. examples/example_fluid.py +7 -3
  8. examples/example_jacobian_ik.py +1 -1
  9. examples/example_mesh_intersect.py +10 -7
  10. examples/example_nvdb.py +3 -3
  11. examples/example_render_opengl.py +19 -10
  12. examples/example_sim_cartpole.py +9 -5
  13. examples/example_sim_cloth.py +29 -25
  14. examples/example_sim_fk_grad.py +2 -2
  15. examples/example_sim_fk_grad_torch.py +3 -3
  16. examples/example_sim_grad_bounce.py +11 -8
  17. examples/example_sim_grad_cloth.py +12 -9
  18. examples/example_sim_granular.py +2 -2
  19. examples/example_sim_granular_collision_sdf.py +13 -13
  20. examples/example_sim_neo_hookean.py +3 -3
  21. examples/example_sim_particle_chain.py +2 -2
  22. examples/example_sim_quadruped.py +8 -5
  23. examples/example_sim_rigid_chain.py +8 -5
  24. examples/example_sim_rigid_contact.py +13 -10
  25. examples/example_sim_rigid_fem.py +2 -2
  26. examples/example_sim_rigid_gyroscopic.py +2 -2
  27. examples/example_sim_rigid_kinematics.py +1 -1
  28. examples/example_sim_trajopt.py +3 -2
  29. examples/fem/example_apic_fluid.py +5 -7
  30. examples/fem/example_diffusion_mgpu.py +18 -16
  31. warp/__init__.py +3 -2
  32. warp/bin/warp.so +0 -0
  33. warp/build_dll.py +29 -9
  34. warp/builtins.py +206 -7
  35. warp/codegen.py +58 -38
  36. warp/config.py +3 -1
  37. warp/context.py +234 -128
  38. warp/fem/__init__.py +2 -2
  39. warp/fem/cache.py +2 -1
  40. warp/fem/field/nodal_field.py +18 -17
  41. warp/fem/geometry/hexmesh.py +11 -6
  42. warp/fem/geometry/quadmesh_2d.py +16 -12
  43. warp/fem/geometry/tetmesh.py +19 -8
  44. warp/fem/geometry/trimesh_2d.py +18 -7
  45. warp/fem/integrate.py +341 -196
  46. warp/fem/quadrature/__init__.py +1 -1
  47. warp/fem/quadrature/pic_quadrature.py +138 -53
  48. warp/fem/quadrature/quadrature.py +81 -9
  49. warp/fem/space/__init__.py +1 -1
  50. warp/fem/space/basis_space.py +169 -51
  51. warp/fem/space/grid_2d_function_space.py +2 -2
  52. warp/fem/space/grid_3d_function_space.py +2 -2
  53. warp/fem/space/hexmesh_function_space.py +2 -2
  54. warp/fem/space/partition.py +9 -6
  55. warp/fem/space/quadmesh_2d_function_space.py +2 -2
  56. warp/fem/space/shape/cube_shape_function.py +27 -15
  57. warp/fem/space/shape/square_shape_function.py +29 -18
  58. warp/fem/space/tetmesh_function_space.py +2 -2
  59. warp/fem/space/topology.py +10 -0
  60. warp/fem/space/trimesh_2d_function_space.py +2 -2
  61. warp/fem/utils.py +10 -5
  62. warp/native/array.h +49 -8
  63. warp/native/builtin.h +31 -14
  64. warp/native/cuda_util.cpp +8 -3
  65. warp/native/cuda_util.h +1 -0
  66. warp/native/exports.h +1177 -1108
  67. warp/native/intersect.h +4 -4
  68. warp/native/intersect_adj.h +8 -8
  69. warp/native/mat.h +65 -6
  70. warp/native/mesh.h +126 -5
  71. warp/native/quat.h +28 -4
  72. warp/native/vec.h +76 -14
  73. warp/native/warp.cu +1 -6
  74. warp/render/render_opengl.py +261 -109
  75. warp/sim/import_mjcf.py +13 -7
  76. warp/sim/import_urdf.py +14 -14
  77. warp/sim/inertia.py +17 -18
  78. warp/sim/model.py +67 -67
  79. warp/sim/render.py +1 -1
  80. warp/sparse.py +6 -6
  81. warp/stubs.py +19 -81
  82. warp/tape.py +1 -1
  83. warp/tests/__main__.py +3 -6
  84. warp/tests/{test_class_kernel.py → aux_test_class_kernel.py} +9 -1
  85. warp/tests/aux_test_conditional_unequal_types_kernels.py +21 -0
  86. warp/tests/{test_dependent.py → aux_test_dependent.py} +2 -2
  87. warp/tests/{test_reference.py → aux_test_reference.py} +1 -1
  88. warp/tests/aux_test_unresolved_func.py +14 -0
  89. warp/tests/aux_test_unresolved_symbol.py +14 -0
  90. warp/tests/{test_kinematics.py → disabled_kinematics.py} +10 -12
  91. warp/tests/run_coverage_serial.py +31 -0
  92. warp/tests/test_adam.py +102 -106
  93. warp/tests/test_arithmetic.py +39 -40
  94. warp/tests/test_array.py +46 -48
  95. warp/tests/test_array_reduce.py +25 -19
  96. warp/tests/test_atomic.py +62 -26
  97. warp/tests/test_bool.py +16 -11
  98. warp/tests/test_builtins_resolution.py +1292 -0
  99. warp/tests/test_bvh.py +9 -12
  100. warp/tests/test_closest_point_edge_edge.py +53 -57
  101. warp/tests/test_codegen.py +164 -134
  102. warp/tests/test_compile_consts.py +13 -19
  103. warp/tests/test_conditional.py +30 -32
  104. warp/tests/test_copy.py +9 -12
  105. warp/tests/test_ctypes.py +90 -98
  106. warp/tests/test_dense.py +20 -14
  107. warp/tests/test_devices.py +34 -35
  108. warp/tests/test_dlpack.py +74 -75
  109. warp/tests/test_examples.py +215 -97
  110. warp/tests/test_fabricarray.py +15 -21
  111. warp/tests/test_fast_math.py +14 -11
  112. warp/tests/test_fem.py +280 -97
  113. warp/tests/test_fp16.py +19 -15
  114. warp/tests/test_func.py +177 -194
  115. warp/tests/test_generics.py +71 -77
  116. warp/tests/test_grad.py +83 -32
  117. warp/tests/test_grad_customs.py +7 -9
  118. warp/tests/test_hash_grid.py +6 -10
  119. warp/tests/test_import.py +9 -23
  120. warp/tests/test_indexedarray.py +19 -21
  121. warp/tests/test_intersect.py +15 -9
  122. warp/tests/test_large.py +17 -19
  123. warp/tests/test_launch.py +14 -17
  124. warp/tests/test_lerp.py +63 -63
  125. warp/tests/test_lvalue.py +84 -35
  126. warp/tests/test_marching_cubes.py +9 -13
  127. warp/tests/test_mat.py +388 -3004
  128. warp/tests/test_mat_lite.py +9 -12
  129. warp/tests/test_mat_scalar_ops.py +2889 -0
  130. warp/tests/test_math.py +10 -11
  131. warp/tests/test_matmul.py +104 -100
  132. warp/tests/test_matmul_lite.py +72 -98
  133. warp/tests/test_mesh.py +35 -32
  134. warp/tests/test_mesh_query_aabb.py +18 -25
  135. warp/tests/test_mesh_query_point.py +39 -23
  136. warp/tests/test_mesh_query_ray.py +9 -21
  137. warp/tests/test_mlp.py +8 -9
  138. warp/tests/test_model.py +89 -93
  139. warp/tests/test_modules_lite.py +15 -25
  140. warp/tests/test_multigpu.py +87 -114
  141. warp/tests/test_noise.py +10 -12
  142. warp/tests/test_operators.py +14 -21
  143. warp/tests/test_options.py +10 -11
  144. warp/tests/test_pinned.py +16 -18
  145. warp/tests/test_print.py +16 -20
  146. warp/tests/test_quat.py +121 -88
  147. warp/tests/test_rand.py +12 -13
  148. warp/tests/test_reload.py +27 -32
  149. warp/tests/test_rounding.py +7 -10
  150. warp/tests/test_runlength_encode.py +105 -106
  151. warp/tests/test_smoothstep.py +8 -9
  152. warp/tests/test_snippet.py +13 -22
  153. warp/tests/test_sparse.py +30 -29
  154. warp/tests/test_spatial.py +179 -174
  155. warp/tests/test_streams.py +100 -107
  156. warp/tests/test_struct.py +98 -67
  157. warp/tests/test_tape.py +11 -17
  158. warp/tests/test_torch.py +89 -86
  159. warp/tests/test_transient_module.py +9 -12
  160. warp/tests/test_types.py +328 -50
  161. warp/tests/test_utils.py +217 -218
  162. warp/tests/test_vec.py +133 -2133
  163. warp/tests/test_vec_lite.py +8 -11
  164. warp/tests/test_vec_scalar_ops.py +2099 -0
  165. warp/tests/test_volume.py +391 -382
  166. warp/tests/test_volume_write.py +122 -135
  167. warp/tests/unittest_serial.py +35 -0
  168. warp/tests/unittest_suites.py +291 -0
  169. warp/tests/{test_base.py → unittest_utils.py} +138 -25
  170. warp/tests/{test_misc.py → unused_test_misc.py} +13 -5
  171. warp/tests/{test_debug.py → walkthough_debug.py} +2 -15
  172. warp/thirdparty/unittest_parallel.py +257 -54
  173. warp/types.py +119 -98
  174. warp/utils.py +14 -0
  175. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/METADATA +2 -1
  176. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/RECORD +182 -178
  177. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/WHEEL +1 -1
  178. warp/tests/test_all.py +0 -239
  179. warp/tests/test_conditional_unequal_types_kernels.py +0 -14
  180. warp/tests/test_coverage.py +0 -38
  181. warp/tests/test_unresolved_func.py +0 -7
  182. warp/tests/test_unresolved_symbol.py +0 -7
  183. /warp/tests/{test_compile_consts_dummy.py → aux_test_compile_consts_dummy.py} +0 -0
  184. /warp/tests/{test_reference_reference.py → aux_test_reference_reference.py} +0 -0
  185. /warp/tests/{test_square.py → aux_test_square.py} +0 -0
  186. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/LICENSE.md +0 -0
  187. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/top_level.txt +0 -0
@@ -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.test_base import *
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
- def register(parent):
1960
- devices = get_test_devices()
1966
+ devices = get_test_devices()
1961
1967
 
1962
- class TestSpatial(parent):
1963
- pass
1964
1968
 
1965
- for dtype in np_float_types:
1966
- add_function_test_register_kernel(
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
- # are these two valid? They don't seem to be doing things you'd want to do,
2066
- # maybe they should be removed
2067
- add_function_test_register_kernel(
2068
- TestSpatial,
2069
- f"test_transform_scalar_multiplication_{dtype.__name__}",
2070
- test_transform_scalar_multiplication,
2071
- devices=devices,
2072
- dtype=dtype,
2073
- )
2074
- add_function_test_register_kernel(
2075
- TestSpatial,
2076
- f"test_transform_add_sub_{dtype.__name__}",
2077
- test_transform_add_sub,
2078
- devices=devices,
2079
- dtype=dtype,
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
- add_function_test_register_kernel(
2083
- TestSpatial,
2084
- f"test_spatial_matrix_constructors_{dtype.__name__}",
2085
- test_spatial_matrix_constructors,
2086
- devices=devices,
2087
- dtype=dtype,
2088
- )
2089
- add_function_test_register_kernel(
2090
- TestSpatial,
2091
- f"test_spatial_matrix_indexing_{dtype.__name__}",
2092
- test_spatial_matrix_indexing,
2093
- devices=devices,
2094
- dtype=dtype,
2095
- )
2096
- add_function_test_register_kernel(
2097
- TestSpatial,
2098
- f"test_spatial_matrix_scalar_multiplication_{dtype.__name__}",
2099
- test_spatial_matrix_scalar_multiplication,
2100
- devices=devices,
2101
- dtype=dtype,
2102
- )
2103
- add_function_test_register_kernel(
2104
- TestSpatial,
2105
- f"test_spatial_matrix_add_sub_{dtype.__name__}",
2106
- test_spatial_matrix_add_sub,
2107
- devices=devices,
2108
- dtype=dtype,
2109
- )
2110
- add_function_test_register_kernel(
2111
- TestSpatial,
2112
- f"test_spatial_matvec_multiplication_{dtype.__name__}",
2113
- test_spatial_matvec_multiplication,
2114
- devices=devices,
2115
- dtype=dtype,
2116
- )
2117
- add_function_test_register_kernel(
2118
- TestSpatial,
2119
- f"test_spatial_matmat_multiplication_{dtype.__name__}",
2120
- test_spatial_matmat_multiplication,
2121
- devices=devices,
2122
- dtype=dtype,
2123
- )
2124
- add_function_test_register_kernel(
2125
- TestSpatial,
2126
- f"test_spatial_outer_product_{dtype.__name__}",
2127
- test_spatial_outer_product,
2128
- devices=devices,
2129
- dtype=dtype,
2130
- )
2131
- add_function_test_register_kernel(
2132
- TestSpatial, f"test_spatial_adjoint_{dtype.__name__}", test_spatial_adjoint, devices=devices, dtype=dtype
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
- # \TODO: test spatial_mass and spatial_jacobian
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
- return TestSpatial
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)
@@ -10,7 +10,7 @@ import unittest
10
10
  import numpy as np
11
11
 
12
12
  import warp as wp
13
- from warp.tests.test_base import *
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
- def test_stream_exceptions(test, device):
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
- # Can't create a stream on the CPU
296
- with test.assertRaises(RuntimeError):
297
- wp.Stream(device="cpu")
290
+ class TestStreams(unittest.TestCase):
291
+ def test_stream_exceptions(self):
292
+ cpu_device = wp.get_device("cpu")
298
293
 
299
- # Can't create an event with CPU device
300
- with test.assertRaises(RuntimeError):
301
- wp.Event(device=cpu_device)
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
- # Can't get the stream on a CPU device
304
- with test.assertRaises(RuntimeError):
305
- cpu_stream = cpu_device.stream # noqa: F841
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
- def test_stream_arg_graph_mgpu(test, device):
309
- # resources on GPU 0
310
- stream0 = wp.get_stream("cuda:0")
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
- # resources on GPU 1
316
- stream1 = wp.get_stream("cuda:1")
317
- a1 = wp.zeros(N, dtype=float, device="cuda:1")
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
- # start recording on stream0
320
- wp.capture_begin(stream=stream0)
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
- # branch into stream1
323
- stream1.wait_stream(stream0)
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
- # launch concurrent kernels on each stream
326
- wp.launch(inc, dim=N, inputs=[a0], stream=stream0)
327
- wp.launch(inc, dim=N, inputs=[a1], stream=stream1)
328
-
329
- # wait for stream1 to finish
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
- # compute sum
336
- wp.launch(sum, dim=N, inputs=[a0, b0, c0], stream=stream0)
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
- # finish recording on stream0
339
- g = wp.capture_end(stream=stream0)
336
+ # wait for stream1 to finish
337
+ stream0.wait_stream(stream1)
340
338
 
341
- # replay
342
- num_iters = 10
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
- # check results
347
- assert_np_equal(c0.numpy(), np.full(N, fill_value=2 * num_iters))
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
- def test_stream_scope_graph_mgpu(test, device):
351
- # resources on GPU 0
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
- # resources on GPU 1
359
- with wp.ScopedDevice("cuda:1"):
360
- stream1 = wp.get_stream()
361
- a1 = wp.zeros(N, dtype=float)
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
- # capture graph
364
- with wp.ScopedDevice("cuda:0"):
365
- # start recording
366
- wp.capture_begin()
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
- # branch into stream1
370
- wp.wait_stream(stream0)
370
+ stream1 = wp.get_stream()
371
+ a1 = wp.zeros(N, dtype=float)
371
372
 
372
- wp.launch(inc, dim=N, inputs=[a1])
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
- wp.launch(inc, dim=N, inputs=[a0])
382
+ wp.launch(inc, dim=N, inputs=[a1])
375
383
 
376
- # wait for stream1 to finish
377
- wp.wait_stream(stream1)
384
+ wp.launch(inc, dim=N, inputs=[a0])
378
385
 
379
- # copy values from stream1
380
- wp.copy(b0, a1)
386
+ # wait for stream1 to finish
387
+ wp.wait_stream(stream1)
381
388
 
382
- # compute sum
383
- wp.launch(sum, dim=N, inputs=[a0, b0, c0])
389
+ # copy values from stream1
390
+ wp.copy(b0, a1)
384
391
 
385
- # finish recording
386
- g = wp.capture_end()
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
- # replay
389
- with wp.ScopedDevice("cuda:0"):
390
- num_iters = 10
391
- for _ in range(num_iters):
392
- wp.capture_launch(g)
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
- class TestStreams(parent):
402
- pass
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
- add_function_test(TestStreams, "test_stream_arg_synchronize", test_stream_arg_synchronize, devices=devices)
408
- add_function_test(TestStreams, "test_stream_arg_wait_event", test_stream_arg_wait_event, devices=devices)
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
- if len(devices) > 1:
416
- add_function_test(TestStreams, "test_stream_arg_graph_mgpu", test_stream_arg_graph_mgpu)
417
- add_function_test(TestStreams, "test_stream_scope_graph_mgpu", test_stream_scope_graph_mgpu)
418
-
419
- return TestStreams
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)