<commit_before>// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-

/* This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Authors:
 * <NAME> <<EMAIL>>
 */

#ifndef _INPUTPROBASENDER_EASY_H_
#define _INPUTPROBASENDER_EASY_H_

#include "Base.h"

namespace dim
{
    namespace inputprobasender
    {
	template <typename EOT>
	class Easy : public Base<EOT>
	{
	public:
	    virtual void firstCall(core::Pop<EOT>& /*pop*/, core::IslandData<EOT>& data)
	    {
		_reqs.resize( this->size() );

		for (size_t i = 0; i < this->size(); ++i)
		    {
			if (i == this->rank()) { continue; }
			_reqs[i] = this->world().send_init( i, this->tag(), data.proba[i] );
		    }
	    }

	    void operator()(core::Pop<EOT>& /*pop*/, core::IslandData<EOT>& data)
	    {
		/***********************************
		 * Send vecProbaRet to all islands *
		 ***********************************/

		for (size_t i = 0; i < this->size(); ++i)
		    {
			if (i == this->rank()) { continue; }
			this->world().start( _reqs[i] );
		    }

		// for island itself because of the MPI communication optimizing.
		data.probaret[this->rank()] = data.proba[this->rank()];

		/**************************************
		 * Receive probaret from all islands *
		 **************************************/

		std::vector< boost::mpi::request > recv_reqs;

		for (size_t i = 0; i < this->size(); ++i)
		    {
			if (i == this->rank()) { continue; }
			recv_reqs.push_back( this->world().irecv( i, this->tag(), data.probaret[i] ) );
		    }

		/****************************
		 * Process all MPI requests *
		 ****************************/

		boost::mpi::wait_all( _reqs.begin(), _reqs.end() );
		boost::mpi::wait_all( recv_reqs.begin(), recv_reqs.end() );
	    }

	private:
	    std::vector< boost::mpi::request > _reqs;
	};
    }
}

#endif /* _INPUTPROBASENDER_EASY_H_ */<commit_msg>* src/dim/inputprobasender/Easy.h: added async class but it's currently not yet ready, use of dummy class available on algo::Easy<commit_after>// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-

/* This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Authors:
 * <NAME> <<EMAIL>>
 */

#ifndef _INPUTPROBASENDER_EASY_H_
#define _INPUTPROBASENDER_EASY_H_

#include "Base.h"

namespace dim
{
    namespace inputprobasender
    {
	namespace sync
	{
	    template <typename EOT>
	    class Easy : public Base<EOT>
	    {
	    public:
		virtual void firstCall(core::Pop<EOT>& /*pop*/, core::IslandData<EOT>& data)
		{
		    _reqs.resize( this->size() );

		    for (size_t i = 0; i < this->size(); ++i)
			{
			    if (i == this->rank()) { continue; }
			    _reqs[i] = this->world().send_init( i, this->tag(), data.proba[i] );
			}
		}

		void operator()(core::Pop<EOT>& /*pop*/, core::IslandData<EOT>& data)
		{
		    /***********************************
		     * Send vecProbaRet to all islands *
		     ***********************************/

		    for (size_t i = 0; i < this->size(); ++i)
			{
			    if (i == this->rank()) { continue; }
			    this->world().start( _reqs[i] );
			}

		    // for island itself because of the MPI communication optimizing.
		    data.probaret[this->rank()] = data.proba[this->rank()];

		    /**************************************
		     * Receive probaret from all islands *
		     **************************************/

		    std::vector< boost::mpi::request > recv_reqs;

		    for (size_t i = 0; i < this->size(); ++i)
			{
			    if (i == this->rank()) { continue; }
			    recv_reqs.push_back( this->world().irecv( i, this->tag(), data.probaret[i] ) );
			}

		    /****************************
		     * Process all MPI requests *
		     ****************************/

		    boost::mpi::wait_all( _reqs.begin(), _reqs.end() );
		    boost::mpi::wait_all( recv_reqs.begin(), recv_reqs.end() );
		}

	    private:
		std::vector< boost::mpi::request > _reqs;
	    };
	} // !sync

	namespace async
	{
	    template <typename EOT>
	    class Easy : public Base<EOT>
	    {
	    public:
		virtual void firstCompute(core::Pop<EOT>& /*pop*/, core::IslandData<EOT>& data)
		{
		    _reqs.resize( this->size() );

		    for (size_t i = 0; i < this->size(); ++i)
			{
			    if (i == this->rank()) { continue; }
			    _reqs[i] = this->world().send_init( i, this->tag(), data.proba[i] );
			}
		}

		void compute(core::Pop<EOT>& /*pop*/, core::IslandData<EOT>& data)
		{
		    /***********************************
		     * Send vecProbaRet to all islands *
		     ***********************************/

		    for (size_t i = 0; i < this->size(); ++i)
			{
			    if (i == this->rank()) { continue; }
			    this->world().start( _reqs[i] );
			}

		    // for island itself because of the MPI communication optimizing.
		    data.probaret[this->rank()] = data.proba[this->rank()];

		    /**************************************
		     * Receive probaret from all islands *
		     **************************************/

		    std::vector< boost::mpi::request > recv_reqs;

		    for (size_t i = 0; i < this->size(); ++i)
			{
			    if (i == this->rank()) { continue; }
			    recv_reqs.push_back( this->world().irecv( i, this->tag(), data.probaret[i] ) );
			}

		    /****************************
		     * Process all MPI requests *
		     ****************************/

		    boost::mpi::wait_all( _reqs.begin(), _reqs.end() );
		    boost::mpi::wait_all( recv_reqs.begin(), recv_reqs.end() );
		}

		void communicate(core::Pop<EOT>& /*pop*/, core::IslandData<EOT>& /*data*/)
		{
		    // empty
		}

	    private:
		std::vector< boost::mpi::request > _reqs;
	    };
	} // !async
    }
}

#endif /* _INPUTPROBASENDER_EASY_H_ */
{'fraction_non_alphanumeric': 0.2331583552055993, 'fraction_numerical': 0.006853310002916302, 'mean_word_length': 3.0973715651135008, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4128814', 'n_tokens_mistral': 2481, 'n_tokens_neox': 2158, 'n_words': 593}