added new speed test functions

This commit is contained in:
2021-04-04 00:47:56 +04:00
parent 9a11b064ee
commit 1c733a694e
7 changed files with 71 additions and 75 deletions

View File

@@ -33,6 +33,8 @@ type GpuClock struct {
GpuMemClock string `xml:"mem_clock"`
}
// Gets GPU information by calling nvidia-smi
// in XML output
func GPUInfo()(*Query,error) {
out, err := exec.Command("nvidia-smi", "-q", "-x").Output()

View File

@@ -2,6 +2,7 @@ package server
import (
"fmt"
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
"github.com/gin-gonic/gin"
"net/http"
@@ -31,7 +32,24 @@ func Server() {
c.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!", file.Filename))
})
//Gets Ip Table from server node
r.GET("/IpTable", func(c *gin.Context) {
// Runs speed test to return only servers in the IP table pingable
err := p2p.SpeedTest()
if err != nil {
c.String(http.StatusOK, fmt.Sprint(err))
}
// Reads IP addresses from ip table
IpAddresses,err := p2p.ReadIpTable()
if err != nil {
c.String(http.StatusOK, fmt.Sprint(err))
}
c.JSON(http.StatusOK, IpAddresses)
})
// Starts docker container in server
r.GET("/startcontainer", func(c *gin.Context) {
resp, err := docker.BuildRunContainer()

View File

@@ -1,60 +0,0 @@
package main
import (
"fmt"
"log"
"os"
"text/template"
"github.com/NVIDIA/gpu-monitoring-tools/bindings/go/nvml"
)
const (
DEVICEINFO = `UUID : {{.UUID}}
Model : {{or .Model "N/A"}}
Path : {{.Path}}
Power : {{if .Power}}{{.Power}} W{{else}}N/A{{end}}
Memory : {{if .Memory}}{{.Memory}} MiB{{else}}N/A{{end}}
CudaComputeCap : {{if .CudaComputeCapability.Major}}{{.CudaComputeCapability.Major}}.{{.CudaComputeCapability.Minor}}{{else}}N/A{{end}}
CPU Affinity : {{if .CPUAffinity}}NUMA node{{.CPUAffinity}}{{else}}N/A{{end}}
Bus ID : {{.PCI.BusID}}
BAR1 : {{if .PCI.BAR1}}{{.PCI.BAR1}} MiB{{else}}N/A{{end}}
Bandwidth : {{if .PCI.Bandwidth}}{{.PCI.Bandwidth}} MB/s{{else}}N/A{{end}}
Cores : {{if .Clocks.Cores}}{{.Clocks.Cores}} MHz{{else}}N/A{{end}}
Memory : {{if .Clocks.Memory}}{{.Clocks.Memory}} MHz{{else}}N/A{{end}}
P2P Available : {{if not .Topology}}None{{else}}{{range .Topology}}
{{.BusID}} - {{(.Link.String)}}{{end}}{{end}}
---------------------------------------------------------------------
`
)
func main() {
nvml.Init()
defer nvml.Shutdown()
count, err := nvml.GetDeviceCount()
if err != nil {
log.Panicln("Error getting device count:", err)
}
driverVersion, err := nvml.GetDriverVersion()
if err != nil {
log.Panicln("Error getting driver version:", err)
}
t := template.Must(template.New("Device").Parse(DEVICEINFO))
fmt.Printf("Driver Version : %5v\n", driverVersion)
for i := uint(0); i < count; i++ {
device, err := nvml.NewDevice(i)
if err != nil {
log.Panicf("Error getting device %d: %v\n", i, err)
}
fmt.Printf("GPU %12s %d\n", ":", i)
err = t.Execute(os.Stdout, device)
if err != nil {
log.Panicln("Template error:", err)
}
}
}