MCPcopy Index your code
hub / github.com/gpujs/gpu.js / setupArguments

Method setupArguments

src/backend/kernel.js:360–395  ·  view source on GitHub ↗

* @desc Setup the parameter types for the parameters * supplied to the Kernel function * * @param {IArguments} args - The actual parameters sent to the Kernel

(args)

Source from the content-addressed store, hash-verified

358 * @param {IArguments} args - The actual parameters sent to the Kernel
359 */
360 setupArguments(args) {
361 this.kernelArguments = [];
362 if (!this.argumentTypes) {
363 if (!this.argumentTypes) {
364 this.argumentTypes = [];
365 for (let i = 0; i < args.length; i++) {
366 const argType = utils.getVariableType(args[i], this.strictIntegers);
367 const type = argType === 'Integer' ? 'Number' : argType;
368 this.argumentTypes.push(type);
369 this.kernelArguments.push({
370 type
371 });
372 }
373 }
374 } else {
375 for (let i = 0; i < this.argumentTypes.length; i++) {
376 this.kernelArguments.push({
377 type: this.argumentTypes[i]
378 });
379 }
380 }
381
382 // setup sizes
383 this.argumentSizes = new Array(args.length);
384 this.argumentBitRatios = new Int32Array(args.length);
385
386 for (let i = 0; i < args.length; i++) {
387 const arg = args[i];
388 this.argumentSizes[i] = arg.constructor === Input ? arg.size : null;
389 this.argumentBitRatios[i] = this.getBitRatio(arg);
390 }
391
392 if (this.argumentNames.length !== args.length) {
393 throw new Error(`arguments are miss-aligned`);
394 }
395 }
396
397 /**
398 * Setup constants

Callers 1

setupArgumentsTestSuiteFunction · 0.45

Calls 2

getBitRatioMethod · 0.95
getVariableTypeMethod · 0.80

Tested by

no test coverage detected