I was experiencing an issue with running Papi in TVM. Whenever I tried to initialize it, I got the error:
File "/home/perry/phd/tvm-power-profile/tvm/src/runtime/contrib/papi/papi.cc", line 131
TVMError: Check failed: PAPI_library_init(((((7)<<24) | ((0)<<16) | ((0)<<8) | (0)) & 0xffff0000)) == ((((7)<<24) | ((0)<<16) | ((0)<<8) | (0)) & 0xffff0000) (-1 vs. 117440512) : Error while initializing PAPI
However, I have v6.0 of PAPI installed.
I verified this by compiling and running this C++ program:
// Import and initalize the PAPI library
// g++ -std=c++11 -o papi_test papi_test.cpp -lpapi
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <papi.h>
#include <string>
#include <vector>
using namespace std;
#define NUM_EVENTS 2
#define NUM_RUNS 10
int main(int argc, char *argv[]) {
// Initialize the PAPI library
int retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT) {
cout << "PAPI library init error!" << endl;
exit(1);
}
cout << PAPI_VER_CURRENT << endl;
}
This confirmed that I was running v6.0, since I printed 100663296
rather than 117440512
. I tried clearing my build directory of TVM and compiling again from scratch. The cmake process confirmed that it had found PAPI v6.0.
However, the error happened again. My workaround is to edit the line of papi.cc
in TVM, so that v6.0 is hardcoded:
CHECK_EQ(PAPI_library_init(100663296), 100663296)
<< "Error while initializing PAPI";
This could be an issue with a partially broken PAPI install on my machine, but all of the libraries and headers appear to be the right version. I have my work around, so I’m just documenting this for anyone else searching for the error.
As I understand it, PAPI_VER_CURRENT
is defined in papi.h
, and there is only one version of that on my system according to $ locate papi.h
.