Skip to content

Conversation

DannyIsFunny
Copy link
Collaborator

cherry-picked from #4378
【背景】
DeviceInfo会申请L3Cache尺寸的workspace_,供算子中汇编使用。
L3 cache与手机型号有关,在mate20手机上可达4M,但相应大小的 workspace_ 在小模型上不能全部被应用,造成内存浪费。

【本PR修改】
新增接口MobileConfig::SetArmL3CacheSize :补充四种设置 workspace_ 初始大小的方法

enum class L3CacheSetMethod {
  kDeviceL3Cache = 0, // Use the system L3 Cache size, best performance.
  kDeviceL2Cache = 1, // Use the system L2 Cache size, trade off performance
                      // with less memory consumption.
  kAbsolute = 2,      // Use the external setting.
  // kAutoGrow = 3,   // Not supported yet, least memory consumption.
};
struct MobileConfig {
  // ...
  // danger area
  void
  SetArmL3CacheSize(L3CacheSetMethod method = L3CacheSetMethod::kDeviceL3Cache,
                    int absolute_val) {}
  // ...
};

【使用示例】
workspace_ 设置为 L3_Cache的大小(默认行为)

// 不需要修改

workspace_ 设置为 L2_Cache的大小

MobileConfig::SetArmL3CacheSize(L3CacheSetMethod::kDeviceL2Cache);

设置绝对值(以1M为例)

MobileConfig::SetArmL3CacheSize(L3CacheSetMethod::kAbsolute, 1024 * 2014);

@DannyIsFunny DannyIsFunny changed the title [Framework] Add api for L3cache [Framework] Add method for specifying initial size of workspace_ Sep 22, 2020
Copy link
Collaborator

@Superjomn Superjomn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@hong19860320 hong19860320 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@chenjiaoAngel chenjiaoAngel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@yongqiangma yongqiangma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ysh329 ysh329 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DannyIsFunny DannyIsFunny merged commit cd9c4e1 into PaddlePaddle:release/v2.7 Sep 23, 2020
@DannyIsFunny DannyIsFunny deleted the L3Cache_v27 branch September 23, 2020 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants