OpenMathLib / OpenMathLib/OpenBLAS

Denormal floats handling

未关闭
#1,237 42 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C
星标
7.6k
派生
1.7k
平均合并
1 天 3 小时
30 天内合并 PR
42

描述

Dear @xianyi and everyone!

Is there a way to forbid denormals in the OpenBLAS?

I tried to execute the following code (MSVC2015) before calling any OpenBLAS routines:

	unsigned int current_word = 0;
	_controlfp_s(&current_word, _DN_FLUSH, _MCW_DN);
	_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
	_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);

and it looked like it worked for some time (about a year)... Does it really affect OpenBLAS denormals handling (especially inside worker threads)?

I started to use some additional OpenBLAS functions and noticed that denormals started to reappear in results again and that extremely slows down computations. I'm heavily suspecting that it is the OpenBLAS, who is responsible for them. Probably, the worker threads might still have enabled denormals?...

How to get rid of them?

I'm using precompiled OpenBLAS-v0.2.19-Win64-int32.

Here is the complete list of used functions (if it helps):

  • cblas_sgemm
  • cblas_ssyrk
  • cblas_ssymm
  • LAPACKE_sgesvd

UPD: indeed, cblas_ssyrk() is a first function which produces the first denormalized float during execution... :-(

How to change denormals behaviour?

May be there is a (reachable from outside) way to execute custom code in context of OpenBLAS's worker threads if there's no predefined way to control denormals?

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 cblas_ssyrk() 开始,该函数被确定为第一个产生非规格化 float 的函数,并检查 OpenBLAS 工作线程是如何初始化的。在预编译的 Windows 构建中,使用列出的 CBLAS 和 LAPACKE 调用复现该行为,然后确定非规格化值的处理是否会在工作线程中保留。完成的标准是解释清楚该行为,并确定一种有文档记录或经过测试的控制方式。

由索引模型根据 Issue 内容生成。

评估

技术栈
c
领域
hpc
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。