Program Listing for File AgentLoggingConfig_Reductions.cuh
↰ Return to documentation for file (include/flamegpu/simulation/AgentLoggingConfig_Reductions.cuh
)
#ifndef INCLUDE_FLAMEGPU_SIMULATION_AGENTLOGGINGCONFIG_REDUCTIONS_CUH_
#define INCLUDE_FLAMEGPU_SIMULATION_AGENTLOGGINGCONFIG_REDUCTIONS_CUH_
namespace flamegpu {
namespace detail {
struct standard_deviation_add_impl {
public:
template <typename OutT>
struct binary_function {
__device__ __forceinline__ OutT operator()(const OutT &a, const OutT &b) const;
};
};
struct standard_deviation_subtract_mean_impl {
public:
template<typename InT, typename OutT>
struct unary_function {
__host__ __device__ OutT operator()(const InT &a) const;
};
};
extern __constant__ double STANDARD_DEVIATION_MEAN;
extern std::mutex STANDARD_DEVIATION_MEAN_mutex;
extern standard_deviation_add_impl standard_deviation_add;
extern standard_deviation_subtract_mean_impl standard_deviation_subtract_mean;
template <typename OutT>
__device__ __forceinline__ OutT standard_deviation_add_impl::binary_function<OutT>::operator()(const OutT & a, const OutT & b) const {
return a + b;
}
template<typename InT, typename OutT>
__device__ __forceinline__ OutT standard_deviation_subtract_mean_impl::unary_function<InT, OutT>::operator()(const InT &a) const {
return pow(a - detail::STANDARD_DEVIATION_MEAN, 2.0);
}
} // namespace detail
} // namespace flamegpu
#endif // INCLUDE_FLAMEGPU_SIMULATION_AGENTLOGGINGCONFIG_REDUCTIONS_CUH_