Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
Removal of unused methods and properties, and a doc cleanup.
Version bump
  • Loading branch information
robertleeplummerjr committed Jul 11, 2018
1 parent 31fc680 commit 01a18ac
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 169 deletions.
4 changes: 2 additions & 2 deletions bin/gpu-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*
* GPU Accelerated JavaScript
*
* @version 1.4.11
* @date Wed Jul 04 2018 15:50:38 GMT-0400 (EDT)
* @version 1.4.12
* @date Wed Jul 11 2018 15:20:52 GMT-0400 (EDT)
*
* @license MIT
* The MIT License
Expand Down
4 changes: 2 additions & 2 deletions bin/gpu-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 3 additions & 27 deletions bin/gpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*
* GPU Accelerated JavaScript
*
* @version 1.4.11
* @date Wed Jul 04 2018 15:50:38 GMT-0400 (EDT)
* @version 1.4.12
* @date Wed Jul 11 2018 15:20:52 GMT-0400 (EDT)
*
* @license MIT
* The MIT License
Expand Down Expand Up @@ -840,7 +840,6 @@ module.exports = function (_KernelBase) {

var _this = _possibleConstructorReturn(this, (CPUKernel.__proto__ || Object.getPrototypeOf(CPUKernel)).call(this, fnString, settings));

_this._fnBody = utils.getFunctionBodyFromString(fnString);
_this._fn = null;
_this.run = null;
_this._canvasCtx = null;
Expand Down Expand Up @@ -1045,22 +1044,8 @@ module.exports = function (_KernelBase) {
}


}, {
key: 'precompileKernelObj',
value: function precompileKernelObj(argTypes) {

var threadDim = this.threadDim || (this.threadDim = utils.clone(this.output));

return {
threadDim: threadDim
};
}


}, {
key: '_getLoopMaxString',


value: function _getLoopMaxString() {
return this.loopMaxIterations ? ' ' + parseInt(this.loopMaxIterations) + ';\n' : ' 1000;\n';
}
Expand Down Expand Up @@ -1107,16 +1092,6 @@ module.exports = function (_KernelBase) {
}
return imagesArray;
}
}], [{
key: 'compileKernel',
value: function compileKernel(precompileObj) {

var threadDim = precompileObj.threadDim;

while (threadDim.length < 3) {
threadDim.push(1);
}
}
}]);

return CPUKernel;
Expand Down Expand Up @@ -5644,6 +5619,7 @@ var _isMixedIdentifiersSupported = function () {
}
}();


var Utils = function (_UtilsCore) {
_inherits(Utils, _UtilsCore);

Expand Down
18 changes: 9 additions & 9 deletions bin/gpu.min.js

Large diffs are not rendered by default.

59 changes: 3 additions & 56 deletions dist/backend/cpu/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module.exports = function (_KernelBase) {

var _this = _possibleConstructorReturn(this, (CPUKernel.__proto__ || Object.getPrototypeOf(CPUKernel)).call(this, fnString, settings));

_this._fnBody = utils.getFunctionBodyFromString(fnString);
_this._fn = null;
_this.run = null;
_this._canvasCtx = null;
Expand Down Expand Up @@ -283,49 +282,6 @@ module.exports = function (_KernelBase) {
return kernelString(this);
}

/**
* @memberOf CPUKernel#
* @function
* @name precompileKernelObj
*
* @desc Precompile the kernel into a single object,
* that can be used for building the execution kernel subsequently.
*
* @param {Array} argTypes - Array of argument types
*
* Return:
* Compiled kernel {Object}
*
*/

}, {
key: 'precompileKernelObj',
value: function precompileKernelObj(argTypes) {

var threadDim = this.threadDim || (this.threadDim = utils.clone(this.output));

return {
threadDim: threadDim
};
}

/**
* @memberOf CPUKernel
* @function
* @name compileKernel
* @static
*
* @desc Takes a previously precompiled kernel object,
* and complete compilation into a full kernel
*
* @returns {Function} Compiled kernel
*
*/

}, {
key: '_getLoopMaxString',


/**
* @memberOf WebGLKernel#
* @function
Expand All @@ -336,6 +292,9 @@ module.exports = function (_KernelBase) {
* @returns {String} result
*
*/

}, {
key: '_getLoopMaxString',
value: function _getLoopMaxString() {
return this.loopMaxIterations ? ' ' + parseInt(this.loopMaxIterations) + ';\n' : ' 1000;\n';
}
Expand Down Expand Up @@ -382,18 +341,6 @@ module.exports = function (_KernelBase) {
}
return imagesArray;
}
}], [{
key: 'compileKernel',
value: function compileKernel(precompileObj) {

// Extract values from precompiled obj
var threadDim = precompileObj.threadDim;

// Normalize certain values : For actual build
while (threadDim.length < 3) {
threadDim.push(1);
}
}
}]);

return CPUKernel;
Expand Down
2 changes: 1 addition & 1 deletion dist/backend/kernel-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module.exports = function () {
* @desc Setup the parameter types for the parameters
* supplied to the Kernel function
*
* @param {Array} args - The actual parameters sent to the Kernel
* @param {IArguments} args - The actual parameters sent to the Kernel
*
*/

Expand Down
5 changes: 5 additions & 0 deletions dist/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ var _isMixedIdentifiersSupported = function () {
}
}();

/**
* @class
* @extends UtilsCore
*/

var Utils = function (_UtilsCore) {
_inherits(Utils, _UtilsCore);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gpu.js",
"version": "1.4.11",
"version": "1.4.12",
"description": "GPU Accelerated JavaScript",
"main": "./dist/index.js",
"directories": {
Expand Down
48 changes: 0 additions & 48 deletions src/backend/cpu/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module.exports = class CPUKernel extends KernelBase {
*/
constructor(fnString, settings) {
super(fnString, settings);
this._fnBody = utils.getFunctionBodyFromString(fnString);
this._fn = null;
this.run = null;
this._canvasCtx = null;
Expand Down Expand Up @@ -307,53 +306,6 @@ ${ this.subKernelOutputVariableNames === null
return kernelString(this);
}

/**
* @memberOf CPUKernel#
* @function
* @name precompileKernelObj
*
* @desc Precompile the kernel into a single object,
* that can be used for building the execution kernel subsequently.
*
* @param {Array} argTypes - Array of argument types
*
* Return:
* Compiled kernel {Object}
*
*/
precompileKernelObj(argTypes) {

const threadDim = this.threadDim || (this.threadDim = utils.clone(this.output));


return {
threadDim: threadDim
};
}

/**
* @memberOf CPUKernel
* @function
* @name compileKernel
* @static
*
* @desc Takes a previously precompiled kernel object,
* and complete compilation into a full kernel
*
* @returns {Function} Compiled kernel
*
*/
static compileKernel(precompileObj) {

// Extract values from precompiled obj
const threadDim = precompileObj.threadDim;

// Normalize certain values : For actual build
while (threadDim.length < 3) {
threadDim.push(1);
}
}

/**
* @memberOf WebGLKernel#
* @function
Expand Down
2 changes: 1 addition & 1 deletion src/backend/kernel-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = class KernelBase {
* @desc Setup the parameter types for the parameters
* supplied to the Kernel function
*
* @param {Array} args - The actual parameters sent to the Kernel
* @param {IArguments} args - The actual parameters sent to the Kernel
*
*/
setupParams(args) {
Expand Down
46 changes: 24 additions & 22 deletions test/issues/91-create-kernel-map-array.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(function () {
function getResult(mode) {
var A = [
[1, 1],
[1, 1],
[1, 1]
[1, 2],
[3, 4],
[5, 6]
];

var B = [
[1, 1, 1],
[1, 1, 1]
[6, 5, 4],
[3, 2, 1]
];

var gpu = new GPU({ mode: mode });
Expand All @@ -26,32 +26,34 @@
}, function (a, b) {
return multiply(b, a, this.thread.y, this.thread.x);
})
.setOutput([B.length, A.length]);
.setOutput([2, 2]);

return kernels(A, B).result;
}
QUnit.test( "Issue #91 - type detection (GPU only) (auto)", function() {
QUnit.test( "Issue #91 - type detection (auto)", function() {
var result = getResult();
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [2,2]);
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [2,2]);
QUnit.assert.deepEqual(QUnit.extend([], result[2]), [0,0]);
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [21,32]);
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [9,14]);
});
QUnit.test( "Issue #91 - type detection (GPU only) (gpu)", function() {
QUnit.test( "Issue #91 - type detection (gpu)", function() {
var result = getResult('gpu');
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [2,2]);
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [2,2]);
QUnit.assert.deepEqual(QUnit.extend([], result[2]), [0,0]);
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [21,32]);
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [9,14]);
});
QUnit.test( "Issue #91 - type detection (GPU only) (webgl)", function() {
QUnit.test( "Issue #91 - type detection (webgl)", function() {
var result = getResult('webgl');
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [2,2]);
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [2,2]);
QUnit.assert.deepEqual(QUnit.extend([], result[2]), [0,0]);
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [21,32]);
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [9,14]);
});
QUnit.test( "Issue #91 - type detection (GPU only) (webgl2)", function() {
QUnit.test( "Issue #91 - type detection (webgl2)", function() {
var result = getResult('webgl2');
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [2,2]);
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [2,2]);
QUnit.assert.deepEqual(QUnit.extend([], result[2]), [0,0]);
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [21,32]);
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [9,14]);
});
QUnit.test( "Issue #91 - type detection (cpu)", function() {
var result = getResult('cpu');
console.log(result);
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [21,32]);
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [9,14]);
});
})();

0 comments on commit 01a18ac

Please sign in to comment.