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
@@ -44,9 +44,9 @@ class Example:
44
44
  cell_x=self.radius * 2.0,
45
45
  cell_y=self.radius * 2.0,
46
46
  cell_z=self.radius * 2.0,
47
- pos=(0.0, 1.0, 0.0),
47
+ pos=wp.vec3(0.0, 1.0, 0.0),
48
48
  rot=wp.quat_identity(),
49
- vel=(5.0, 0.0, 0.0),
49
+ vel=wp.vec3(5.0, 0.0, 0.0),
50
50
  mass=0.1,
51
51
  jitter=self.radius * 0.1,
52
52
  )
@@ -48,9 +48,9 @@ class Example:
48
48
  cell_x=self.radius * 2.0,
49
49
  cell_y=self.radius * 2.0,
50
50
  cell_z=self.radius * 2.0,
51
- pos=(0.0, 20.0, 0.0),
51
+ pos=wp.vec3(0.0, 20.0, 0.0),
52
52
  rot=wp.quat_identity(),
53
- vel=(2.0, 0.0, 0.0),
53
+ vel=wp.vec3(2.0, 0.0, 0.0),
54
54
  mass=0.1,
55
55
  jitter=self.radius * 0.1,
56
56
  )
@@ -67,9 +67,9 @@ class Example:
67
67
  mu=0.5,
68
68
  sdf=rock_sdf,
69
69
  body=-1,
70
- pos=(0.0, 0.0, 0.0),
71
- rot=wp.quat_from_axis_angle((1.0, 0.0, 0.0), -0.5 * math.pi),
72
- scale=(0.01, 0.01, 0.01),
70
+ pos=wp.vec3(0.0, 0.0, 0.0),
71
+ rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), -0.5 * math.pi),
72
+ scale=wp.vec3(0.01, 0.01, 0.01),
73
73
  )
74
74
 
75
75
  mins = np.array([-3.0, -3.0, -3.0])
@@ -89,7 +89,7 @@ class Example:
89
89
  sphere_vdb = wp.Volume.load_from_numpy(sphere_sdf_np, mins, voxel_size, rad + 3.0 * voxel_size)
90
90
  sphere_sdf = wp.sim.SDF(sphere_vdb)
91
91
 
92
- self.sphere_pos = (3.0, 15.0, 0.0)
92
+ self.sphere_pos = wp.vec3(3.0, 15.0, 0.0)
93
93
  self.sphere_scale = 1.0
94
94
  self.sphere_radius = rad
95
95
  builder.add_shape_sdf(
@@ -100,7 +100,7 @@ class Example:
100
100
  sdf=sphere_sdf,
101
101
  body=-1,
102
102
  pos=self.sphere_pos,
103
- scale=(self.sphere_scale, self.sphere_scale, self.sphere_scale),
103
+ scale=wp.vec3(self.sphere_scale, self.sphere_scale, self.sphere_scale),
104
104
  )
105
105
 
106
106
  self.model = builder.finalize()
@@ -136,21 +136,21 @@ class Example:
136
136
 
137
137
  self.renderer.begin_frame(time)
138
138
 
139
- # Note the extra wp.quat_from_axis_angle((1.0, 0.0, 0.0), math.pi) is because .usd is oriented differently from .nvdb
139
+ # Note the extra wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), math.pi) is because .usd is oriented differently from .nvdb
140
140
  self.renderer.render_ref(
141
141
  name="collision",
142
142
  path=os.path.join(os.path.dirname(__file__), "assets/rocks.usd"),
143
- pos=(0.0, 0.0, 0.0),
144
- rot=wp.quat_from_axis_angle((1.0, 0.0, 0.0), -0.5 * math.pi)
145
- * wp.quat_from_axis_angle((1.0, 0.0, 0.0), math.pi),
146
- scale=(0.01, 0.01, 0.01),
143
+ pos=wp.vec3(0.0, 0.0, 0.0),
144
+ rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), -0.5 * math.pi)
145
+ * wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), math.pi),
146
+ scale=wp.vec3(0.01, 0.01, 0.01),
147
147
  )
148
148
 
149
149
  self.renderer.render_sphere(
150
150
  name="sphere",
151
151
  pos=self.sphere_pos,
152
152
  radius=self.sphere_scale * self.sphere_radius,
153
- rot=(0.0, 0.0, 0.0, 1.0),
153
+ rot=wp.quat(0.0, 0.0, 0.0, 1.0),
154
154
  )
155
155
 
156
156
  self.renderer.render(self.state_0)
@@ -80,9 +80,9 @@ class Example:
80
80
  center = cell_size * cell_dim * 0.5
81
81
 
82
82
  builder.add_soft_grid(
83
- pos=(-center, 0.0, -center),
83
+ pos=wp.vec3(-center, 0.0, -center),
84
84
  rot=wp.quat_identity(),
85
- vel=(0.0, 0.0, 0.0),
85
+ vel=wp.vec3(0.0, 0.0, 0.0),
86
86
  dim_x=cell_dim,
87
87
  dim_y=cell_dim,
88
88
  dim_z=cell_dim,
@@ -117,7 +117,7 @@ class Example:
117
117
  with wp.ScopedTimer("simulate"):
118
118
  xform = wp.transform(
119
119
  (0.0, self.lift_speed * self.sim_time, 0.0),
120
- wp.quat_from_axis_angle((0.0, 1.0, 0.0), self.rot_speed * self.sim_time),
120
+ wp.quat_from_axis_angle(wp.vec3(0.0, 1.0, 0.0), self.rot_speed * self.sim_time),
121
121
  )
122
122
  wp.launch(
123
123
  kernel=twist_points,
@@ -38,13 +38,13 @@ class Example:
38
38
  builder = wp.sim.ModelBuilder()
39
39
 
40
40
  # anchor
41
- builder.add_particle((0.0, 1.0, 0.0), (0.0, 0.0, 0.0), 0.0)
41
+ builder.add_particle(wp.vec3(0.0, 1.0, 0.0), wp.vec3(0.0, 0.0, 0.0), 0.0)
42
42
 
43
43
  # chain
44
44
  for i in range(1, 10):
45
45
  radius = math.sqrt(i) * 0.2
46
46
  mass = math.pi * radius * radius * radius
47
- builder.add_particle((i, 1.0, 0.0), (0.0, 0.0, 0.0), mass, radius=radius)
47
+ builder.add_particle(wp.vec3(i, 1.0, 0.0), wp.vec3(0.0, 0.0, 0.0), mass, radius=radius)
48
48
  builder.add_spring(i - 1, i, 1.0e6, 0.0, 0)
49
49
 
50
50
  self.model = builder.finalize()
@@ -70,12 +70,13 @@ def compute_env_offsets(num_envs, env_offset=(5.0, 0.0, 5.0), up_axis="Y"):
70
70
 
71
71
  class Example:
72
72
  def __init__(self, stage=None, num_envs=1, enable_rendering=True, print_timers=True):
73
+ self.device = wp.get_device()
73
74
  self.num_envs = num_envs
74
75
  articulation_builder = wp.sim.ModelBuilder()
75
76
  wp.sim.parse_urdf(
76
77
  os.path.join(os.path.dirname(__file__), "assets/quadruped.urdf"),
77
78
  articulation_builder,
78
- xform=wp.transform([0.0, 0.7, 0.0], wp.quat_from_axis_angle((1.0, 0.0, 0.0), -math.pi * 0.5)),
79
+ xform=wp.transform([0.0, 0.7, 0.0], wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), -math.pi * 0.5)),
79
80
  floating=True,
80
81
  density=1000,
81
82
  armature=0.01,
@@ -135,13 +136,15 @@ class Example:
135
136
 
136
137
  if self.use_graph:
137
138
  # create update graph
138
- wp.capture_begin()
139
- self.update()
140
- self.graph = wp.capture_end()
139
+ wp.capture_begin(self.device)
140
+ try:
141
+ self.update()
142
+ finally:
143
+ self.graph = wp.capture_end(self.device)
141
144
 
142
145
  def update(self):
143
146
  with wp.ScopedTimer("simulate", active=True, print=self.print_timers):
144
- if self.use_graph is False or self.graph is None:
147
+ if not self.use_graph or self.graph is None:
145
148
  for _ in range(self.sim_substeps):
146
149
  self.state_0.clear_forces()
147
150
  wp.sim.collide(self.model, self.state_0)
@@ -27,6 +27,7 @@ wp.init()
27
27
 
28
28
  class Example:
29
29
  def __init__(self, stage):
30
+ self.device = wp.get_device()
30
31
  self.chain_length = 8
31
32
  self.chain_width = 1.0
32
33
  self.chain_types = [
@@ -65,7 +66,7 @@ class Example:
65
66
 
66
67
  # create shape
67
68
  builder.add_shape_box(
68
- pos=(self.chain_width * 0.5, 0.0, 0.0),
69
+ pos=wp.vec3(self.chain_width * 0.5, 0.0, 0.0),
69
70
  hx=self.chain_width * 0.5,
70
71
  hy=0.1,
71
72
  hz=0.1,
@@ -146,13 +147,15 @@ class Example:
146
147
 
147
148
  if self.use_graph:
148
149
  # create update graph
149
- wp.capture_begin()
150
- self.update()
151
- self.graph = wp.capture_end()
150
+ wp.capture_begin(self.device)
151
+ try:
152
+ self.update()
153
+ finally:
154
+ self.graph = wp.capture_end(self.device)
152
155
 
153
156
  def update(self):
154
157
  with wp.ScopedTimer("simulate", active=True):
155
- if self.use_graph is False or self.graph is None:
158
+ if not self.use_graph or self.graph is None:
156
159
  for _ in range(self.sim_substeps):
157
160
  self.state_0.clear_forces()
158
161
  self.integrator.simulate(self.model, self.state_0, self.state_1, self.sim_dt)
@@ -28,6 +28,7 @@ wp.init()
28
28
 
29
29
  class Example:
30
30
  def __init__(self, stage):
31
+ self.device = wp.get_device()
31
32
  builder = wp.sim.ModelBuilder()
32
33
 
33
34
  self.sim_time = 0.0
@@ -50,7 +51,7 @@ class Example:
50
51
  b = builder.add_body(origin=wp.transform((i, 1.0, 0.0), wp.quat_identity()))
51
52
 
52
53
  builder.add_shape_box(
53
- pos=(0.0, 0.0, 0.0),
54
+ pos=wp.vec3(0.0, 0.0, 0.0),
54
55
  hx=0.5 * self.scale,
55
56
  hy=0.2 * self.scale,
56
57
  hz=0.2 * self.scale,
@@ -65,7 +66,7 @@ class Example:
65
66
  b = builder.add_body(origin=wp.transform((i, 1.0, 2.0), wp.quat_identity()))
66
67
 
67
68
  builder.add_shape_sphere(
68
- pos=(0.0, 0.0, 0.0), radius=0.25 * self.scale, body=b, ke=self.ke, kd=self.kd, kf=self.kf
69
+ pos=wp.vec3(0.0, 0.0, 0.0), radius=0.25 * self.scale, body=b, ke=self.ke, kd=self.kd, kf=self.kf
69
70
  )
70
71
 
71
72
  # capsules
@@ -73,7 +74,7 @@ class Example:
73
74
  b = builder.add_body(origin=wp.transform((i, 1.0, 6.0), wp.quat_identity()))
74
75
 
75
76
  builder.add_shape_capsule(
76
- pos=(0.0, 0.0, 0.0),
77
+ pos=wp.vec3(0.0, 0.0, 0.0),
77
78
  radius=0.25 * self.scale,
78
79
  half_height=self.scale * 0.5,
79
80
  up_axis=0,
@@ -93,15 +94,15 @@ class Example:
93
94
  b = builder.add_body(
94
95
  origin=wp.transform(
95
96
  (i * 0.5 * self.scale, 1.0 + i * 1.7 * self.scale, 4.0 + i * 0.5 * self.scale),
96
- wp.quat_from_axis_angle((0.0, 1.0, 0.0), math.pi * 0.1 * i),
97
+ wp.quat_from_axis_angle(wp.vec3(0.0, 1.0, 0.0), math.pi * 0.1 * i),
97
98
  )
98
99
  )
99
100
 
100
101
  builder.add_shape_mesh(
101
102
  body=b,
102
103
  mesh=bunny,
103
- pos=(0.0, 0.0, 0.0),
104
- scale=(self.scale, self.scale, self.scale),
104
+ pos=wp.vec3(0.0, 0.0, 0.0),
105
+ scale=wp.vec3(self.scale, self.scale, self.scale),
105
106
  ke=self.ke,
106
107
  kd=self.kd,
107
108
  kf=self.kf,
@@ -126,9 +127,11 @@ class Example:
126
127
 
127
128
  if self.use_graph:
128
129
  # create update graph
129
- wp.capture_begin()
130
- self.update()
131
- self.graph = wp.capture_end()
130
+ wp.capture_begin(self.device)
131
+ try:
132
+ self.update()
133
+ finally:
134
+ self.graph = wp.capture_end(self.device)
132
135
 
133
136
  def load_mesh(self, filename, path):
134
137
  asset_stage = Usd.Stage.Open(filename)
@@ -141,7 +144,7 @@ class Example:
141
144
 
142
145
  def update(self):
143
146
  with wp.ScopedTimer("simulate", active=True):
144
- if self.use_graph is False or self.graph is None:
147
+ if not self.use_graph or self.graph is None:
145
148
  for _ in range(self.sim_substeps):
146
149
  self.state_0.clear_forces()
147
150
  wp.sim.collide(self.model, self.state_0)
@@ -40,9 +40,9 @@ class Example:
40
40
  builder.default_particle_radius = 0.01
41
41
 
42
42
  builder.add_soft_grid(
43
- pos=(0.0, 0.0, 0.0),
43
+ pos=wp.vec3(0.0, 0.0, 0.0),
44
44
  rot=wp.quat_identity(),
45
- vel=(0.0, 0.0, 0.0),
45
+ vel=wp.vec3(0.0, 0.0, 0.0),
46
46
  dim_x=20,
47
47
  dim_y=10,
48
48
  dim_z=10,
@@ -36,7 +36,7 @@ class Example:
36
36
 
37
37
  # axis shape
38
38
  builder.add_shape_box(
39
- pos=(0.3 * self.scale, 0.0, 0.0),
39
+ pos=wp.vec3(0.3 * self.scale, 0.0, 0.0),
40
40
  hx=0.25 * self.scale,
41
41
  hy=0.1 * self.scale,
42
42
  hz=0.1 * self.scale,
@@ -46,7 +46,7 @@ class Example:
46
46
 
47
47
  # tip shape
48
48
  builder.add_shape_box(
49
- pos=(0.0, 0.0, 0.0), hx=0.05 * self.scale, hy=0.2 * self.scale, hz=1.0 * self.scale, density=100.0, body=b
49
+ pos=wp.vec3(0.0, 0.0, 0.0), hx=0.05 * self.scale, hy=0.2 * self.scale, hz=1.0 * self.scale, density=100.0, body=b
50
50
  )
51
51
 
52
52
  # initial spin
@@ -59,7 +59,7 @@ class Example:
59
59
  # base
60
60
  builder.joint_q[coord_start : coord_start + 3] = [i * 2.0, 0.70, 0.0]
61
61
  builder.joint_q[coord_start + 3 : coord_start + 7] = wp.quat_from_axis_angle(
62
- (1.0, 0.0, 0.0), -math.pi * 0.5
62
+ wp.vec3(1.0, 0.0, 0.0), -math.pi * 0.5
63
63
  )
64
64
 
65
65
  # joints
@@ -16,7 +16,6 @@
16
16
 
17
17
  import os
18
18
 
19
- import matplotlib.pyplot as plt
20
19
  import numpy as np
21
20
 
22
21
  import warp as wp
@@ -72,7 +71,7 @@ class Example:
72
71
  builder = wp.sim.ModelBuilder(gravity=0.0)
73
72
  builder.add_articulation()
74
73
  b = builder.add_body(origin=wp.transform())
75
- builder.add_shape_box(pos=(0.0, 0.0, 0.0), hx=0.5, hy=0.5, hz=0.5, density=100.0, body=b)
74
+ builder.add_shape_box(pos=wp.vec3(0.0, 0.0, 0.0), hx=0.5, hy=0.5, hz=0.5, density=100.0, body=b)
76
75
 
77
76
  # compute reference trajectory
78
77
  rad = np.linspace(0.0, np.pi * 2, self.episode_frames)
@@ -194,6 +193,8 @@ class Example:
194
193
 
195
194
 
196
195
  if __name__ == "__main__":
196
+ import matplotlib.pyplot as plt
197
+
197
198
  stage_path = os.path.join(os.path.dirname(__file__), "outputs/example_sim_trajopt.usd")
198
199
  example = Example(stage_path, device=wp.get_preferred_device(), verbose=True)
199
200
 
@@ -64,8 +64,6 @@ def update_particles(
64
64
  pos_proj = domain(lookup(domain, pos_adv))
65
65
  pos[s.qp_index] = pos_proj
66
66
 
67
- return 0.0
68
-
69
67
 
70
68
  @integrand
71
69
  def velocity_boundary_projector_form(s: Sample, domain: Domain, u: Field, v: Field):
@@ -171,10 +169,10 @@ class Example:
171
169
  grid_cell_volume = np.prod(grid_cell_size)
172
170
 
173
171
  PARTICLES_PER_CELL_DIM = 3
174
- self.radius = np.max(grid_cell_size) / (2 * PARTICLES_PER_CELL_DIM)
172
+ self.radius = float(np.max(grid_cell_size) / (2 * PARTICLES_PER_CELL_DIM))
175
173
 
176
174
  particle_grid_res = np.array(particle_fill_frac * grid_res * PARTICLES_PER_CELL_DIM, dtype=int)
177
- particle_grid_offset = self.radius * np.ones(3)
175
+ particle_grid_offset = wp.vec3(self.radius, self.radius, self.radius)
178
176
 
179
177
  np.random.seed(0)
180
178
  builder = wp.sim.ModelBuilder()
@@ -185,9 +183,9 @@ class Example:
185
183
  cell_x=self.radius * 2.0,
186
184
  cell_y=self.radius * 2.0,
187
185
  cell_z=self.radius * 2.0,
188
- pos=(0.0, 0.0, 0.0) + particle_grid_offset,
186
+ pos=wp.vec3(0.0, 0.0, 0.0) + particle_grid_offset,
189
187
  rot=wp.quat_identity(),
190
- vel=(0.0, 0.0, 0.0),
188
+ vel=wp.vec3(0.0, 0.0, 0.0),
191
189
  mass=grid_cell_volume / PARTICLES_PER_CELL_DIM**3,
192
190
  jitter=self.radius * 1.0,
193
191
  radius_mean=self.radius,
@@ -331,7 +329,7 @@ class Example:
331
329
  )
332
330
 
333
331
  # (A)PIC advection
334
- fem.integrate(
332
+ fem.interpolate(
335
333
  update_particles,
336
334
  quadrature=pic,
337
335
  values={
@@ -6,19 +6,18 @@ from typing import Tuple
6
6
 
7
7
  import warp as wp
8
8
  import warp.fem as fem
9
-
10
9
  from warp.sparse import bsr_axpy, bsr_mv
11
10
  from warp.utils import array_cast
12
11
 
13
12
  # Import example utilities
14
13
  # Make sure that works both when imported as module and run as standalone file
15
14
  try:
16
- from .example_diffusion import linear_form, diffusion_form
17
15
  from .bsr_utils import bsr_cg
16
+ from .example_diffusion import diffusion_form, linear_form
18
17
  from .plot_utils import Plot
19
18
  except ImportError:
20
- from example_diffusion import linear_form, diffusion_form
21
19
  from bsr_utils import bsr_cg
20
+ from example_diffusion import diffusion_form, linear_form
22
21
  from plot_utils import Plot
23
22
 
24
23
 
@@ -100,14 +99,18 @@ class Example:
100
99
  self._quiet = quiet
101
100
 
102
101
  self._geo = fem.Grid2D(res=wp.vec2i(25))
103
- self._scalar_space = fem.make_polynomial_space(self._geo, degree=3)
104
- self._scalar_field = self._scalar_space.make_field()
102
+
103
+ self._main_device = wp.get_device("cuda")
104
+
105
+ with wp.ScopedDevice(self._main_device):
106
+ self._scalar_space = fem.make_polynomial_space(self._geo, degree=3)
107
+ self._scalar_field = self._scalar_space.make_field()
105
108
 
106
109
  self.renderer = Plot(stage)
107
110
 
108
111
  def update(self):
109
112
  devices = wp.get_cuda_devices()
110
- main_device = devices[0]
113
+ main_device = self._main_device
111
114
 
112
115
  rhs_vecs = []
113
116
  res_vecs = []
@@ -141,16 +144,15 @@ class Example:
141
144
  A.tmp_buf = tmp
142
145
  A.rank_data = (matrices, rhs_vecs, res_vecs, indices)
143
146
 
144
- with wp.ScopedDevice(main_device):
145
- bsr_cg(
146
- A,
147
- x=global_res,
148
- b=glob_rhs,
149
- use_diag_precond=False,
150
- quiet=self._quiet,
151
- mv_routine=mv_routine,
152
- device=main_device,
153
- )
147
+ bsr_cg(
148
+ A,
149
+ x=global_res,
150
+ b=glob_rhs,
151
+ use_diag_precond=False,
152
+ quiet=self._quiet,
153
+ mv_routine=mv_routine,
154
+ device=main_device,
155
+ )
154
156
 
155
157
  array_cast(in_array=global_res, out_array=self._scalar_field.dof_values)
156
158
 
warp/__init__.py CHANGED
@@ -26,7 +26,9 @@ from warp.types import spatial_matrix, spatial_matrixh, spatial_matrixf, spatial
26
26
 
27
27
  # geometry types
28
28
  from warp.types import Bvh, Mesh, HashGrid, Volume, MarchingCubes
29
- from warp.types import bvh_query_t, mesh_query_aabb_t, hash_grid_query_t
29
+ from warp.types import bvh_query_t, hash_grid_query_t, mesh_query_aabb_t, mesh_query_point_t, mesh_query_ray_t
30
+
31
+
30
32
 
31
33
  # device-wide gemms
32
34
  from warp.types import matmul, adj_matmul, batched_matmul, adj_batched_matmul, from_ptr
@@ -57,7 +59,6 @@ from warp.context import (
57
59
  )
58
60
  from warp.context import set_module_options, get_module_options, get_module
59
61
  from warp.context import capture_begin, capture_end, capture_launch
60
- from warp.context import print_builtins, export_builtins, export_stubs
61
62
  from warp.context import Kernel, Function, Launch
62
63
  from warp.context import Stream, get_stream, set_stream, synchronize_stream
63
64
  from warp.context import Event, record_event, wait_event, wait_stream
warp/bin/warp.so CHANGED
Binary file
warp/build_dll.py CHANGED
@@ -8,11 +8,24 @@
8
8
  import sys
9
9
  import os
10
10
  import subprocess
11
+ import platform
11
12
 
12
13
  import warp.config
13
14
  from warp.utils import ScopedTimer
14
15
 
15
16
 
17
+ # return a canonical machine architecture string
18
+ # - "x86_64" for x86-64, aka. AMD64, aka. x64
19
+ # - "aarch64" for AArch64, aka. ARM64
20
+ def machine_architecture() -> str:
21
+ machine = platform.machine()
22
+ if machine == "x86_64" or machine == "AMD64":
23
+ return "x86_64"
24
+ if machine == "aarch64" or machine == "arm64":
25
+ return "aarch64"
26
+ raise RuntimeError(f"Unrecognized machine architecture {machine}")
27
+
28
+
16
29
  def run_cmd(cmd, capture=False):
17
30
  if warp.config.verbose:
18
31
  print(cmd)
@@ -182,12 +195,15 @@ def build_dll_for_arch(dll_path, cpp_paths, cu_path, libs, mode, arch, verify_fp
182
195
  "-gencode=arch=compute_75,code=sm_75", # Turing
183
196
  "-gencode=arch=compute_80,code=sm_80", # Ampere
184
197
  "-gencode=arch=compute_86,code=sm_86",
185
- # SASS for supported mobile architectures (e.g. Tegra/Jetson)
186
- # "-gencode=arch=compute_53,code=sm_53",
187
- # "-gencode=arch=compute_62,code=sm_62",
188
- # "-gencode=arch=compute_72,code=sm_72",
189
- # "-gencode=arch=compute_87,code=sm_87",
190
198
  ]
199
+ if arch == "aarch64" and sys.platform == "linux":
200
+ gencode_opts += [
201
+ # SASS for supported mobile architectures (e.g. Tegra/Jetson)
202
+ "-gencode=arch=compute_53,code=sm_53", # X1
203
+ "-gencode=arch=compute_62,code=sm_62", # X2
204
+ "-gencode=arch=compute_72,code=sm_72", # Xavier
205
+ "-gencode=arch=compute_87,code=sm_87", # Orin
206
+ ]
191
207
 
192
208
  # support for Ada and Hopper is available with CUDA Toolkit 11.8+
193
209
  if ctk_version >= (11, 8):
@@ -354,11 +370,15 @@ def build_dll(dll_path, cpp_paths, cu_path, libs=[], mode="release", verify_fp=F
354
370
  if sys.platform == "darwin":
355
371
  # create a universal binary by combining x86-64 and AArch64 builds
356
372
  build_dll_for_arch(dll_path + "-x86_64", cpp_paths, cu_path, libs, mode, "x86_64", verify_fp, fast_math, quick)
357
- build_dll_for_arch(dll_path + "-arm64", cpp_paths, cu_path, libs, mode, "arm64", verify_fp, fast_math, quick)
373
+ build_dll_for_arch(
374
+ dll_path + "-aarch64", cpp_paths, cu_path, libs, mode, "aarch64", verify_fp, fast_math, quick
375
+ )
358
376
 
359
- run_cmd(f"lipo -create -output {dll_path} {dll_path}-x86_64 {dll_path}-arm64")
377
+ run_cmd(f"lipo -create -output {dll_path} {dll_path}-x86_64 {dll_path}-aarch64")
360
378
  os.remove(f"{dll_path}-x86_64")
361
- os.remove(f"{dll_path}-arm64")
379
+ os.remove(f"{dll_path}-aarch64")
362
380
 
363
381
  else:
364
- build_dll_for_arch(dll_path, cpp_paths, cu_path, libs, mode, "x86_64", verify_fp, fast_math, quick)
382
+ build_dll_for_arch(
383
+ dll_path, cpp_paths, cu_path, libs, mode, machine_architecture(), verify_fp, fast_math, quick
384
+ )