@@ -22,18 +22,18 @@ func NewCPUDB() *CPUDB {
2222
2323// GetCPU retrieves the CPU structure that matches the provided args
2424func (c * CPUDB ) GetCPU (family , model , stepping string ) (cpu CPU , err error ) {
25- return c .GetCPUExtended (family , model , stepping , "" , "" , "" )
25+ return c .GetCPUExtended (family , model , stepping , "" , "" )
2626}
2727
2828// GetCPUExtended retrieves the CPU structure that matches the provided args
2929// capid4 needed to differentiate EMR MCC from EMR XCC
3030//
3131// capid4: $ lspci -s $(lspci | grep 325b | awk 'NR==1{{print $1}}') -xxx | awk '$1 ~ /^90/{{print $9 $8 $7 $6; exit}}'
3232//
33- // sockets and devices (eventually devices per socket) needed to differentiate GNR X1/2/3
33+ // devices needed to differentiate GNR X1/2/3
3434//
3535// devices: $ lspci -d 8086:3258 | wc -l
36- func (c * CPUDB ) GetCPUExtended (family , model , stepping , capid4 , sockets , devices string ) (cpu CPU , err error ) {
36+ func (c * CPUDB ) GetCPUExtended (family , model , stepping , capid4 , devices string ) (cpu CPU , err error ) {
3737 for _ , info := range * c {
3838 // if family matches
3939 if info .Family == family {
@@ -59,7 +59,7 @@ func (c *CPUDB) GetCPUExtended(family, model, stepping, capid4, sockets, devices
5959 }
6060 cpu = info
6161 if cpu .Family == "6" && (cpu .Model == "143" || cpu .Model == "207" || cpu .Model == "173" ) { // SPR, EMR, GNR
62- cpu , err = c .getSpecificCPU (family , model , capid4 , sockets , devices )
62+ cpu , err = c .getSpecificCPU (family , model , capid4 , devices )
6363 }
6464 return
6565 }
@@ -80,13 +80,13 @@ func (c *CPUDB) GetCPUByMicroArchitecture(uarch string) (cpu CPU, err error) {
8080 return
8181}
8282
83- func (c * CPUDB ) getSpecificCPU (family , model , capid4 , sockets , devices string ) (cpu CPU , err error ) {
83+ func (c * CPUDB ) getSpecificCPU (family , model , capid4 , devices string ) (cpu CPU , err error ) {
8484 if family == "6" && model == "143" { // SPR
8585 cpu , err = c .getSPRCPU (capid4 )
8686 } else if family == "6" && model == "207" { // EMR
8787 cpu , err = c .getEMRCPU (capid4 )
8888 } else if family == "6" && model == "173" { // GNR
89- cpu , err = c .getGNRCPU (sockets , devices )
89+ cpu , err = c .getGNRCPU (devices )
9090 }
9191 return
9292}
@@ -149,21 +149,17 @@ func (c *CPUDB) getEMRCPU(capid4 string) (cpu CPU, err error) {
149149 return
150150}
151151
152- func (c * CPUDB ) getGNRCPU (sockets , devices string ) (cpu CPU , err error ) {
152+ func (c * CPUDB ) getGNRCPU (devices string ) (cpu CPU , err error ) {
153153 var uarch string
154- if sockets != "" && devices != "" {
155- s , err := strconv .Atoi (sockets )
156- if err == nil && s != 0 {
157- d , err := strconv .Atoi (devices )
158- if err == nil && d != 0 {
159- devicesPerSocket := d / s
160- if devicesPerSocket == 3 {
161- uarch = "GNR_X1"
162- } else if devicesPerSocket == 4 {
163- uarch = "GNR_X2"
164- } else if devicesPerSocket == 5 {
165- uarch = "GNR_X3"
166- }
154+ if devices != "" {
155+ d , err := strconv .Atoi (devices )
156+ if err == nil && d != 0 {
157+ if d % 5 == 0 { // device count is multiple of 5
158+ uarch = "GNR_X3"
159+ } else if d % 4 == 0 { // device count is multiple of 4
160+ uarch = "GNR_X2"
161+ } else if d % 3 == 0 { // device count is multiple of 3
162+ uarch = "GNR_X1"
167163 }
168164 }
169165 }
0 commit comments