Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit errors in eshoppen #147

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions examples/impls/msft-eshoppen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ graph:
tdp-mem: 12.16
tdp-coeff: 0.12
sci-m:
te: 350 # kgCO2eq
te: 350000 # kgCO2eq
tir: 3600 # == the duration field
el: 126144000 # 4 years in seconds
rr: 1
Expand All @@ -63,8 +63,8 @@ graph:
n-hours: 1
n-chips: 1
sci:
time: hour # signal to convert /s -> /hr
factor: 500 # factor to convert per time to per f.unit ()
time: '' # signal to convert /s -> /hr
factor: 1 # factor to convert per time to per f.unit ()
observations:
- timestamp: 2023-07-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred
duration: 3600 # Secs
Expand All @@ -75,13 +75,14 @@ graph:
- sci-e # sums e components
- sci-m # duration & config -> embodied
- sci-o # energy & grid-carbon-intensity & embodied -> carbon
- sci
config:
sci-m:
te: 1205.52 # kgCO2eq
tir: 3600 # == duration field
el: 126144000 # 4 years in seconds
te: 1205520 # kgCO2eq
tir: 1 # == duration field
el: 35040 # 4 years in seconds
rr: 2 # using cores
tor: 26 # the original report has a typo, says 16 but actually has 26 cores.
tor: 16 # the original report has a typo, says 16 but actually has 26 cores.
sci-o:
grid-ci: 951 # gCO2e/kWh
e-cpu:
Expand All @@ -91,8 +92,8 @@ graph:
n-hours: 1
n-chips: 1
sci:
time: hour # signal to convert /s -> /hr
factor: 500 # factor to convert per time to per f.unit ()
time: '' # signal to convert /s -> /hr
factor: 1 # factor to convert per time to per f.unit ()
observations:
- timestamp: 2023-07-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred
duration: 3600
Expand All @@ -107,22 +108,22 @@ graph:
sci-o:
grid-ci: 1000 # gCO2e/kWh
sci-m:
te: 1433.12 # kgCO2eq
tir: 3600 # == duration field
el: 126144000 # 4 years in seconds
te: 1433120 # kgCO2eq
tir: 1 # == duration field
el: 35040 # 4 years in hours
rr: 2 # using cores
tor: 24 # total cores
tor: 16 # total cores
sci-c:
i: 951
grid-ci: 951
e-cpu:
n-hours: 1
n-chips: 1
processor: Intel® Xeon® Platinum 8160
tdp: 150 # W
tdp-coeff: 0.32
sci:
time: hour # signal to convert /s -> /hr
factor: 500 # factor to convert per time to per f.unit ()
time: '' # signal to convert /s -> /hr
factor: 1 # factor to convert per time to per f.unit ()
observations:
- timestamp: 2023-07-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred
duration: 3600
Expand All @@ -132,23 +133,23 @@ graph:
pipeline:
- eshoppen-net
- sci-e # sums e components
- sci-o
- sci-m
- sci-o
- sci
config:
sci-m:
te: 1433.12 # kgCO2eq
tir: 3600 # == duration field
el: 126144000 # 4 years in seconds
rr: 2 # using cores
tor: 24 # total cores
te: 0 # kgCO2eq
tir: 1 # == duration field
el: 35040 # 4 years in seconds
rr: 1 # using cores
tor: 1 # total cores
e-net:
net-energy: 0.001 #kwh/GB
sci:
time: hour
factor: 500
time: ''
factor: 1
sci-o:
grid-ci: 1000
grid-ci: 951
observations:
- timestamp: 2023-07-06T00:00
duration: 3600
Expand Down
23 changes: 13 additions & 10 deletions src/lib/case-studies/eshoppen-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ export class EshoppenModel implements IImpactModelInterface {
case 'e-cpu': {
// e-cpu = n-hours * n-chips * tdp * tdp-coeff
observation['e-cpu'] =
observation['n-hours'] *
observation['n-chips'] *
observation['tdp'] *
observation['tdp-coeff'];
(observation['n-hours'] *
observation['n-chips'] *
observation['tdp'] *
observation['tdp-coeff']) /
1000;
if (isNaN(observation['e-cpu'])) {
throw new Error('e-cpu not computable');
}
Expand All @@ -34,10 +35,11 @@ export class EshoppenModel implements IImpactModelInterface {
case 'e-mem': {
// e-mem-tdp = n-hours * n-chip * tdp-mem * tdp-coeff
observation['e-mem'] =
observation['n-hours'] *
observation['n-chips'] *
observation['tdp-mem'] *
observation['tdp-coeff'];
(observation['n-hours'] *
observation['n-chips'] *
observation['tdp-mem'] *
observation['tdp-coeff']) /
1000;
if (isNaN(observation['e-mem'])) {
throw new Error('e-mem not computable');
}
Expand All @@ -46,8 +48,9 @@ export class EshoppenModel implements IImpactModelInterface {
case 'e-net': {
// e-net = data-in + data-out * net-energy
observation['e-net'] =
(observation['data-in'] + observation['data-out']) *
observation['net-energy'];
((observation['data-in'] + observation['data-out']) *
observation['net-energy']) /
1000;
if (isNaN(observation['e-net'])) {
throw new Error('e-net not computable');
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/case-studies/eshoppen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('eshoppen:configure test', () => {
])
).resolves.toStrictEqual([
{
'e-cpu': 122.4,
'e-cpu': 0.12240000000000001,
'n-hours': 1,
'n-chips': 1,
tdp: 120,
Expand Down
9 changes: 6 additions & 3 deletions src/lib/sci-m/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ export class SciMModel implements IImpactModelInterface {
) {
observation['te'] = observation['te'] ?? observation['total-embodied'];
observation['tir'] = observation['tir'] ?? observation['time-reserved'];
observation['el'] = observation['el'] ?? observation['expected-lifespan'];
observation['rr'] = observation['rr'] ?? observation['resources-reserved'];
observation['tor'] = observation['tor'] ?? observation['total-resources'];
observation['el'] =
observation['el'] ?? observation['expected-lifespan'];
observation['rr'] =
observation['rr'] ?? observation['resources-reserved'];
observation['tor'] =
observation['tor'] ?? observation['total-resources'];
if (typeof observation['te'] === 'string') {
te = parseFloat(observation[observation['te']]);
} else if (typeof observation['te'] === 'number') {
Expand Down