[PATCH v3 0/7] GPU workload hints for better performance

Arvind Yadav posted 7 patches 2 years, 3 months ago
drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu.h           |   3 +
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |   8 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |   6 +
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       |   5 +
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c       |  14 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c  | 226 ++++++++++++++++++
drivers/gpu/drm/amd/include/amdgpu_workload.h |  61 +++++
8 files changed, 309 insertions(+), 16 deletions(-)
create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c
create mode 100644 drivers/gpu/drm/amd/include/amdgpu_workload.h
[PATCH v3 0/7] GPU workload hints for better performance
Posted by Arvind Yadav 2 years, 3 months ago
AMDGPU SOCs supports dynamic workload based power profiles, which can
provide fine-tuned performance for a particular type of workload.
This patch series adds an interface to set/reset these power profiles
based on the submitted job. The driver can dynamically switch
the power profiles based on submitted job. This can optimize the power
performance when the particular workload is on. 

v2:
- Splitting workload_profile_set and workload_profile_put
  into two separate patches.
- Addressed review comment.
- Added new suspend function.
- Added patch to switches the GPU workload mode for KFD. 

v3:
- Addressed all review comment.
- Changed the function name from *_set() to *_get().
- Now clearing all the profile in work handler.
- Added *_clear_all function to clear all the power profile.


Arvind Yadav (7):
  drm/amdgpu: Added init/fini functions for workload
  drm/amdgpu: Add new function to set GPU power profile
  drm/amdgpu: Add new function to put GPU power profile
  drm/amdgpu: Add suspend function to clear the GPU power profile.
  drm/amdgpu: Set/Reset GPU workload profile
  drm/amdgpu: switch workload context to/from compute
  Revert "drm/amd/amdgpu: switch on/off vcn power profile mode"

 drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |   3 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |   8 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |   6 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       |   5 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c       |  14 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c  | 226 ++++++++++++++++++
 drivers/gpu/drm/amd/include/amdgpu_workload.h |  61 +++++
 8 files changed, 309 insertions(+), 16 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c
 create mode 100644 drivers/gpu/drm/amd/include/amdgpu_workload.h

-- 
2.34.1
Re: [PATCH v3 0/7] GPU workload hints for better performance
Posted by Helen Mae Koike Fornazier 2 years, 3 months ago
On Monday, August 28, 2023 09:26 -03, Arvind Yadav <Arvind.Yadav@amd.com> wrote:

> AMDGPU SOCs supports dynamic workload based power profiles, which can
> provide fine-tuned performance for a particular type of workload.
> This patch series adds an interface to set/reset these power profiles
> based on the submitted job. The driver can dynamically switch
> the power profiles based on submitted job. This can optimize the power
> performance when the particular workload is on. 

Hi Arvind,

Would you mind to test your patchset with drm-ci ? There is a amdgpu
test there and I would love to get your feedback of the ci.

You basically just need to apply the ci patch which is available on
https://cgit.freedesktop.org/drm/drm/log/?h=topic/drm-ci

There are instruction on the docs, but in short: to configure it, you push
your branch to gitlab.freedesktop.org, go to the settings and change the
CI/CD configuration file from .gitlab-ci.yml to drivers/gpu/drm/ci/gitlab-ci.yml,
and you can trigger a pipeline on your branch to get tests running.

(by the time of this writing, gitlab.fdo is under maintenance but should
be up soonish).

Thank you!
Helen

> 
> v2:
> - Splitting workload_profile_set and workload_profile_put
>   into two separate patches.
> - Addressed review comment.
> - Added new suspend function.
> - Added patch to switches the GPU workload mode for KFD. 
> 
> v3:
> - Addressed all review comment.
> - Changed the function name from *_set() to *_get().
> - Now clearing all the profile in work handler.
> - Added *_clear_all function to clear all the power profile.
> 
> 
> Arvind Yadav (7):
>   drm/amdgpu: Added init/fini functions for workload
>   drm/amdgpu: Add new function to set GPU power profile
>   drm/amdgpu: Add new function to put GPU power profile
>   drm/amdgpu: Add suspend function to clear the GPU power profile.
>   drm/amdgpu: Set/Reset GPU workload profile
>   drm/amdgpu: switch workload context to/from compute
>   Revert "drm/amd/amdgpu: switch on/off vcn power profile mode"
> 
>  drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h           |   3 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |   8 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |   6 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       |   5 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c       |  14 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c  | 226 ++++++++++++++++++
>  drivers/gpu/drm/amd/include/amdgpu_workload.h |  61 +++++
>  8 files changed, 309 insertions(+), 16 deletions(-)
>  create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c
>  create mode 100644 drivers/gpu/drm/amd/include/amdgpu_workload.h
> 
> -- 
> 2.34.1
>
Re: [PATCH v3 0/7] GPU workload hints for better performance
Posted by Yadav, Arvind 2 years, 3 months ago
On 8/28/2023 9:13 PM, Helen Mae Koike Fornazier wrote:
> On Monday, August 28, 2023 09:26 -03, Arvind Yadav <Arvind.Yadav@amd.com> wrote:
>
>> AMDGPU SOCs supports dynamic workload based power profiles, which can
>> provide fine-tuned performance for a particular type of workload.
>> This patch series adds an interface to set/reset these power profiles
>> based on the submitted job. The driver can dynamically switch
>> the power profiles based on submitted job. This can optimize the power
>> performance when the particular workload is on.
> Hi Arvind,
>
> Would you mind to test your patchset with drm-ci ? There is a amdgpu
> test there and I would love to get your feedback of the ci.
>
> You basically just need to apply the ci patch which is available on
> https://cgit.freedesktop.org/drm/drm/log/?h=topic/drm-ci
>
> There are instruction on the docs, but in short: to configure it, you push
> your branch to gitlab.freedesktop.org, go to the settings and change the
> CI/CD configuration file from .gitlab-ci.yml to drivers/gpu/drm/ci/gitlab-ci.yml,
> and you can trigger a pipeline on your branch to get tests running.
>
> (by the time of this writing, gitlab.fdo is under maintenance but should
> be up soonish).

Hi Helen,

I tried the steps as mentioned by you but looks like something is 
missing and build itself is failing.

https://gitlab.freedesktop.org/ArvindYadav/drm-next/-/commits/smu_workload

Regards,
~Arvind

> Thank you!
> Helen
>
>> v2:
>> - Splitting workload_profile_set and workload_profile_put
>>    into two separate patches.
>> - Addressed review comment.
>> - Added new suspend function.
>> - Added patch to switches the GPU workload mode for KFD.
>>
>> v3:
>> - Addressed all review comment.
>> - Changed the function name from *_set() to *_get().
>> - Now clearing all the profile in work handler.
>> - Added *_clear_all function to clear all the power profile.
>>
>>
>> Arvind Yadav (7):
>>    drm/amdgpu: Added init/fini functions for workload
>>    drm/amdgpu: Add new function to set GPU power profile
>>    drm/amdgpu: Add new function to put GPU power profile
>>    drm/amdgpu: Add suspend function to clear the GPU power profile.
>>    drm/amdgpu: Set/Reset GPU workload profile
>>    drm/amdgpu: switch workload context to/from compute
>>    Revert "drm/amd/amdgpu: switch on/off vcn power profile mode"
>>
>>   drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h           |   3 +
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |   8 +-
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |   6 +
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       |   5 +
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c       |  14 +-
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c  | 226 ++++++++++++++++++
>>   drivers/gpu/drm/amd/include/amdgpu_workload.h |  61 +++++
>>   8 files changed, 309 insertions(+), 16 deletions(-)
>>   create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c
>>   create mode 100644 drivers/gpu/drm/amd/include/amdgpu_workload.h
>>
>> -- 
>> 2.34.1
>>
Re: [PATCH v3 0/7] GPU workload hints for better performance
Posted by Helen Koike 2 years, 3 months ago

On 28/08/2023 17:14, Yadav, Arvind wrote:
> 
> On 8/28/2023 9:13 PM, Helen Mae Koike Fornazier wrote:
>> On Monday, August 28, 2023 09:26 -03, Arvind Yadav 
>> <Arvind.Yadav@amd.com> wrote:
>>
>>> AMDGPU SOCs supports dynamic workload based power profiles, which can
>>> provide fine-tuned performance for a particular type of workload.
>>> This patch series adds an interface to set/reset these power profiles
>>> based on the submitted job. The driver can dynamically switch
>>> the power profiles based on submitted job. This can optimize the power
>>> performance when the particular workload is on.
>> Hi Arvind,
>>
>> Would you mind to test your patchset with drm-ci ? There is a amdgpu
>> test there and I would love to get your feedback of the ci.
>>
>> You basically just need to apply the ci patch which is available on
>> https://cgit.freedesktop.org/drm/drm/log/?h=topic/drm-ci
>>
>> There are instruction on the docs, but in short: to configure it, you 
>> push
>> your branch to gitlab.freedesktop.org, go to the settings and change the
>> CI/CD configuration file from .gitlab-ci.yml to 
>> drivers/gpu/drm/ci/gitlab-ci.yml,
>> and you can trigger a pipeline on your branch to get tests running.
>>
>> (by the time of this writing, gitlab.fdo is under maintenance but should
>> be up soonish).
> 
> Hi Helen,
> 
> I tried the steps as mentioned by you but looks like something is 
> missing and build itself is failing.
> 
> https://gitlab.freedesktop.org/ArvindYadav/drm-next/-/commits/smu_workload

Thanks for your feedback!

You need to apply this patch 
https://gitlab.freedesktop.org/ArvindYadav/drm-next/-/commit/cc6dcff192d07f9fe82645fbc4213c97e872156b

This patch adds the file drivers/gpu/drm/ci/gitlab-ci.yml for you.

And you can drop the patch where gitlab added the ci template.

I replied here too 
https://gitlab.freedesktop.org/ArvindYadav/drm-next/-/commit/cc6dcff192d07f9fe82645fbc4213c97e872156b

Could you try again with that patch?

Thanks a lot!
Helen


> 
> Regards,
> ~Arvind
> 
>> Thank you!
>> Helen
>>
>>> v2:
>>> - Splitting workload_profile_set and workload_profile_put
>>>    into two separate patches.
>>> - Addressed review comment.
>>> - Added new suspend function.
>>> - Added patch to switches the GPU workload mode for KFD.
>>>
>>> v3:
>>> - Addressed all review comment.
>>> - Changed the function name from *_set() to *_get().
>>> - Now clearing all the profile in work handler.
>>> - Added *_clear_all function to clear all the power profile.
>>>
>>>
>>> Arvind Yadav (7):
>>>    drm/amdgpu: Added init/fini functions for workload
>>>    drm/amdgpu: Add new function to set GPU power profile
>>>    drm/amdgpu: Add new function to put GPU power profile
>>>    drm/amdgpu: Add suspend function to clear the GPU power profile.
>>>    drm/amdgpu: Set/Reset GPU workload profile
>>>    drm/amdgpu: switch workload context to/from compute
>>>    Revert "drm/amd/amdgpu: switch on/off vcn power profile mode"
>>>
>>>   drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h           |   3 +
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |   8 +-
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |   6 +
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       |   5 +
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c       |  14 +-
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c  | 226 ++++++++++++++++++
>>>   drivers/gpu/drm/amd/include/amdgpu_workload.h |  61 +++++
>>>   8 files changed, 309 insertions(+), 16 deletions(-)
>>>   create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c
>>>   create mode 100644 drivers/gpu/drm/amd/include/amdgpu_workload.h
>>>
>>> -- 
>>> 2.34.1
>>>
Re: [PATCH v3 0/7] GPU workload hints for better performance
Posted by Lazar, Lijo 2 years, 3 months ago
[AMD Official Use Only - General]

As mentioned with an older version of this series, this is an 'abuse' of power profile interface.

This series is oversimplifying what PMFW algorithms are supposed to be doing. Whatever this series is doing, FW can do it better.

To explain in simpler terms - it just tries to boost a profile based on ring type without even knowing how much of activity a job can trigger on a particular ring. A job scheduled to a GFX ring doesn't deserve a profile boost unless it can create a certain level of activity. In CPU terms, a job scheduled to a processor doesn't mean it deserves a frequency boost of that CPU.  At minimum it depends on more details like whether that job is compute bound or memory bound or memory bound.

While FW algorithms are designed to do that, this series tries to trivialise all such things.

Unless you are able to show the tangible benefits in some terms like performance, power, or performance per watt,  I don't think this should be the default behaviour where driver tries to override FW just based on job submissions to rings.

Thanks,
Lijo
________________________________
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Arvind Yadav <Arvind.Yadav@amd.com>
Sent: Monday, August 28, 2023 5:56:07 PM
To: Koenig, Christian <Christian.Koenig@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Sharma, Shashank <Shashank.Sharma@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>; airlied@gmail.com <airlied@gmail.com>; daniel@ffwll.ch <daniel@ffwll.ch>; Kuehling, Felix <Felix.Kuehling@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Cc: Yadav, Arvind <Arvind.Yadav@amd.com>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; dri-devel@lists.freedesktop.org <dri-devel@lists.freedesktop.org>
Subject: [PATCH v3 0/7] GPU workload hints for better performance

AMDGPU SOCs supports dynamic workload based power profiles, which can
provide fine-tuned performance for a particular type of workload.
This patch series adds an interface to set/reset these power profiles
based on the submitted job. The driver can dynamically switch
the power profiles based on submitted job. This can optimize the power
performance when the particular workload is on.

v2:
- Splitting workload_profile_set and workload_profile_put
  into two separate patches.
- Addressed review comment.
- Added new suspend function.
- Added patch to switches the GPU workload mode for KFD.

v3:
- Addressed all review comment.
- Changed the function name from *_set() to *_get().
- Now clearing all the profile in work handler.
- Added *_clear_all function to clear all the power profile.


Arvind Yadav (7):
  drm/amdgpu: Added init/fini functions for workload
  drm/amdgpu: Add new function to set GPU power profile
  drm/amdgpu: Add new function to put GPU power profile
  drm/amdgpu: Add suspend function to clear the GPU power profile.
  drm/amdgpu: Set/Reset GPU workload profile
  drm/amdgpu: switch workload context to/from compute
  Revert "drm/amd/amdgpu: switch on/off vcn power profile mode"

 drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |   3 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |   8 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |   6 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       |   5 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c       |  14 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c  | 226 ++++++++++++++++++
 drivers/gpu/drm/amd/include/amdgpu_workload.h |  61 +++++
 8 files changed, 309 insertions(+), 16 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c
 create mode 100644 drivers/gpu/drm/amd/include/amdgpu_workload.h

--
2.34.1

Re: [PATCH v3 0/7] GPU workload hints for better performance
Posted by Michel Dänzer 2 years, 3 months ago
On 8/28/23 17:02, Lazar, Lijo wrote:
> [AMD Official Use Only - General]
> 
> 
> As mentioned with an older version of this series, this is an 'abuse' of power profile interface.
> 
> This series is oversimplifying what PMFW algorithms are supposed to be doing. Whatever this series is doing, FW can do it better.
> 
> To explain in simpler terms - it just tries to boost a profile based on ring type without even knowing how much of activity a job can trigger on a particular ring. A job scheduled to a GFX ring doesn't deserve a profile boost unless it can create a certain level of activity. In CPU terms, a job scheduled to a processor doesn't mean it deserves a frequency boost of that CPU.  At minimum it depends on more details like whether that job is compute bound or memory bound or memory bound. 
> 
> While FW algorithms are designed to do that, this series tries to trivialise all such things.
> 
> Unless you are able to show the tangible benefits in some terms like performance, power, or performance per watt,  I don't think this should be the default behaviour where driver tries to override FW just based on job submissions to rings.

I know at least one tangible benefit this would have: a snappier GNOME desktop with lower input → output latency on many laptops. The bootup default profile doesn't work well for that IME.

It should also help for issues like
https://gitlab.freedesktop.org/drm/amd/-/issues/1500 .

That said, I agree this approach is very aggressive. I think it might be acceptable with AC power, not sure about on battery though. (There might be better performance/power profile mechanisms to hook into than AC vs battery)


-- 
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer