Skip to content

Commit

Permalink
Expose CPU accuracy as a parameter in stellerator embedded.
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtyHairy committed Jan 2, 2019
1 parent d2b1f00 commit fa9184c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/web/embedded/stellerator/Stellerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ import { decode as decodeBase64 } from '../../../tools/base64';
import ControlPanel from './ControlPanel';
import ControlPanelProxy from './ControlPanelProxy';
import { Target } from '../../driver/gamepad/Mapping';
import CpuFactory from '../../../machine/cpu/Factory';

function cpuType(config = Stellerator.CpuAccuracy.cycle): CpuFactory.Type {
switch (config) {
case Stellerator.CpuAccuracy.cycle:
return CpuFactory.Type.stateMachine;

case Stellerator.CpuAccuracy.instruction:
return CpuFactory.Type.batchedAccess;

default:
throw new Error(`invalid CPU Accuracy: ${config}`);
}
}

/**
* The stellerator class and namespace. In a typical application, a single instance is
Expand Down Expand Up @@ -327,6 +341,8 @@ class Stellerator {
stellaConfig.frameStart = config.frameStart;
}

stellaConfig.cpuType = cpuType(config.cpuAccuracy);

await this._serviceInitialized;

return (this._state = this._mapState(
Expand Down Expand Up @@ -808,6 +824,13 @@ namespace Stellerator {
* Default: undefined [autodetect]
*/
frameStart: number;

/**
* The accuracy of the CPU core (see below).
*
* Default: cycle (high precision)
*/
cpuAccuracy: CpuAccuracy;
}

/**
Expand Down Expand Up @@ -862,6 +885,20 @@ namespace Stellerator {
*/
error = 'error'
}

/**
* The different possible CPU emulation modes.
*/
export enum CpuAccuracy {
/**
* True cycle-exact CPU emulation. High accuracy.
*/
cycle = 'cycle',
/**
* Less accurate memory access patters. Slightly less accurate, but faster
*/
instruction = 'instruction'
}
}

export { Stellerator as default };

0 comments on commit fa9184c

Please sign in to comment.