Hi everyone,
For energy measurement purposes I need to run a program "X" on the Intel phi, that detects when a program "Y" is running in the Intel phi.
Program X runs natively on the Intel Phi (I launch it directly from an ssh terminal logged in the Intel Phi) while program Y is offloaded from the host using micnativeloadex
Here is the code I use in program X, to find if a process is running is a function, that takes in parameter the name of the process:
int findProcessByName(const char* name) { DIR* dir; struct dirent* ent; char* endptr; char buf[512]; //Can we open /proc directory ? if (!(dir = opendir("/proc"))) { perror("can't open /proc"); return -1; } while((ent = readdir(dir)) != NULL) { /* if endptr is not a null character, the directory is not * entirely numeric, so ignore it */ long lpid = strtol(ent->d_name, &endptr, 10); if (*endptr != '\0') { continue; } /* try to open the cmdline file */ snprintf(buf, sizeof(buf), "/proc/%ld/cmdline", lpid); FILE* fp = fopen(buf, "r"); if (fp) { if (fgets(buf, sizeof(buf), fp) != NULL) { /* check the first token in the file, the program name */ char* first = strtok(buf, ""); if (!strcmp(first, name)) { fclose(fp); closedir(dir); return 1; } } fclose(fp); } } closedir(dir); return -1; }
However I am guessing that the problem comes from the fact the processes running on the Phi are not present at this location "/proc/[PID]/cmdline" ?
Because, this function above, works perfectly on a "regular computer" (the host of the Intel Phi for example).
But it does not work on the Intel Phi.
I am guessing that the directory where I should look is "/tmp/coi_procs/1" am I right ? Is it the right place to look for process running on the Intel Phi?
Thanks in advance for your help