Re: [eigen] runtime API to configure the cache/blocking parameters

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]




On Mon, Jun 7, 2010 at 5:28 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
Great!

Just one nit: why ei_ ? This is public API, and doesn't conflict with
a std:: name, so I don't think it should be ei_ prefixed.

sure!
 

Can you quickly explain me what the maxK and maxM are ?

see last commit:

  * \b Explanations: \n
  * Let A * B be a m x k times k x n matrix product. Then Eigen's product yield
  * L2 blocking on B with panels of size max_k x n, and L1 blocking on A,
  * with blocks of size max_m x max_k.

gael
 

Thanks,
Benoit

2010/6/7 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
> Hi,
>
> I've committed a change allowing to configure the cache size and the related
> blocking size parameters at runtime. It use the trick that consists in
> storing runtime variables as static members of a global function. This way
> no need to have a shared binary lib just for that.
>
> Here is the related "public" documented API:
>
> /** \returns the currently set cpu cache size (in bytes) used to estimate
> the ideal blocking size parameters */
> std::ptrdiff_t ei_cpuCacheSize();
>
> /** Set the cpu cache size (in bytes) for blocking.
>   * This function also automatically set the blocking size parameters for
> each scalar type using the following formula:
>   * \code
>   *  max_k = 4 * sqrt(cache_size/(64*sizeof(Scalar)));
>   *  max_m = 2 * k;
>   * \endcode
>   * overwriting custom values set using the ei_setBlockingSizes function.
>   * \sa ei_setBlockingSizes */
> void ei_setCpuCacheSize(std::ptrdiff_t cache_size);
>
> /** Set the blocking size parameters \a maxK and \a maxM for the scalar type
> \a Scalar.
>   * Note that in practice there is no distinction between scalar types of
> same size.
>   * \sa ei_setCpuCacheSize */
> template<typename Scalar>
> void ei_setBlockingSizes(std::ptrdiff_t maxK, std::ptrdiff_t maxM);
>
> /** \returns in \a makK, \a maxM the blocking size parameters for the scalar
> type \a Scalar.
>   * \sa ei_setBlockingSizes */
> template<typename Scalar>
> void ei_getBlockingSizes(std::ptrdiff_t& maxK, std::ptrdiff_t& maxM);
>
> You can also see the complete diff there:
> http://bitbucket.org/eigen/eigen/changeset/af6d26ce2778 to see how it is
> implemented in practice.
>
> This API is just a proposal, if someone has better ideas...
>
> gael
>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/