-
Notifications
You must be signed in to change notification settings - Fork 5
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
WIP: PMU data collection #4
Open
haojiang66
wants to merge
9
commits into
dev
Choose a base branch
from
jyh5
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ab9df0e
add collector
haojiang66 6042ca2
L1_DCM
haojiang66 c0db651
7_31
haojiang66 b7e5b5e
7_31_2
haojiang66 360233c
using vector and changed forms
haojiang66 f76f828
Add: dataq store
zhengly123 46d83cd
Add: new test case sketch
zhengly123 e9c42d3
do some storing and std
haojiang66 a0d2a36
add io and pictures
haojiang66 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ class Controller { | |
public: | ||
Controller(); | ||
|
||
void readData(); | ||
DataVec readData(); | ||
}; | ||
|
||
} // namespace vapro |
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 |
---|---|---|
@@ -1,16 +1,43 @@ | ||
#include "collector_papi.h" | ||
#include <papi.h> | ||
|
||
namespace vapro { | ||
#define checkPapi(call,stdpapi) \ | ||
{ \ | ||
auto err = call; \ | ||
if (stdpapi != err) { \ | ||
fprintf(stderr, "PAPI error in %s:%i : %s.\n", __FILE__, __LINE__, \ | ||
PAPI_strerror(retval)); \ | ||
exit(EXIT_FAILURE); \ | ||
} \ | ||
} | ||
|
||
namespace vapro { | ||
CollectorPapi::CollectorPapi() { | ||
// TODO: init the PAPI library. Refer to PAPI-reated functions in papi_init() | ||
// and papi_start_counters() in deprecated/pmc.cpp. | ||
int retval = 0; | ||
EventSet = PAPI_NULL; | ||
checkPapi(PAPI_library_init(PAPI_VER_CURRENT),PAPI_VER_CURRENT); | ||
checkPapi(PAPI_create_eventset(&EventSet),PAPI_OK); | ||
checkPapi(PAPI_add_event(EventSet, PAPI_TOT_INS),PAPI_OK); | ||
checkPapi(PAPI_add_event(EventSet, PAPI_L1_DCM),PAPI_OK); | ||
checkPapi(PAPI_start(EventSet),PAPI_OK); | ||
} | ||
|
||
DataVec CollectorPapi::readData() { | ||
dbg("Invoked"); | ||
// TODO: read data by the PAPI library. Refer to papi_get_data() in | ||
// deprecated/pmc.cpp. | ||
DataVec dtvc; | ||
long long int values[2]; | ||
int retval = 0; | ||
if (retval = PAPI_read(EventSet, values) != PAPI_OK) { | ||
fprintf(stderr, "4,PAPI error %d: %s\n", retval, PAPI_strerror(retval)); | ||
exit(-1); | ||
} | ||
|
||
dtvc.emplace_back(values[0]); | ||
dtvc.emplace_back(values[1]); | ||
dtvc.emplace_back(rdtsc()); | ||
return dtvc; | ||
} | ||
|
||
} // namespace vapro |
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 |
---|---|---|
@@ -1,13 +1,81 @@ | ||
#include "controller.h" | ||
#include "papi.h" | ||
#include "stdio.h" | ||
zhengly123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using namespace vapro; | ||
|
||
void workload() { | ||
int load = 0; | ||
for (int i = 0; i < 10000; i++) | ||
for (int j = 0; j < i; j++) | ||
load += (i + j); | ||
} | ||
void workload_1() { | ||
int N = 1000; | ||
int x[N]; | ||
for (int j = 0; j < N; j++) { | ||
x[j] = j; | ||
} | ||
for (int loop = 0; loop < 10; loop++) { | ||
for (int i = 0; i < N; i++) { | ||
x[i] = x[i] * x[i]; | ||
} | ||
} | ||
} | ||
void workload_2() { | ||
int N = 1000; | ||
int x[N]; | ||
for (int j = 0; j < N; j++) { | ||
x[j] = j; | ||
} | ||
for (int i = 0; i < N; i++) { | ||
for (int loop = 0; loop < 10; loop++) { | ||
x[i] = x[i] * x[i]; | ||
} | ||
} | ||
} | ||
|
||
void result(DataVec d1,DataVec d2) | ||
{ | ||
printf("TOT_INS:%ld\n",d2[0]-d1[0]); | ||
printf("TOT_CM:%ld\n",d2[1]-d1[1]); | ||
printf("TOT_TIME:%ld\n",d2[2]-d1[2]); | ||
} | ||
|
||
int main() { | ||
|
||
printf("begin test\n"); | ||
// test0(); | ||
Controller controller; | ||
|
||
DataVec d1,d2,d3; | ||
// 完成CollectorPapi.cc中的TODO。利用PAPI采集PAPI_TOT_INS,即程序片段的总指令数。如果遇到采集出来为0,或者出错,可能和系统的权限相关,可以来问下我。 | ||
|
||
// This readData function will print the performance data | ||
controller.readData(); | ||
d1=controller.readData(); | ||
// TODO: add some workload here for profiling | ||
controller.readData(); | ||
|
||
workload_1(); | ||
|
||
d2=controller.readData(); | ||
|
||
result(d1,d2); | ||
// TOOD: compare the whether the printed data matches your expectation | ||
|
||
workload_2(); | ||
|
||
d3=controller.readData(); | ||
|
||
result(d2,d3); | ||
|
||
printf("end test\n"); | ||
return 0; | ||
} | ||
// 在test终端打开 | ||
// source /opt/spack/share/spack/setup-env.sh | ||
// spack load openmpi@4.1.5 | ||
// spack load papi | ||
// cmake .. | ||
// make | ||
//./test_vapro | ||
|
||
// source /opt/spack/share/spack/setup-env.sh;spack load openmpi@4.1.5;spack load papi;cmake ..;make;./test_vapro |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro is already defined in
include/collector_papi.h
. This overload with two paramters seems to be seldom used as most of the return values arePAPI_OK
. I suggest using the originalpapiCheck
without a custom return value.