<commit_before>//=======================================================================
// Copyright (c) 2014-2020 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#pragma once

#include "cufft.h"

namespace etl::impl::cufft {

/*!
 * \brief Returns the string representation of the given
 * CUFFT status code.
 *
 * \param code The CUFFT status code
 *
 * \return the string representation of the given status code
 */
inline const char* cufft_str(cufftResult code) {
    switch (code) {
        case CUFFT_SUCCESS:
            return "CUFFT_SUCCESS";
        case CUFFT_INVALID_PLAN:
            return "CUFFT_INVALID_PLAN";
        case CUFFT_ALLOC_FAILED:
            return "CUFFT_ALLOC_FAILED";
        case CUFFT_INVALID_TYPE:
            return "CUFFT_INVALID_TYPE";
        case CUFFT_INVALID_VALUE:
            return "CUFFT_INVALID_VALUE";
        case CUFFT_INTERNAL_ERROR:
            return "CUFFT_INTERNAL_ERROR";
        case CUFFT_EXEC_FAILED:
            return "CUFFT_EXEC_FAILED";
        case CUFFT_SETUP_FAILED:
            return "CUFFT_SETUP_FAILED";
        case CUFFT_INVALID_SIZE:
            return "CUFFT_INVALID_SIZE";
        case CUFFT_UNALIGNED_DATA:
            return "CUFFT_UNALIGNED_DATA";
        default:
            return "unknown CUFFT error";
    }
}

#define cufft_check(call)                                                                                        \
    {                                                                                                            \
        auto status = call;                                                                                      \
        if (status != CUFFT_SUCCESS) {                                                                           \
            std::cerr << "CUDA error: " << etl::impl::cufft::cufft_str(status) << " from " << #call << std::endl \
                      << "from " << __FILE__ << ":" << __LINE__ << std::endl;                                    \
        }                                                                                                        \
    }

/*!
 * \brief RAII wrapper for CUFFT context
 */
struct cufft_handle {
    cufftHandle handle; ///< The CUFFT context handle

    /*!
     * \brief Create a new cufft_handle.
     */
    cufft_handle() {<commit_msg>Cleanup code<commit_after>//=======================================================================
// Copyright (c) 2014-2020 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#pragma once

#include "cufft.h"

namespace etl::impl::cufft {

/*!
 * \brief Returns the string representation of the given
 * CUFFT status code.
 *
 * \param code The CUFFT status code
 *
 * \return the string representation of the given status code
 */
inline const char* cufft_str(cufftResult code) {
    switch (code) {
        case CUFFT_SUCCESS:
            return "CUFFT_SUCCESS";
        case CUFFT_INVALID_PLAN:
            return "CUFFT_INVALID_PLAN";
        case CUFFT_ALLOC_FAILED:
            return "CUFFT_ALLOC_FAILED";
        case CUFFT_INVALID_TYPE:
            return "CUFFT_INVALID_TYPE";
        case CUFFT_INVALID_VALUE:
            return "CUFFT_INVALID_VALUE";
        case CUFFT_INTERNAL_ERROR:
            return "CUFFT_INTERNAL_ERROR";
        case CUFFT_EXEC_FAILED:
            return "CUFFT_EXEC_FAILED";
        case CUFFT_SETUP_FAILED:
            return "CUFFT_SETUP_FAILED";
        case CUFFT_INVALID_SIZE:
            return "CUFFT_INVALID_SIZE";
        case CUFFT_UNALIGNED_DATA:
            return "CUFFT_UNALIGNED_DATA";
        default:
            return "unknown CUFFT error";
    }
}

#define cufft_check(call)                                                                                    \
    if (auto status = call; status != CUFFT_SUCCESS) {                                                       \
        std::cerr << "CUDA error: " << etl::impl::cufft::cufft_str(status) << " from " << #call << std::endl \
                  << "from " << __FILE__ << ":" << __LINE__ << std::endl;                                    \
    }

/*!
 * \brief RAII wrapper for CUFFT context
 */
struct cufft_handle {
    cufftHandle handle; ///< The CUFFT context handle

    /*!
     * \brief Create a new cufft_handle.
     */
    cufft_handle() {
{'fraction_non_alphanumeric': 0.14560796192124623, 'fraction_numerical': 0.0034617048896581565, 'mean_word_length': 1.607445008460237, 'pattern_counts': {'":': 2, '<': 47, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1985775', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1203, 'n_words': 289}