<commit_before>/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
/* ffpack/ffpack_ppluq.inl
 * Copyright (C) 2014 <NAME>
 *
 * Written by <EMAIL>
 *
 *
 * ========LICENCE========
 * This file is part of the library FFLAS-FFPACK.
 *
 * FFLAS-FFPACK 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 2.1 of the License, or (at your option) any later version.
 *
 * This library 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 this library; if not, WRITE to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 *.
 */

#ifndef __FFLASFFPACK_ffpack_ppluq_INL
#define __FFLASFFPACK_ffpack_ppluq_INL


//#ifdef __FFLASFFPACK_USE_OPENMP

#define __FFLAS__TRSM_READONLY

#define PBASECASE_K 256


namespace FFPACK {

	template<class Field>
	void  threads_fgemm(const size_t m, const size_t n, const size_t r, int nbthreads, size_t * W1, size_t * W2, size_t * W3, size_t gamma)
	{
		size_t H1, H2, H3;
		size_t M2 = m>>1;
		size_t N2 = n>>1;

		H1 = ((m-N2)*r*(N2-r))<<1;
		H2 = ((M2-r)*r*(n-N2))<<1;
		H3 = ((m-M2)*r*(n-N2))<<1;

		// if we take into account 2 concurrent pluq calls....
		size_t h;
		size_t z1= h*((m-M2)*(N2-r)*(N2-r)-(N2-r)*(N2-r)*(N2-r)/3);
		size_t z2= h*((n-N2)*(M2-r)*(M2-r)-(M2-r)*(M2-r)*(M2-r)/3);

		H1+= z1;
		H2+= z2;

		// compute number of threads for each fgemm call
		*W1=std::max(H1*nbthreads/(H1+H2+H3),(size_t)1);
		*W2=std::max(H2*nbthreads/(H1+H2+H3),(size_t)1);
		*W3=std::max(nbthreads-*W1-*W2,(size_t)1);

		// add gamma factor to change number of threads for pluq calls
		W1-= gamma*z1/(z1+z2);
		W2-= gamma*(1-z1/(z1+z2));
		W3+= gamma;

	}

	template<class Field>
	void threads_ftrsm(const size_t m, const size_t n, int nbthreads, size_t * t1, size_t * t2)
	{
		*t1 = nbthreads*m/(m+n);
		*t2 = nbthreads-(int)*t1;
	}


	template<class Field>
	inline size_t
	pPLUQ(const Field& Fi, const FFLAS::FFLAS_DIAG Diag,
	      const size_t M, const size_t N,
	      typename Field::Element_ptr A, const size_t lda,
	      size_t* P, size_t* Q, int nt)
	  {<commit_msg>pPLUQ should be PLUQ with Parallel Helper<commit_after>/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
/* ffpack/ffpack_ppluq.inl
 * Copyright (C) 2014 <NAME>
 *
 * Written by <EMAIL>
 *
 *
 * ========LICENCE========
 * This file is part of the library FFLAS-FFPACK.
 *
 * FFLAS-FFPACK 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 2.1 of the License, or (at your option) any later version.
 *
 * This library 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 this library; if not, WRITE to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 *.
 */

#ifndef __FFLASFFPACK_ffpack_ppluq_INL
#define __FFLASFFPACK_ffpack_ppluq_INL


//#ifdef __FFLASFFPACK_USE_OPENMP

#define __FFLAS__TRSM_READONLY

#define PBASECASE_K 256


namespace FFPACK {

	template<class Field>
	void  threads_fgemm(const size_t m, const size_t n, const size_t r, int nbthreads, size_t * W1, size_t * W2, size_t * W3, size_t gamma)
	{
		size_t H1, H2, H3;
		size_t M2 = m>>1;
		size_t N2 = n>>1;

		H1 = ((m-N2)*r*(N2-r))<<1;
		H2 = ((M2-r)*r*(n-N2))<<1;
		H3 = ((m-M2)*r*(n-N2))<<1;

		// if we take into account 2 concurrent pluq calls....
		size_t h;
		size_t z1= h*((m-M2)*(N2-r)*(N2-r)-(N2-r)*(N2-r)*(N2-r)/3);
		size_t z2= h*((n-N2)*(M2-r)*(M2-r)-(M2-r)*(M2-r)*(M2-r)/3);

		H1+= z1;
		H2+= z2;

		// compute number of threads for each fgemm call
		*W1=std::max(H1*nbthreads/(H1+H2+H3),(size_t)1);
		*W2=std::max(H2*nbthreads/(H1+H2+H3),(size_t)1);
		*W3=std::max(nbthreads-*W1-*W2,(size_t)1);

		// add gamma factor to change number of threads for pluq calls
		W1-= gamma*z1/(z1+z2);
		W2-= gamma*(1-z1/(z1+z2));
		W3+= gamma;

	}

	template<class Field>
	void threads_ftrsm(const size_t m, const size_t n, int nbthreads, size_t * t1, size_t * t2)
	{
		*t1 = nbthreads*m/(m+n);
		*t2 = nbthreads-(int)*t1;
	}


	    // TODO: replace pPLUQ and "int nt", by PLUQ and a Parallel Helper ...
	template<class Field>
	inline size_t
	pPLUQ(const Field& Fi, const FFLAS::FFLAS_DIAG Diag,
	      const size_t M, const size_t N,
	      typename Field::Element_ptr A, const size_t lda,
	      size_t* P, size_t* Q, int nt)
	  {
{'fraction_non_alphanumeric': 0.15856437523737182, 'fraction_numerical': 0.040258260539308775, 'mean_word_length': 3.7579042457091236, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, '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': '2870877', 'n_tokens_mistral': 2318, 'n_tokens_neox': 2130, 'n_words': 598}