From a28604f88ab5e662a7e01593b8f3d76090f05400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Mon, 16 Sep 2024 20:16:19 +0200 Subject: [PATCH] REMOVE_ME: add more debug printing --- src/bvh/split/cluster.hpp | 3 +++ src/bvh/util/sort.hpp | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/bvh/split/cluster.hpp b/src/bvh/split/cluster.hpp index 2b8e06c..8bd1acb 100644 --- a/src/bvh/split/cluster.hpp +++ b/src/bvh/split/cluster.hpp @@ -157,6 +157,9 @@ namespace bvh // Mark these with 1, then we can execute an exclusive scan to re-index Kokkos::parallel_for( n - 1, KOKKOS_CLASS_LAMBDA( std::size_t _i ) { m_reindex( m_depths_indices( _i ) ) = ( _i < cluster_count ) ? 1 : 0; + printf( "cluster_count: %d\t_i: %d\t m_depths_indices(_i): %d\tm_reindex(...): %d\n", + static_cast< int >( cluster_count ), static_cast< int >( _i ), + static_cast< int >( m_depths_indices( _i ) ), static_cast< int >( m_reindex( m_depths_indices( _i ) ) ) ); } ); prefix_sum( m_reindex ); diff --git a/src/bvh/util/sort.hpp b/src/bvh/util/sort.hpp index fe7f438..99a4aec 100644 --- a/src/bvh/util/sort.hpp +++ b/src/bvh/util/sort.hpp @@ -33,6 +33,7 @@ #ifndef INC_BVH_UTIL_SORT_HPP #define INC_BVH_UTIL_SORT_HPP +#include #include #include @@ -122,9 +123,18 @@ namespace bvh m_bits( i ) = ~h & 0x1; m_scan( i ) = m_bits( i ); } ); + // Kokkos::fence(); prefix_sum( m_scan ); - Kokkos::parallel_for( n, KOKKOS_CLASS_LAMBDA ( int i ){ + // Kokkos::fence(); + + Kokkos::parallel_for( n, KOKKOS_CLASS_LAMBDA( int i ) { + // this seems to work fine + // printf("i: %d\t num_bits: %d\t _shift: %d\t \n", + // i, + // static_cast(num_bits), + // static_cast(_shift)); + const auto total = m_scan( n - 1 ) + m_bits( n - 1 ); auto t = i - m_scan( i ) + total; @@ -132,6 +142,7 @@ namespace bvh m_index_scratch( new_idx ) = _indices( i ); m_scratch( new_idx ) = _hashes( i ); } ); + // Kokkos::fence(); } private: