Upgrade macos

This commit is contained in:
Bassem Girgis
2025-03-19 08:52:56 -05:00
parent 53580cb51f
commit d29ef955f5
8041 changed files with 1936720 additions and 130842 deletions

View File

@@ -0,0 +1,61 @@
This tool displays process and thread binding in an interative web page.
1) Basic Usage
Run the hwloc-ps tool in JSON server mode:
$ hwloc-ps --json-server
server running on port 8888...
Export the topology as a SVG file using the native backend:
$ lstopo filename.svg --of nativesvg
Now run the client side for displaying the binding:
$ cd /path/to/hwloc-ps.www/
$ node client.js /path/to/filename.svg
This should open a webpage in your browser.
Otherwise add -u to see the URL that you should open (usually http://localhost:3000).
2) Installing node.js and JS dependencies
The "node" command is available in the "nodejs" package in most Linux distributions,
but you should rather install the "npm" package to get additional utilities:
# apt instal npm
# yum install npm
Then install the dependencies needed by client.js:
$ cd /path/to/hwloc-ps.www/
$ npm install
If you don't have write-access to the hwloc-ps.www/ directory,
copy it somewhere else, run "npm install" from there,
and then run the client from there:
$ cp -a /path/to/hwloc-ps.www/ $HOME/myhwloc-ps.www/
$ cd $HOME/myhwloc-ps.www/
$ npm install
$ node client.js /path/to/filename.svg
3) Running on a remote server
This tool is often useful for debugging process placement on remote servers, hence:
* hwloc-ps and lstopo should run on that remote server
(this requires a recent hwloc on the remote side).
* you must copy the SVG file back to your machine:
$ scp target:/path/to/filename.svg .
* if the target machine port 8888 is not directly accessible, you may
have to forward its 8888 port:
$ ssh target -L 8888:localhost:8888 -Nf

View File

@@ -0,0 +1,65 @@
<!-- Copyright © 2018-2019 Inria. All rights reserved. -->
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="/stylecss">
<link rel="stylesheet" type="text/css" href="/maincss">
<meta charset="utf-8">
<title>Dynamic SVG</title>
<script type='text/javascript' src='/js'></script>
</head>
<ul class='navul'>
<li class='navli'><a onclick='clearProc()'>Clear processes</a></li>
<li class='navli'><a class='procButton' type='all'>All processes</a></li>
<li class='navli'><a class='procButton' type='bound'>Bound processes</a></li>
<li class='navli'><label for="threads">Show threads<input id='threads' class='checkbox' type="checkbox" name="threads"></label></li>
<li class='navli'><label for="lastLocation">Show last location<input id='lastcpulocation' class='checkbox' type="checkbox" name="lastLocation"></label></li>
<li class='navli'><input class='hide-mobile' type='text' placeholder='PID or Name' value='' id='searchId'/> <input class='button hide-mobile' type='button' value='Search process' onclick="procByid()"/></li>
</ul>
<body style='text-align: center; background-color: #959ba5'>
<object style='margin-top: 50px' id="svg-object" type="image/svg+xml" data="/svg">
Your browser does not support SVG.
</object>
<br>
<div style="display: inline-block;">
<div id='info' class='hidden'>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<div id='info-not-found' class='hidden'>
<ul style="list-style: none;">
<li> Process : not found </li>
</ul>
</div>
</div>
<div id='processTable' class="table100 ver2 m-b-110 hidden">
<div class="table100-head">
<table>
<thead>
<tr class="row100 head">
<th class="cell100 column1">Process id</th>
<th class="cell100 column2">Name</th>
<th class="cell100 column3">Displayed <input id='mainCheck' checked='true' type="checkbox"></input> </th>
</tr>
</thead>
</table>
</div>
<div class="table100-body js-pscroll">
<table>
<tbody id='table'>
</tbody>
</table>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,115 @@
/* Copyright © 2019 Inria. All rights reserved. */
/*//////////////////////////////////////////////////////////////////
[ Scroll bar ]*/
.js-pscroll {
position: relative;
overflow: hidden;
}
.table100 .ps__rail-y {
width: 9px;
background-color: transparent;
opacity: 1 !important;
right: 5px;
}
.table100 .ps__rail-y::before {
content: "";
display: block;
position: absolute;
background-color: #ebebeb;
border-radius: 5px;
width: 50%;
height: calc(100% - 30px);
top: 15px;
}
.table100 .ps__rail-y .ps__thumb-y {
width: 50%;
background-color: transparent;
opacity: 1 !important;
}
.table100 .ps__rail-y .ps__thumb-y::before {
content: "";
display: block;
position: absolute;
background-color: #cccccc;
border-radius: 5px;
width: 50%;
height: calc(100% - 30px);
left: 0;
top: 15px;
}
/*//////////////////////////////////////////////////////////////////
[ Table ]*/
.table100 {
margin-top: 30px;
width: 22.5%;
background-color: #5d5e60;
min-width: 250px;
left: 38.8%;
}
.column1{
left:0;
}
th {
width: 33%;
font-weight: unset;
}
td {
width: 33%;
}
tr, table, thead {
width: 100%;
}
.table100-head th {
padding-top: 10px;
padding-bottom: 10px;
}
/*==================================================================
Table*/
.table100 {
position: relative;
padding-top: 60px;
}
.table100-head {
position: absolute;
width: 100%;
top: 0;
left: 0;
}
.table100-body {
max-height: 585px;
overflow: auto;
}
.table100.ver2 th {
font-size: 13px;
color: white;
line-height: 1.4;
background-color: transparent;
}
.table100.ver2 td {
font-size: 11px;
color: white;
line-height: 1.4;
padding-left: 22px;
padding-right: 17px;
}
.table100.ver2 {
border-radius: 10px;
}

View File

@@ -0,0 +1,489 @@
/* Copyright © 2019 Inria. All rights reserved. */
function start(svgObject){
const texts = svgObject.getElementsByTagName('text')
for (let text of texts) {
text.setAttribute("style", text.getAttribute("style") + "; pointer-events:none")
}
}
async function createProcesses(svgdoc, req, json = null){
await clear(svgdoc)
clearTable()
if(!json){
response = await fetch("/" + req)
json = await response.json()
}
json.forEach(proc => {
displayProcess(svgdoc, proc, req)
})
createTooltip(svgdoc)
if (/^proc\/\d+$/.test(req)) {
//only show if single PID
displayInfo(svgdoc, json)
//threads auto-enabled for single PID
document.getElementById('threads').checked = true
}
}
async function displayProcess(svgdoc, proc, req = null){
if(!proc.object)
return
//create table except when looking at a single process
if(!/proc\/\d+$/.test(req))
fillTable(svgdoc, proc)
bullet(svgdoc, proc, "")
text(svgdoc, proc, "")
if(proc.threads){
proc.threads.forEach(async thread =>{
if(thread.object){
bullet(svgdoc, thread, "thread")
text(svgdoc, thread, "thread")
}
})
}
}
function bullet(svgdoc, obj, objType){
let bulletCircle = svgdoc.getElementById("bulletCircle" + objType + "_" + obj.object.replace(':','_'))
//if a bullet doesn't already exist, if it does, just add the process id to the bullet attributes
if(!bulletCircle){
let id = obj.object.replace(':','_')+"_rect"
let rect = svgdoc.getElementById(id)
bulletCircle = svgdoc.createElementNS("http://www.w3.org/2000/svg","rect")
//difference thread and process
if(objType === "thread"){
bulletCircle.setAttribute("thread", true)
bulletCircle.setAttribute("height", "15")
bulletCircle.setAttribute("fill", "#7cacf9")
bulletCircle.setAttribute("y", rect.y.animVal.value + 12)
}else{
bulletCircle.setAttribute("y", rect.y.animVal.value - 5)
bulletCircle.setAttribute("height", "15")
bulletCircle.setAttribute("fill", "#FFFFFF")
}
//set the bullet in the middle if the process is on machine_O
if(id == "Machine_0_rect"){
const svg = svgdoc.getElementsByTagName('svg')[0]
bulletCircle.setAttribute("x", svg.width.baseVal.value / 2 - 10)
bulletCircle.setAttribute("y", 5)
if(objType === "thread"){
bulletCircle.setAttribute("x", svg.width.baseVal.value / 2 + 45)
bulletCircle.setAttribute("y", 5)
}
}else{
bulletCircle.setAttribute("x", rect.x.animVal.value-5)
}
bulletCircle.setAttribute("rx", 10)
bulletCircle.setAttribute("ry", 10)
bulletCircle.setAttribute("circle", true)
bulletCircle.setAttribute("stroke-width", "1")
bulletCircle.setAttribute("stroke", "#000000")
bulletCircle.classList.add("tooltip-trigger")
rect.parentNode.appendChild(bulletCircle)
bulletCircle.id = "bulletCircle" + objType + "_" + obj.object.replace(':','_')
let secondId
if(objType === "thread")
secondId = "thread id : " + obj.PID
else
secondId = "process id : " + obj.PID
bulletCircle.setAttribute('secondId', secondId)
}else {
let secondId = bulletCircle.getAttribute('secondId')
if(objType === "thread")
secondId += ';' + "thread id : " + obj.PID
else
secondId += ';' + "process id : " + obj.PID
bulletCircle.setAttribute('secondId', secondId)
}
}
function text(svgdoc, obj, objType){
let id = obj.object.replace(':','_')+"_rect"
let rect = svgdoc.getElementById(id)
let bulletText = svgdoc.createElementNS("http://www.w3.org/2000/svg","text")
let bulletCircle = svgdoc.getElementById("bulletCircle" + objType + "_" + obj.object.replace(':','_'))
//if a bullet doesn't already exist, if it does, increment the text
if(!svgdoc.getElementById("bulletText" + objType + "_" + obj.object.replace(':','_'))){
bulletText.setAttribute("circle", true)
//set the text in the middle if the process is on machine_O
if(id == "Machine_0_rect"){
const svg = svgdoc.getElementsByTagName('svg')[0]
bulletText.setAttribute("x", svg.width.baseVal.value / 2 - 3)
bulletText.setAttribute("y", 15)
if(objType === "thread"){
bulletText.setAttribute("x", svg.width.baseVal.value / 2 + 52)
bulletText.setAttribute("y", 15)
}
}else{
bulletText.setAttribute("x", rect.x.animVal.value+2)
bulletText.setAttribute("y", rect.y.animVal.value+6)
}
//difference thread and process
if(objType === "thread" && id != "Machine_0_rect"){
bulletText.setAttribute("thread", true)
bulletText.setAttribute("y", rect.y.animVal.value+22)
}
bulletText.setAttribute("style", bulletText.getAttribute("style") + "; pointer-events:none")
bulletText.setAttribute("font-size", "10px")
updateBulletText(bulletText, obj.PID, bulletCircle)
bulletText.id = "bulletText" + objType + "_" + obj.object.replace(':','_')
rect.parentNode.appendChild(bulletText)
}else{
let text = svgdoc.getElementById("bulletText" + objType + "_" + obj.object.replace(':','_'))
updateBulletText(text, findPid(text, '+'), bulletCircle)
//set the text in the middle if the process is on machine_O
if(id == "Machine_0_rect"){
if (text.textContent == 10)
text.setAttribute("x", parseInt(text.getAttribute('x')) - 3)
else if(text.textContent == 100)
text.setAttribute("x", parseInt(text.getAttribute('x')) - 4)
return
}
}
}
async function updateBulletText(text, pid, bulletCircle){
text.textContent = await pid
let length = text.getComputedTextLength()
bulletCircle.setAttribute("width", length + 15)
}
function findPid(text, op){
let nb
if(!text.getAttribute('nb')){
nb = "[2]"
text.setAttribute('nb', nb)
}else{
nb = text.getAttribute('nb')
nb = nb.replace('[','')
nb = nb.replace(']','')
if(op == '+')
nb = parseInt(nb) + 1
else{
nb = parseInt(nb) - 1
}
nb = '[' + nb + ']'
text.setAttribute('nb', nb)
}
return nb
}
function clear(svgdoc){
document.getElementById('searchId').value = ''
const info = document.getElementById('info')
info.classList = 'hidden'
const infoNotFound = document.getElementById('info-not-found')
infoNotFound.classList = 'hidden'
svgElements = svgdoc.getElementsByTagName('svg')[0].children
let i = 0;
for(element of svgElements){
if(element.id.includes('bulletCircle'))
i += 2
}
if(i == 0)
return
for(i ; i >= 0 ; i--){
svgElements[svgElements.length - 1].remove()
}
}
function createTooltip(svgdoc){
if(svgdoc.getElementById('tooltip'))
svgdoc.getElementById('tooltip').remove()
//Create tooltip to display process id
const g = svgdoc.createElementNS("http://www.w3.org/2000/svg","g")
const blackRect = svgdoc.createElementNS("http://www.w3.org/2000/svg",'rect')
const whiteRect = svgdoc.createElementNS("http://www.w3.org/2000/svg",'rect')
const tooltip = svgdoc.createElementNS("http://www.w3.org/2000/svg",'text')
blackRect.setAttribute('fill','black')
blackRect.setAttribute('opacity','0.4')
blackRect.setAttribute('rx','2')
blackRect.setAttribute('ry','2')
blackRect.setAttribute('x','2')
blackRect.setAttribute('y','-8')
blackRect.setAttribute('height','11')
blackRect.setAttribute('opacity','0.4')
whiteRect.setAttribute('y','-10')
whiteRect.setAttribute('fill','white')
whiteRect.setAttribute('rx','2')
whiteRect.setAttribute('ry','2')
whiteRect.setAttribute('height','11')
tooltip.setAttribute('x','4')
tooltip.setAttribute('y','6')
g.setAttribute('visibility', 'hidden')
g.id = "tooltip"
g.appendChild(blackRect)
g.appendChild(whiteRect)
g.appendChild(tooltip)
svgdoc.getElementsByTagName('svg')[0].appendChild(g)
let triggers = svgdoc.getElementsByClassName('tooltip-trigger')
for (let i = 0; i < triggers.length; i++) {
triggers[i].onmousemove = showTooltip
triggers[i].onmouseout = hideTooltip
triggers[i].onclick = async function(){
//on click : display process info for the first process in the bullet
procs = triggers[i].getAttribute('secondId').split(";")
let data = new Array()
response = await fetch("/json")
json = await response.json()
await procs.forEach(proc => {
json.forEach(jsonProcess => {
if(proc.substring(13) == jsonProcess.PID)
data.push(jsonProcess)
})
})
let req = data.length == 1 ? "proc/" + data[0].PID : null
createProcesses(svgdoc, req, data)
}
}
function showTooltip(evt) {
const tooltip = svgdoc.getElementById('tooltip')
let tooltipText = tooltip.getElementsByTagName('text')[0]
let tooltipRects = tooltip.getElementsByTagName('rect')
//clear tooltip
while(tooltipText.firstChild){
tooltipText.removeChild(tooltipText.firstChild)
for (let i = 0; i < tooltipRects.length; i++) {
tooltipRects[i].setAttribute("height", parseInt(tooltipRects[i].getAttribute("height")) - 15)
}
}
//display all processes id in the bullet
let text = evt.target.getAttribute('secondId')
let tspan
text = text.split(';')
let length = 0
for (str of text ) {
//create the text element
tspan = svgdoc.createElementNS("http://www.w3.org/2000/svg",'tspan')
if(text.indexOf(str) !== 0)
tspan.setAttribute('dy', '1em')
tspan.setAttribute('x', '0')
tspan.textContent = str
tooltipText.appendChild(tspan)
//find the length of the longest text
if(tspan.getComputedTextLength() > length)
length = tspan.getComputedTextLength()
//ajust the height of the tooltip element ( and its shadow )
for (let i = 0; i < tooltipRects.length; i++) {
tooltipRects[i].setAttribute("height", parseInt(tooltipRects[i].getAttribute("height")) + 15)
}
//display "..." if there is more than 5 processes
if(text.indexOf(str) === 5){
tspan.textContent = '\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0...'
tooltipText.appendChild(tspan)
break
}
}
//set the tooltip ( and its shadow ) width according to the longest element
for (let i = 0; i < tooltipRects.length; i++) {
tooltipRects[i].setAttributeNS(null, "width", length + 8)
}
//display the tooltip at the mouse coordonates
let CTM = svgdoc.getElementsByTagName('svg')[0].getScreenCTM()
let x = (evt.clientX - CTM.e + 6) / CTM.a;
let y = (evt.clientY - CTM.f + 20) / CTM.d;
tooltip.setAttributeNS(null, "transform", "translate(" + x + " " + y + ")");
tooltip.setAttributeNS(null, "visibility", "visible")
}
function hideTooltip() {
const tooltip = svgdoc.getElementById('tooltip')
tooltip.setAttributeNS(null, "visibility", "hidden")
}
}
async function displayInfo(svgdoc, data){
//handle 2 div : one if the process is found, and one if it isn't
const info = document.getElementById('info')
const infoNotFound = document.getElementById('info-not-found')
info.classList = 'hidden'
infoNotFound.classList = 'hidden'
if(!data[0].object){
infoNotFound.classList.toggle('hidden')
return
}
const infos = info.children[0].children
infos[0].innerHTML = 'Process: ' + data[0].PID
infos[1].innerHTML = 'Name: ' + data[0].name
infos[2].innerHTML = 'Object: ' + data[0].object.replace(':',' L#')
if(data[0].threads){
infos[3].innerHTML = 'Threads: ' + (data[0].threads.length - 1)
}else{
infos[3].classList = 'hidden'
}
info.classList.toggle('hidden')
}
function fillTable(svgdoc, proc){
document.getElementById('processTable').classList = "table100 ver2 m-b-110"
const table = document.getElementById('table')
const tr = document.createElement('tr')
const td = document.createElement('td')
const td2 = document.createElement('td')
const td3 = document.createElement('td')
const checkbox = document.getElementById('mainCheck')
tr.classList.add("row100", "head")
td.classList.add("cell100", "column1")
td2.classList.add("cell100", "column1")
td3.classList.add("cell100", "column1")
tr.setAttribute("object", proc.object)
td.innerHTML = proc.PID
td2.innerHTML = proc.name
td3.innerHTML = "<input class='subCheck' checked='true' type='checkbox'>"
td3.children[0].addEventListener('change', displayTableElement)
checkbox.checked = true
checkbox.onchange = changeAll
tr.appendChild(td)
tr.appendChild(td2)
tr.appendChild(td3)
table.appendChild(tr)
//toggle dispay - hide according to checkbox value
function displayTableElement(event){
const tr = event.target.parentElement.parentElement
const tds = tr.children
const proc = { PID : tds[0].innerHTML, name : tds[1].innerHTML, object : tr.getAttribute('object') }
if(event.target.checked == false){
const element = svgdoc.getElementById("bulletCircle" + "_" + proc.object.replace(':','_'))
removeProc(element, proc)
}else{
bullet(svgdoc, proc, "")
text(svgdoc, proc, "")
createTooltip(svgdoc)
}
}
function removeProc(element, proc){
let id = element.id
let text = svgdoc.getElementById(id.replace('bulletCircle', 'bulletText'))
let secondId = element.getAttribute('secondId').replace('process id : ' + proc.PID + ';', '')
if(!text.getAttribute('nb') || text.getAttribute('nb') == '[1]'){
text.remove()
element.remove()
}else{
updateBulletText(text, findPid(text, '-'), element)
}
element.setAttribute('secondId', secondId)
}
//handle click on main checkbox -> set all checkbox value to its value
function changeAll(event){
const checkboxes = document.getElementsByClassName('subCheck')
size = checkboxes.length
for(let i = 0 ; i < size ; i++ ){
if(checkboxes[i].checked != event.target.checked){
checkboxes[i].checked = event.target.checked
displayTableElement({target: checkboxes[i]})
}
}
}
}
function clearProc(){
document.getElementById('searchId').value = ""
const checkboxes = document.getElementsByClassName('checkbox')
for( let i = 0 ; i < checkboxes.length ; i++ ){
checkboxes[i].checked = false
}
let svgObject = document.getElementById('svg-object').contentDocument
clear(svgObject)
}
function clearTable(){
const table = document.getElementById("table");
while (table.firstChild) {
table.removeChild(table.firstChild);
}
document.getElementById("processTable").classList = "table100 ver2 m-b-110 hidden"
}
function handleProcButton(){
let functionIsRunning = false
//use function is running so that the function doesn't run twice if the user double click.
async function addProc(req){
if (!functionIsRunning) {
functionIsRunning = true
if(req == 'bound' || req == 'all'){
clearProc()
clearTable()
}
let svgObject = document.getElementById('svg-object').contentDocument
await createProcesses(svgObject, req)
functionIsRunning = false
}
}
const procButtons = document.getElementsByClassName('procButton')
for(let i = 0 ; i < procButtons.length ; i++){
procButtons[i].addEventListener('click', function(){
addProc(procButtons[i].type)
})
}
}
function handleCheckbox(){
const checkboxes = document.getElementsByClassName('checkbox')
for( let i = 0 ; i < checkboxes.length ; i++ ){
checkboxes[i].checked = false
checkboxes[i].addEventListener('change',function(e){
clearTable()
let svgObject = document.getElementById('svg-object').contentDocument
createProcesses(svgObject, e.target.id)
})
}
}
function procByid(){
let svgObject = document.getElementById('svg-object').contentDocument
let id = document.getElementById('searchId').value
clearProc()
createProcesses(svgObject, 'proc/'+id)
}
//time out so that the svg has the time to load
setTimeout(function() {
handleCheckbox()
handleProcButton()
const input = document.getElementById('searchId')
input.value = ''
input.addEventListener('keyup',function(event){
if(event.keyCode === 13){
event.preventDefault()
procByid()
}
})
let svgObject = document.getElementById('svg-object').contentDocument
let svgElement = svgObject.getElementById('Machine_0_rect')
if(svgObject.getElementById('Machine_0_rect')){
createProcesses(svgObject, 'bound')
start(svgObject)
}else{
const h1 = document.createElement('h1')
h1.innerHTML = "Your svg file doesn't have the good format to load javascript"
document.body.appendChild(h1)
}
}, 200)

View File

@@ -0,0 +1,142 @@
/* Copyright © 2019 Inria. All rights reserved. */
.navul {
position: fixed;
left: 0;
top: 0;
width: 100%;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #5d5e60;
}
.navli {
float: left;
}
li a{
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.draggable {
display: inline;
}
/* Change the link color to #111 (black) on hover */
li a:hover{
background-color: #111;
}
label {
display: inline-block;
padding-left: 15px;
text-indent: -15px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.checkbox {
width: 13px;
height: 13px;
padding: 0;
margin:0;
vertical-align: bottom;
position: relative;
top: -2px;
*overflow: hidden;
margin-left: 14px;
}
#mainCheck{
width: 13px;
height: 13px;
padding: 0;
margin:0;
vertical-align: bottom;
position: relative;
top: -2px;
*overflow: hidden;
}
input{
margin-top:7px;
}
.button {
position:fixed;
right: 10px;
background-color: #7f8082;
border: none;
color: white;
padding: 7px 16px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border-radius: 4px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
}
#searchId{
position: fixed;
right: 150px;
}
.button:hover {
background-color: #111; /* Green */
color: white;
}
#info{
padding-top : 5px;
color: black;
border-radius: 5px;
background-color: white;
width:300px;
min-height:200px;
box-shadow: 5px 10px #888888;
text-align: left;
}
#info-not-found{
padding-top : 5px;
color: black;
border: 2x solid black;
border-radius: 5px;
background-color: white;
width:300px;
min-height:200px;
box-shadow: 5px 10px #888888;
text-align: left;
}
.hidden{
display:none;
}
@media only screen and (max-width: 1175px) {
.show-mobile {
display: block;
}
.hide-mobile {
display: none;
}
}
@media only screen and (min-width: 1176px) {
.show-mobile {
display: none;
}
.hide-mobile {
display: block;
}
}

View File

@@ -0,0 +1,188 @@
/* Copyright © 2019 Inria. All rights reserved. */
var express = require('express')
var path = require('path')
var app = express()
var net = require('net')
var HOST = 'localhost'
var HPPORT = 8888
var NPORT = 3000
var verbose = 0
var open = 1
var fs = require('fs')
var open = require("open")
var lastRequest = ''
var client = new net.Socket()
var svg
var json
function usage() {
console.log(path.basename(process.argv[0]) + " " + path.basename(process.argv[1]) + " [options] <file.svg>")
console.log(" SVG file <file.svg> must be generated with lstopo --of nativesvg <file.svg>")
console.log("Options:")
console.log(" --hp <port> Change hwloc-ps JSON server port (default is "+HPPORT+")")
console.log(" --np <port> Change node port (default is "+NPORT+")")
console.log(" -u Display the webpage URL instead of opening it")
console.log(" -v --verbose Increase verbosity")
console.log(" -h --help Show this help")
}
var currentarg = 2
while(process.argv.length > currentarg){
if(process.argv[currentarg] === '-h' || process.argv[currentarg] === '-help'){
usage()
return
}else if (process.argv[currentarg] === '-v' || process.argv[currentarg] === '--verbose'){
verbose++
currentarg++
}else if (process.argv[currentarg] === '-u'){
open = 0
currentarg++
}else if (process.argv[currentarg] === '--hp'){
if(currentarg+2 > process.argv.length){
console.err("Missing argument after --hp")
usage()
return
}
HPPORT = process.argv[currentarg + 1]
currentarg += 2
}else if (process.argv[currentarg] === '--np'){
if(currentarg+2 > process.argv.length){
console.err("Missing argument after --np")
usage()
return
}
NPORT = process.argv[currentarg + 1]
currentarg += 2
}else{
if(svg != undefined){
console.err("Unexpected parameter after SVG filename.")
usage()
return
}
svg = process.argv[currentarg]
currentarg++
}
}
if(svg === undefined){
console.err("Missing SVG filename.")
usage()
return
}
client.on('data', function(data) {
if (verbose > 0)
console.log('##########################\n'
+ 'Client received:\n'
+ data
+ '##########################\n')
json += data
})
client.on('close', function() {
console.log('Client closed')
})
client.on('error', function(err) {
console.error(err)
})
app.get('/svg', function (req, res, next) {
res.setHeader('Content-Type', 'image/svg+xml')
res.sendFile(path.resolve(__dirname, svg))
})
app.get('/js', function (req, res, next) {
res.setHeader('Content-Type', 'text/javascript')
res.sendFile(path.join(__dirname, './assets/script.js'))
})
app.get('/json', function (req, res, next) {
res.setHeader('Content-Type', 'application/json')
res.send(json)
})
app.get('/stylecss', function (req, res, next) {
res.setHeader('Content-Type', 'text/css')
res.sendFile(path.join(__dirname, './assets/style.css'))
})
app.get('/maincss', function (req, res, next) {
res.setHeader('Content-Type', 'text/css')
res.sendFile(path.join(__dirname, './assets/main.css'))
})
app.get('/', function(req, res){
res.sendFile(path.join(__dirname+'/assets/index.html'))
})
app.get('/bound', async (req, res) =>{
json = ""
lastRequest = 'bound'
await client.write(lastRequest)
setTimeout(function(){
res.setHeader('Content-Type', 'application/json')
res.send(JSON.parse(json))
}, 500)
})
app.get('/all', async (req, res) =>{
json = ""
lastRequest = 'all'
await client.write(lastRequest)
setTimeout(function(){
res.setHeader('Content-Type', 'application/json')
res.send(json)
}, 500)
})
app.get('/proc/:filter', async (req, res) =>{
json = ""
if (/^\d+$/.test(req.params.filter))
lastRequest = 'threads pid=' + req.params.filter
else
lastRequest = 'name=' + req.params.filter
await client.write(lastRequest)
setTimeout(function(){
res.setHeader('Content-Type', 'application/json')
res.send(json)
}, 500)
})
app.get('/threads', async (req, res) =>{
json = ""
if(!lastRequest.includes('threads'))
lastRequest = 'threads ' + lastRequest
else
lastRequest = lastRequest.replace('threads ', '')
await client.write(lastRequest)
setTimeout(function(){
res.setHeader('Content-Type', 'application/json')
res.send(json)
}, 500)
})
app.get('/lastcpulocation', async (req, res) =>{
json = ""
if(!lastRequest.includes('lastcpulocation'))
lastRequest = 'lastcpulocation ' + lastRequest
else
lastRequest = lastRequest.replace('lastcpulocation ', '')
await client.write(lastRequest)
setTimeout(function(){
res.setHeader('Content-Type', 'application/json')
res.send(json)
}, 500)
})
client.connect(HPPORT, HOST, function() {
console.log('Client connected to hwloc-ps JSON server running on ' + HOST + ':' + HPPORT)
let serv = app.listen(NPORT)
if(open){
open("http://localhost:" + NPORT)
}else{
console.log("Page is available from http://localhost:" + NPORT)
}
})

View File

@@ -0,0 +1,17 @@
{
"name": "js",
"version": "1.0.0",
"description": "",
"main": "client.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"grunt": "grunt",
"server": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.4",
"open": ">=6.0.0"
}
}

View File

@@ -0,0 +1,161 @@
# Copyright © 2012-2018 Inria. All rights reserved.
# See COPYING in top-level directory.
# suppressions file to be passed to valgrind with
# --suppressions=/path/to/hwloc-valgrind.supp
# zlib (brought by libpci or libxml2) doesn't cleanup its global state
{
inflate_init
Memcheck:Cond
fun:inflateReset2
fun:inflateInit2_
}
# hwloc cannot free the global parser (with xmlCleanupParser()) because other threads may be using it
{
xml_init_parser
Memcheck:Leak
...
fun:xmlInitParser
}
# hwloc cannot free the global xml dict RMutex because it cannot call xmlCleanupParser() as explained above
{
xml_dict_create_new_rmutex
Memcheck:Leak
fun:malloc
fun:xmlNewRMutex
...
fun:xmlDictCreate
}
# ltdl dlopen global state?
{
ltdl_dlopen_doit_leak
Memcheck:Leak
...
fun:dl_open_worker
fun:_dl_catch_error
fun:_dl_open
fun:dlopen_doit
}
# ltdl_dlclose_leak
{
ltdl_dlclose_leak
Memcheck:Leak
...
fun:_dl_close_worker
fun:_dl_close
...
fun:dlclose
}
# lt_dlforeachfile abusing paths
{
lt_dlforeachfile_addr8
Memcheck:Addr8
fun:_wordcopy_fwd_dest_aligned
fun:__GI_memmove
fun:argz_insert
...
fun:lt_dlforeachfile
}
# cuda
{
cuda_leak
Memcheck:Leak
...
obj:*libcuda*
}
# nvml
{
nvmlInit_cond
Memcheck:Cond
...
obj:*nvidia-ml*
...
fun:nvmlInit
}
# amd opencl
{
atical_leak
Memcheck:Leak
...
obj:*libatical*
}
{
atical_cond
Memcheck:Cond
...
obj:*libatical*
}
{
amdocl_leak
Memcheck:Leak
...
obj:*libamdocl*
}
{
amdocl_param
Memcheck:Param
write(buf)
fun:*write*
obj:*libamdocl*
}
{
opencl_leak
Memcheck:Leak
...
obj:*libOpenCL*
...
fun:clGetPlatformIDs
}
{
libatiadl_xcb_leak
Memcheck:Leak
...
obj:*libxcb*
...
fun:XOpenDisplay
...
obj:*libatiadl*
}
# libpciaccess global state leak
{
libpciaccess_device_name_leak
Memcheck:Leak
...
fun:pci_device_get_device_name
fun:hwloc_look_pci
}
{
libpciaccess_leak
Memcheck:Leak
...
obj:*libpciaccess*
...
fun:hwloc_look_pci
}
# libudev global hashes
{
libudev_hashmap_property
Memcheck:Leak
fun:malloc
...
fun:udev_device_get_property_value
}
{
libudev_hashmap_sysname
Memcheck:Leak
fun:malloc
...
fun:udev_device_new_from_subsystem_sysname
}

View File

@@ -0,0 +1,73 @@
<!--
Copyright © 2009 CNRS
Copyright © 2009-2017 Inria. All rights reserved.
Copyright © 2009-2011 Université Bordeaux.
See COPYING in top-level directory.
This is the old DTD for hwloc v1.x XMLs and diff XMLs.
-->
<!ELEMENT topology (object)+>
<!ELEMENT root (object)+>
<!ELEMENT object (page_type*,info*,distances*,userdata*,object*)>
<!ATTLIST object type (System | Machine | Misc | Group | NUMANode | Socket | Package | Cache | Core | PU | Bridge | PCIDev | OSDev) #REQUIRED>
<!ATTLIST object os_level CDATA "-1" >
<!ATTLIST object os_index CDATA "-1" >
<!ATTLIST object name CDATA "" >
<!ATTLIST object local_memory CDATA "0" >
<!ATTLIST object cache_size CDATA "0" >
<!ATTLIST object cache_linesize CDATA "0" >
<!ATTLIST object cache_associativity CDATA "0" >
<!ATTLIST object cache_type CDATA "0" >
<!ATTLIST object huge_page_size_kB CDATA "0" >
<!ATTLIST object huge_page_free CDATA "0" >
<!ATTLIST object depth CDATA "-1" >
<!ATTLIST object cpuset CDATA "0" >
<!ATTLIST object complete_cpuset CDATA "" >
<!ATTLIST object online_cpuset CDATA "" >
<!ATTLIST object allowed_cpuset CDATA "" >
<!ATTLIST object nodeset CDATA "" >
<!ATTLIST object complete_nodeset CDATA "" >
<!ATTLIST object allowed_nodeset CDATA "" >
<!ATTLIST object bridge_type CDATA "" >
<!ATTLIST object bridge_pci CDATA "" >
<!ATTLIST object pci_busid CDATA "" >
<!ATTLIST object pci_type CDATA "" >
<!ATTLIST object pci_link_speed CDATA "0." >
<!ATTLIST object osdev_type CDATA "" >
<!ELEMENT page_type EMPTY>
<!ATTLIST page_type size CDATA #REQUIRED>
<!ATTLIST page_type count CDATA #REQUIRED>
<!ELEMENT info EMPTY>
<!ATTLIST info name CDATA #REQUIRED>
<!ATTLIST info value CDATA #REQUIRED>
<!ELEMENT distances (latency*)>
<!ATTLIST distances nbobjs CDATA #REQUIRED>
<!ATTLIST distances relative_depth CDATA #REQUIRED>
<!ATTLIST distances latency_base CDATA #REQUIRED>
<!ELEMENT latency EMPTY>
<!ATTLIST latency value CDATA #REQUIRED>
<!ELEMENT userdata (#PCDATA)>
<!ATTLIST userdata name CDATA "" >
<!ATTLIST userdata length CDATA "0" >
<!ATTLIST userdata encoding CDATA "" >
<!ELEMENT topologydiff (diff)*>
<!ATTLIST topologydiff refname CDATA "">
<!ELEMENT diff EMPTY>
<!ATTLIST diff type CDATA #REQUIRED>
<!ATTLIST diff obj_depth CDATA "-1" >
<!ATTLIST diff obj_index CDATA "-1" >
<!ATTLIST diff obj_attr_type CDATA "-1" >
<!ATTLIST diff obj_attr_index CDATA "-1" >
<!ATTLIST diff obj_attr_name CDATA "" >
<!ATTLIST diff obj_attr_newvalue CDATA "" >
<!ATTLIST diff obj_attr_oldvalue CDATA "" >

View File

@@ -0,0 +1,21 @@
<!--
Copyright © 2009 CNRS
Copyright © 2009-2017 Inria. All rights reserved.
Copyright © 2009-2011 Université Bordeaux.
See COPYING in top-level directory.
This is the DTD for hwloc v2.x diff XMLs.
-->
<!ELEMENT topologydiff (diff)*>
<!ATTLIST topologydiff refname CDATA "">
<!ELEMENT diff EMPTY>
<!ATTLIST diff type CDATA #REQUIRED>
<!ATTLIST diff obj_depth CDATA "-1" >
<!ATTLIST diff obj_index CDATA "-1" >
<!ATTLIST diff obj_attr_type CDATA "-1" >
<!ATTLIST diff obj_attr_index CDATA "-1" >
<!ATTLIST diff obj_attr_name CDATA "" >
<!ATTLIST diff obj_attr_newvalue CDATA "" >
<!ATTLIST diff obj_attr_oldvalue CDATA "" >

View File

@@ -0,0 +1,90 @@
<!--
Copyright © 2009 CNRS
Copyright © 2009-2021 Inria. All rights reserved.
Copyright © 2009-2011 Université Bordeaux.
See COPYING in top-level directory.
This is the DTD for hwloc v2.x XMLs.
-->
<!ELEMENT topology (object+,distances2*,distances2hetero*,support*,memattr*,cpukind*)>
<!ATTLIST topology version CDATA "">
<!ELEMENT object (page_type*,info*,userdata*,object*)>
<!ATTLIST object type (Machine | Misc | Group | NUMANode | MemCache | Package | Die | L1Cache | L2Cache | L3Cache | L4Cache | L5Cache | L1iCache | L2iCache | L3iCache | Core | PU | Bridge | PCIDev | OSDev) #REQUIRED>
<!ATTLIST object subtype CDATA "" >
<!ATTLIST object os_index CDATA "-1" >
<!ATTLIST object gp_index CDATA "-1" >
<!ATTLIST object name CDATA "" >
<!ATTLIST object local_memory CDATA "0" >
<!ATTLIST object cache_size CDATA "0" >
<!ATTLIST object cache_linesize CDATA "0" >
<!ATTLIST object cache_associativity CDATA "0" >
<!ATTLIST object cache_type CDATA "0" >
<!ATTLIST object cpuset CDATA "0" >
<!ATTLIST object complete_cpuset CDATA "" >
<!ATTLIST object allowed_cpuset CDATA "" >
<!ATTLIST object nodeset CDATA "" >
<!ATTLIST object complete_nodeset CDATA "" >
<!ATTLIST object allowed_nodeset CDATA "" >
<!ATTLIST object depth CDATA "-1" >
<!ATTLIST object kind CDATA "0" >
<!ATTLIST object subkind CDATA "0" >
<!ATTLIST object dont_merge CDATA "0" >
<!ATTLIST object bridge_type CDATA "" >
<!ATTLIST object bridge_pci CDATA "" >
<!ATTLIST object pci_busid CDATA "" >
<!ATTLIST object pci_type CDATA "" >
<!ATTLIST object pci_link_speed CDATA "0." >
<!ATTLIST object osdev_type CDATA "" >
<!ELEMENT page_type EMPTY>
<!ATTLIST page_type size CDATA #REQUIRED>
<!ATTLIST page_type count CDATA #REQUIRED>
<!ELEMENT info EMPTY>
<!ATTLIST info name CDATA #REQUIRED>
<!ATTLIST info value CDATA #REQUIRED>
<!ELEMENT distances2 (indexes+,u64values+)>
<!ATTLIST distances2 type CDATA #REQUIRED>
<!ATTLIST distances2 nbobjs CDATA #REQUIRED>
<!ATTLIST distances2 indexing CDATA #REQUIRED>
<!ATTLIST distances2 kind CDATA #REQUIRED>
<!ATTLIST distances2 name CDATA "">
<!ELEMENT distances2hetero (indexes+,u64values+)>
<!ATTLIST distances2hetero nbobjs CDATA #REQUIRED>
<!ATTLIST distances2hetero kind CDATA #REQUIRED>
<!ATTLIST distances2hetero name CDATA "">
<!ELEMENT memattr (memattr_value*)>
<!ATTLIST memattr name CDATA #REQUIRED>
<!ATTLIST memattr flags CDATA #REQUIRED>
<!ELEMENT memattr_value EMPTY>
<!ATTLIST memattr_value target_obj_gp_index CDATA "">
<!ATTLIST memattr_value target_obj_type CDATA #REQUIRED>
<!ATTLIST memattr_value value CDATA #REQUIRED>
<!ATTLIST memattr_value initiator_cpuset CDATA "">
<!ATTLIST memattr_value initiator_obj_gp_index CDATA "">
<!ATTLIST memattr_value initiator_obj_type CDATA "">
<!ELEMENT indexes (#PCDATA)>
<!ATTLIST indexes length CDATA #REQUIRED>
<!ELEMENT u64values (#PCDATA)>
<!ATTLIST u64values length CDATA #REQUIRED>
<!ELEMENT userdata (#PCDATA)>
<!ATTLIST userdata name CDATA "" >
<!ATTLIST userdata length CDATA "0" >
<!ATTLIST userdata encoding CDATA "" >
<!ELEMENT support EMPTY>
<!ATTLIST support name CDATA #REQUIRED>
<!ATTLIST support value CDATA "1" >
<!ELEMENT cpukind (info*)>
<!ATTLIST cpukind cpuset CDATA "0">
<!ATTLIST cpukind forced_efficiency CDATA "-1">