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

Energy APIs: Print and JSON (PR from fork/304) #530

Merged
merged 55 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
cf3f474
Initial setup to add variorum_print_energy (archs other than AMD) and…
tpatki Jul 26, 2022
905a5f9
Merge branch 'dev' into add_print_energy_impl
tpatki Apr 25, 2023
40b6e1d
Merge branch 'dev' into add_print_energy_impl
tpatki Nov 10, 2023
acfe66c
Stub now builds on Lassen (CPU-only)
tpatki Nov 10, 2023
b5c0815
Work in progress for sampling thread
tpatki Nov 10, 2023
d3928d5
Fix some, but not all, build errors
tpatki Nov 10, 2023
abc85e4
Formatted files.
tpatki Nov 10, 2023
d3d867f
Build but has pthread/mutex issues and doesn't work correctly. Saving…
tpatki Nov 11, 2023
1070d69
Format and save current state. Example builds but doesn't call the ta…
tpatki Nov 11, 2023
ee59784
put return inside if check
slabasan Nov 13, 2023
adbcaf7
fix sampling code, add 2s sleep to print energy example
slabasan Nov 13, 2023
809e107
Fixed pthread_attr_destroy issue, changed scope of variables used by …
amarathe84 Nov 13, 2023
11aebd8
Added energy measurement in IBM P9
amarathe84 Jan 5, 2024
2ea2c63
Merge branch 'dev' into add_print_energy_impl
tpatki Jan 30, 2024
968ea9e
Merged changes from tpatki/dev with the recent commit
amarathe84 Jan 30, 2024
13eb162
Print energy support for Intel Broadwell and Haswell
amarathe84 Feb 2, 2024
4208fb9
Formatting pass.
tpatki Jan 30, 2024
a85a615
Add variorum_get_energy_json API for IBM
tpatki Feb 7, 2024
d7e370a
Add missing example file
tpatki Feb 7, 2024
dd0b4fd
To resolve conflicts, first restore to dev
tpatki Mar 1, 2024
b8471ba
Next, add the print energy support functions
tpatki Mar 1, 2024
7f3dda5
Resolve conflicts, attempt 2. Had to pull from upstream, not origin
tpatki Mar 1, 2024
1017e56
Next, add the print energy fns. Shouldn't have conflicts or incorrect…
tpatki Mar 1, 2024
67afcc2
Ugh. Let's try that again. Rebase origin's dev, and checkout the dev'…
tpatki Mar 1, 2024
8a8cdd2
Trying again.
tpatki Mar 1, 2024
7f8ebfd
Merge branch 'LLNL:dev' into add_print_energy_impl
tpatki Mar 1, 2024
4329b7d
Fix uninitialized variable warnings in print_energy functions
tpatki Mar 1, 2024
ba7be33
Fixed minor copy paste error
tpatki Mar 1, 2024
2a4d8b8
Merge branch 'dev' into add_print_energy_impl
tpatki Mar 12, 2024
2ec71ee
reorder examples alphabetically
slabasan Mar 12, 2024
23084aa
fix unused variables error
slabasan Mar 15, 2024
9ab81c4
print-energy works on multi-arch, need to exclude adding this example…
tpatki Mar 17, 2024
fe0fed1
Fix multi-platform build on all three APIs, works correctly on lassen
tpatki Mar 18, 2024
8485b65
Fix warnings
tpatki Mar 18, 2024
0521ada
Merge remote-tracking branch 'origin/dev' into pr-from-fork/304
slabasan Mar 19, 2024
efd88de
first pass
slabasan Mar 19, 2024
730f63f
Merge remote-tracking branch 'origin/dev' into pr-from-fork/304
slabasan Mar 19, 2024
2a7f1e8
add functions to header
slabasan Mar 19, 2024
b75be03
fix input parameters
slabasan Mar 19, 2024
4888b89
fixes
slabasan Mar 20, 2024
6fec55f
update print/print-verbose energy example outputs to match others
slabasan Mar 20, 2024
6031377
start get energy json on intel
Mar 21, 2024
0d6f603
formatting
slabasan Mar 21, 2024
b391db7
implement intel json
slabasan Mar 22, 2024
d82a6b1
fix warnings
slabasan Mar 22, 2024
62ec7ac
formatting fixes
slabasan Mar 22, 2024
a10af2f
correct watts to energy
Mar 22, 2024
33bd625
add DRAM energy, fix output formatting
Mar 22, 2024
dd167b2
support energy on all intel architectures
slabasan Mar 22, 2024
bda6b67
update docs
slabasan Mar 22, 2024
f144ecc
fix header definitions
slabasan Mar 22, 2024
73c4a74
fix build
slabasan Mar 22, 2024
3a3ef0e
fixes
slabasan Mar 22, 2024
5f13341
cleanup, remove debug statements
slabasan Mar 25, 2024
df5790a
cleanup
slabasan Mar 25, 2024
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
2 changes: 2 additions & 0 deletions host-configs/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ set(VARIORUM_WITH_NVIDIA_GPU OFF CACHE BOOL "")
set(VARIORUM_DEBUG OFF CACHE BOOL "")

set(BUILD_TESTS ON CACHE BOOL "")

set(CMAKE_SHARED_LINKER_FLAGS "-lpthread" CACHE PATH "")
2 changes: 2 additions & 0 deletions src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(BASIC_EXAMPLES
variorum-cap-socket-power-limit-example
variorum-disable-turbo-example
variorum-enable-turbo-example
variorum-get-energy-json-example
variorum-get-frequency-json-example
variorum-get-node-power-domain-info-json-example
variorum-get-power-json-example
Expand All @@ -39,6 +40,7 @@ set(BASIC_EXAMPLES
variorum-print-topology-example
variorum-print-turbo-example
variorum-print-verbose-counters-example
variorum-print-verbose-energy-example
variorum-print-verbose-frequency-example
variorum-print-verbose-gpu-utilization-example
variorum-print-verbose-power-example
Expand Down
89 changes: 89 additions & 0 deletions src/examples/variorum-get-energy-json-example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright 2019-2023 Lawrence Livermore National Security, LLC and other
// Variorum Project Developers. See the top-level LICENSE file for details.
//
// SPDX-License-Identifier: MIT

#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>

#include <variorum.h>
#include <variorum_topology.h>

#ifdef SECOND_RUN
static inline double do_work(int input)
{
int i;
double result = (double)input;

for (i = 0; i < 100000; i++)
{
result += i * result;
}

return result;
}
#endif

int main(int argc, char **argv)
{
int ret;
char *s = NULL;
#ifdef SECOND_RUN
int i;
int size = 1E4;
volatile double x = 0.0;
#endif

const char *usage = "Usage: %s [-h] [-v]\n";
int opt;
while ((opt = getopt(argc, argv, "hv")) != -1)
{
switch (opt)
{
case 'h':
printf(usage, argv[0]);
return 0;
case 'v':
printf("%s\n", variorum_get_current_version());
return 0;
default:
fprintf(stderr, usage, argv[0]);
return -1;
}
}

ret = variorum_get_energy_json(&s);
if (ret != 0)
{
printf("First run: JSON get energy failed!\n");
free(s);
exit(-1);
}

/* Print the entire JSON object */
puts(s);

#ifdef SECOND_RUN
for (i = 0; i < size; i++)
{
x += do_work(i);
}
printf("Final result: %f\n", x);
ret = variorum_get_energy_json(&s);
if (ret != 0)
{
printf("Second run: JSON get energy failed!\n");
free(s);
exit(-1);
}

/* Print the entire JSON object */
puts(s);
#endif

/* Deallocate the string */
free(s);

return ret;
}
16 changes: 14 additions & 2 deletions src/examples/variorum-print-energy-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <getopt.h>
#include <stdio.h>
#include <unistd.h>

#include <variorum.h>

Expand All @@ -30,10 +31,21 @@ int main(int argc, char **argv)
}
}

// First call to variorum_print_energy should print zero.
ret = variorum_print_energy();
if (ret != 0)
{
printf("Print core and Socket energy failed!\n");
printf("Print core and socket energy failed!\n");
return ret;
}

sleep(2);

// Second call to variorum_print_energy should print a valid value.
ret = variorum_print_energy();
if (ret != 0)
{
printf("Print core and socket energy failed!\n");
return ret;
}
return ret;
}
49 changes: 49 additions & 0 deletions src/examples/variorum-print-verbose-energy-example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2019-2023 Lawrence Livermore National Security, LLC and other
// Variorum Project Developers. See the top-level LICENSE file for details.
//
// SPDX-License-Identifier: MIT

#include <getopt.h>
#include <stdio.h>
#include <unistd.h>

#include <variorum.h>

int main(int argc, char **argv)
{
int ret;

const char *usage = "Usage: %s [-h] [-v]\n";
int opt;
while ((opt = getopt(argc, argv, "hv")) != -1)
{
switch (opt)
{
case 'h':
printf(usage, argv[0]);
return 0;
case 'v':
printf("%s\n", variorum_get_current_version());
return 0;
default:
fprintf(stderr, usage, argv[0]);
return -1;
}
}

ret = variorum_print_verbose_energy();
if (ret != 0)
{
printf("Print core and socket energy failed!\n");
return ret;
}

sleep(2);

ret = variorum_print_verbose_energy();
if (ret != 0)
{
printf("Print core and socket energy failed!\n");
return ret;
}
}
5 changes: 3 additions & 2 deletions src/variorum/AMD/epyc.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ static struct EPYC_19h_offsets msrs =
.msr_pkg_energy_stat = 0xC001029B
};

int amd_cpu_epyc_print_energy()

int amd_cpu_epyc_print_energy(int long_ver)
{
char *val = getenv("VARIORUM_LOG");
if (val != NULL && atoi(val) == 1)
Expand All @@ -376,7 +377,7 @@ int amd_cpu_epyc_print_energy()
}

int ret;
if (!esmi_init())
if (!esmi_init() && long_ver == 0)
{
int i;
uint64_t energy;
Expand Down
Loading
Loading