#!/bin/bash
#Nvidia GPU memory channel disabler script
#by n00b
#version 0.01

shopt -s nocasematch #disable case sensitive comparsion for "case" operator
channels_arg=$1
chA_dis_mask=0x01
chB_dis_mask=0x02
chC_dis_mask=0x04
chD_dis_mask=0x08
chE_dis_mask=0x10
chF_dis_mask=0x20
channels_dis=0
i=0
while [ "$i" -lt "${#channels_arg}" ]; do
 case ${channels_arg:$i:1} in

  A)
	((channels_dis+=chA_dis_mask))
    ;;

  B)
	((channels_dis+=chB_dis_mask))
    ;;

  C)
	((channels_dis+=chC_dis_mask))
    ;;
	
  D)
	((channels_dis+=chD_dis_mask))
    ;;
	
  E)
	((channels_dis+=chE_dis_mask))
    ;;

  F)
	((channels_dis+=chF_dis_mask))
    ;;
	
  *)
    echo "Unknown channel"
	exit 1
    ;;
 esac
  ((i++))
done
./mods gputest.jse -oqa -test $2 -fan_speed 70 -dramclk_percent $3 -ignore_fatal_errors -run_on_error -floorsweep fbio_disable:0x$(printf '%x' "${channels_dis}"):fbp_disable:0x$(printf '%x' "${channels_dis}")