2018-05-25 02:49:00 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "machine.h"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
struct cpuid_out res;
|
|
|
|
|
2018-04-11 13:40:43 +03:00
|
|
|
// Logic below from https://github.com/intel/intel-cmt-cat/blob/master/lib/cap.c
|
2018-05-25 02:49:00 +03:00
|
|
|
lcpuid(0x7, 0x0, &res);
|
|
|
|
if (!(res.ebx & (1 << 12))) {
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
// check for overall monitoring capability first
|
|
|
|
lcpuid(0xf, 0x0, &res);
|
|
|
|
if (!(res.edx & (1 << 1))) {
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
// check for more detailed capability, CMT monitoring
|
|
|
|
lcpuid(0xf, 0x1, &res);
|
|
|
|
if (!(res.edx & (1 << 0))) {
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we are here, then CMT cache monitoring capability is available.
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|