ysh329 / OpenCL-101

Learn OpenCL step by step.
123 stars 31 forks source link

The Midgard Shader Core #44

Open ysh329 opened 3 years ago

ysh329 commented 3 years ago

https://developer.arm.com/solutions/graphics-and-gaming/developer-guides/learn-the-basics/the-midgard-shader-core/single-page

https://developer.arm.com/documentation/100614/0314/OpenCL-optimizations-list/Mali-Midgard-GPU-specific-optimizations

ysh329 commented 3 years ago

Mali Midgard GPU架构优化细节

Midgard架构包括了T600、T700以及800系列,Arm官方给了对该架构的优化细节,下面将逐一展开,并结合我的理解。这部分内容主题来自其官网对Midgard GPU在OpenCL的文档

kernel中所有线程结束的时间是相同的

Make your kernel code as simple as possible

Use vector operations in kernel code

Vectorize your code

Note

The Midgard compiler can auto-vectorize some scalar code.

Vectorize incrementally

Vectorize in incremental steps. For example, start processing one pixel at a time, then two, then four.

Avoid processing single values

Avoid writing kernels that operate on single bytes or other small values. Write kernels that work on vectors.

Use 128-bit vectors

Vector sizes of 128-bits are optimal. Vector sizes greater than 128-bits are broken into 128-bit parts and operated on separately. For example, adding two 256-bit vectors takes twice as long as adding two 128-bit vectors. You can use vector sizes less than 128 bits without issue.

The disadvantage of using vectors greater than 128 bits is that they can increase code size. Increased code size uses more instruction cache space and this can reduce performance.