-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expands support for variorum_print_energy other than AMD and adds two new APIs -- variorum_print_verbose_energy, variorum_get_energy_json on Intel and IBM platforms. --------- Co-authored-by: Tapasya Patki <[email protected]> Co-authored-by: Aniruddha Marathe <[email protected]> Co-authored-by: Stephanie Brink <[email protected]>
- Loading branch information
1 parent
c47e6af
commit 790446f
Showing
36 changed files
with
1,244 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.