Path: blob/master/thirdparty/embree/kernels/common/stat.h
9905 views
// Copyright 2009-2021 Intel Corporation1// SPDX-License-Identifier: Apache-2.023#pragma once45#include "default.h"67/* Macros to gather statistics */8#ifdef EMBREE_STAT_COUNTERS9# define STAT(x) x10# define STAT3(s,x,y,z) \11STAT(Stat::get().code .s+=x); \12STAT(Stat::get().active.s+=y); \13STAT(Stat::get().all .s+=z);14# define STAT_USER(i,x) Stat::get().user[i]+=x;15#else16# define STAT(x)17# define STAT3(s,x,y,z)18# define STAT_USER(i,x)19#endif2021namespace embree22{23/*! Gathers ray tracing statistics. We count 1) how often a code24* location is reached, 2) how many SIMD lanes are active, 3) how25* many SIMD lanes reach the code location */26class Stat27{28public:2930static const size_t SIZE_HISTOGRAM = 64+1;3132/*! constructs stat counter class */33Stat ();3435/*! destructs stat counter class */36~Stat ();3738class Counters39{40public:41Counters () {42clear();43}4445void clear()46{47all.clear();48active.clear();49code.clear();50for (auto& u : user) u.store(0);51}5253public:5455/* per packet and per ray stastics */56struct Data57{58void clear () {59normal.clear();60shadow.clear();61point_query.clear();62}6364/* normal and shadow ray statistics */65struct66{67void clear()68{69travs.store(0);70trav_nodes.store(0);71trav_leaves.store(0);72trav_prims.store(0);73trav_prim_hits.store(0);74for (auto& v : trav_hit_boxes) v.store(0);75trav_stack_pop.store(0);76trav_stack_nodes.store(0);77trav_xfm_nodes.store(0);78}7980public:81std::atomic<size_t> travs;82std::atomic<size_t> trav_nodes;83std::atomic<size_t> trav_leaves;84std::atomic<size_t> trav_prims;85std::atomic<size_t> trav_prim_hits;86std::atomic<size_t> trav_hit_boxes[SIZE_HISTOGRAM+1];87std::atomic<size_t> trav_stack_pop;88std::atomic<size_t> trav_stack_nodes;89std::atomic<size_t> trav_xfm_nodes;9091} normal, shadow, point_query;92} all, active, code;9394std::atomic<size_t> user[10];95};9697public:9899static __forceinline Counters& get() {100return instance.cntrs;101}102103static void clear() {104instance.cntrs.clear();105}106107static void print(embree_ostream cout);108109private:110Counters cntrs;111112private:113static Stat instance;114};115}116117118