<commit_before>/**
 * \file
 * Copyright 2016 <NAME>
 *
 * This file is part of alpaka.
 *
 * alpaka is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * alpaka is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with alpaka.
 * If not, see <http://www.gnu.org/licenses/>.
 */

// \Hack: Boost.MPL defines BOOST_MPL_CFG_GPU_ENABLED to __host__ __device__ if nvcc is used.
// BOOST_AUTO_TEST_CASE_TEMPLATE and its internals are not GPU enabled but is using boost::mpl::for_each internally.
// For each template parameter this leads to:
// /home/travis/build/boost/boost/mpl/for_each.hpp(78): warning: calling a __host__ function from a __host__ __device__ function is not allowed
// because boost::mpl::for_each has the BOOST_MPL_CFG_GPU_ENABLED attribute but the test internals are pure host methods.
// Because we do not use MPL within GPU code here, we can disable the MPL GPU support.
#define BOOST_MPL_CFG_GPU_ENABLED

#include <alpaka/alpaka.hpp>
#include <alpaka/test/acc/Acc.hpp>                  // alpaka::test::acc::TestAccs
#include <alpaka/test/KernelExecutionFixture.hpp>   // alpaka::test::KernelExecutionFixture

#include <boost/assert.hpp>                         // BOOST_VERIFY
#include <boost/predef.h>                           // BOOST_COMP_CLANG
#if BOOST_COMP_CLANG
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wunused-parameter"
#endif
#include <boost/test/unit_test.hpp>
#if BOOST_COMP_CLANG
    #pragma clang diagnostic pop
#endif

//#############################################################################
//!
//#############################################################################
class AtomicTestKernel
{
public:
    //-----------------------------------------------------------------------------
    //!
    //-----------------------------------------------------------------------------
    ALPAKA_NO_HOST_ACC_WARNING
    template<
        typename TAcc,
        typename T>
    ALPAKA_FN_ACC auto operator()(
        TAcc const & acc,
        T operandOrig) const
    -> void
    {
        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Add
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Add>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = operandOrig + value;
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Sub
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Sub>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = operandOrig - value;
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Min
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Min>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = std::min(operandOrig, value);
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Max
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Max>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = std::max(operandOrig, value);
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Exch
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Exch>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = value;
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------<commit_msg>replace std::min and std::max in kernel with ternary operators<commit_after>/**
 * \file
 * Copyright 2016 <NAME>
 *
 * This file is part of alpaka.
 *
 * alpaka is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * alpaka is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with alpaka.
 * If not, see <http://www.gnu.org/licenses/>.
 */

// \Hack: Boost.MPL defines BOOST_MPL_CFG_GPU_ENABLED to __host__ __device__ if nvcc is used.
// BOOST_AUTO_TEST_CASE_TEMPLATE and its internals are not GPU enabled but is using boost::mpl::for_each internally.
// For each template parameter this leads to:
// /home/travis/build/boost/boost/mpl/for_each.hpp(78): warning: calling a __host__ function from a __host__ __device__ function is not allowed
// because boost::mpl::for_each has the BOOST_MPL_CFG_GPU_ENABLED attribute but the test internals are pure host methods.
// Because we do not use MPL within GPU code here, we can disable the MPL GPU support.
#define BOOST_MPL_CFG_GPU_ENABLED

#include <alpaka/alpaka.hpp>
#include <alpaka/test/acc/Acc.hpp>                  // alpaka::test::acc::TestAccs
#include <alpaka/test/KernelExecutionFixture.hpp>   // alpaka::test::KernelExecutionFixture

#include <boost/assert.hpp>                         // BOOST_VERIFY
#include <boost/predef.h>                           // BOOST_COMP_CLANG
#if BOOST_COMP_CLANG
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wunused-parameter"
#endif
#include <boost/test/unit_test.hpp>
#if BOOST_COMP_CLANG
    #pragma clang diagnostic pop
#endif

//#############################################################################
//!
//#############################################################################
class AtomicTestKernel
{
public:
    //-----------------------------------------------------------------------------
    //!
    //-----------------------------------------------------------------------------
    ALPAKA_NO_HOST_ACC_WARNING
    template<
        typename TAcc,
        typename T>
    ALPAKA_FN_ACC auto operator()(
        TAcc const & acc,
        T operandOrig) const
    -> void
    {
        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Add
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Add>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = operandOrig + value;
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Sub
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Sub>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = operandOrig - value;
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Min
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Min>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = (operandOrig < value) ? operandOrig : value;
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Max
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Max>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = (operandOrig > value) ? operandOrig : value;
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------
        // alpaka::atomic::op::Exch
        {
            T operand = operandOrig;
            T const value = static_cast<T>(4);
            T const ret =
                alpaka::atomic::atomicOp<
                    alpaka::atomic::op::Exch>(
                        acc,
                        &operand,
                        value);
            BOOST_VERIFY(operandOrig == ret);
            T const reference = value;
            BOOST_VERIFY(operand == reference);
        }

        //-----------------------------------------------------------------------------
{'fraction_non_alphanumeric': 0.2195973154362416, 'fraction_numerical': 0.002147651006711409, 'mean_word_length': 1.301956745623069, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5432329', 'n_tokens_mistral': 2777, 'n_tokens_neox': 2665, 'n_words': 744}