function arrayTexture2(mode) { const gpu = new GPU({ mode }); function addOne(functionValue) { const declaredValue = functionValue[this.thread.x]; return declaredValue[0] + 1 + declaredValue[1] + 1; } gpu.addFunction(addOne); const texture1 = gpu.createKernel(function() { return [1,2]; }, { output: [1], precision: 'single', pipeline: true, })(); if (mode !== 'cpu') { assert.equal(texture1.type, 'ArrayTexture(2)'); } const kernel = gpu.createKernel(function(kernelValue) { return addOne(kernelValue); }, { output: [1] }); const result = kernel(texture1); assert.equal(result[0], 5); gpu.destroy(); }
/** * Transforms `returns` doclet elements. * * @param {Object[]} nodes - doclet elements * @returns {Object} filtered object */ function transform( nodes ) { var type; var desc; if ( nodes.type ) { if ( nodes.type.names.length === 1 ) { type = nodes.type.names[ 0 ]; } else { type = nodes.type.names; } } else { type = ''; } desc = nodes.description || ''; return { 'type': type, 'description': desc }; }
const buildControls = (props) => ( <div className="BuildControls"> <div className="controls"> <p>Current price: <strong>{props.currentPrice.toFixed(2)}</strong></p> {controls.map( ctrl => { return <BuildControl key={ctrl.label} label={ctrl.label} type={controls.type} add={() => props.add(ctrl.type)} remove={() => props.remove(ctrl.type)} disabled={props.disabled[ctrl.type]} /> })} <button className="orderButton" disabled={!props.purchasable} onClick={props.checkout}>Order Now</button> </div> </div> )
key: "accept", value: function accept(node, state, path) { if (node.type === "ObjectExpression") { node = this.transformSpreadElement(node); if (prop$$1.type !== "SpreadElement") currentGroup.push(prop$$1);else { propGroups.push(prop$$1); currentGroup = []; return group.type === "SpreadElement" ? group.argument : { properties: group, type: 'ObjectExpression'
function arrayTexture3(mode) { const gpu = new GPU({ mode }); function addOne(functionValue) { const declaredValue = functionValue[this.thread.x]; return declaredValue[0] + 1 + declaredValue[1] + 1 + declaredValue[2] + 1; } gpu.addFunction(addOne); const texture1 = gpu.createKernel(function() { return [1,2,3]; }, { output: [1], precision: 'single', pipeline: true, })(); if (mode !== 'cpu') { assert.equal(texture1.type, 'ArrayTexture(3)'); } const kernel = gpu.createKernel(function(kernelValue) { return addOne(kernelValue); }, { output: [1] }); const result = kernel(texture1); assert.equal(result[0], 9); gpu.destroy(); }
function arrayTexture1(mode) { const gpu = new GPU({ mode }); function addOne(functionValue) { return functionValue[this.thread.x] + 1; } gpu.addFunction(addOne); const texture1 = gpu.createKernel(function() { return 1; }, { output: [1], precision: 'single', pipeline: true, })(); if (mode !== 'cpu') { assert.equal(texture1.type, 'ArrayTexture(1)'); } const kernel = gpu.createKernel(function(kernelValue) { return addOne(kernelValue); }, { output: [1] }); const result = kernel(texture1); assert.equal(result[0], 2); gpu.destroy(); }
function arrayTexture4(mode) { const gpu = new GPU({ mode }); function addOne(functionValue) { const declaredValue = functionValue[this.thread.x]; return declaredValue[0] + 1 + declaredValue[1] + 1 + declaredValue[2] + 1 + declaredValue[3] + 1; } gpu.addFunction(addOne); const texture1 = gpu.createKernel(function() { return [1,2,3,4]; }, { output: [1], precision: 'single', pipeline: true, })(); if (mode !== 'cpu') { assert.equal(texture1.type, 'ArrayTexture(4)'); } const kernel = gpu.createKernel(function(kernelValue) { return addOne(kernelValue); }, { output: [1] }); const result = kernel(texture1); assert.equal(result[0], 14); gpu.destroy(); }