Hwo to use atomic_min in warp

Isaac Sim Version

4.5.0

@wp.kernel
def bin_bbox_process(bbox_corners: wp.array(ndim=3, dtype=wp.float32),
                     x_offset: wp.float32,
                     y_offset: wp.float32,
                     x_res: wp.float32,
                     y_res: wp.float32,
                    #  bbox_corners_bin_idx: wp.array(ndim=2, dtype=wp.vec2ui),
                    aligned_bbox_corners_idx: wp.array(ndim=2, dtype=wp.uint32)
                    ):
    i, j = wp.tid()
    bbox_corner_spher = cartesian_to_spherical(wp.vec3(bbox_corners[i,j,0],
                                                       bbox_corners[i,j,1],
                                                       bbox_corners[i,j,1]))
    
    x_bin_idx = wp.uint32((bbox_corner_spher[0] - x_offset) / x_res)
    y_bin_idx = wp.uint32((bbox_corner_spher[1] - y_offset) / y_res)

   # This line gives an error.
    wp.atomic_min(aligned_bbox_corners_idx, wp.uint32(0), wp.uint32(0), x_bin_idx)

Gives an kernel compilation error saying

no instance of overloaded function "wp::atomic_min" matches the argument list
            argument types are: (wp::uint32 *, wp::uint32)
          detected during instantiation of "T wp::atomic_min(const A<T> &, int, int, T) [with A=wp::array_t, T=wp::uint32]" 

The weird thing is If replace atomic_min with atomic_add, this kernel can run without any problem.

But atomic_min and atomic_add has exactly same syntax, please correct if I am wrong.

Thanks

An update to this problem, I have used wp.float32 or wp.int32 for the value and array entries in this function,
now this kernel can be compiled without any problem.

Is this a bug that this function only accepts unsigned data type?

Thank you for reporting this. We have shared it with our team and will provide an update once we have more information.

Hi @HaoyuMa, thanks for reporting this! We have a fix for Warp that is in progress and that should be part of the next 1.7.2 release coming at the end of the month.

Just to expand on what Chris said, we previously only exposed wp.atomic_min() on signed integer types (int). We will expose atomic operations on unsigned integers in the upcoming 1.7.2 or 1.8.0 release.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.