-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from gpujs/benchmark-v3
Benchmark v3
- Loading branch information
Showing
46 changed files
with
1,024 additions
and
762 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
"matrix_size", | ||
"num_iterations", | ||
"cpu_benchmark" | ||
] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const readlineSync = require('readline-sync'), | ||
defaultInputs = require('./default-options-input.json'), | ||
{ YELLOW_UNDER, GREEN_NO_UNDER, NC } = require('./colors'), | ||
defaults = require('../src/util/defaults.json'); | ||
|
||
function getOptionsInput(options) { | ||
console.log(`${GREEN_NO_UNDER}OPTIONS:${NC} (Press Enter to Select the Default Value)`); | ||
|
||
defaultInputs.forEach(input => { | ||
if (options.hasOwnProperty(input)) return; | ||
|
||
options[input] = readlineSync.question(`${YELLOW_UNDER}${input}${NC} (${typeof defaults[input]})(default: ${defaults[input]}): `); | ||
|
||
if (options[input] === '') options[input] = defaults[input]; | ||
}) | ||
|
||
return options; | ||
} | ||
|
||
module.exports = getOptionsInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"x": "matrix_size", | ||
"y": "gpu_score" | ||
}, | ||
{ | ||
"x": "matrix_size", | ||
"y": "gpu_run_time_mat_mult" | ||
}, | ||
{ | ||
"x": "matrix_size", | ||
"y": "cpu_score" | ||
}, | ||
{ | ||
"x": "matrix_size", | ||
"y": "cpu_run_time_mat_mult" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const { NC, YELLOW_UNDER } = require('./colors'); | ||
|
||
const getVal = val => val.avg == -1 ? | ||
`${YELLOW_UNDER}Not Benchmarked${NC}` : | ||
`${YELLOW_UNDER}${val.avg}${NC} ms +- ${YELLOW_UNDER}${val.deviation}${NC}%` | ||
|
||
module.exports = minMax => { | ||
console.log(`GPU average: ${getVal(minMax.gpu)}`); | ||
console.log(`CPU average: ${getVal(minMax.cpu)}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const { NC, YELLOW_NO_UNDER, YELLOW_UNDER, GREEN_UNDER, GREEN_NO_UNDER, RED_NO_UNDER } = require('./colors'), | ||
{ br } = require('./format'); | ||
|
||
const performerMap = { | ||
gpu: 'GPU', | ||
cpu: 'CPU', | ||
pipe: 'GPU(pipeline mode)' | ||
}, | ||
benchMap = { | ||
mat_mult: 'Matrix Multiplication', | ||
mat_conv: 'Matrix Convolution', | ||
pipe: 'Pipelining' | ||
} | ||
|
||
const logRunTimeStats = ({run_time}, cpuBenched) => { | ||
if (cpuBenched) { | ||
for (const bench in run_time) { | ||
console.log(`Benchmark: ${GREEN_UNDER}${benchMap[bench]}${NC}`); | ||
br(); | ||
let performerNotBenched; | ||
|
||
for (const diff in run_time[bench].diff) { | ||
const performers = diff.split('_'), | ||
{ avg } = run_time[bench].diff[diff], | ||
percentage = { | ||
avg: run_time[bench].diff[diff].avg.percentage | ||
}; | ||
|
||
performerNotBenched = (performerNotBenched || percentage.min == -1 || percentage.max == -1 || percentage.avg == -1); | ||
|
||
if (!performerNotBenched){ | ||
console.log(`Performance Comparison between ${YELLOW_NO_UNDER}${performerMap[performers[0]]}${NC} and ${YELLOW_NO_UNDER}${performerMap[performers[1]]}${NC}:`); | ||
console.log(`Better Performer: ${YELLOW_NO_UNDER}${performerMap[avg.winner]}${NC} by ${YELLOW_UNDER}${percentage.avg}${NC}%`); | ||
} | ||
} | ||
br(2); | ||
} | ||
} | ||
else console.log('Nothing to Compare With \n') | ||
} | ||
|
||
const logBuildTimeStats = ({build_time}) => { | ||
for (const bench in build_time) { | ||
const performers = ['gpu', 'pipe']; | ||
performers.splice(performers.indexOf(build_time[bench].diff.winner)); | ||
console.log(`Benchmark: ${GREEN_UNDER}${benchMap[bench]}${NC}`); | ||
console.log(`${YELLOW_NO_UNDER}${performerMap[build_time[bench].diff.gpu_pipe.winner]}${NC} compiled ${YELLOW_UNDER}${build_time[bench].diff.gpu_pipe.percentage}${NC}% faster than ${YELLOW_NO_UNDER}${performerMap[performers[0]]}${NC}`); | ||
br(2); | ||
} | ||
} | ||
|
||
const logOverallStats = ({overall}, cpuBenched) => { | ||
if (cpuBenched) { | ||
for (const bench in overall) { | ||
console.log(`Benchmark: ${GREEN_UNDER}${benchMap[bench]}${NC}`); | ||
br(); | ||
if (overall[bench].diff.percentage != -1) console.log(`${YELLOW_NO_UNDER}${performerMap[overall[bench].best_performer]}${NC} was ${YELLOW_UNDER}${overall[bench].diff.percentage}${NC}% faster than ${YELLOW_NO_UNDER}${performerMap[overall[bench].worst_performer]}${NC}`); | ||
br(2); | ||
} | ||
} | ||
else console.log('Nothing to Compare With') | ||
} | ||
|
||
module.exports = { | ||
logRunTimeStats, | ||
logBuildTimeStats, | ||
logOverallStats, | ||
performerMap, | ||
benchMap | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"common_options": { | ||
"cpu_benchmark": false, | ||
"logs": true | ||
}, | ||
"range": { | ||
"option_name": "matrix_size", | ||
"interval": [64, 512], | ||
"common_ratio": 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @description Parses all the CLI arguments | ||
* @param {Float32Array} args The user CLI arguments (Usually process.argv) | ||
*/ | ||
function parseArgs(args) { | ||
if (args[2] !== undefined) { | ||
const multiple = args.includes('--multiple'); | ||
const options = args.find(opt => /^{.*}$/.test(opt)) || false; | ||
|
||
const returnPlotlyJSON = args.includes('--returnPlotlyJSON'); | ||
const returnChartistJSON = args.includes('--returnChartistJSON'); | ||
|
||
const plotlySavePath = args.find(opt => /^--savePlotlyJSONToFile=/.test(opt)) || false; | ||
const chartistSavePath = args.find(opt => /^--saveChartistJSONToFile=/.test(opt)) || false; | ||
|
||
return { | ||
multiple, | ||
options, | ||
returnPlotlyJSON, | ||
returnChartistJSON, | ||
plotlySavePath, | ||
chartistSavePath | ||
} | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
|
||
module.exports = parseArgs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const fs = require('fs'), | ||
path = require('path'); | ||
|
||
/** | ||
* @description Saves a file to a given path recursively, ie also creates the required directories. | ||
* @param {String} path Path to the file including the name of the file with the extension | ||
* @param {String} content Contents of the file | ||
*/ | ||
function writeFileSyncRecursive(path, content) { | ||
const folders = path.split(path.sep).slice(0, -1); | ||
if (folders.length > 0) { | ||
|
||
// create folder path if it doesn't exist | ||
folders.reduce((last, folder) => { | ||
if (!fs.existsSync(last)) { | ||
fs.mkdirSync(last); | ||
} | ||
const folderPath = last + path.sep + folder; | ||
|
||
if (!fs.existsSync(folderPath)) { | ||
fs.mkdirSync(folderPath); | ||
} | ||
|
||
return folderPath; | ||
}) | ||
} | ||
fs.writeFileSync(path, content); | ||
} | ||
|
||
module.exports = writeFileSyncRecursive; |
Oops, something went wrong.