diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 1426ec2e32ad793a1ea92bdabc68d527870c7567..0000000000000000000000000000000000000000 Binary files a/.DS_Store and /dev/null differ diff --git a/01_Code/.DS_Store b/01_Code/.DS_Store deleted file mode 100644 index 9e590ec8f16bcb601558a4c31c4dd79d41f2a26f..0000000000000000000000000000000000000000 Binary files a/01_Code/.DS_Store and /dev/null differ diff --git a/01_Code/physical_computing_interface/.DS_Store b/01_Code/physical_computing_interface/.DS_Store deleted file mode 100644 index 7d0dddfdc9ef619267093ef33b77a5d6305dec4b..0000000000000000000000000000000000000000 Binary files a/01_Code/physical_computing_interface/.DS_Store and /dev/null differ diff --git a/01_Code/physical_computing_interface/globals.js b/01_Code/physical_computing_interface/globals.js index ecb3a6a816db00aa708bb5ec088437477c2e771a..a4c9917074db4ef92ef267c3e875dbd2182cebaf 100644 --- a/01_Code/physical_computing_interface/globals.js +++ b/01_Code/physical_computing_interface/globals.js @@ -220,7 +220,7 @@ function globals(utils){ }; - this.grid=this.gridPresets.Dice; + this.grid=this.gridPresets.Cubic; this.utils=utils; this.occupancy=[]; diff --git a/01_Code/physical_computing_interface/graph/code.js b/01_Code/physical_computing_interface/graph/code.js index 545c4fd2e62a7777bddb885d4de94e49a7785905..d3dbd29956db1a2627682570fbe0cfb89952e929 100644 --- a/01_Code/physical_computing_interface/graph/code.js +++ b/01_Code/physical_computing_interface/graph/code.js @@ -1,13 +1,38 @@ -var cy = cytoscape({ +var color1= "#ffffff"; //white +var color11= "#ffffff8c"; //white transparent +var color2= "#020227"; //dark blue +var color3= "#1c5c61"; //teal +var color33= "#1c5c618c"; //teal transparent +var color4= "#fa6e70"; //red/orange +var color44= "#fa6e708c"; //red/orange +var color5="#380152"; //purple +var color6="#696767"; //grey +var font= "consolas";//'font-family' + +var cy = window.cy= cytoscape({ container: document.getElementById('cy'), + ready: function(){ + var api = this.expandCollapse({ + layoutBy: { + name: "cose-bilkent", + animate: "end", + randomize: false, + fit: true + }, + fisheye: true, + animate: false, + undoable: false + }); + // api.collapseAll(); + }, style: cytoscape.stylesheet() .selector('node') .css({ 'content': 'data(name)', 'text-valign': 'center', 'color': 'white', - // 'font-family': "consolas", - 'font-family':"Times New Roman", + 'font-family': "consolas", + // 'font-family':"Times New Roman", 'width': 80, 'height': 80 }) @@ -21,31 +46,29 @@ var cy = cytoscape({ 'target-arrow-shape': 'triangle' }) .selector(':selected') -// .css({ -// 'background-color': 'black', -// 'line-color': 'black', -// 'target-arrow-color': 'black', -// 'source-arrow-color': 'black', -// 'text-outline-color': 'black' -// }) + // .css({ + // 'background-color': 'black', + // 'line-color': 'black', + // 'target-arrow-color': 'black', + // 'source-arrow-color': 'black', + // 'text-outline-color': 'black' + // }) .selector('$node > node') .css({ 'shape': 'roundrectangle', 'text-valign': 'top', - 'height': 'auto', - 'width': 'auto', 'background-color': '#ccc', - 'background-opacity': 0.333, + 'background-opacity': 0.1, 'color': '#888', 'text-outline-width': 0, 'font-size': 25 }) -// .selector('#core') -// .css({ -// 'background-color': '#000', -// 'text-outline-color': '#000' -// }) + // .selector('#core') + // .css({ + // 'background-color': '#000', + // 'text-outline-color': '#000' + // }) .selector('#core, #app') .css({ 'width': 120, @@ -61,10 +84,25 @@ var cy = cytoscape({ }) .selector('#ext, .ext') .css({ - 'background-color': '#93CDDD', - 'text-outline-color': '#93CDDD', - 'line-color': '#93CDDD', - 'target-arrow-color': '#93CDDD' + 'background-color': color3, + // 'text-outline-color': '#93CDDD', + 'line-color': color3, + 'target-arrow-color': color3, + 'color': color6, + 'font-family':font, + "text-wrap": "wrap", + }) + .selector('#exte, .exte') + .css({ + 'background-color': color3, + // 'text-outline-color': '#93CDDD', + 'line-color': color3, + 'target-arrow-color': color3, + 'color': color6, + 'font-family':font, + 'curve-style': 'bezier', + 'width': 2, + "text-wrap": "wrap", }) .selector('#app, .app') .css({ @@ -80,7 +118,7 @@ var cy = cytoscape({ 'background-opacity': 0, 'border-width': 1, 'border-color': '#aaa', - 'border-opacity': 0.5, + 'border-opacity': 0.3, 'font-size': 50, 'padding-top': 40, 'padding-left': 40, @@ -91,78 +129,165 @@ var cy = cytoscape({ elements: { nodes: [ { - data: { id: 'cy', name: 'DICE' } + data: { id: 'DICE', name: 'DICE' } }, + ///////////hardware + { - data: { id: 'core', name: 'Core', parent: 'api' }, + data: { id: 'hardware', name: 'Hardware', parent: 'DICE' }, position: { x: 0, y: 0 } }, - { - data: { id: 'eles', name: 'Collection', parent: 'api' }, - position: { x: 150, y: 150 } + data: { id: 'chip', name: 'Chip', parent: 'hardware' }, + position: { x: 0, y: 0 } }, - { - data: { id: 'style', name: 'Stylesheet', parent: 'api' }, - position: { x: 0, y: 150 } + data: { id: 'ram', name: 'ram', parent: 'chip' }, + position: { x: 0, y: 0 },classes: 'ext', }, - { - data: { id: 'selector', name: 'Selector', parent: 'api' }, - position: { x: -150, y: 150 } + data: { id: 'cyclesPerSecond', name: 'cycles Per second', parent: 'chip' }, + position: { x: 0, y: 0 },classes: 'ext', }, - { - data: { id: 'ext', name: 'Extensions', parent: 'cy' } + data: { id: 'bitsPerSecond', name: 'bits per second', parent: 'chip' }, + position: { x: 0, y: 0 },classes: 'ext', }, - { - data: { id: 'corefn', name: 'Core Function', parent: 'ext' }, - classes: 'ext', - position: { x: 350, y: -140 } + data: { id: 'costPerChip', name: 'cost per chip', parent: 'chip' }, + position: { x: 0, y: 0 },classes: 'ext', }, - { - data: { id: 'elesfn', name: 'Collection Function', parent: 'ext' }, - classes: 'ext', - position: { x: 350, y: 0 } + data: { id: 'flopsPerWatt', name: 'flops per watt', parent: 'chip' }, + position: { x: 0, y: 0 },classes: 'ext', + }, + { + data: { id: 'interconnect', name: '# of Interconnect', parent: 'hardware' }, + position: { x: 0, y: 0 },classes: 'ext', + }, + { + data: { id: 'nodesNumber', name: '# of Nodes', parent: 'hardware' }, + position: { x: 0, y: 0 },classes: 'ext', }, + ///////////////software + { + data: { id: 'software', name: 'Software', parent: 'DICE' }, + position: { x: 1000, y: 0 } + }, { - data: { id: 'layout', name: 'Layout', parent: 'ext' }, - classes: 'ext', - position: { x: 350, y: 140 } + data: { id: 'dataExchangeSize', name: 'Data Exchanged Size', parent: 'software' }, + position: { x: 1000, y: 0 },classes: 'ext', + }, + { + data: { id: 'computation', name: 'Computation', parent: 'software' }, + position: { x: 1000, y: 0 },classes: 'ext', + }, + { + data: { id: 'dataSize', name: 'Data Size', parent: 'software' }, + position: { x: 1000, y: 0 },classes: 'ext', + }, + { + data: { id: 'maxNumberOfInterconnects', name: '# of Interconnects', parent: 'software' }, + position: { x: 1000, y: 0 },classes: 'ext', + }, + { + data: { id: 'numberofComputations', name: '# of Computations', parent: 'software' }, + position: { x: 1000, y: 0 },classes: 'ext', }, + /////////////performance + { - data: { id: 'renderer', name: 'Renderer', parent: 'ext' }, - classes: 'ext', - position: { x: 350, y: 280 } + data: { id: 'performance', name: 'Performance per Frame' }, + position: { x: 0, y: 2000 } }, { - data: { id: 'api', name: 'Core API', parent: 'cy' } + data: { id: 'speed', name: 'Speed' , parent: 'performance'}, + position: { x: 0, y: 2000 },classes: 'ext', + }, + { + data: { id: 'energy', name: 'Energy' , parent: 'performance'}, + position: { x: 0, y: 2000 },classes: 'ext', + }, + { + data: { id: 'cost', name: 'Cost' , parent: 'performance'}, + position: { x: 0, y: 2000 },classes: 'ext', }, + ///intermediate numbers + //in between computations + { + data: { id: 'intermediate', name: 'intermediate calculations',parent:"DICE" }, + position: { x: 0, y: 1000 } + }, + { + data: { id: 'nodesPerComputation', name: 'nodes per computation' , parent: 'intermediate'}, + position: { x: 0, y: 1000 },classes: 'ext', + }, + { + data: { id: 'numberofNodesNeeded', name: 'number of nodes needed' , parent: 'intermediate'}, + position: { x: 0, y: 1000 },classes: 'ext', + }, { - data: { id: 'app', name: 'Client' }, - position: { x: 0, y: 480 } - } + data: { id: 'computationTime', name: 'computation time' , parent: 'intermediate'}, + position: { x: 0, y: 1000 },classes: 'ext', + }, + { + data: { id: 'communicationTime', name: 'communication time' , parent: 'intermediate'}, + position: { x: 0, y: 1000 },classes: 'ext', + }, + ], edges: [ - { data: { source: 'core', target: 'eles' } }, - { data: { source: 'core', target: 'ext' } }, - { data: { source: 'core', target: 'style' } }, - { data: { source: 'style', target: 'selector' } }, - { data: { source: 'core', target: 'selector' } }, - { data: { source: 'elesfn', target: 'eles' }, classes: 'ext' }, - { data: { source: 'corefn', target: 'core' }, classes: 'ext' }, - { data: { source: 'layout', target: 'api' }, classes: 'ext' }, - { data: { source: 'renderer', target: 'api' }, classes: 'ext' }, - { data: { source: 'app', target: 'api', name: 'use' }, classes: 'app' }, - { data: { source: 'app', target: 'ext', name: 'register' }, classes: 'app' } + // //////////////hardware + // { data: { source: 'ram', target: 'speed' },classes: 'exte', }, + // { data: { source: 'cyclesPerSecond', target: 'speed' },classes: 'exte', }, + // { data: { source: 'bitsPerSecond', target: 'speed' },classes: 'exte', }, + // { data: { source: 'costPerChip', target: 'cost' },classes: 'exte', }, + // { data: { source: 'flopsPerWatt', target: 'Energy' },classes: 'exte', }, + + // { data: { source: 'interconnect', target: 'speed' },classes: 'exte', }, + // { data: { source: 'nodesNumber', target: 'cost' },classes: 'exte', }, + + // ///////// software + // { data: { source: 'dataExchangeSize', target: 'performance' },classes: 'exte', }, + // { data: { source: 'numberofComputations', target: 'performance' },classes: 'exte', }, + // { data: { source: 'computation', target: 'performance' },classes: 'exte', }, + // { data: { source: 'maxNumberOfInterconnects', target: 'performance' },classes: 'exte', }, + // { data: { source: 'dataSize', target: 'performance' },classes: 'exte', }, + + { data: { source: 'ram', target: 'nodesPerComputation' },classes: 'exte', }, + { data: { source: 'dataSize', target: 'nodesPerComputation' },classes: 'exte', }, + + { data: { source: 'maxNumberOfInterconnects', target: 'nodesPerComputation' },classes: 'exte', }, + { data: { source: 'interconnect', target: 'nodesPerComputation' },classes: 'exte', }, + + { data: { source: 'nodesPerComputation', target: 'numberofNodesNeeded' },classes: 'exte', }, + { data: { source: 'numberofComputations', target: 'numberofNodesNeeded' },classes: 'exte', }, + + { data: { source: 'computation', target: 'computationTime' },classes: 'exte', }, + { data: { source: 'cyclesPerSecond', target: 'computationTime' },classes: 'exte', }, + + { data: { source: 'dataExchangeSize', target: 'communicationTime' },classes: 'exte', }, + { data: { source: 'bitsPerSecond', target: 'communicationTime' },classes: 'exte', }, + { data: { source: 'nodesPerComputation', target: 'communicationTime' },classes: 'exte', }, + + { data: { source: 'computationTime', target: 'speed' },classes: 'exte', }, + { data: { source: 'communicationTime', target: 'speed' },classes: 'exte', }, + + { data: { source: 'numberofNodesNeeded', target: 'cost' },classes: 'exte', }, + { data: { source: 'costPerChip', target: 'cost' },classes: 'exte', }, + + { data: { source: 'flopsPerWatt', target: 'energy' },classes: 'exte', }, + { data: { source: 'numberofNodesNeeded', target: 'energy' },classes: 'exte', }, + { data: { source: 'computation', target: 'energy' },classes: 'exte', }, + + + + ] }, @@ -170,3 +295,244 @@ var cy = cytoscape({ name: 'preset' } }); + +var api = cy.expandCollapse('get'); + + +api.expandAll(); +// Hardware +// Node type +// Speed +// Bandwidth +// Number of interconnects +// Number of nodes +// Software +// number of computations +// operations per computation +// Max bandwidth +// Max interconnects + +///hardware +let processors={ + type:{ + stm32f412 : + { + name: "STM32F412", + ram: 256e3, + // cyclesPerSecond : 100e6, // ZF: this is based on 100 MHz clock rate + cyclesPerSecond : 12.8e6, // ZF: this is based on MFlops from pi benchmark at 84 MHz + bitsPerSecond : 6e6, // ZF: 6 MBit UART max spec (from datasheet) + costPerChip : 3.34925, // reel qty (5000) + flopsPerWatt : 1.71e8 // ZF: calculated from datasheet and pi test + }, + samd51j19: + { + name : "SAMD51J19", + ram : 192e3, + // cyclesPerSecond : 120e6, // ZF: this is based on 120 MHz clock rate + cyclesPerSecond : 16.8e6, // ZF: this is based on MFlops from pi benchmark at ~160 MHz + bitsPerSecond : 3e6, // ZF: 3 MBit UART max spec (from datasheet) + costPerChip : 3.44003, // reel qty (5000) + flopsPerWatt : 2.33e8 // ZF: calculated from datasheet and pi test + }, + samd51j20: + { + name : "SAMD51J20", + ram : 262e3, + // cyclesPerSecond : 120e6, // ZF: this is based on 120 MHz clock rate + cyclesPerSecond : 16.8e6, // ZF: this is based on MFlops from pi benchmark at ~160 MHz + bitsPerSecond : 3e6, // ZF: 3 MBit UART max spec (from datasheet) + costPerChip : 4.08002, // reel qty (5000) + flopsPerWatt : 2.33e8 // ZF: calculated from datasheet and pi test + }, + MAX32660: + { + name : "MAX32660", + ram : 96e3, + // cyclesPerSecond : 96e6, // ZF: this is based on 96 MHz clock rate + cyclesPerSecond : 12.8e6, // ZF: this is based on extrapolating MFlops from STM32F412 pi benchmark + bitsPerSecond : 48e6, + costPerChip : 1.1745, // reel qty (2000) + flopsPerWatt: 4.75e8 // ZF: calculated from datasheet and STM32F412 pi test + + }, + STM32F412: + { + name : "STM32F412", + ram : 256e3, + // cyclesPerSecond : 100e6, // ZF: this is based on 100 MHz clock rate + cyclesPerSecond : 12.8e6, // ZF: this is based on MFlops from pi benchmark at 84 MHz + bitsPerSecond : 6e6, // ZF: 6 MBit UART max spec (from datasheet) + costPerChip : 3.34925, // reel qty (5000) + flopsPerWatt : 1.71e8 // ZF: calculated from datasheet and pi test + + }, + XMEGA: + { + name: 'XMEGA', + ram:10, + cyclesPerSecond:100, + bitsPerSecond:10 + + } + } +}; + + +var chip=processors.type.samd51j19; +var ram=chip.ram; +var cyclesPerSecond =chip.cyclesPerSecond; +var bitsPerSecond =chip.bitsPerSecond ; +var costPerChip =chip.costPerChip ; +var flopsPerWatt =chip.flopsPerWatt ; + +updateVariable("chip", chip.name,""); +updateVariable("ram", ram,"bytes"); +updateVariable("cyclesPerSecond", cyclesPerSecond),""; +updateVariable("bitsPerSecond", bitsPerSecond ,""); +updateVariable("costPerChip", costPerChip ,"dollars" ); +updateVariable("flopsPerWatt", flopsPerWatt ,"" ); + +var interconnect=4; //2,4,6 +var nodesNumber= 50; //10,20,30,40,50 +updateVariable("interconnect", interconnect,"neighbor"); +updateVariable("nodesNumber", nodesNumber,"node"); + +var dataExchangeSize= 20; +var dataSize= 200; +var numberofComputations= 200; +var computation= 100; //cylces +var maxNumberOfInterconnects= 10; + +updateVariable("dataExchangeSize", dataExchangeSize,"bytes"); +updateVariable("dataSize", dataSize,"bytes"); +updateVariable("numberofComputations", numberofComputations,""); +updateVariable("computation", computation,"cycle"); +updateVariable("maxNumberOfInterconnects", maxNumberOfInterconnects,"neighbor"); + +var nodesPerComputation=1; +var numberofNodesNeeded=1; +var computationTime; +var communicationTime; +var speed; +var cost; +var energy; + +// 1- look data size/storage +if(dataSize>ram){ + nodesPerComputation=Math.ceil(dataSize/ram); +} +// 2- look for number of interconnects in the software +if(interconnect<maxNumberOfInterconnects*nodesPerComputation){ + nodesPerComputation=Math.ceil(maxNumberOfInterconnects*nodesPerComputation/interconnect); + //Or add time for interchange? +} +updateVariable("nodesPerComputation", nodesPerComputation,""); +// 3- Look for number of computations vs number of nodes +// if number of nodes needed <number of nodes +numberofNodesNeeded= nodesPerComputation*numberofComputations; +updateVariable("numberofNodesNeeded", numberofNodesNeeded,"nodes"); +if(numberofNodesNeeded>nodesNumber){ + console.log("need more nodes"); + //Then overload some of the computations where one node doing double of work others have to wait for it +} +// 4- compute performance +// Time of computation +computationTime=computation/cyclesPerSecond; //?? remove nodes percomp +communicationTime=dataExchangeSize/bitsPerSecond*nodesPerComputation; //assume all in parallel +updateVariable("computationTime", computationTime/1000,"ms"); +updateVariable("communicationTime", communicationTime/1000,"ms"); + + +speed=computationTime+communicationTime; //frame +cost=numberofNodesNeeded*costPerChip; +energy= 1 / flopsPerWatt*numberofNodesNeeded*computation;//perframe + +updateVariable("speed", speed/1000,"ms/frame"); +updateVariable("cost", cost,"dollars"); +updateVariable("energy", energy,"watt/frame"); + + +function updateVariable(name, value,unit){ + var oldName=cy.$id(name).data('name'); + cy.$id(name).data('name', oldName+'\n'+value+'\n'+unit); +} + + +// elements: { +// nodes: [ +// { +// data: { id: 'cy', name: 'DICE' } +// }, + +// { +// data: { id: 'core', name: 'Core', parent: 'api' }, +// position: { x: 0, y: 0 } +// }, + +// { +// data: { id: 'eles', name: 'Collection', parent: 'api' }, +// position: { x: 150, y: 150 } +// }, + +// { +// data: { id: 'style', name: 'Stylesheet', parent: 'api' }, +// position: { x: 0, y: 150 } +// }, + +// { +// data: { id: 'selector', name: 'Selector', parent: 'api' }, +// position: { x: -150, y: 150 } +// }, + +// { +// data: { id: 'ext', name: 'Extensions', parent: 'cy' } +// }, + +// { +// data: { id: 'corefn', name: 'Core Function', parent: 'ext' }, +// classes: 'ext', +// position: { x: 350, y: -140 } +// }, + +// { +// data: { id: 'elesfn', name: 'Collection Function', parent: 'ext' }, +// classes: 'ext', +// position: { x: 350, y: 0 } +// }, + +// { +// data: { id: 'layout', name: 'Layout', parent: 'ext' }, +// classes: 'ext', +// position: { x: 350, y: 140 } +// }, + +// { +// data: { id: 'renderer', name: 'Renderer', parent: 'ext' }, +// classes: 'ext', +// position: { x: 350, y: 280 } +// }, + +// { +// data: { id: 'api', name: 'Core API', parent: 'cy' } +// }, + +// { +// data: { id: 'app', name: 'Client' }, +// position: { x: 0, y: 480 } +// } +// ], +// edges: [ +// { data: { source: 'core', target: 'eles' } }, +// { data: { source: 'core', target: 'ext' } }, +// { data: { source: 'core', target: 'style' } }, +// { data: { source: 'style', target: 'selector' } }, +// { data: { source: 'core', target: 'selector' } }, +// { data: { source: 'elesfn', target: 'eles' }, classes: 'ext' }, +// { data: { source: 'corefn', target: 'core' }, classes: 'ext' }, +// { data: { source: 'layout', target: 'api' }, classes: 'ext' }, +// { data: { source: 'renderer', target: 'api' }, classes: 'ext' }, +// { data: { source: 'app', target: 'api', name: 'use' }, classes: 'app' }, +// { data: { source: 'app', target: 'ext', name: 'register' }, classes: 'app' } +// ] +// }, diff --git a/01_Code/physical_computing_interface/graph/index.html b/01_Code/physical_computing_interface/graph/index.html index da2de86d7944c806e795802ff2624fe86d14c2fc..197732aef59e5d7e8d0d7ec81eae0c03082aacf9 100644 --- a/01_Code/physical_computing_interface/graph/index.html +++ b/01_Code/physical_computing_interface/graph/index.html @@ -2,9 +2,49 @@ <!-- This code is for demonstration purposes only. You should not hotlink to Github, Rawgit, or files from the Cytoscape.js documentation in your production apps. --> <html> <head> -<link href="style.css" rel="stylesheet" /> +<style> + :root { + --color1: #ffffff; /*white*/ + --color11: #ffffff8c; /*shafaf*/ + --color2: #020227; /*kohly*/ + --color3: #1c5c61; /*teal*/ + --top: 20px; + --dragwidth: 10px; + --bottom: 20px; + --font: "Times New Roman", Times, serif; + } + body { + font: 8px helvetica neue, helvetica, arial, sans-serif; + } + + #cy { + background-color: var(--color2); + height: 100%; + width: 100%; + position: absolute; + left: 0; + top: 0; + } + + /* you can set the disabled style how you like on the text/icon */ + .cxtmenu-disabled { + opacity: 0.1; + } + /* you can set the disabled style how you like on the text/icon */ + .cxtmenu { + opacity: 0.1; + } +</style> + <meta charset=utf-8 /> + <script src="../lib/cytoscape.min.js"></script> +<script src="../lib/cytoscape-cxtmenu.js"></script> +<script src="https://unpkg.com/layout-base/layout-base.js"></script> +<script src="https://unpkg.com/cose-base/cose-base.js"></script> +<script src="https://unpkg.com/cytoscape-cose-bilkent/cytoscape-cose-bilkent.js"></script> +<script src="../lib/cytoscape-expand-collapse.js"></script> + </head> <body> <div id="cy"></div> diff --git a/01_Code/physical_computing_interface/simulation/.DS_Store b/01_Code/physical_computing_interface/simulation/.DS_Store deleted file mode 100644 index 2e3e2ad91ff3cd598996d669a864298882b349a4..0000000000000000000000000000000000000000 Binary files a/01_Code/physical_computing_interface/simulation/.DS_Store and /dev/null differ