<commit_before>/******************************************************************************\
 *           ___        __                                                    *
 *          /\_ \    __/\ \                                                   *
 *          \//\ \  /\_\ \ \____    ___   _____   _____      __               *
 *            \ \ \ \/\ \ \ '__`\  /'___\/\ '__`\/\ '__`\  /'__`\             *
 *             \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_           *
 *             /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\          *
 *             \/____/ \/_/\/___/  \/____/ \ \ \/  \ \ \/  \/__/\/_/          *
 *                                          \ \_\   \ \_\                     *
 *                                           \/_/    \/_/                     *
 *                                                                            *
 * Copyright (C) 2011-2013                                                    *
 * <NAME> <<EMAIL>>                     *
 * <NAME> <<EMAIL>>                           *
 *                                                                            *
 * This file is part of libcppa.                                              *
 * libcppa 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.                                     *
 *                                                                            *
 * libcppa 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 libcppa. If not, see <http://www.gnu.org/licenses/>.            *
\******************************************************************************/


#ifndef CPPA_OPENCL_ACTOR_FACADE_HPP
#define CPPA_OPENCL_ACTOR_FACADE_HPP

#include <iostream>

#include "cppa/channel.hpp"
#include "cppa/to_string.hpp"
#include "cppa/tuple_cast.hpp"
#include "cppa/intrusive_ptr.hpp"

#include "cppa/util/int_list.hpp"
#include "cppa/util/type_list.hpp"

#include "cppa/opencl/global.hpp"
#include "cppa/opencl/command.hpp"
#include "cppa/opencl/program.hpp"
#include "cppa/opencl/smart_ptr.hpp"

#include "cppa/detail/scheduled_actor_dummy.hpp"

namespace cppa { namespace opencl {

class command_dispatcher;

void enqueue_to_dispatcher(command_dispatcher*, command_ptr);

template<typename Signature>
class actor_facade;

template<typename Ret, typename... Args>
class actor_facade<Ret(Args...)> : public cppa::detail::scheduled_actor_dummy {

 public:

    actor_facade(command_dispatcher* dispatcher,
                 const program& prog,
                 const std::string& kernel_name)
        : m_program(prog.m_program)
        , m_context(prog.m_context)
        , m_kernel_name(kernel_name)
        , m_dispatcher(dispatcher)
    {
        cl_int err{0};
        m_kernel.adopt(clCreateKernel(m_program.get(),
                                      m_kernel_name.c_str(),
                                      &err));
        if (err != CL_SUCCESS) {
            throw std::runtime_error("[!!!] clCreateKernel: '"
                                     + get_opencl_error(err)
                                     + "'.");
        }
    }

    void enqueue(actor* sender, any_tuple msg) {
        typename util::il_indices<util::type_list<Args...>>::type indices;
        enqueue_impl(sender, msg, indices);
    }

 private:

    template<long... Is>
    void enqueue_impl(actor* sender, any_tuple msg, util::int_list<Is...>) {
        auto opt = tuple_cast<Args...>(msg);
        if (opt) {
            response_handle handle{this, sender, message_id_t{}};
            std::vector<size_t> global_dimensions {1024, 1, 1};
            std::vector<size_t> local_dimensions;
            int number_of_values = 1;
            for (size_t s : global_dimensions) {
                number_of_values *= s;<commit_msg>adapt to changed actor interface<commit_after>/******************************************************************************\
 *           ___        __                                                    *
 *          /\_ \    __/\ \                                                   *
 *          \//\ \  /\_\ \ \____    ___   _____   _____      __               *
 *            \ \ \ \/\ \ \ '__`\  /'___\/\ '__`\/\ '__`\  /'__`\             *
 *             \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_           *
 *             /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\          *
 *             \/____/ \/_/\/___/  \/____/ \ \ \/  \ \ \/  \/__/\/_/          *
 *                                          \ \_\   \ \_\                     *
 *                                           \/_/    \/_/                     *
 *                                                                            *
 * Copyright (C) 2011-2013                                                    *
 * <NAME> <<EMAIL>>                     *
 * <NAME> <<EMAIL>>                           *
 *                                                                            *
 * This file is part of libcppa.                                              *
 * libcppa 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.                                     *
 *                                                                            *
 * libcppa 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 libcppa. If not, see <http://www.gnu.org/licenses/>.            *
\******************************************************************************/


#ifndef CPPA_OPENCL_ACTOR_FACADE_HPP
#define CPPA_OPENCL_ACTOR_FACADE_HPP

#include <iostream>

#include "cppa/channel.hpp"
#include "cppa/to_string.hpp"
#include "cppa/tuple_cast.hpp"
#include "cppa/intrusive_ptr.hpp"

#include "cppa/util/int_list.hpp"
#include "cppa/util/type_list.hpp"

#include "cppa/opencl/global.hpp"
#include "cppa/opencl/command.hpp"
#include "cppa/opencl/program.hpp"
#include "cppa/opencl/smart_ptr.hpp"

#include "cppa/detail/scheduled_actor_dummy.hpp"

namespace cppa { namespace opencl {

class command_dispatcher;

void enqueue_to_dispatcher(command_dispatcher*, command_ptr);

template<typename Signature>
class actor_facade;

template<typename Ret, typename... Args>
class actor_facade<Ret(Args...)> : public cppa::detail::scheduled_actor_dummy {

 public:

    actor_facade(command_dispatcher* dispatcher,
                 const program& prog,
                 const std::string& kernel_name)
        : m_program(prog.m_program)
        , m_context(prog.m_context)
        , m_kernel_name(kernel_name)
        , m_dispatcher(dispatcher)
    {
        cl_int err{0};
        m_kernel.adopt(clCreateKernel(m_program.get(),
                                      m_kernel_name.c_str(),
                                      &err));
        if (err != CL_SUCCESS) {
            throw std::runtime_error("[!!!] clCreateKernel: '"
                                     + get_opencl_error(err)
                                     + "'.");
        }
    }

    void enqueue(const actor_ptr& sender, any_tuple msg) {
        typename util::il_indices<util::type_list<Args...>>::type indices;
        enqueue_impl(sender, msg, indices);
    }

 private:

    template<long... Is>
    void enqueue_impl(const actor_ptr& sender, any_tuple msg, util::int_list<Is...>) {
        auto opt = tuple_cast<Args...>(msg);
        if (opt) {
            response_handle handle{this, sender, message_id_t{}};
            std::vector<size_t> global_dimensions {1024, 1, 1};
            std::vector<size_t> local_dimensions;
            int number_of_values = 1;
            for (size_t s : global_dimensions) {
                number_of_values *= s;
{'fraction_non_alphanumeric': 0.14573713255997298, 'fraction_numerical': 0.003829260051807636, 'mean_word_length': 1.2373393801965231, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 60, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3281277', 'n_tokens_mistral': 2380, 'n_tokens_neox': 2269, 'n_words': 477}