Reply to comment

Вместо pow() и sqrt() использовать native_pow() и native_sqrt(). Вместо умножений и сложений можно использовать mad(). Некоторые операции можно заменить на dot(). Если видеокарта - ATI, лучше все векторизовать. Функцию mul(float4 A, float4 B) можно заменить/перпеписать как A.yzx*B.zxy - A.zxy*B.yzx. Дальше - смотреть профайлером что просаживает производительность.

Ещё, не надо определять PI - уже есть M_PI_F.

Все операции производятся над 3-х компонентными векторами, но используются 4-х компонентные float4. Если это из соображений быстрого чтения из памяти - проверьте, возможно на платформе и так sizeof(cl_float4) == sizeof(float3), и не имеет смысла использовать float4.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <i> <table> <td> <tr> <th>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Images can be added to this post.

More information about formatting options

Copyright © 2008-2011 Alex Tutubalin