Last active
October 2, 2017 16:22
-
-
Save kusayuzayushko/14602fed665a9404ada113c2bc32d665 to your computer and use it in GitHub Desktop.
oc_dpm2.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| CONFIG_FILE="/root/config.txt" | |
| source $CONFIG_FILE | |
| if [ -z "$1" ] || [ -z "$2" ] | |
| then | |
| echo "Missing variable" | |
| exit 1 | |
| fi | |
| gpu_number=`lspci | grep VGA | wc -l` | |
| coreState="7" | |
| clocks="$1" | |
| memorys="$2" | |
| coreArray=() | |
| memoryArray=() | |
| coreVoltArray=() | |
| # memoryVoltArray=() | |
| for i in $(echo $clocks | sed "s/,/ /g") | |
| do | |
| coreArray+=($i) | |
| done | |
| for i in $(echo $memorys | sed "s/,/ /g") | |
| do | |
| memoryArray+=($i) | |
| done | |
| function inputcheck() { | |
| declare -n array=$1 | |
| if [ ${#array[@]} -ge "$gpu_number" ]; then | |
| : | |
| elif [ ${#array[@]} -eq 1 ]; then | |
| for (( i = 1; i < $gpu_number; i++ )); do | |
| array+=(${array[0]}) | |
| done | |
| else | |
| for (( i = $gpu_number - ${#array[@]}; i < $gpu_number ; i++ )); do | |
| array+=(${array[-1]}) | |
| done | |
| fi | |
| } | |
| inputcheck coreArray | |
| inputcheck memoryArray | |
| if [ ! -z "$3" ] # || [ -z "$4" ] | |
| then | |
| # UV | |
| coreVolts="$3" | |
| for i in $(echo $coreVolts | sed "s/,/ /g") | |
| do | |
| coreVoltArray+=($i) | |
| done | |
| # memoryVolts="$4" | |
| # for i in $(echo $memoryVolts | sed "s/,/ /g" ) | |
| # do | |
| # memoryVoltArray+=($i) | |
| # done | |
| inputcheck coreVoltArray | |
| # inputcheck memoryVoltArray | |
| else | |
| # no UV | |
| : | |
| fi | |
| if [ "$MINER_POWERLIMIT" -ge "0" ] && [ "$MINER_POWERLIMIT" -le "7" ]; then | |
| coreState=$MINER_POWERLIMIT | |
| fi | |
| g=0 | |
| i=0 | |
| for (( x=0; x<$gpu_number; x++ )); do | |
| if [ -e "/sys/class/drm/card$g/device/pp_table" ] | |
| then | |
| if [ ! -e "/var/tmp/pp_tables/gpu$g/pp_table" ] | |
| then | |
| echo "ERROR OC GPU$g, you need to reboot rig this time to get this working !!!" | |
| break | |
| fi | |
| else | |
| ((++g)) | |
| fi | |
| if [ "${coreArray[$i]}" -ge "300" ] && [ "${coreArray[$i]}" -le "1500" ] && [ "${memoryArray[$i]}" -ge "300" ] && [ "${memoryArray[$i]}" -le "3000" ]; then | |
| echo "GPU$i:" | |
| else | |
| echo "Invalid OC values: core:${coreArray[$i]} memory:${memoryArray[$i]} , skipping OC" | |
| exit | |
| fi | |
| cp /var/tmp/pp_tables/gpu$g/pp_table /sys/class/drm/card$g/device/pp_table | |
| sleep 0.1 | |
| mem_states=`cat /sys/class/drm/card$g/device/pp_dpm_mclk | wc -l` | |
| memoryState=$(($mem_states-1)) | |
| if [ ! -z "${coreVoltArray[$i]}" ] && [ "${coreVoltArray[$i]}" -ge "800" ] && [ "${coreVoltArray[$i]}" -le "1300" ]; then | |
| /root/utils/wolfamdctrl -i $g --core-state $coreState --mem-state $memoryState --core-clock ${coreArray[$i]} --mem-clock ${memoryArray[$j]} --volt-state $coreState --vddc-table-set ${coreVoltArray[$i]} #--mem-state $memoryState --mvdd 950 | |
| else | |
| /root/utils/wolfamdctrl -i $g --core-state $coreState --mem-state $memoryState --core-clock ${coreArray[$i]} --mem-clock ${memoryArray[$j]} | |
| fi | |
| sleep 0.1 | |
| echo manual > /sys/class/drm/card$g/device/power_dpm_force_performance_level | |
| echo $coreState > /sys/class/drm/card$g/device/pp_dpm_sclk | |
| echo $memoryState > /sys/class/drm/card$g/device/pp_dpm_mclk | |
| ((++i)) | |
| ((++g)) | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment