Skip to content

Cuda 13 support #306

@johnnynunez

Description

@johnnynunez
# --- PATCH: replace deprecated cub::Equality with a portable functor ---
# 1) Ensure we can include thrust functors if needed.
grep -q '#include <thrust/functional.h>' nerfacc/cuda/csrc/scan_cub.cu || \
  sed -i '1i #include <thrust/functional.h>' nerfacc/cuda/csrc/scan_cub.cu

# 2) Define a tiny comparator that works across CUB versions.
#    (Templated operator() so it matches whatever KeyT is.)
awk '
/^#include/ {print; next}
!p && /^[[:space:]]*$/ {print; next}
!p {
  print "";
  print "struct EqualByKey {";
  print "  template <typename T>";
  print "  __host__ __device__ bool operator()(const T& a, const T& b) const { return a == b; }";
  print "};";
  print "";
  p=1
}
{print}
' nerfacc/cuda/csrc/scan_cub.cu > nerfacc/cuda/csrc/scan_cub.cu.new && mv nerfacc/cuda/csrc/scan_cub.cu.new nerfacc/cuda/csrc/scan_cub.cu

# 3) Swap all uses of cub::Equality() to our functor.
sed -i 's/cub::Equality()/EqualByKey()/g' nerfacc/cuda/csrc/scan_cub.cu

# (Alternative you could use: sed -i "s/cub::Equality()/thrust::equal_to<int32_t>()/g" ...)

# 4) Fix the trailing-backslash warning by ensuring a newline at EOF.
#    This removes a stray final backslash and ensures newline exists.
#    If no backslash issue, this is harmless.
sed -i -e '$a\' nerfacc/cuda/csrc/include/utils.cub.cuh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions