Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error/Warning message improvement #320

Open
Alex-V69 opened this issue Oct 28, 2024 · 4 comments
Open

Error/Warning message improvement #320

Alex-V69 opened this issue Oct 28, 2024 · 4 comments

Comments

@Alex-V69
Copy link

I am trying to reduce the tctl_temp value of my CPU.

After I finished editing the configuration section of readjustService.ps1 and tried to run the script, I get this warning:

config_warning

I tried to set a user environment variable with this name ("tctl_temp") but still get the same warning.

Can somebody please point me in the right direction where I can learn more about this "profile" thing?

@Falcosc
Copy link
Collaborator

Falcosc commented Oct 29, 2024

The script is only needed if values are changing and is a template for developers.
If the comments in the script are not enough to understand the configuration, then it's not advisable to proceed with it and better go for UI solutions of automation.

If you just want to reduce it, you only need to reduce the Average Power Limit below the capabilities of the cooling design of your platform.

For example, if your laptop is designed for 30W you could reduce your performance by 30-40% using a15W target with ./ryzenadj --slow-limit=15000

Don't use the build in AMD temperature settings to reduce the temps, always use the watt based ones. Because the Thermal Limit is an emergency hold which reduces the power allowance to the lowest possible value, making the system completely freezing

@Alex-V69
Copy link
Author

Hello. Thank you for the advice. I still want to understand what this "profile" is but will use a Python based option if I don't find that out.

"reduces the power allowance to the lowest possible value, making the system completely freezing"

I use Universal x86 Tuning Utility at the moment but want to find a more robust, controllable, and lightweight solution (in this order).
When I set "Temperature Limit" via "APU Temperature Tuning" I haven't seen the behavior you described even when I played resource intensive games (neither the frame rate nor the CPU temp suggested that – the temperature just reached a plateau and there was no sudden and drastic frame rate drop).

P.S. It is an HP ProBook x360 435 G8 with an AMD Ryzen 7 PRO 5850U (Cezanne) CPU

@Falcosc
Copy link
Collaborator

Falcosc commented Oct 30, 2024

On my end hitting reduced max temps triggers prochot and reduce clocl to 500mhz

@Alex-V69
Copy link
Author

Alex-V69 commented Oct 31, 2024

I assume thermal protection behavior depends on a CPU architecture and its manufacturer.

In my case, it's just throttling:

image.gif

cpu_stats

I get the same result when I use a modified version of readjust.py

my_readjust.py
import os, sys, time
from ctypes import *
from shutil import copyfile


set_tctl_temp = 60


lib_path = os.path.dirname(os.path.abspath(__file__))
os.chdir(lib_path)

if sys.platform == 'win32' or sys.platform == 'cygwin':
    try:
        os.add_dll_directory(lib_path)
    except AttributeError:
        pass #not needed for old python version

    winring0_driver_file_path = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), 'WinRing0x64.sys')
    if not os.path.isfile(winring0_driver_file_path):
        copyfile(os.path.join(lib_path, 'WinRing0x64.sys'), winring0_driver_file_path)

    lib = cdll.LoadLibrary('libryzenadj')
else:
    lib = cdll.LoadLibrary('libryzenadj.so')

# define ctype mappings for types which can not be mapped automatically
lib.init_ryzenadj.restype = c_void_p
lib.refresh_table.argtypes = [c_void_p]
lib.get_tctl_temp.restype = c_float
lib.get_tctl_temp.argtypes = [c_void_p]


ry = lib.init_ryzenadj()

if not ry:
    sys.exit("RyzenAdj could not get initialized")

error_messages = {
    -1: "{:s} is not supported on this family\n",
    -3: "{:s} is not supported on this SMU\n",
    -4: "{:s} is rejected by SMU\n"
}

def adjust(field, value):
    function_name = "set_" + field
    adjust_func = lib.__getattr__(function_name)
    adjust_func.argtypes = [c_void_p, c_ulong]
    res = adjust_func(ry, value)
    if res:
        error = error_messages.get(res, "{:s} did fail with {:d}\n")
        sys.stderr.write(error.format(function_name, res));

def enable(field):
    function_name = "set_" + field
    adjust_func = lib.__getattr__(function_name)
    adjust_func.argtypes = [c_void_p]
    res = adjust_func(ry)
    if res:
        error = error_messages.get(res, "{:s} did fail with {:d}\n")
        sys.stderr.write(error.format(function_name, res));

print(f"Monitor if tctl_temp is not {set_tctl_temp}")
while True:
    lib.refresh_table(ry)
    limit = round(lib.get_tctl_temp(ry))
    print(f"Current limit is: {limit}")
    if limit != set_tctl_temp:
        print("reapply limits, because old limit was {:d}".format(limit))
        adjust("tctl_temp", set_tctl_temp)
    time.sleep(3)

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

No branches or pull requests

2 participants