forked from OSchip/llvm-project
Clang-format and whitespace cleanup of source code
This patch contains the clang-format and cleanup of the entire code base. Some of clang-formats changes made the code look worse in places. A best effort was made to resolve the bulk of these problems, but many remain. Most of the problems were mangling line-breaks and tabbing of comments. Patch by Terry Wilmarth Differential Revision: https://reviews.llvm.org/D32659 llvm-svn: 302929
This commit is contained in:
parent
fab6b1af6e
commit
3041982dd1
|
|
@ -13,13 +13,13 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <strstream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <strstream>
|
||||
|
||||
/* Given a set of n object files h ('external' object files) and a set of m
|
||||
object files o ('internal' object files),
|
||||
|
|
@ -30,468 +30,457 @@
|
|||
Usage:
|
||||
hide.exe <n> <filenames for h> <filenames for o>
|
||||
|
||||
Thus, the prefixed symbols become hidden in the sense that they now have a special
|
||||
prefix.
|
||||
Thus, the prefixed symbols become hidden in the sense that they now have a
|
||||
special prefix.
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
void stop(char* errorMsg) {
|
||||
printf("%s\n", errorMsg);
|
||||
exit(1);
|
||||
void stop(char *errorMsg) {
|
||||
printf("%s\n", errorMsg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// an entry in the symbol table of a .OBJ file
|
||||
class Symbol {
|
||||
public:
|
||||
__int64 name;
|
||||
unsigned value;
|
||||
unsigned short sectionNum, type;
|
||||
char storageClass, nAux;
|
||||
__int64 name;
|
||||
unsigned value;
|
||||
unsigned short sectionNum, type;
|
||||
char storageClass, nAux;
|
||||
};
|
||||
|
||||
class _rstream : public istrstream {
|
||||
private:
|
||||
const char *buf;
|
||||
const char *buf;
|
||||
|
||||
protected:
|
||||
_rstream(pair<const char*, streamsize> p):istrstream(p.first,p.second),buf(p.first){}
|
||||
~_rstream() {
|
||||
delete[]buf;
|
||||
}
|
||||
_rstream(pair<const char *, streamsize> p)
|
||||
: istrstream(p.first, p.second), buf(p.first) {}
|
||||
~_rstream() { delete[] buf; }
|
||||
};
|
||||
|
||||
/* A stream encapuslating the content of a file or the content of a string, overriding the
|
||||
>> operator to read various integer types in binary form, as well as a symbol table
|
||||
entry.
|
||||
*/
|
||||
// A stream encapuslating the content of a file or the content of a string,
|
||||
// overriding the >> operator to read various integer types in binary form,
|
||||
// as well as a symbol table entry.
|
||||
class rstream : public _rstream {
|
||||
private:
|
||||
template<class T>
|
||||
inline rstream& doRead(T &x) {
|
||||
read((char*)&x, sizeof(T));
|
||||
return *this;
|
||||
}
|
||||
static pair<const char*, streamsize> getBuf(const char *fileName) {
|
||||
ifstream raw(fileName,ios::binary | ios::in);
|
||||
if(!raw.is_open())
|
||||
stop("rstream.getBuf: Error opening file");
|
||||
raw.seekg(0,ios::end);
|
||||
streampos fileSize = raw.tellg();
|
||||
if(fileSize < 0)
|
||||
stop("rstream.getBuf: Error reading file");
|
||||
char *buf = new char[fileSize];
|
||||
raw.seekg(0,ios::beg);
|
||||
raw.read(buf, fileSize);
|
||||
return pair<const char*, streamsize>(buf,fileSize);
|
||||
}
|
||||
template <class T> inline rstream &doRead(T &x) {
|
||||
read((char *)&x, sizeof(T));
|
||||
return *this;
|
||||
}
|
||||
static pair<const char *, streamsize> getBuf(const char *fileName) {
|
||||
ifstream raw(fileName, ios::binary | ios::in);
|
||||
if (!raw.is_open())
|
||||
stop("rstream.getBuf: Error opening file");
|
||||
raw.seekg(0, ios::end);
|
||||
streampos fileSize = raw.tellg();
|
||||
if (fileSize < 0)
|
||||
stop("rstream.getBuf: Error reading file");
|
||||
char *buf = new char[fileSize];
|
||||
raw.seekg(0, ios::beg);
|
||||
raw.read(buf, fileSize);
|
||||
return pair<const char *, streamsize>(buf, fileSize);
|
||||
}
|
||||
|
||||
public:
|
||||
// construct from a string
|
||||
rstream(const char *buf,streamsize size):_rstream(pair<const char*,streamsize>(buf, size)){}
|
||||
/* construct from a file whole content is fully read once to initialize the content of
|
||||
this stream
|
||||
*/
|
||||
rstream(const char *fileName):_rstream(getBuf(fileName)){}
|
||||
rstream& operator>>(int &x) {
|
||||
return doRead(x);
|
||||
}
|
||||
rstream& operator>>(unsigned &x) {
|
||||
return doRead(x);
|
||||
}
|
||||
rstream& operator>>(short &x) {
|
||||
return doRead(x);
|
||||
}
|
||||
rstream& operator>>(unsigned short &x) {
|
||||
return doRead(x);
|
||||
}
|
||||
rstream& operator>>(Symbol &e) {
|
||||
read((char*)&e, 18);
|
||||
return *this;
|
||||
}
|
||||
// construct from a string
|
||||
rstream(const char *buf, streamsize size)
|
||||
: _rstream(pair<const char *, streamsize>(buf, size)) {}
|
||||
// construct from a file whole content is fully read once to initialize the
|
||||
// content of this stream
|
||||
rstream(const char *fileName) : _rstream(getBuf(fileName)) {}
|
||||
rstream &operator>>(int &x) { return doRead(x); }
|
||||
rstream &operator>>(unsigned &x) { return doRead(x); }
|
||||
rstream &operator>>(short &x) { return doRead(x); }
|
||||
rstream &operator>>(unsigned short &x) { return doRead(x); }
|
||||
rstream &operator>>(Symbol &e) {
|
||||
read((char *)&e, 18);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
// string table in a .OBJ file
|
||||
class StringTable {
|
||||
private:
|
||||
map<string, unsigned> directory;
|
||||
size_t length;
|
||||
char *data;
|
||||
map<string, unsigned> directory;
|
||||
size_t length;
|
||||
char *data;
|
||||
|
||||
// make <directory> from <length> bytes in <data>
|
||||
void makeDirectory(void) {
|
||||
unsigned i = 4;
|
||||
while(i < length) {
|
||||
string s = string(data + i);
|
||||
directory.insert(make_pair(s, i));
|
||||
i += s.size() + 1;
|
||||
}
|
||||
// make <directory> from <length> bytes in <data>
|
||||
void makeDirectory(void) {
|
||||
unsigned i = 4;
|
||||
while (i < length) {
|
||||
string s = string(data + i);
|
||||
directory.insert(make_pair(s, i));
|
||||
i += s.size() + 1;
|
||||
}
|
||||
// initialize <length> and <data> with contents specified by the arguments
|
||||
void init(const char *_data) {
|
||||
unsigned _length = *(unsigned*)_data;
|
||||
}
|
||||
// initialize <length> and <data> with contents specified by the arguments
|
||||
void init(const char *_data) {
|
||||
unsigned _length = *(unsigned *)_data;
|
||||
|
||||
if(_length < sizeof(unsigned) || _length != *(unsigned*)_data)
|
||||
stop("StringTable.init: Invalid symbol table");
|
||||
if(_data[_length - 1]) {
|
||||
// to prevent runaway strings, make sure the data ends with a zero
|
||||
data = new char[length = _length + 1];
|
||||
data[_length] = 0;
|
||||
} else {
|
||||
data = new char[length = _length];
|
||||
}
|
||||
*(unsigned*)data = length;
|
||||
KMP_MEMCPY(data + sizeof(unsigned), _data + sizeof(unsigned),
|
||||
length - sizeof(unsigned));
|
||||
makeDirectory();
|
||||
if (_length < sizeof(unsigned) || _length != *(unsigned *)_data)
|
||||
stop("StringTable.init: Invalid symbol table");
|
||||
if (_data[_length - 1]) {
|
||||
// to prevent runaway strings, make sure the data ends with a zero
|
||||
data = new char[length = _length + 1];
|
||||
data[_length] = 0;
|
||||
} else {
|
||||
data = new char[length = _length];
|
||||
}
|
||||
*(unsigned *)data = length;
|
||||
KMP_MEMCPY(data + sizeof(unsigned), _data + sizeof(unsigned),
|
||||
length - sizeof(unsigned));
|
||||
makeDirectory();
|
||||
}
|
||||
|
||||
public:
|
||||
StringTable(rstream &f) {
|
||||
/* Construct string table by reading from f.
|
||||
*/
|
||||
streampos s;
|
||||
unsigned strSize;
|
||||
char *strData;
|
||||
StringTable(rstream &f) {
|
||||
// Construct string table by reading from f.
|
||||
streampos s;
|
||||
unsigned strSize;
|
||||
char *strData;
|
||||
|
||||
s = f.tellg();
|
||||
f>>strSize;
|
||||
if(strSize < sizeof(unsigned))
|
||||
stop("StringTable: Invalid string table");
|
||||
strData = new char[strSize];
|
||||
*(unsigned*)strData = strSize;
|
||||
// read the raw data into <strData>
|
||||
f.read(strData + sizeof(unsigned), strSize - sizeof(unsigned));
|
||||
s = f.tellg() - s;
|
||||
if(s < strSize)
|
||||
stop("StringTable: Unexpected EOF");
|
||||
init(strData);
|
||||
delete[]strData;
|
||||
}
|
||||
StringTable(const set<string> &strings) {
|
||||
/* Construct string table from given strings.
|
||||
*/
|
||||
char *p;
|
||||
set<string>::const_iterator it;
|
||||
size_t s;
|
||||
s = f.tellg();
|
||||
f >> strSize;
|
||||
if (strSize < sizeof(unsigned))
|
||||
stop("StringTable: Invalid string table");
|
||||
strData = new char[strSize];
|
||||
*(unsigned *)strData = strSize;
|
||||
// read the raw data into <strData>
|
||||
f.read(strData + sizeof(unsigned), strSize - sizeof(unsigned));
|
||||
s = f.tellg() - s;
|
||||
if (s < strSize)
|
||||
stop("StringTable: Unexpected EOF");
|
||||
init(strData);
|
||||
delete[] strData;
|
||||
}
|
||||
StringTable(const set<string> &strings) {
|
||||
// Construct string table from given strings.
|
||||
char *p;
|
||||
set<string>::const_iterator it;
|
||||
size_t s;
|
||||
|
||||
// count required size for data
|
||||
for(length = sizeof(unsigned), it = strings.begin(); it != strings.end(); ++it) {
|
||||
size_t l = (*it).size();
|
||||
// count required size for data
|
||||
for (length = sizeof(unsigned), it = strings.begin(); it != strings.end();
|
||||
++it) {
|
||||
size_t l = (*it).size();
|
||||
|
||||
if(l > (unsigned) 0xFFFFFFFF)
|
||||
stop("StringTable: String too long");
|
||||
if(l > 8) {
|
||||
length += l + 1;
|
||||
if(length > (unsigned) 0xFFFFFFFF)
|
||||
stop("StringTable: Symbol table too long");
|
||||
}
|
||||
}
|
||||
data = new char[length];
|
||||
*(unsigned*)data = length;
|
||||
// populate data and directory
|
||||
for(p = data + sizeof(unsigned), it = strings.begin(); it != strings.end(); ++it) {
|
||||
const string &str = *it;
|
||||
size_t l = str.size();
|
||||
if(l > 8) {
|
||||
directory.insert(make_pair(str, p - data));
|
||||
KMP_MEMCPY(p, str.c_str(), l);
|
||||
p[l] = 0;
|
||||
p += l + 1;
|
||||
}
|
||||
}
|
||||
if (l > (unsigned)0xFFFFFFFF)
|
||||
stop("StringTable: String too long");
|
||||
if (l > 8) {
|
||||
length += l + 1;
|
||||
if (length > (unsigned)0xFFFFFFFF)
|
||||
stop("StringTable: Symbol table too long");
|
||||
}
|
||||
}
|
||||
~StringTable() {
|
||||
delete[] data;
|
||||
data = new char[length];
|
||||
*(unsigned *)data = length;
|
||||
// populate data and directory
|
||||
for (p = data + sizeof(unsigned), it = strings.begin(); it != strings.end();
|
||||
++it) {
|
||||
const string &str = *it;
|
||||
size_t l = str.size();
|
||||
if (l > 8) {
|
||||
directory.insert(make_pair(str, p - data));
|
||||
KMP_MEMCPY(p, str.c_str(), l);
|
||||
p[l] = 0;
|
||||
p += l + 1;
|
||||
}
|
||||
}
|
||||
/* Returns encoding for given string based on this string table.
|
||||
Error if string length is greater than 8 but string is not in
|
||||
the string table--returns 0.
|
||||
*/
|
||||
__int64 encode(const string &str) {
|
||||
__int64 r;
|
||||
}
|
||||
~StringTable() { delete[] data; }
|
||||
// Returns encoding for given string based on this string table. Error if
|
||||
// string length is greater than 8 but string is not in the string table
|
||||
// -- returns 0.
|
||||
__int64 encode(const string &str) {
|
||||
__int64 r;
|
||||
|
||||
if(str.size() <= 8) {
|
||||
// encoded directly
|
||||
((char*)&r)[7] = 0;
|
||||
KMP_STRNCPY_S((char*)&r, sizeof(r), str.c_str(), 8);
|
||||
return r;
|
||||
} else {
|
||||
// represented as index into table
|
||||
map<string,unsigned>::const_iterator it = directory.find(str);
|
||||
if(it == directory.end())
|
||||
stop("StringTable::encode: String now found in string table");
|
||||
((unsigned*)&r)[0] = 0;
|
||||
((unsigned*)&r)[1] = (*it).second;
|
||||
return r;
|
||||
}
|
||||
if (str.size() <= 8) {
|
||||
// encoded directly
|
||||
((char *)&r)[7] = 0;
|
||||
KMP_STRNCPY_S((char *)&r, sizeof(r), str.c_str(), 8);
|
||||
return r;
|
||||
} else {
|
||||
// represented as index into table
|
||||
map<string, unsigned>::const_iterator it = directory.find(str);
|
||||
if (it == directory.end())
|
||||
stop("StringTable::encode: String now found in string table");
|
||||
((unsigned *)&r)[0] = 0;
|
||||
((unsigned *)&r)[1] = (*it).second;
|
||||
return r;
|
||||
}
|
||||
/* Returns string represented by x based on this string table.
|
||||
Error if x references an invalid position in the table--returns
|
||||
the empty string.
|
||||
*/
|
||||
string decode(__int64 x) const {
|
||||
if(*(unsigned*)&x == 0) {
|
||||
// represented as index into table
|
||||
unsigned &p = ((unsigned*)&x)[1];
|
||||
if(p >= length)
|
||||
stop("StringTable::decode: Invalid string table lookup");
|
||||
return string(data + p);
|
||||
} else {
|
||||
// encoded directly
|
||||
char *p = (char*)&x;
|
||||
int i;
|
||||
}
|
||||
// Returns string represented by x based on this string table. Error if x
|
||||
// references an invalid position in the table--returns the empty string.
|
||||
string decode(__int64 x) const {
|
||||
if (*(unsigned *)&x == 0) {
|
||||
// represented as index into table
|
||||
unsigned &p = ((unsigned *)&x)[1];
|
||||
if (p >= length)
|
||||
stop("StringTable::decode: Invalid string table lookup");
|
||||
return string(data + p);
|
||||
} else {
|
||||
// encoded directly
|
||||
char *p = (char *)&x;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 8 && p[i]; ++i);
|
||||
return string(p, i);
|
||||
}
|
||||
}
|
||||
void write(ostream &os) {
|
||||
os.write(data, length);
|
||||
for (i = 0; i < 8 && p[i]; ++i)
|
||||
;
|
||||
return string(p, i);
|
||||
}
|
||||
}
|
||||
void write(ostream &os) { os.write(data, length); }
|
||||
};
|
||||
|
||||
/* for the named object file, determines the set of defined symbols and the set of undefined external symbols
|
||||
and writes them to <defined> and <undefined> respectively
|
||||
*/
|
||||
void computeExternalSymbols(const char *fileName, set<string> *defined, set<string> *undefined){
|
||||
streampos fileSize;
|
||||
size_t strTabStart;
|
||||
unsigned symTabStart, symNEntries;
|
||||
rstream f(fileName);
|
||||
// for the named object file, determines the set of defined symbols and the set
|
||||
// of undefined external symbols and writes them to <defined> and <undefined>
|
||||
// respectively
|
||||
void computeExternalSymbols(const char *fileName, set<string> *defined,
|
||||
set<string> *undefined) {
|
||||
streampos fileSize;
|
||||
size_t strTabStart;
|
||||
unsigned symTabStart, symNEntries;
|
||||
rstream f(fileName);
|
||||
|
||||
f.seekg(0,ios::end);
|
||||
fileSize = f.tellg();
|
||||
f.seekg(0, ios::end);
|
||||
fileSize = f.tellg();
|
||||
|
||||
f.seekg(8);
|
||||
f >> symTabStart >> symNEntries;
|
||||
// seek to the string table
|
||||
f.seekg(strTabStart = symTabStart + 18 * (size_t)symNEntries);
|
||||
if(f.eof()) {
|
||||
printf("computeExternalSymbols: fileName='%s', fileSize = %lu, symTabStart = %u, symNEntries = %u\n",
|
||||
fileName, (unsigned long) fileSize, symTabStart, symNEntries);
|
||||
stop("computeExternalSymbols: Unexpected EOF 1");
|
||||
}
|
||||
StringTable stringTable(f); // read the string table
|
||||
if(f.tellg() != fileSize)
|
||||
stop("computeExternalSymbols: Unexpected data after string table");
|
||||
|
||||
f.clear();
|
||||
f.seekg(symTabStart); // seek to the symbol table
|
||||
|
||||
defined->clear(); undefined->clear();
|
||||
for(int i = 0; i < symNEntries; ++i) {
|
||||
// process each entry
|
||||
Symbol e;
|
||||
|
||||
if(f.eof())
|
||||
stop("computeExternalSymbols: Unexpected EOF 2");
|
||||
f>>e;
|
||||
if(f.fail())
|
||||
stop("computeExternalSymbols: File read error");
|
||||
if(e.nAux) { // auxiliary entry: skip
|
||||
f.seekg(e.nAux * 18, ios::cur);
|
||||
i += e.nAux;
|
||||
}
|
||||
// if symbol is extern and defined in the current file, insert it
|
||||
if(e.storageClass == 2)
|
||||
if(e.sectionNum)
|
||||
defined->insert(stringTable.decode(e.name));
|
||||
else
|
||||
undefined->insert(stringTable.decode(e.name));
|
||||
f.seekg(8);
|
||||
f >> symTabStart >> symNEntries;
|
||||
// seek to the string table
|
||||
f.seekg(strTabStart = symTabStart + 18 * (size_t)symNEntries);
|
||||
if (f.eof()) {
|
||||
printf("computeExternalSymbols: fileName='%s', fileSize = %lu, symTabStart "
|
||||
"= %u, symNEntries = %u\n",
|
||||
fileName, (unsigned long)fileSize, symTabStart, symNEntries);
|
||||
stop("computeExternalSymbols: Unexpected EOF 1");
|
||||
}
|
||||
StringTable stringTable(f); // read the string table
|
||||
if (f.tellg() != fileSize)
|
||||
stop("computeExternalSymbols: Unexpected data after string table");
|
||||
|
||||
f.clear();
|
||||
f.seekg(symTabStart); // seek to the symbol table
|
||||
|
||||
defined->clear();
|
||||
undefined->clear();
|
||||
for (int i = 0; i < symNEntries; ++i) {
|
||||
// process each entry
|
||||
Symbol e;
|
||||
|
||||
if (f.eof())
|
||||
stop("computeExternalSymbols: Unexpected EOF 2");
|
||||
f >> e;
|
||||
if (f.fail())
|
||||
stop("computeExternalSymbols: File read error");
|
||||
if (e.nAux) { // auxiliary entry: skip
|
||||
f.seekg(e.nAux * 18, ios::cur);
|
||||
i += e.nAux;
|
||||
}
|
||||
// if symbol is extern and defined in the current file, insert it
|
||||
if (e.storageClass == 2)
|
||||
if (e.sectionNum)
|
||||
defined->insert(stringTable.decode(e.name));
|
||||
else
|
||||
undefined->insert(stringTable.decode(e.name));
|
||||
}
|
||||
}
|
||||
|
||||
/* For each occurrence of an external symbol in the object file named by
|
||||
by <fileName> that is a member of <hide>, renames it by prefixing
|
||||
with "__kmp_external_", writing back the file in-place
|
||||
*/
|
||||
// For each occurrence of an external symbol in the object file named by
|
||||
// by <fileName> that is a member of <hide>, renames it by prefixing
|
||||
// with "__kmp_external_", writing back the file in-place
|
||||
void hideSymbols(char *fileName, const set<string> &hide) {
|
||||
static const string prefix("__kmp_external_");
|
||||
set<string> strings; // set of all occurring symbols, appropriately prefixed
|
||||
streampos fileSize;
|
||||
size_t strTabStart;
|
||||
unsigned symTabStart, symNEntries;
|
||||
int i;
|
||||
rstream in(fileName);
|
||||
static const string prefix("__kmp_external_");
|
||||
set<string> strings; // set of all occurring symbols, appropriately prefixed
|
||||
streampos fileSize;
|
||||
size_t strTabStart;
|
||||
unsigned symTabStart, symNEntries;
|
||||
int i;
|
||||
rstream in(fileName);
|
||||
|
||||
in.seekg(0,ios::end);
|
||||
fileSize = in.tellg();
|
||||
in.seekg(0, ios::end);
|
||||
fileSize = in.tellg();
|
||||
|
||||
in.seekg(8);
|
||||
in >> symTabStart >> symNEntries;
|
||||
in.seekg(strTabStart = symTabStart + 18 * (size_t)symNEntries);
|
||||
if(in.eof())
|
||||
stop("hideSymbols: Unexpected EOF");
|
||||
StringTable stringTableOld(in); // read original string table
|
||||
in.seekg(8);
|
||||
in >> symTabStart >> symNEntries;
|
||||
in.seekg(strTabStart = symTabStart + 18 * (size_t)symNEntries);
|
||||
if (in.eof())
|
||||
stop("hideSymbols: Unexpected EOF");
|
||||
StringTable stringTableOld(in); // read original string table
|
||||
|
||||
if(in.tellg() != fileSize)
|
||||
stop("hideSymbols: Unexpected data after string table");
|
||||
if (in.tellg() != fileSize)
|
||||
stop("hideSymbols: Unexpected data after string table");
|
||||
|
||||
// compute set of occurring strings with prefix added
|
||||
for(i = 0; i < symNEntries; ++i) {
|
||||
Symbol e;
|
||||
// compute set of occurring strings with prefix added
|
||||
for (i = 0; i < symNEntries; ++i) {
|
||||
Symbol e;
|
||||
|
||||
in.seekg(symTabStart + i * 18);
|
||||
if(in.eof())
|
||||
stop("hideSymbols: Unexpected EOF");
|
||||
in >> e;
|
||||
if(in.fail())
|
||||
stop("hideSymbols: File read error");
|
||||
if(e.nAux)
|
||||
i += e.nAux;
|
||||
const string &s = stringTableOld.decode(e.name);
|
||||
// if symbol is extern and found in <hide>, prefix and insert into strings,
|
||||
// otherwise, just insert into strings without prefix
|
||||
strings.insert( (e.storageClass == 2 && hide.find(s) != hide.end()) ?
|
||||
prefix + s : s);
|
||||
in.seekg(symTabStart + i * 18);
|
||||
if (in.eof())
|
||||
stop("hideSymbols: Unexpected EOF");
|
||||
in >> e;
|
||||
if (in.fail())
|
||||
stop("hideSymbols: File read error");
|
||||
if (e.nAux)
|
||||
i += e.nAux;
|
||||
const string &s = stringTableOld.decode(e.name);
|
||||
// if symbol is extern and found in <hide>, prefix and insert into strings,
|
||||
// otherwise, just insert into strings without prefix
|
||||
strings.insert(
|
||||
(e.storageClass == 2 && hide.find(s) != hide.end()) ? prefix + s : s);
|
||||
}
|
||||
|
||||
ofstream out(fileName, ios::trunc | ios::out | ios::binary);
|
||||
if (!out.is_open())
|
||||
stop("hideSymbols: Error opening output file");
|
||||
|
||||
// make new string table from string set
|
||||
StringTable stringTableNew = StringTable(strings);
|
||||
|
||||
// copy input file to output file up to just before the symbol table
|
||||
in.seekg(0);
|
||||
char *buf = new char[symTabStart];
|
||||
in.read(buf, symTabStart);
|
||||
out.write(buf, symTabStart);
|
||||
delete[] buf;
|
||||
|
||||
// copy input symbol table to output symbol table with name translation
|
||||
for (i = 0; i < symNEntries; ++i) {
|
||||
Symbol e;
|
||||
|
||||
in.seekg(symTabStart + i * 18);
|
||||
if (in.eof())
|
||||
stop("hideSymbols: Unexpected EOF");
|
||||
in >> e;
|
||||
if (in.fail())
|
||||
stop("hideSymbols: File read error");
|
||||
const string &s = stringTableOld.decode(e.name);
|
||||
out.seekp(symTabStart + i * 18);
|
||||
e.name = stringTableNew.encode(
|
||||
(e.storageClass == 2 && hide.find(s) != hide.end()) ? prefix + s : s);
|
||||
out.write((char *)&e, 18);
|
||||
if (out.fail())
|
||||
stop("hideSymbols: File write error");
|
||||
if (e.nAux) {
|
||||
// copy auxiliary symbol table entries
|
||||
int nAux = e.nAux;
|
||||
for (int j = 1; j <= nAux; ++j) {
|
||||
in >> e;
|
||||
out.seekp(symTabStart + (i + j) * 18);
|
||||
out.write((char *)&e, 18);
|
||||
}
|
||||
i += nAux;
|
||||
}
|
||||
|
||||
ofstream out(fileName, ios::trunc | ios::out | ios::binary);
|
||||
if(!out.is_open())
|
||||
stop("hideSymbols: Error opening output file");
|
||||
|
||||
// make new string table from string set
|
||||
StringTable stringTableNew = StringTable(strings);
|
||||
|
||||
// copy input file to output file up to just before the symbol table
|
||||
in.seekg(0);
|
||||
char *buf = new char[symTabStart];
|
||||
in.read(buf, symTabStart);
|
||||
out.write(buf, symTabStart);
|
||||
delete []buf;
|
||||
|
||||
// copy input symbol table to output symbol table with name translation
|
||||
for(i = 0; i < symNEntries; ++i) {
|
||||
Symbol e;
|
||||
|
||||
in.seekg(symTabStart + i*18);
|
||||
if(in.eof())
|
||||
stop("hideSymbols: Unexpected EOF");
|
||||
in >> e;
|
||||
if(in.fail())
|
||||
stop("hideSymbols: File read error");
|
||||
const string &s = stringTableOld.decode(e.name);
|
||||
out.seekp(symTabStart + i*18);
|
||||
e.name = stringTableNew.encode( (e.storageClass == 2 && hide.find(s) != hide.end()) ?
|
||||
prefix + s : s);
|
||||
out.write((char*)&e, 18);
|
||||
if(out.fail())
|
||||
stop("hideSymbols: File write error");
|
||||
if(e.nAux) {
|
||||
// copy auxiliary symbol table entries
|
||||
int nAux = e.nAux;
|
||||
for(int j = 1; j <= nAux; ++j) {
|
||||
in >> e;
|
||||
out.seekp(symTabStart + (i + j) * 18);
|
||||
out.write((char*)&e, 18);
|
||||
}
|
||||
i += nAux;
|
||||
}
|
||||
}
|
||||
// output string table
|
||||
stringTableNew.write(out);
|
||||
}
|
||||
// output string table
|
||||
stringTableNew.write(out);
|
||||
}
|
||||
|
||||
// returns true iff <a> and <b> have no common element
|
||||
template <class T>
|
||||
bool isDisjoint(const set<T> &a, const set<T> &b) {
|
||||
set<T>::const_iterator ita, itb;
|
||||
template <class T> bool isDisjoint(const set<T> &a, const set<T> &b) {
|
||||
set<T>::const_iterator ita, itb;
|
||||
|
||||
for(ita = a.begin(), itb = b.begin(); ita != a.end() && itb != b.end();) {
|
||||
const T &ta = *ita, &tb = *itb;
|
||||
if(ta < tb)
|
||||
++ita;
|
||||
else if (tb < ta)
|
||||
++itb;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
for (ita = a.begin(), itb = b.begin(); ita != a.end() && itb != b.end();) {
|
||||
const T &ta = *ita, &tb = *itb;
|
||||
if (ta < tb)
|
||||
++ita;
|
||||
else if (tb < ta)
|
||||
++itb;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* precondition: <defined> and <undefined> are arrays with <nTotal> elements where
|
||||
<nTotal> >= <nExternal>. The first <nExternal> elements correspond to the external object
|
||||
files and the rest correspond to the internal object files.
|
||||
postcondition: file x is said to depend on file y if undefined[x] and defined[y] are not
|
||||
disjoint. Returns the transitive closure of the set of internal object files, as a set of
|
||||
file indexes, under the 'depends on' relation, minus the set of internal object files.
|
||||
*/
|
||||
set<int> *findRequiredExternal(int nExternal, int nTotal, set<string> *defined, set<string> *undefined) {
|
||||
set<int> *required = new set<int>;
|
||||
set<int> fresh[2];
|
||||
int i, cur = 0;
|
||||
bool changed;
|
||||
// PRE: <defined> and <undefined> are arrays with <nTotal> elements where
|
||||
// <nTotal> >= <nExternal>. The first <nExternal> elements correspond to the
|
||||
// external object files and the rest correspond to the internal object files.
|
||||
// POST: file x is said to depend on file y if undefined[x] and defined[y] are
|
||||
// not disjoint. Returns the transitive closure of the set of internal object
|
||||
// files, as a set of file indexes, under the 'depends on' relation, minus the
|
||||
// set of internal object files.
|
||||
set<int> *findRequiredExternal(int nExternal, int nTotal, set<string> *defined,
|
||||
set<string> *undefined) {
|
||||
set<int> *required = new set<int>;
|
||||
set<int> fresh[2];
|
||||
int i, cur = 0;
|
||||
bool changed;
|
||||
|
||||
for(i = nTotal - 1; i >= nExternal; --i)
|
||||
fresh[cur].insert(i);
|
||||
do {
|
||||
changed = false;
|
||||
for(set<int>::iterator it = fresh[cur].begin(); it != fresh[cur].end(); ++it) {
|
||||
set<string> &s = undefined[*it];
|
||||
for (i = nTotal - 1; i >= nExternal; --i)
|
||||
fresh[cur].insert(i);
|
||||
do {
|
||||
changed = false;
|
||||
for (set<int>::iterator it = fresh[cur].begin(); it != fresh[cur].end();
|
||||
++it) {
|
||||
set<string> &s = undefined[*it];
|
||||
|
||||
for(i = 0; i < nExternal; ++i) {
|
||||
if(required->find(i) == required->end()) {
|
||||
if(!isDisjoint(defined[i], s)) {
|
||||
// found a new qualifying element
|
||||
required->insert(i);
|
||||
fresh[1 - cur].insert(i);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fresh[cur].clear();
|
||||
cur = 1 - cur;
|
||||
} while(changed);
|
||||
return required;
|
||||
for (i = 0; i < nExternal; ++i) {
|
||||
if (required->find(i) == required->end()) {
|
||||
if (!isDisjoint(defined[i], s)) {
|
||||
// found a new qualifying element
|
||||
required->insert(i);
|
||||
fresh[1 - cur].insert(i);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fresh[cur].clear();
|
||||
cur = 1 - cur;
|
||||
} while (changed);
|
||||
return required;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int nExternal, nInternal, i;
|
||||
set<string> *defined, *undefined;
|
||||
set<int>::iterator it;
|
||||
int nExternal, nInternal, i;
|
||||
set<string> *defined, *undefined;
|
||||
set<int>::iterator it;
|
||||
|
||||
if(argc < 3)
|
||||
stop("Please specify a positive integer followed by a list of object filenames");
|
||||
nExternal = atoi(argv[1]);
|
||||
if(nExternal <= 0)
|
||||
stop("Please specify a positive integer followed by a list of object filenames");
|
||||
if(nExternal + 2 > argc)
|
||||
stop("Too few external objects");
|
||||
nInternal = argc - nExternal - 2;
|
||||
defined = new set<string>[argc - 2];
|
||||
undefined = new set<string>[argc - 2];
|
||||
if (argc < 3)
|
||||
stop("Please specify a positive integer followed by a list of object "
|
||||
"filenames");
|
||||
nExternal = atoi(argv[1]);
|
||||
if (nExternal <= 0)
|
||||
stop("Please specify a positive integer followed by a list of object "
|
||||
"filenames");
|
||||
if (nExternal + 2 > argc)
|
||||
stop("Too few external objects");
|
||||
nInternal = argc - nExternal - 2;
|
||||
defined = new set<string>[argc - 2];
|
||||
undefined = new set<string>[argc - 2];
|
||||
|
||||
// determine the set of defined and undefined external symbols
|
||||
for(i = 2; i < argc; ++i)
|
||||
computeExternalSymbols(argv[i], defined + i - 2, undefined + i - 2);
|
||||
// determine the set of defined and undefined external symbols
|
||||
for (i = 2; i < argc; ++i)
|
||||
computeExternalSymbols(argv[i], defined + i - 2, undefined + i - 2);
|
||||
|
||||
// determine the set of required external files
|
||||
set<int> *requiredExternal = findRequiredExternal(nExternal, argc - 2, defined, undefined);
|
||||
set<string> hide;
|
||||
// determine the set of required external files
|
||||
set<int> *requiredExternal =
|
||||
findRequiredExternal(nExternal, argc - 2, defined, undefined);
|
||||
set<string> hide;
|
||||
|
||||
/* determine the set of symbols to hide--namely defined external symbols of the
|
||||
required external files
|
||||
*/
|
||||
for(it = requiredExternal->begin(); it != requiredExternal->end(); ++it) {
|
||||
int idx = *it;
|
||||
set<string>::iterator it2;
|
||||
/* We have to insert one element at a time instead of inserting a range because
|
||||
the insert member function taking a range doesn't exist on Windows* OS, at least
|
||||
at the time of this writing.
|
||||
*/
|
||||
for(it2 = defined[idx].begin(); it2 != defined[idx].end(); ++it2)
|
||||
hide.insert(*it2);
|
||||
}
|
||||
// determine the set of symbols to hide--namely defined external symbols of
|
||||
// the required external files
|
||||
for (it = requiredExternal->begin(); it != requiredExternal->end(); ++it) {
|
||||
int idx = *it;
|
||||
set<string>::iterator it2;
|
||||
// We have to insert one element at a time instead of inserting a range
|
||||
// because the insert member function taking a range doesn't exist on
|
||||
// Windows* OS, at least at the time of this writing.
|
||||
for (it2 = defined[idx].begin(); it2 != defined[idx].end(); ++it2)
|
||||
hide.insert(*it2);
|
||||
}
|
||||
|
||||
/* process the external files--removing those that are not required and hiding
|
||||
the appropriate symbols in the others
|
||||
*/
|
||||
for(i = 0; i < nExternal; ++i)
|
||||
if(requiredExternal->find(i) != requiredExternal->end())
|
||||
hideSymbols(argv[2 + i], hide);
|
||||
else
|
||||
remove(argv[2 + i]);
|
||||
// hide the appropriate symbols in the internal files
|
||||
for(i = nExternal + 2; i < argc; ++i)
|
||||
hideSymbols(argv[i], hide);
|
||||
return 0;
|
||||
// process the external files--removing those that are not required and hiding
|
||||
// the appropriate symbols in the others
|
||||
for (i = 0; i < nExternal; ++i)
|
||||
if (requiredExternal->find(i) != requiredExternal->end())
|
||||
hideSymbols(argv[2 + i], hide);
|
||||
else
|
||||
remove(argv[2 + i]);
|
||||
// hide the appropriate symbols in the internal files
|
||||
for (i = nExternal + 2; i < argc; ++i)
|
||||
hideSymbols(argv[i], hide);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -22,76 +22,80 @@
|
|||
@param gtid Global thread ID of encountering thread
|
||||
@param cncl_kind Cancellation kind (parallel, for, sections, taskgroup)
|
||||
|
||||
@return returns true if the cancellation request has been activated and the execution thread
|
||||
needs to proceed to the end of the canceled region.
|
||||
@return returns true if the cancellation request has been activated and the
|
||||
execution thread needs to proceed to the end of the canceled region.
|
||||
|
||||
Request cancellation of the binding OpenMP region.
|
||||
*/
|
||||
kmp_int32 __kmpc_cancel(ident_t* loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) {
|
||||
kmp_info_t *this_thr = __kmp_threads [ gtid ];
|
||||
kmp_int32 __kmpc_cancel(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) {
|
||||
kmp_info_t *this_thr = __kmp_threads[gtid];
|
||||
|
||||
KC_TRACE( 10, ("__kmpc_cancel: T#%d request %d OMP_CANCELLATION=%d\n", gtid, cncl_kind, __kmp_omp_cancellation) );
|
||||
KC_TRACE(10, ("__kmpc_cancel: T#%d request %d OMP_CANCELLATION=%d\n", gtid,
|
||||
cncl_kind, __kmp_omp_cancellation));
|
||||
|
||||
KMP_DEBUG_ASSERT(cncl_kind != cancel_noreq);
|
||||
KMP_DEBUG_ASSERT(cncl_kind == cancel_parallel || cncl_kind == cancel_loop ||
|
||||
cncl_kind == cancel_sections || cncl_kind == cancel_taskgroup);
|
||||
KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
|
||||
KMP_DEBUG_ASSERT(cncl_kind != cancel_noreq);
|
||||
KMP_DEBUG_ASSERT(cncl_kind == cancel_parallel || cncl_kind == cancel_loop ||
|
||||
cncl_kind == cancel_sections ||
|
||||
cncl_kind == cancel_taskgroup);
|
||||
KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
|
||||
|
||||
if (__kmp_omp_cancellation) {
|
||||
switch (cncl_kind) {
|
||||
case cancel_parallel:
|
||||
case cancel_loop:
|
||||
case cancel_sections:
|
||||
// cancellation requests for parallel and worksharing constructs
|
||||
// are handled through the team structure
|
||||
{
|
||||
kmp_team_t *this_team = this_thr->th.th_team;
|
||||
KMP_DEBUG_ASSERT(this_team);
|
||||
kmp_int32 old = KMP_COMPARE_AND_STORE_RET32(&(this_team->t.t_cancel_request), cancel_noreq, cncl_kind);
|
||||
if (old == cancel_noreq || old == cncl_kind) {
|
||||
//printf("__kmpc_cancel: this_team->t.t_cancel_request=%d @ %p\n",
|
||||
// this_team->t.t_cancel_request, &(this_team->t.t_cancel_request));
|
||||
// we do not have a cancellation request in this team or we do have one
|
||||
// that matches the current request -> cancel
|
||||
return 1 /* true */;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cancel_taskgroup:
|
||||
// cancellation requests for a task group
|
||||
// are handled through the taskgroup structure
|
||||
{
|
||||
kmp_taskdata_t* task;
|
||||
kmp_taskgroup_t* taskgroup;
|
||||
|
||||
task = this_thr->th.th_current_task;
|
||||
KMP_DEBUG_ASSERT( task );
|
||||
|
||||
taskgroup = task->td_taskgroup;
|
||||
if (taskgroup) {
|
||||
kmp_int32 old = KMP_COMPARE_AND_STORE_RET32(&(taskgroup->cancel_request), cancel_noreq, cncl_kind);
|
||||
if (old == cancel_noreq || old == cncl_kind) {
|
||||
// we do not have a cancellation request in this taskgroup or we do have one
|
||||
// that matches the current request -> cancel
|
||||
return 1 /* true */;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TODO: what needs to happen here?
|
||||
// the specification disallows cancellation w/o taskgroups
|
||||
// so we might do anything here, let's abort for now
|
||||
KMP_ASSERT( 0 /* false */);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
KMP_ASSERT (0 /* false */);
|
||||
if (__kmp_omp_cancellation) {
|
||||
switch (cncl_kind) {
|
||||
case cancel_parallel:
|
||||
case cancel_loop:
|
||||
case cancel_sections:
|
||||
// cancellation requests for parallel and worksharing constructs
|
||||
// are handled through the team structure
|
||||
{
|
||||
kmp_team_t *this_team = this_thr->th.th_team;
|
||||
KMP_DEBUG_ASSERT(this_team);
|
||||
kmp_int32 old = KMP_COMPARE_AND_STORE_RET32(
|
||||
&(this_team->t.t_cancel_request), cancel_noreq, cncl_kind);
|
||||
if (old == cancel_noreq || old == cncl_kind) {
|
||||
// printf("__kmpc_cancel: this_team->t.t_cancel_request=%d @ %p\n",
|
||||
// this_team->t.t_cancel_request,
|
||||
// &(this_team->t.t_cancel_request));
|
||||
// we do not have a cancellation request in this team or we do have
|
||||
// one that matches the current request -> cancel
|
||||
return 1 /* true */;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cancel_taskgroup:
|
||||
// cancellation requests for a task group
|
||||
// are handled through the taskgroup structure
|
||||
{
|
||||
kmp_taskdata_t *task;
|
||||
kmp_taskgroup_t *taskgroup;
|
||||
|
||||
// ICV OMP_CANCELLATION=false, so we ignored this cancel request
|
||||
KMP_DEBUG_ASSERT(!__kmp_omp_cancellation);
|
||||
return 0 /* false */;
|
||||
task = this_thr->th.th_current_task;
|
||||
KMP_DEBUG_ASSERT(task);
|
||||
|
||||
taskgroup = task->td_taskgroup;
|
||||
if (taskgroup) {
|
||||
kmp_int32 old = KMP_COMPARE_AND_STORE_RET32(
|
||||
&(taskgroup->cancel_request), cancel_noreq, cncl_kind);
|
||||
if (old == cancel_noreq || old == cncl_kind) {
|
||||
// we do not have a cancellation request in this taskgroup or we do
|
||||
// have one that matches the current request -> cancel
|
||||
return 1 /* true */;
|
||||
}
|
||||
} else {
|
||||
// TODO: what needs to happen here?
|
||||
// the specification disallows cancellation w/o taskgroups
|
||||
// so we might do anything here, let's abort for now
|
||||
KMP_ASSERT(0 /* false */);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
KMP_ASSERT(0 /* false */);
|
||||
}
|
||||
}
|
||||
|
||||
// ICV OMP_CANCELLATION=false, so we ignored this cancel request
|
||||
KMP_DEBUG_ASSERT(!__kmp_omp_cancellation);
|
||||
return 0 /* false */;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -100,77 +104,77 @@ kmp_int32 __kmpc_cancel(ident_t* loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) {
|
|||
@param gtid Global thread ID of encountering thread
|
||||
@param cncl_kind Cancellation kind (parallel, for, sections, taskgroup)
|
||||
|
||||
@return returns true if a matching cancellation request has been flagged in the RTL and the
|
||||
encountering thread has to cancel..
|
||||
@return returns true if a matching cancellation request has been flagged in the
|
||||
RTL and the encountering thread has to cancel..
|
||||
|
||||
Cancellation point for the encountering thread.
|
||||
*/
|
||||
kmp_int32 __kmpc_cancellationpoint(ident_t* loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) {
|
||||
kmp_info_t *this_thr = __kmp_threads [ gtid ];
|
||||
kmp_int32 __kmpc_cancellationpoint(ident_t *loc_ref, kmp_int32 gtid,
|
||||
kmp_int32 cncl_kind) {
|
||||
kmp_info_t *this_thr = __kmp_threads[gtid];
|
||||
|
||||
KC_TRACE( 10, ("__kmpc_cancellationpoint: T#%d request %d OMP_CANCELLATION=%d\n", gtid, cncl_kind, __kmp_omp_cancellation) );
|
||||
KC_TRACE(10,
|
||||
("__kmpc_cancellationpoint: T#%d request %d OMP_CANCELLATION=%d\n",
|
||||
gtid, cncl_kind, __kmp_omp_cancellation));
|
||||
|
||||
KMP_DEBUG_ASSERT(cncl_kind != cancel_noreq);
|
||||
KMP_DEBUG_ASSERT(cncl_kind == cancel_parallel || cncl_kind == cancel_loop ||
|
||||
cncl_kind == cancel_sections || cncl_kind == cancel_taskgroup);
|
||||
KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
|
||||
KMP_DEBUG_ASSERT(cncl_kind != cancel_noreq);
|
||||
KMP_DEBUG_ASSERT(cncl_kind == cancel_parallel || cncl_kind == cancel_loop ||
|
||||
cncl_kind == cancel_sections ||
|
||||
cncl_kind == cancel_taskgroup);
|
||||
KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
|
||||
|
||||
if (__kmp_omp_cancellation) {
|
||||
switch (cncl_kind) {
|
||||
case cancel_parallel:
|
||||
case cancel_loop:
|
||||
case cancel_sections:
|
||||
// cancellation requests for parallel and worksharing constructs
|
||||
// are handled through the team structure
|
||||
{
|
||||
kmp_team_t *this_team = this_thr->th.th_team;
|
||||
KMP_DEBUG_ASSERT(this_team);
|
||||
if (this_team->t.t_cancel_request) {
|
||||
if (cncl_kind == this_team->t.t_cancel_request) {
|
||||
// the request in the team structure matches the type of
|
||||
// cancellation point so we can cancel
|
||||
return 1 /* true */;
|
||||
}
|
||||
KMP_ASSERT( 0 /* false */);
|
||||
}
|
||||
else {
|
||||
// we do not have a cancellation request pending, so we just
|
||||
// ignore this cancellation point
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cancel_taskgroup:
|
||||
// cancellation requests for a task group
|
||||
// are handled through the taskgroup structure
|
||||
{
|
||||
kmp_taskdata_t* task;
|
||||
kmp_taskgroup_t* taskgroup;
|
||||
|
||||
task = this_thr->th.th_current_task;
|
||||
KMP_DEBUG_ASSERT( task );
|
||||
|
||||
taskgroup = task->td_taskgroup;
|
||||
if (taskgroup) {
|
||||
// return the current status of cancellation for the
|
||||
// taskgroup
|
||||
return !!taskgroup->cancel_request;
|
||||
}
|
||||
else {
|
||||
// if a cancellation point is encountered by a task
|
||||
// that does not belong to a taskgroup, it is OK
|
||||
// to ignore it
|
||||
return 0 /* false */;
|
||||
}
|
||||
}
|
||||
default:
|
||||
KMP_ASSERT (0 /* false */);
|
||||
if (__kmp_omp_cancellation) {
|
||||
switch (cncl_kind) {
|
||||
case cancel_parallel:
|
||||
case cancel_loop:
|
||||
case cancel_sections:
|
||||
// cancellation requests for parallel and worksharing constructs
|
||||
// are handled through the team structure
|
||||
{
|
||||
kmp_team_t *this_team = this_thr->th.th_team;
|
||||
KMP_DEBUG_ASSERT(this_team);
|
||||
if (this_team->t.t_cancel_request) {
|
||||
if (cncl_kind == this_team->t.t_cancel_request) {
|
||||
// the request in the team structure matches the type of
|
||||
// cancellation point so we can cancel
|
||||
return 1 /* true */;
|
||||
}
|
||||
KMP_ASSERT(0 /* false */);
|
||||
} else {
|
||||
// we do not have a cancellation request pending, so we just
|
||||
// ignore this cancellation point
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cancel_taskgroup:
|
||||
// cancellation requests for a task group
|
||||
// are handled through the taskgroup structure
|
||||
{
|
||||
kmp_taskdata_t *task;
|
||||
kmp_taskgroup_t *taskgroup;
|
||||
|
||||
// ICV OMP_CANCELLATION=false, so we ignore the cancellation point
|
||||
KMP_DEBUG_ASSERT(!__kmp_omp_cancellation);
|
||||
return 0 /* false */;
|
||||
task = this_thr->th.th_current_task;
|
||||
KMP_DEBUG_ASSERT(task);
|
||||
|
||||
taskgroup = task->td_taskgroup;
|
||||
if (taskgroup) {
|
||||
// return the current status of cancellation for the taskgroup
|
||||
return !!taskgroup->cancel_request;
|
||||
} else {
|
||||
// if a cancellation point is encountered by a task that does not
|
||||
// belong to a taskgroup, it is OK to ignore it
|
||||
return 0 /* false */;
|
||||
}
|
||||
}
|
||||
default:
|
||||
KMP_ASSERT(0 /* false */);
|
||||
}
|
||||
}
|
||||
|
||||
// ICV OMP_CANCELLATION=false, so we ignore the cancellation point
|
||||
KMP_DEBUG_ASSERT(!__kmp_omp_cancellation);
|
||||
return 0 /* false */;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -178,63 +182,61 @@ kmp_int32 __kmpc_cancellationpoint(ident_t* loc_ref, kmp_int32 gtid, kmp_int32 c
|
|||
@param loc_ref location of the original task directive
|
||||
@param gtid Global thread ID of encountering thread
|
||||
|
||||
@return returns true if a matching cancellation request has been flagged in the RTL and the
|
||||
encountering thread has to cancel..
|
||||
@return returns true if a matching cancellation request has been flagged in the
|
||||
RTL and the encountering thread has to cancel..
|
||||
|
||||
Barrier with cancellation point to send threads from the barrier to the
|
||||
end of the parallel region. Needs a special code pattern as documented
|
||||
in the design document for the cancellation feature.
|
||||
*/
|
||||
kmp_int32
|
||||
__kmpc_cancel_barrier(ident_t *loc, kmp_int32 gtid) {
|
||||
int ret = 0 /* false */;
|
||||
kmp_info_t *this_thr = __kmp_threads [ gtid ];
|
||||
kmp_team_t *this_team = this_thr->th.th_team;
|
||||
kmp_int32 __kmpc_cancel_barrier(ident_t *loc, kmp_int32 gtid) {
|
||||
int ret = 0 /* false */;
|
||||
kmp_info_t *this_thr = __kmp_threads[gtid];
|
||||
kmp_team_t *this_team = this_thr->th.th_team;
|
||||
|
||||
KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
|
||||
KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
|
||||
|
||||
// call into the standard barrier
|
||||
__kmpc_barrier(loc, gtid);
|
||||
// call into the standard barrier
|
||||
__kmpc_barrier(loc, gtid);
|
||||
|
||||
// if cancellation is active, check cancellation flag
|
||||
if (__kmp_omp_cancellation) {
|
||||
// depending on which construct to cancel, check the flag and
|
||||
// reset the flag
|
||||
switch (this_team->t.t_cancel_request) {
|
||||
case cancel_parallel:
|
||||
ret = 1;
|
||||
// ensure that threads have checked the flag, when
|
||||
// leaving the above barrier
|
||||
__kmpc_barrier(loc, gtid);
|
||||
this_team->t.t_cancel_request = cancel_noreq;
|
||||
// the next barrier is the fork/join barrier, which
|
||||
// synchronizes the threads leaving here
|
||||
break;
|
||||
case cancel_loop:
|
||||
case cancel_sections:
|
||||
ret = 1;
|
||||
// ensure that threads have checked the flag, when
|
||||
// leaving the above barrier
|
||||
__kmpc_barrier(loc, gtid);
|
||||
this_team->t.t_cancel_request = cancel_noreq;
|
||||
// synchronize the threads again to make sure we
|
||||
// do not have any run-away threads that cause a race
|
||||
// on the cancellation flag
|
||||
__kmpc_barrier(loc, gtid);
|
||||
break;
|
||||
case cancel_taskgroup:
|
||||
// this case should not occur
|
||||
KMP_ASSERT (0 /* false */ );
|
||||
break;
|
||||
case cancel_noreq:
|
||||
// do nothing
|
||||
break;
|
||||
default:
|
||||
KMP_ASSERT ( 0 /* false */);
|
||||
}
|
||||
// if cancellation is active, check cancellation flag
|
||||
if (__kmp_omp_cancellation) {
|
||||
// depending on which construct to cancel, check the flag and
|
||||
// reset the flag
|
||||
switch (this_team->t.t_cancel_request) {
|
||||
case cancel_parallel:
|
||||
ret = 1;
|
||||
// ensure that threads have checked the flag, when
|
||||
// leaving the above barrier
|
||||
__kmpc_barrier(loc, gtid);
|
||||
this_team->t.t_cancel_request = cancel_noreq;
|
||||
// the next barrier is the fork/join barrier, which
|
||||
// synchronizes the threads leaving here
|
||||
break;
|
||||
case cancel_loop:
|
||||
case cancel_sections:
|
||||
ret = 1;
|
||||
// ensure that threads have checked the flag, when
|
||||
// leaving the above barrier
|
||||
__kmpc_barrier(loc, gtid);
|
||||
this_team->t.t_cancel_request = cancel_noreq;
|
||||
// synchronize the threads again to make sure we do not have any run-away
|
||||
// threads that cause a race on the cancellation flag
|
||||
__kmpc_barrier(loc, gtid);
|
||||
break;
|
||||
case cancel_taskgroup:
|
||||
// this case should not occur
|
||||
KMP_ASSERT(0 /* false */);
|
||||
break;
|
||||
case cancel_noreq:
|
||||
// do nothing
|
||||
break;
|
||||
default:
|
||||
KMP_ASSERT(0 /* false */);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -242,8 +244,8 @@ __kmpc_cancel_barrier(ident_t *loc, kmp_int32 gtid) {
|
|||
@param loc_ref location of the original task directive
|
||||
@param gtid Global thread ID of encountering thread
|
||||
|
||||
@return returns true if a matching cancellation request has been flagged in the RTL and the
|
||||
encountering thread has to cancel..
|
||||
@return returns true if a matching cancellation request has been flagged in the
|
||||
RTL and the encountering thread has to cancel..
|
||||
|
||||
Query function to query the current status of cancellation requests.
|
||||
Can be used to implement the following pattern:
|
||||
|
|
@ -254,29 +256,27 @@ if (kmp_get_cancellation_status(kmp_cancel_parallel)) {
|
|||
}
|
||||
*/
|
||||
int __kmp_get_cancellation_status(int cancel_kind) {
|
||||
if (__kmp_omp_cancellation) {
|
||||
kmp_info_t *this_thr = __kmp_entry_thread();
|
||||
if (__kmp_omp_cancellation) {
|
||||
kmp_info_t *this_thr = __kmp_entry_thread();
|
||||
|
||||
switch (cancel_kind) {
|
||||
case cancel_parallel:
|
||||
case cancel_loop:
|
||||
case cancel_sections:
|
||||
{
|
||||
kmp_team_t *this_team = this_thr->th.th_team;
|
||||
return this_team->t.t_cancel_request == cancel_kind;
|
||||
}
|
||||
case cancel_taskgroup:
|
||||
{
|
||||
kmp_taskdata_t* task;
|
||||
kmp_taskgroup_t* taskgroup;
|
||||
task = this_thr->th.th_current_task;
|
||||
taskgroup = task->td_taskgroup;
|
||||
return taskgroup && taskgroup->cancel_request;
|
||||
}
|
||||
}
|
||||
switch (cancel_kind) {
|
||||
case cancel_parallel:
|
||||
case cancel_loop:
|
||||
case cancel_sections: {
|
||||
kmp_team_t *this_team = this_thr->th.th_team;
|
||||
return this_team->t.t_cancel_request == cancel_kind;
|
||||
}
|
||||
case cancel_taskgroup: {
|
||||
kmp_taskdata_t *task;
|
||||
kmp_taskgroup_t *taskgroup;
|
||||
task = this_thr->th.th_current_task;
|
||||
taskgroup = task->td_taskgroup;
|
||||
return taskgroup && taskgroup->cancel_request;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0 /* false */;
|
||||
return 0 /* false */;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -19,124 +19,116 @@
|
|||
#include "kmp_io.h"
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
void
|
||||
__kmp_debug_printf_stdout( char const * format, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, format );
|
||||
void __kmp_debug_printf_stdout(char const *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
__kmp_vprintf( kmp_out, format, ap );
|
||||
__kmp_vprintf(kmp_out, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
__kmp_debug_printf( char const * format, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, format );
|
||||
void __kmp_debug_printf(char const *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
__kmp_vprintf( kmp_err, format, ap );
|
||||
__kmp_vprintf(kmp_err, format, ap);
|
||||
|
||||
va_end( ap );
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#ifdef KMP_USE_ASSERT
|
||||
int
|
||||
__kmp_debug_assert(
|
||||
char const * msg,
|
||||
char const * file,
|
||||
int line
|
||||
) {
|
||||
int __kmp_debug_assert(char const *msg, char const *file, int line) {
|
||||
|
||||
if ( file == NULL ) {
|
||||
file = KMP_I18N_STR( UnknownFile );
|
||||
} else {
|
||||
// Remove directories from path, leave only file name. File name is enough, there is no need
|
||||
// in bothering developers and customers with full paths.
|
||||
char const * slash = strrchr( file, '/' );
|
||||
if ( slash != NULL ) {
|
||||
file = slash + 1;
|
||||
}; // if
|
||||
}; // if
|
||||
if (file == NULL) {
|
||||
file = KMP_I18N_STR(UnknownFile);
|
||||
} else {
|
||||
// Remove directories from path, leave only file name. File name is enough,
|
||||
// there is no need in bothering developers and customers with full paths.
|
||||
char const *slash = strrchr(file, '/');
|
||||
if (slash != NULL) {
|
||||
file = slash + 1;
|
||||
}; // if
|
||||
}; // if
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
__kmp_acquire_bootstrap_lock( & __kmp_stdio_lock );
|
||||
__kmp_debug_printf( "Assertion failure at %s(%d): %s.\n", file, line, msg );
|
||||
__kmp_release_bootstrap_lock( & __kmp_stdio_lock );
|
||||
#ifdef USE_ASSERT_BREAK
|
||||
#if KMP_OS_WINDOWS
|
||||
DebugBreak();
|
||||
#endif
|
||||
#endif // USE_ASSERT_BREAK
|
||||
#ifdef USE_ASSERT_STALL
|
||||
/* __kmp_infinite_loop(); */
|
||||
for(;;);
|
||||
#endif // USE_ASSERT_STALL
|
||||
#ifdef USE_ASSERT_SEG
|
||||
{
|
||||
int volatile * ZERO = (int*) 0;
|
||||
++ (*ZERO);
|
||||
}
|
||||
#endif // USE_ASSERT_SEG
|
||||
#endif
|
||||
#ifdef KMP_DEBUG
|
||||
__kmp_acquire_bootstrap_lock(&__kmp_stdio_lock);
|
||||
__kmp_debug_printf("Assertion failure at %s(%d): %s.\n", file, line, msg);
|
||||
__kmp_release_bootstrap_lock(&__kmp_stdio_lock);
|
||||
#ifdef USE_ASSERT_BREAK
|
||||
#if KMP_OS_WINDOWS
|
||||
DebugBreak();
|
||||
#endif
|
||||
#endif // USE_ASSERT_BREAK
|
||||
#ifdef USE_ASSERT_STALL
|
||||
/* __kmp_infinite_loop(); */
|
||||
for (;;)
|
||||
;
|
||||
#endif // USE_ASSERT_STALL
|
||||
#ifdef USE_ASSERT_SEG
|
||||
{
|
||||
int volatile *ZERO = (int *)0;
|
||||
++(*ZERO);
|
||||
}
|
||||
#endif // USE_ASSERT_SEG
|
||||
#endif
|
||||
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal,
|
||||
KMP_MSG( AssertionFailure, file, line ),
|
||||
KMP_HNT( SubmitBugReport ),
|
||||
__kmp_msg_null
|
||||
);
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(AssertionFailure, file, line),
|
||||
KMP_HNT(SubmitBugReport), __kmp_msg_null);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
} // __kmp_debug_assert
|
||||
} // __kmp_debug_assert
|
||||
|
||||
#endif // KMP_USE_ASSERT
|
||||
|
||||
/* Dump debugging buffer to stderr */
|
||||
void
|
||||
__kmp_dump_debug_buffer( void )
|
||||
{
|
||||
if ( __kmp_debug_buffer != NULL ) {
|
||||
int i;
|
||||
int dc = __kmp_debug_count;
|
||||
char *db = & __kmp_debug_buffer[ (dc % __kmp_debug_buf_lines) * __kmp_debug_buf_chars ];
|
||||
char *db_end = & __kmp_debug_buffer[ __kmp_debug_buf_lines * __kmp_debug_buf_chars ];
|
||||
char *db2;
|
||||
void __kmp_dump_debug_buffer(void) {
|
||||
if (__kmp_debug_buffer != NULL) {
|
||||
int i;
|
||||
int dc = __kmp_debug_count;
|
||||
char *db = &__kmp_debug_buffer[(dc % __kmp_debug_buf_lines) *
|
||||
__kmp_debug_buf_chars];
|
||||
char *db_end =
|
||||
&__kmp_debug_buffer[__kmp_debug_buf_lines * __kmp_debug_buf_chars];
|
||||
char *db2;
|
||||
|
||||
__kmp_acquire_bootstrap_lock( & __kmp_stdio_lock );
|
||||
__kmp_printf_no_lock( "\nStart dump of debugging buffer (entry=%d):\n",
|
||||
dc % __kmp_debug_buf_lines );
|
||||
__kmp_acquire_bootstrap_lock(&__kmp_stdio_lock);
|
||||
__kmp_printf_no_lock("\nStart dump of debugging buffer (entry=%d):\n",
|
||||
dc % __kmp_debug_buf_lines);
|
||||
|
||||
for ( i = 0; i < __kmp_debug_buf_lines; i++ ) {
|
||||
for (i = 0; i < __kmp_debug_buf_lines; i++) {
|
||||
|
||||
if ( *db != '\0' ) {
|
||||
/* Fix up where no carriage return before string termination char */
|
||||
for ( db2 = db + 1; db2 < db + __kmp_debug_buf_chars - 1; db2 ++) {
|
||||
if ( *db2 == '\0' ) {
|
||||
if ( *(db2-1) != '\n' ) { *db2 = '\n'; *(db2+1) = '\0'; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Handle case at end by shortening the printed message by one char if necessary */
|
||||
if ( db2 == db + __kmp_debug_buf_chars - 1 &&
|
||||
*db2 == '\0' && *(db2-1) != '\n' ) {
|
||||
*(db2-1) = '\n';
|
||||
}
|
||||
|
||||
__kmp_printf_no_lock( "%4d: %.*s", i, __kmp_debug_buf_chars, db );
|
||||
*db = '\0'; /* only let it print once! */
|
||||
if (*db != '\0') {
|
||||
/* Fix up where no carriage return before string termination char */
|
||||
for (db2 = db + 1; db2 < db + __kmp_debug_buf_chars - 1; db2++) {
|
||||
if (*db2 == '\0') {
|
||||
if (*(db2 - 1) != '\n') {
|
||||
*db2 = '\n';
|
||||
*(db2 + 1) = '\0';
|
||||
}
|
||||
|
||||
db += __kmp_debug_buf_chars;
|
||||
if ( db >= db_end )
|
||||
db = __kmp_debug_buffer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Handle case at end by shortening the printed message by one char if
|
||||
* necessary */
|
||||
if (db2 == db + __kmp_debug_buf_chars - 1 && *db2 == '\0' &&
|
||||
*(db2 - 1) != '\n') {
|
||||
*(db2 - 1) = '\n';
|
||||
}
|
||||
|
||||
__kmp_printf_no_lock( "End dump of debugging buffer (entry=%d).\n\n",
|
||||
( dc+i-1 ) % __kmp_debug_buf_lines );
|
||||
__kmp_release_bootstrap_lock( & __kmp_stdio_lock );
|
||||
__kmp_printf_no_lock("%4d: %.*s", i, __kmp_debug_buf_chars, db);
|
||||
*db = '\0'; /* only let it print once! */
|
||||
}
|
||||
|
||||
db += __kmp_debug_buf_chars;
|
||||
if (db >= db_end)
|
||||
db = __kmp_debug_buffer;
|
||||
}
|
||||
|
||||
__kmp_printf_no_lock("End dump of debugging buffer (entry=%d).\n\n",
|
||||
(dc + i - 1) % __kmp_debug_buf_lines);
|
||||
__kmp_release_bootstrap_lock(&__kmp_stdio_lock);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,94 +19,155 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Build-time assertion.
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
// New C++11 style build assert
|
||||
#define KMP_BUILD_ASSERT( expr ) static_assert(expr, "Build condition error")
|
||||
#define KMP_BUILD_ASSERT(expr) static_assert(expr, "Build condition error")
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Run-time assertions.
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
extern void __kmp_dump_debug_buffer( void );
|
||||
extern void __kmp_dump_debug_buffer(void);
|
||||
|
||||
#ifdef KMP_USE_ASSERT
|
||||
extern int __kmp_debug_assert( char const * expr, char const * file, int line );
|
||||
#ifdef KMP_DEBUG
|
||||
#define KMP_ASSERT( cond ) ( (cond) ? 0 : __kmp_debug_assert( #cond, __FILE__, __LINE__ ) )
|
||||
#define KMP_ASSERT2( cond, msg ) ( (cond) ? 0 : __kmp_debug_assert( (msg), __FILE__, __LINE__ ) )
|
||||
#define KMP_DEBUG_ASSERT( cond ) KMP_ASSERT( cond )
|
||||
#define KMP_DEBUG_ASSERT2( cond, msg ) KMP_ASSERT2( cond, msg )
|
||||
#else
|
||||
// Do not expose condition in release build. Use "assertion failure".
|
||||
#define KMP_ASSERT( cond ) ( (cond) ? 0 : __kmp_debug_assert( "assertion failure", __FILE__, __LINE__ ) )
|
||||
#define KMP_ASSERT2( cond, msg ) KMP_ASSERT( cond )
|
||||
#define KMP_DEBUG_ASSERT( cond ) 0
|
||||
#define KMP_DEBUG_ASSERT2( cond, msg ) 0
|
||||
#endif // KMP_DEBUG
|
||||
extern int __kmp_debug_assert(char const *expr, char const *file, int line);
|
||||
#ifdef KMP_DEBUG
|
||||
#define KMP_ASSERT(cond) \
|
||||
((cond) ? 0 : __kmp_debug_assert(#cond, __FILE__, __LINE__))
|
||||
#define KMP_ASSERT2(cond, msg) \
|
||||
((cond) ? 0 : __kmp_debug_assert((msg), __FILE__, __LINE__))
|
||||
#define KMP_DEBUG_ASSERT(cond) KMP_ASSERT(cond)
|
||||
#define KMP_DEBUG_ASSERT2(cond, msg) KMP_ASSERT2(cond, msg)
|
||||
#else
|
||||
#define KMP_ASSERT( cond ) 0
|
||||
#define KMP_ASSERT2( cond, msg ) 0
|
||||
#define KMP_DEBUG_ASSERT( cond ) 0
|
||||
#define KMP_DEBUG_ASSERT2( cond, msg ) 0
|
||||
// Do not expose condition in release build. Use "assertion failure".
|
||||
#define KMP_ASSERT(cond) \
|
||||
((cond) ? 0 : __kmp_debug_assert("assertion failure", __FILE__, __LINE__))
|
||||
#define KMP_ASSERT2(cond, msg) KMP_ASSERT(cond)
|
||||
#define KMP_DEBUG_ASSERT(cond) 0
|
||||
#define KMP_DEBUG_ASSERT2(cond, msg) 0
|
||||
#endif // KMP_DEBUG
|
||||
#else
|
||||
#define KMP_ASSERT(cond) 0
|
||||
#define KMP_ASSERT2(cond, msg) 0
|
||||
#define KMP_DEBUG_ASSERT(cond) 0
|
||||
#define KMP_DEBUG_ASSERT2(cond, msg) 0
|
||||
#endif // KMP_USE_ASSERT
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
extern void __kmp_debug_printf_stdout( char const * format, ... );
|
||||
extern void __kmp_debug_printf_stdout(char const *format, ...);
|
||||
#endif
|
||||
extern void __kmp_debug_printf( char const * format, ... );
|
||||
extern void __kmp_debug_printf(char const *format, ...);
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
|
||||
extern int kmp_a_debug;
|
||||
extern int kmp_b_debug;
|
||||
extern int kmp_c_debug;
|
||||
extern int kmp_d_debug;
|
||||
extern int kmp_e_debug;
|
||||
extern int kmp_f_debug;
|
||||
extern int kmp_diag;
|
||||
extern int kmp_a_debug;
|
||||
extern int kmp_b_debug;
|
||||
extern int kmp_c_debug;
|
||||
extern int kmp_d_debug;
|
||||
extern int kmp_e_debug;
|
||||
extern int kmp_f_debug;
|
||||
extern int kmp_diag;
|
||||
|
||||
#define KA_TRACE(d,x) if (kmp_a_debug >= d) { __kmp_debug_printf x ; }
|
||||
#define KB_TRACE(d,x) if (kmp_b_debug >= d) { __kmp_debug_printf x ; }
|
||||
#define KC_TRACE(d,x) if (kmp_c_debug >= d) { __kmp_debug_printf x ; }
|
||||
#define KD_TRACE(d,x) if (kmp_d_debug >= d) { __kmp_debug_printf x ; }
|
||||
#define KE_TRACE(d,x) if (kmp_e_debug >= d) { __kmp_debug_printf x ; }
|
||||
#define KF_TRACE(d,x) if (kmp_f_debug >= d) { __kmp_debug_printf x ; }
|
||||
#define K_DIAG(d,x) {if (kmp_diag == d) { __kmp_debug_printf_stdout x ; } }
|
||||
#define KA_TRACE(d, x) \
|
||||
if (kmp_a_debug >= d) { \
|
||||
__kmp_debug_printf x; \
|
||||
}
|
||||
#define KB_TRACE(d, x) \
|
||||
if (kmp_b_debug >= d) { \
|
||||
__kmp_debug_printf x; \
|
||||
}
|
||||
#define KC_TRACE(d, x) \
|
||||
if (kmp_c_debug >= d) { \
|
||||
__kmp_debug_printf x; \
|
||||
}
|
||||
#define KD_TRACE(d, x) \
|
||||
if (kmp_d_debug >= d) { \
|
||||
__kmp_debug_printf x; \
|
||||
}
|
||||
#define KE_TRACE(d, x) \
|
||||
if (kmp_e_debug >= d) { \
|
||||
__kmp_debug_printf x; \
|
||||
}
|
||||
#define KF_TRACE(d, x) \
|
||||
if (kmp_f_debug >= d) { \
|
||||
__kmp_debug_printf x; \
|
||||
}
|
||||
#define K_DIAG(d, x) \
|
||||
{ \
|
||||
if (kmp_diag == d) { \
|
||||
__kmp_debug_printf_stdout x; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define KA_DUMP(d,x) if (kmp_a_debug >= d) { int ks; __kmp_disable(&ks); (x) ; __kmp_enable(ks); }
|
||||
#define KB_DUMP(d,x) if (kmp_b_debug >= d) { int ks; __kmp_disable(&ks); (x) ; __kmp_enable(ks); }
|
||||
#define KC_DUMP(d,x) if (kmp_c_debug >= d) { int ks; __kmp_disable(&ks); (x) ; __kmp_enable(ks); }
|
||||
#define KD_DUMP(d,x) if (kmp_d_debug >= d) { int ks; __kmp_disable(&ks); (x) ; __kmp_enable(ks); }
|
||||
#define KE_DUMP(d,x) if (kmp_e_debug >= d) { int ks; __kmp_disable(&ks); (x) ; __kmp_enable(ks); }
|
||||
#define KF_DUMP(d,x) if (kmp_f_debug >= d) { int ks; __kmp_disable(&ks); (x) ; __kmp_enable(ks); }
|
||||
#define KA_DUMP(d, x) \
|
||||
if (kmp_a_debug >= d) { \
|
||||
int ks; \
|
||||
__kmp_disable(&ks); \
|
||||
(x); \
|
||||
__kmp_enable(ks); \
|
||||
}
|
||||
#define KB_DUMP(d, x) \
|
||||
if (kmp_b_debug >= d) { \
|
||||
int ks; \
|
||||
__kmp_disable(&ks); \
|
||||
(x); \
|
||||
__kmp_enable(ks); \
|
||||
}
|
||||
#define KC_DUMP(d, x) \
|
||||
if (kmp_c_debug >= d) { \
|
||||
int ks; \
|
||||
__kmp_disable(&ks); \
|
||||
(x); \
|
||||
__kmp_enable(ks); \
|
||||
}
|
||||
#define KD_DUMP(d, x) \
|
||||
if (kmp_d_debug >= d) { \
|
||||
int ks; \
|
||||
__kmp_disable(&ks); \
|
||||
(x); \
|
||||
__kmp_enable(ks); \
|
||||
}
|
||||
#define KE_DUMP(d, x) \
|
||||
if (kmp_e_debug >= d) { \
|
||||
int ks; \
|
||||
__kmp_disable(&ks); \
|
||||
(x); \
|
||||
__kmp_enable(ks); \
|
||||
}
|
||||
#define KF_DUMP(d, x) \
|
||||
if (kmp_f_debug >= d) { \
|
||||
int ks; \
|
||||
__kmp_disable(&ks); \
|
||||
(x); \
|
||||
__kmp_enable(ks); \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define KA_TRACE(d,x) /* nothing to do */
|
||||
#define KB_TRACE(d,x) /* nothing to do */
|
||||
#define KC_TRACE(d,x) /* nothing to do */
|
||||
#define KD_TRACE(d,x) /* nothing to do */
|
||||
#define KE_TRACE(d,x) /* nothing to do */
|
||||
#define KF_TRACE(d,x) /* nothing to do */
|
||||
#define K_DIAG(d,x) {}/* nothing to do */
|
||||
#define KA_TRACE(d, x) /* nothing to do */
|
||||
#define KB_TRACE(d, x) /* nothing to do */
|
||||
#define KC_TRACE(d, x) /* nothing to do */
|
||||
#define KD_TRACE(d, x) /* nothing to do */
|
||||
#define KE_TRACE(d, x) /* nothing to do */
|
||||
#define KF_TRACE(d, x) /* nothing to do */
|
||||
#define K_DIAG(d, x) \
|
||||
{} /* nothing to do */
|
||||
|
||||
#define KA_DUMP(d,x) /* nothing to do */
|
||||
#define KB_DUMP(d,x) /* nothing to do */
|
||||
#define KC_DUMP(d,x) /* nothing to do */
|
||||
#define KD_DUMP(d,x) /* nothing to do */
|
||||
#define KE_DUMP(d,x) /* nothing to do */
|
||||
#define KF_DUMP(d,x) /* nothing to do */
|
||||
#define KA_DUMP(d, x) /* nothing to do */
|
||||
#define KB_DUMP(d, x) /* nothing to do */
|
||||
#define KC_DUMP(d, x) /* nothing to do */
|
||||
#define KD_DUMP(d, x) /* nothing to do */
|
||||
#define KE_DUMP(d, x) /* nothing to do */
|
||||
#define KF_DUMP(d, x) /* nothing to do */
|
||||
|
||||
#endif // KMP_DEBUG
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif /* KMP_DEBUG_H */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#if USE_DEBUGGER
|
||||
/*
|
||||
* kmp_debugger.c -- debugger support.
|
||||
* kmp_debugger.cpp -- debugger support.
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -19,47 +19,36 @@
|
|||
#include "kmp_omp.h"
|
||||
#include "kmp_str.h"
|
||||
|
||||
/*
|
||||
NOTE: All variable names are known to the debugger, do not change!
|
||||
*/
|
||||
// NOTE: All variable names are known to the debugger, do not change!
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern kmp_omp_struct_info_t __kmp_omp_debug_struct_info;
|
||||
} // extern "C"
|
||||
extern "C" {
|
||||
extern kmp_omp_struct_info_t __kmp_omp_debug_struct_info;
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
int __kmp_debugging = FALSE; // Boolean whether currently debugging OpenMP RTL.
|
||||
int __kmp_debugging = FALSE; // Boolean whether currently debugging OpenMP RTL.
|
||||
|
||||
#define offset_and_size_of( structure, field ) \
|
||||
{ \
|
||||
offsetof( structure, field ), \
|
||||
sizeof( ( (structure *) NULL)->field ) \
|
||||
}
|
||||
#define offset_and_size_of(structure, field) \
|
||||
{ offsetof(structure, field), sizeof(((structure *)NULL)->field) }
|
||||
|
||||
#define offset_and_size_not_available \
|
||||
{ -1, -1 }
|
||||
#define offset_and_size_not_available \
|
||||
{ -1, -1 }
|
||||
|
||||
#define addr_and_size_of( var ) \
|
||||
{ \
|
||||
(kmp_uint64)( & var ), \
|
||||
sizeof( var ) \
|
||||
}
|
||||
#define addr_and_size_of(var) \
|
||||
{ (kmp_uint64)(&var), sizeof(var) }
|
||||
|
||||
#define nthr_buffer_size 1024
|
||||
static kmp_int32
|
||||
kmp_omp_nthr_info_buffer[ nthr_buffer_size ] =
|
||||
{ nthr_buffer_size * sizeof( kmp_int32 ) };
|
||||
static kmp_int32 kmp_omp_nthr_info_buffer[nthr_buffer_size] = {
|
||||
nthr_buffer_size * sizeof(kmp_int32)};
|
||||
|
||||
/* TODO: Check punctuation for various platforms here */
|
||||
static char func_microtask[] = "__kmp_invoke_microtask";
|
||||
static char func_fork[] = "__kmpc_fork_call";
|
||||
static char func_fork_teams[] = "__kmpc_fork_teams";
|
||||
|
||||
static char func_microtask[] = "__kmp_invoke_microtask";
|
||||
static char func_fork[] = "__kmpc_fork_call";
|
||||
static char func_fork_teams[] = "__kmpc_fork_teams";
|
||||
|
||||
// Various info about runtime structures: addresses, field offsets, sizes, etc.
|
||||
kmp_omp_struct_info_t
|
||||
__kmp_omp_debug_struct_info = {
|
||||
kmp_omp_struct_info_t __kmp_omp_debug_struct_info = {
|
||||
|
||||
/* Change this only if you make a fundamental data structure change here */
|
||||
KMP_OMP_VERSION,
|
||||
|
|
@ -67,166 +56,167 @@ __kmp_omp_debug_struct_info = {
|
|||
/* sanity check. Only should be checked if versions are identical
|
||||
* This is also used for backward compatibility to get the runtime
|
||||
* structure size if it the runtime is older than the interface */
|
||||
sizeof( kmp_omp_struct_info_t ),
|
||||
sizeof(kmp_omp_struct_info_t),
|
||||
|
||||
/* OpenMP RTL version info. */
|
||||
addr_and_size_of( __kmp_version_major ),
|
||||
addr_and_size_of( __kmp_version_minor ),
|
||||
addr_and_size_of( __kmp_version_build ),
|
||||
addr_and_size_of( __kmp_openmp_version ),
|
||||
{ (kmp_uint64)( __kmp_copyright ) + KMP_VERSION_MAGIC_LEN, 0 }, // Skip magic prefix.
|
||||
addr_and_size_of(__kmp_version_major),
|
||||
addr_and_size_of(__kmp_version_minor),
|
||||
addr_and_size_of(__kmp_version_build),
|
||||
addr_and_size_of(__kmp_openmp_version),
|
||||
{(kmp_uint64)(__kmp_copyright) + KMP_VERSION_MAGIC_LEN,
|
||||
0}, // Skip magic prefix.
|
||||
|
||||
/* Various globals. */
|
||||
addr_and_size_of( __kmp_threads ),
|
||||
addr_and_size_of( __kmp_root ),
|
||||
addr_and_size_of( __kmp_threads_capacity ),
|
||||
addr_and_size_of( __kmp_monitor ),
|
||||
#if ! KMP_USE_DYNAMIC_LOCK
|
||||
addr_and_size_of( __kmp_user_lock_table ),
|
||||
addr_and_size_of(__kmp_threads),
|
||||
addr_and_size_of(__kmp_root),
|
||||
addr_and_size_of(__kmp_threads_capacity),
|
||||
addr_and_size_of(__kmp_monitor),
|
||||
#if !KMP_USE_DYNAMIC_LOCK
|
||||
addr_and_size_of(__kmp_user_lock_table),
|
||||
#endif
|
||||
addr_and_size_of( func_microtask ),
|
||||
addr_and_size_of( func_fork ),
|
||||
addr_and_size_of( func_fork_teams ),
|
||||
addr_and_size_of( __kmp_team_counter ),
|
||||
addr_and_size_of( __kmp_task_counter ),
|
||||
addr_and_size_of( kmp_omp_nthr_info_buffer ),
|
||||
sizeof( void * ),
|
||||
addr_and_size_of(func_microtask),
|
||||
addr_and_size_of(func_fork),
|
||||
addr_and_size_of(func_fork_teams),
|
||||
addr_and_size_of(__kmp_team_counter),
|
||||
addr_and_size_of(__kmp_task_counter),
|
||||
addr_and_size_of(kmp_omp_nthr_info_buffer),
|
||||
sizeof(void *),
|
||||
OMP_LOCK_T_SIZE < sizeof(void *),
|
||||
bs_last_barrier,
|
||||
INITIAL_TASK_DEQUE_SIZE,
|
||||
|
||||
// thread structure information
|
||||
sizeof( kmp_base_info_t ),
|
||||
offset_and_size_of( kmp_base_info_t, th_info ),
|
||||
offset_and_size_of( kmp_base_info_t, th_team ),
|
||||
offset_and_size_of( kmp_base_info_t, th_root ),
|
||||
offset_and_size_of( kmp_base_info_t, th_serial_team ),
|
||||
offset_and_size_of( kmp_base_info_t, th_ident ),
|
||||
offset_and_size_of( kmp_base_info_t, th_spin_here ),
|
||||
offset_and_size_of( kmp_base_info_t, th_next_waiting ),
|
||||
offset_and_size_of( kmp_base_info_t, th_task_team ),
|
||||
offset_and_size_of( kmp_base_info_t, th_current_task ),
|
||||
offset_and_size_of( kmp_base_info_t, th_task_state ),
|
||||
offset_and_size_of( kmp_base_info_t, th_bar ),
|
||||
offset_and_size_of( kmp_bstate_t, b_worker_arrived ),
|
||||
sizeof(kmp_base_info_t),
|
||||
offset_and_size_of(kmp_base_info_t, th_info),
|
||||
offset_and_size_of(kmp_base_info_t, th_team),
|
||||
offset_and_size_of(kmp_base_info_t, th_root),
|
||||
offset_and_size_of(kmp_base_info_t, th_serial_team),
|
||||
offset_and_size_of(kmp_base_info_t, th_ident),
|
||||
offset_and_size_of(kmp_base_info_t, th_spin_here),
|
||||
offset_and_size_of(kmp_base_info_t, th_next_waiting),
|
||||
offset_and_size_of(kmp_base_info_t, th_task_team),
|
||||
offset_and_size_of(kmp_base_info_t, th_current_task),
|
||||
offset_and_size_of(kmp_base_info_t, th_task_state),
|
||||
offset_and_size_of(kmp_base_info_t, th_bar),
|
||||
offset_and_size_of(kmp_bstate_t, b_worker_arrived),
|
||||
|
||||
#if OMP_40_ENABLED
|
||||
// teams information
|
||||
offset_and_size_of( kmp_base_info_t, th_teams_microtask),
|
||||
offset_and_size_of( kmp_base_info_t, th_teams_level),
|
||||
offset_and_size_of( kmp_teams_size_t, nteams ),
|
||||
offset_and_size_of( kmp_teams_size_t, nth ),
|
||||
offset_and_size_of(kmp_base_info_t, th_teams_microtask),
|
||||
offset_and_size_of(kmp_base_info_t, th_teams_level),
|
||||
offset_and_size_of(kmp_teams_size_t, nteams),
|
||||
offset_and_size_of(kmp_teams_size_t, nth),
|
||||
#endif
|
||||
|
||||
// kmp_desc structure (for info field above)
|
||||
sizeof( kmp_desc_base_t ),
|
||||
offset_and_size_of( kmp_desc_base_t, ds_tid ),
|
||||
offset_and_size_of( kmp_desc_base_t, ds_gtid ),
|
||||
// On Windows* OS, ds_thread contains a thread /handle/, which is not usable, while thread /id/
|
||||
// is in ds_thread_id.
|
||||
#if KMP_OS_WINDOWS
|
||||
offset_and_size_of( kmp_desc_base_t, ds_thread_id),
|
||||
#else
|
||||
offset_and_size_of( kmp_desc_base_t, ds_thread),
|
||||
#endif
|
||||
sizeof(kmp_desc_base_t),
|
||||
offset_and_size_of(kmp_desc_base_t, ds_tid),
|
||||
offset_and_size_of(kmp_desc_base_t, ds_gtid),
|
||||
// On Windows* OS, ds_thread contains a thread /handle/, which is not usable,
|
||||
// while thread /id/ is in ds_thread_id.
|
||||
#if KMP_OS_WINDOWS
|
||||
offset_and_size_of(kmp_desc_base_t, ds_thread_id),
|
||||
#else
|
||||
offset_and_size_of(kmp_desc_base_t, ds_thread),
|
||||
#endif
|
||||
|
||||
// team structure information
|
||||
sizeof( kmp_base_team_t ),
|
||||
offset_and_size_of( kmp_base_team_t, t_master_tid ),
|
||||
offset_and_size_of( kmp_base_team_t, t_ident ),
|
||||
offset_and_size_of( kmp_base_team_t, t_parent ),
|
||||
offset_and_size_of( kmp_base_team_t, t_nproc ),
|
||||
offset_and_size_of( kmp_base_team_t, t_threads ),
|
||||
offset_and_size_of( kmp_base_team_t, t_serialized ),
|
||||
offset_and_size_of( kmp_base_team_t, t_id ),
|
||||
offset_and_size_of( kmp_base_team_t, t_pkfn ),
|
||||
offset_and_size_of( kmp_base_team_t, t_task_team ),
|
||||
offset_and_size_of( kmp_base_team_t, t_implicit_task_taskdata ),
|
||||
sizeof(kmp_base_team_t),
|
||||
offset_and_size_of(kmp_base_team_t, t_master_tid),
|
||||
offset_and_size_of(kmp_base_team_t, t_ident),
|
||||
offset_and_size_of(kmp_base_team_t, t_parent),
|
||||
offset_and_size_of(kmp_base_team_t, t_nproc),
|
||||
offset_and_size_of(kmp_base_team_t, t_threads),
|
||||
offset_and_size_of(kmp_base_team_t, t_serialized),
|
||||
offset_and_size_of(kmp_base_team_t, t_id),
|
||||
offset_and_size_of(kmp_base_team_t, t_pkfn),
|
||||
offset_and_size_of(kmp_base_team_t, t_task_team),
|
||||
offset_and_size_of(kmp_base_team_t, t_implicit_task_taskdata),
|
||||
#if OMP_40_ENABLED
|
||||
offset_and_size_of( kmp_base_team_t, t_cancel_request ),
|
||||
offset_and_size_of(kmp_base_team_t, t_cancel_request),
|
||||
#endif
|
||||
offset_and_size_of( kmp_base_team_t, t_bar ),
|
||||
offset_and_size_of( kmp_balign_team_t, b_master_arrived ),
|
||||
offset_and_size_of( kmp_balign_team_t, b_team_arrived ),
|
||||
offset_and_size_of(kmp_base_team_t, t_bar),
|
||||
offset_and_size_of(kmp_balign_team_t, b_master_arrived),
|
||||
offset_and_size_of(kmp_balign_team_t, b_team_arrived),
|
||||
|
||||
// root structure information
|
||||
sizeof( kmp_base_root_t ),
|
||||
offset_and_size_of( kmp_base_root_t, r_root_team ),
|
||||
offset_and_size_of( kmp_base_root_t, r_hot_team ),
|
||||
offset_and_size_of( kmp_base_root_t, r_uber_thread ),
|
||||
sizeof(kmp_base_root_t),
|
||||
offset_and_size_of(kmp_base_root_t, r_root_team),
|
||||
offset_and_size_of(kmp_base_root_t, r_hot_team),
|
||||
offset_and_size_of(kmp_base_root_t, r_uber_thread),
|
||||
offset_and_size_not_available,
|
||||
|
||||
// ident structure information
|
||||
sizeof( ident_t ),
|
||||
offset_and_size_of( ident_t, psource ),
|
||||
offset_and_size_of( ident_t, flags ),
|
||||
sizeof(ident_t),
|
||||
offset_and_size_of(ident_t, psource),
|
||||
offset_and_size_of(ident_t, flags),
|
||||
|
||||
// lock structure information
|
||||
sizeof( kmp_base_queuing_lock_t ),
|
||||
offset_and_size_of( kmp_base_queuing_lock_t, initialized ),
|
||||
offset_and_size_of( kmp_base_queuing_lock_t, location ),
|
||||
offset_and_size_of( kmp_base_queuing_lock_t, tail_id ),
|
||||
offset_and_size_of( kmp_base_queuing_lock_t, head_id ),
|
||||
offset_and_size_of( kmp_base_queuing_lock_t, next_ticket ),
|
||||
offset_and_size_of( kmp_base_queuing_lock_t, now_serving ),
|
||||
offset_and_size_of( kmp_base_queuing_lock_t, owner_id ),
|
||||
offset_and_size_of( kmp_base_queuing_lock_t, depth_locked ),
|
||||
offset_and_size_of( kmp_base_queuing_lock_t, flags ),
|
||||
sizeof(kmp_base_queuing_lock_t),
|
||||
offset_and_size_of(kmp_base_queuing_lock_t, initialized),
|
||||
offset_and_size_of(kmp_base_queuing_lock_t, location),
|
||||
offset_and_size_of(kmp_base_queuing_lock_t, tail_id),
|
||||
offset_and_size_of(kmp_base_queuing_lock_t, head_id),
|
||||
offset_and_size_of(kmp_base_queuing_lock_t, next_ticket),
|
||||
offset_and_size_of(kmp_base_queuing_lock_t, now_serving),
|
||||
offset_and_size_of(kmp_base_queuing_lock_t, owner_id),
|
||||
offset_and_size_of(kmp_base_queuing_lock_t, depth_locked),
|
||||
offset_and_size_of(kmp_base_queuing_lock_t, flags),
|
||||
|
||||
#if ! KMP_USE_DYNAMIC_LOCK
|
||||
#if !KMP_USE_DYNAMIC_LOCK
|
||||
/* Lock table. */
|
||||
sizeof( kmp_lock_table_t ),
|
||||
offset_and_size_of( kmp_lock_table_t, used ),
|
||||
offset_and_size_of( kmp_lock_table_t, allocated ),
|
||||
offset_and_size_of( kmp_lock_table_t, table ),
|
||||
sizeof(kmp_lock_table_t),
|
||||
offset_and_size_of(kmp_lock_table_t, used),
|
||||
offset_and_size_of(kmp_lock_table_t, allocated),
|
||||
offset_and_size_of(kmp_lock_table_t, table),
|
||||
#endif
|
||||
|
||||
// Task team structure information.
|
||||
sizeof( kmp_base_task_team_t ),
|
||||
offset_and_size_of( kmp_base_task_team_t, tt_threads_data ),
|
||||
offset_and_size_of( kmp_base_task_team_t, tt_found_tasks ),
|
||||
offset_and_size_of( kmp_base_task_team_t, tt_nproc ),
|
||||
offset_and_size_of( kmp_base_task_team_t, tt_unfinished_threads ),
|
||||
offset_and_size_of( kmp_base_task_team_t, tt_active ),
|
||||
sizeof(kmp_base_task_team_t),
|
||||
offset_and_size_of(kmp_base_task_team_t, tt_threads_data),
|
||||
offset_and_size_of(kmp_base_task_team_t, tt_found_tasks),
|
||||
offset_and_size_of(kmp_base_task_team_t, tt_nproc),
|
||||
offset_and_size_of(kmp_base_task_team_t, tt_unfinished_threads),
|
||||
offset_and_size_of(kmp_base_task_team_t, tt_active),
|
||||
|
||||
// task_data_t.
|
||||
sizeof( kmp_taskdata_t ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_task_id ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_flags ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_team ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_parent ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_level ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_ident ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_allocated_child_tasks ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_incomplete_child_tasks ),
|
||||
sizeof(kmp_taskdata_t),
|
||||
offset_and_size_of(kmp_taskdata_t, td_task_id),
|
||||
offset_and_size_of(kmp_taskdata_t, td_flags),
|
||||
offset_and_size_of(kmp_taskdata_t, td_team),
|
||||
offset_and_size_of(kmp_taskdata_t, td_parent),
|
||||
offset_and_size_of(kmp_taskdata_t, td_level),
|
||||
offset_and_size_of(kmp_taskdata_t, td_ident),
|
||||
offset_and_size_of(kmp_taskdata_t, td_allocated_child_tasks),
|
||||
offset_and_size_of(kmp_taskdata_t, td_incomplete_child_tasks),
|
||||
|
||||
offset_and_size_of( kmp_taskdata_t, td_taskwait_ident ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_taskwait_counter ),
|
||||
offset_and_size_of( kmp_taskdata_t, td_taskwait_thread ),
|
||||
offset_and_size_of(kmp_taskdata_t, td_taskwait_ident),
|
||||
offset_and_size_of(kmp_taskdata_t, td_taskwait_counter),
|
||||
offset_and_size_of(kmp_taskdata_t, td_taskwait_thread),
|
||||
|
||||
#if OMP_40_ENABLED
|
||||
offset_and_size_of( kmp_taskdata_t, td_taskgroup ),
|
||||
offset_and_size_of( kmp_taskgroup_t, count ),
|
||||
offset_and_size_of( kmp_taskgroup_t, cancel_request ),
|
||||
offset_and_size_of(kmp_taskdata_t, td_taskgroup),
|
||||
offset_and_size_of(kmp_taskgroup_t, count),
|
||||
offset_and_size_of(kmp_taskgroup_t, cancel_request),
|
||||
|
||||
offset_and_size_of( kmp_taskdata_t, td_depnode ),
|
||||
offset_and_size_of( kmp_depnode_list_t, node ),
|
||||
offset_and_size_of( kmp_depnode_list_t, next ),
|
||||
offset_and_size_of( kmp_base_depnode_t, successors ),
|
||||
offset_and_size_of( kmp_base_depnode_t, task ),
|
||||
offset_and_size_of( kmp_base_depnode_t, npredecessors ),
|
||||
offset_and_size_of( kmp_base_depnode_t, nrefs ),
|
||||
offset_and_size_of(kmp_taskdata_t, td_depnode),
|
||||
offset_and_size_of(kmp_depnode_list_t, node),
|
||||
offset_and_size_of(kmp_depnode_list_t, next),
|
||||
offset_and_size_of(kmp_base_depnode_t, successors),
|
||||
offset_and_size_of(kmp_base_depnode_t, task),
|
||||
offset_and_size_of(kmp_base_depnode_t, npredecessors),
|
||||
offset_and_size_of(kmp_base_depnode_t, nrefs),
|
||||
#endif
|
||||
offset_and_size_of( kmp_task_t, routine ),
|
||||
offset_and_size_of(kmp_task_t, routine),
|
||||
|
||||
// thread_data_t.
|
||||
sizeof( kmp_thread_data_t ),
|
||||
offset_and_size_of( kmp_base_thread_data_t, td_deque ),
|
||||
offset_and_size_of( kmp_base_thread_data_t, td_deque_size ),
|
||||
offset_and_size_of( kmp_base_thread_data_t, td_deque_head ),
|
||||
offset_and_size_of( kmp_base_thread_data_t, td_deque_tail ),
|
||||
offset_and_size_of( kmp_base_thread_data_t, td_deque_ntasks ),
|
||||
offset_and_size_of( kmp_base_thread_data_t, td_deque_last_stolen ),
|
||||
sizeof(kmp_thread_data_t),
|
||||
offset_and_size_of(kmp_base_thread_data_t, td_deque),
|
||||
offset_and_size_of(kmp_base_thread_data_t, td_deque_size),
|
||||
offset_and_size_of(kmp_base_thread_data_t, td_deque_head),
|
||||
offset_and_size_of(kmp_base_thread_data_t, td_deque_tail),
|
||||
offset_and_size_of(kmp_base_thread_data_t, td_deque_ntasks),
|
||||
offset_and_size_of(kmp_base_thread_data_t, td_deque_last_stolen),
|
||||
|
||||
// The last field.
|
||||
KMP_OMP_VERSION,
|
||||
|
|
@ -236,80 +226,66 @@ __kmp_omp_debug_struct_info = {
|
|||
#undef offset_and_size_of
|
||||
#undef addr_and_size_of
|
||||
|
||||
/*
|
||||
Intel compiler on IA-32 architecture issues a warning "conversion
|
||||
/* Intel compiler on IA-32 architecture issues a warning "conversion
|
||||
from "unsigned long long" to "char *" may lose significant bits"
|
||||
when 64-bit value is assigned to 32-bit pointer. Use this function
|
||||
to suppress the warning.
|
||||
*/
|
||||
static inline
|
||||
void *
|
||||
__kmp_convert_to_ptr(
|
||||
kmp_uint64 addr
|
||||
) {
|
||||
#if KMP_COMPILER_ICC
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 810 ) // conversion from "unsigned long long" to "char *" may lose significant bits
|
||||
#pragma warning( disable: 1195 ) // conversion from integer to smaller pointer
|
||||
#endif // KMP_COMPILER_ICC
|
||||
return (void *) addr;
|
||||
#if KMP_COMPILER_ICC
|
||||
#pragma warning( pop )
|
||||
#endif // KMP_COMPILER_ICC
|
||||
to suppress the warning. */
|
||||
static inline void *__kmp_convert_to_ptr(kmp_uint64 addr) {
|
||||
#if KMP_COMPILER_ICC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 810) // conversion from "unsigned long long" to "char
|
||||
// *" may lose significant bits
|
||||
#pragma warning(disable : 1195) // conversion from integer to smaller pointer
|
||||
#endif // KMP_COMPILER_ICC
|
||||
return (void *)addr;
|
||||
#if KMP_COMPILER_ICC
|
||||
#pragma warning(pop)
|
||||
#endif // KMP_COMPILER_ICC
|
||||
} // __kmp_convert_to_ptr
|
||||
|
||||
static int kmp_location_match(kmp_str_loc_t *loc, kmp_omp_nthr_item_t *item) {
|
||||
|
||||
static int
|
||||
kmp_location_match(
|
||||
kmp_str_loc_t * loc,
|
||||
kmp_omp_nthr_item_t * item
|
||||
) {
|
||||
int file_match = 0;
|
||||
int func_match = 0;
|
||||
int line_match = 0;
|
||||
|
||||
int file_match = 0;
|
||||
int func_match = 0;
|
||||
int line_match = 0;
|
||||
char *file = (char *)__kmp_convert_to_ptr(item->file);
|
||||
char *func = (char *)__kmp_convert_to_ptr(item->func);
|
||||
file_match = __kmp_str_fname_match(&loc->fname, file);
|
||||
func_match =
|
||||
item->func == 0 // If item->func is NULL, it allows any func name.
|
||||
|| strcmp(func, "*") == 0 ||
|
||||
(loc->func != NULL && strcmp(loc->func, func) == 0);
|
||||
line_match =
|
||||
item->begin <= loc->line &&
|
||||
(item->end <= 0 ||
|
||||
loc->line <= item->end); // if item->end <= 0, it means "end of file".
|
||||
|
||||
char * file = (char *) __kmp_convert_to_ptr( item->file );
|
||||
char * func = (char *) __kmp_convert_to_ptr( item->func );
|
||||
file_match = __kmp_str_fname_match( & loc->fname, file );
|
||||
func_match =
|
||||
item->func == 0 // If item->func is NULL, it allows any func name.
|
||||
||
|
||||
strcmp( func, "*" ) == 0
|
||||
||
|
||||
( loc->func != NULL && strcmp( loc->func, func ) == 0 );
|
||||
line_match =
|
||||
item->begin <= loc->line
|
||||
&&
|
||||
( item->end <= 0 || loc->line <= item->end ); // if item->end <= 0, it means "end of file".
|
||||
|
||||
return ( file_match && func_match && line_match );
|
||||
return (file_match && func_match && line_match);
|
||||
|
||||
} // kmp_location_match
|
||||
|
||||
int __kmp_omp_num_threads(ident_t const *ident) {
|
||||
|
||||
int
|
||||
__kmp_omp_num_threads(
|
||||
ident_t const * ident
|
||||
) {
|
||||
int num_threads = 0;
|
||||
|
||||
int num_threads = 0;
|
||||
kmp_omp_nthr_info_t *info = (kmp_omp_nthr_info_t *)__kmp_convert_to_ptr(
|
||||
__kmp_omp_debug_struct_info.nthr_info.addr);
|
||||
if (info->num > 0 && info->array != 0) {
|
||||
kmp_omp_nthr_item_t *items =
|
||||
(kmp_omp_nthr_item_t *)__kmp_convert_to_ptr(info->array);
|
||||
kmp_str_loc_t loc = __kmp_str_loc_init(ident->psource, 1);
|
||||
int i;
|
||||
for (i = 0; i < info->num; ++i) {
|
||||
if (kmp_location_match(&loc, &items[i])) {
|
||||
num_threads = items[i].num_threads;
|
||||
}; // if
|
||||
}; // for
|
||||
__kmp_str_loc_free(&loc);
|
||||
}; // if
|
||||
|
||||
kmp_omp_nthr_info_t * info =
|
||||
(kmp_omp_nthr_info_t *) __kmp_convert_to_ptr( __kmp_omp_debug_struct_info.nthr_info.addr );
|
||||
if ( info->num > 0 && info->array != 0 ) {
|
||||
kmp_omp_nthr_item_t * items = (kmp_omp_nthr_item_t *) __kmp_convert_to_ptr( info->array );
|
||||
kmp_str_loc_t loc = __kmp_str_loc_init( ident->psource, 1 );
|
||||
int i;
|
||||
for ( i = 0; i < info->num; ++ i ) {
|
||||
if ( kmp_location_match( & loc, & items[ i ] ) ) {
|
||||
num_threads = items[ i ].num_threads;
|
||||
}; // if
|
||||
}; // for
|
||||
__kmp_str_loc_free( & loc );
|
||||
}; // if
|
||||
|
||||
return num_threads;;
|
||||
return num_threads;
|
||||
;
|
||||
|
||||
} // __kmp_omp_num_threads
|
||||
#endif /* USE_DEBUGGER */
|
||||
|
|
|
|||
|
|
@ -18,34 +18,34 @@
|
|||
#define KMP_DEBUGGER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/* * This external variable can be set by any debugger to flag to the runtime that we
|
||||
are currently executing inside a debugger. This will allow the debugger to override
|
||||
the number of threads spawned in a parallel region by using __kmp_omp_num_threads() (below).
|
||||
* When __kmp_debugging is TRUE, each team and each task gets a unique integer identifier
|
||||
that can be used by debugger to conveniently identify teams and tasks.
|
||||
* The debugger has access to __kmp_omp_debug_struct_info which contains information
|
||||
about the OpenMP library's important internal structures. This access will allow the debugger
|
||||
to read detailed information from the typical OpenMP constructs (teams, threads, tasking, etc. )
|
||||
during a debugging session and offer detailed and useful information which the user can probe
|
||||
about the OpenMP portion of their code.
|
||||
*/
|
||||
extern int __kmp_debugging; /* Boolean whether currently debugging OpenMP RTL */
|
||||
/* This external variable can be set by any debugger to flag to the runtime
|
||||
that we are currently executing inside a debugger. This will allow the
|
||||
debugger to override the number of threads spawned in a parallel region by
|
||||
using __kmp_omp_num_threads() (below).
|
||||
* When __kmp_debugging is TRUE, each team and each task gets a unique integer
|
||||
identifier that can be used by debugger to conveniently identify teams and
|
||||
tasks.
|
||||
* The debugger has access to __kmp_omp_debug_struct_info which contains
|
||||
information about the OpenMP library's important internal structures. This
|
||||
access will allow the debugger to read detailed information from the typical
|
||||
OpenMP constructs (teams, threads, tasking, etc. ) during a debugging
|
||||
session and offer detailed and useful information which the user can probe
|
||||
about the OpenMP portion of their code. */
|
||||
extern int __kmp_debugging; /* Boolean whether currently debugging OpenMP RTL */
|
||||
// Return number of threads specified by the debugger for given parallel region.
|
||||
/* The ident field, which represents a source file location, is used to check if the
|
||||
debugger has changed the number of threads for the parallel region at source file
|
||||
location ident. This way, specific parallel regions' number of threads can be changed
|
||||
at the debugger's request.
|
||||
*/
|
||||
int __kmp_omp_num_threads( ident_t const * ident );
|
||||
/* The ident field, which represents a source file location, is used to check if
|
||||
the debugger has changed the number of threads for the parallel region at
|
||||
source file location ident. This way, specific parallel regions' number of
|
||||
threads can be changed at the debugger's request. */
|
||||
int __kmp_omp_num_threads(ident_t const *ident);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#endif // KMP_DEBUGGER_H
|
||||
|
||||
#endif // USE_DEBUGGER
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -13,355 +13,297 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------------------------
|
||||
We use GetEnvironmentVariable for Windows* OS instead of getenv because the act of
|
||||
loading a DLL on Windows* OS makes any user-set environment variables (i.e. with putenv())
|
||||
unavailable. getenv() apparently gets a clean copy of the env variables as they existed
|
||||
at the start of the run.
|
||||
JH 12/23/2002
|
||||
------------------------------------------------------------------------------------------------
|
||||
On Windows* OS, there are two environments (at least, see below):
|
||||
/* We use GetEnvironmentVariable for Windows* OS instead of getenv because the
|
||||
act of loading a DLL on Windows* OS makes any user-set environment variables
|
||||
(i.e. with putenv()) unavailable. getenv() apparently gets a clean copy of
|
||||
the env variables as they existed at the start of the run. JH 12/23/2002
|
||||
|
||||
1. Environment maintained by Windows* OS on IA-32 architecture.
|
||||
Accessible through GetEnvironmentVariable(),
|
||||
SetEnvironmentVariable(), and GetEnvironmentStrings().
|
||||
On Windows* OS, there are two environments (at least, see below):
|
||||
|
||||
2. Environment maintained by C RTL. Accessible through getenv(), putenv().
|
||||
1. Environment maintained by Windows* OS on IA-32 architecture. Accessible
|
||||
through GetEnvironmentVariable(), SetEnvironmentVariable(), and
|
||||
GetEnvironmentStrings().
|
||||
|
||||
putenv() function updates both C and Windows* OS on IA-32 architecture. getenv() function
|
||||
search for variables in C RTL environment only. Windows* OS on IA-32 architecture functions work *only*
|
||||
with Windows* OS on IA-32 architecture.
|
||||
2. Environment maintained by C RTL. Accessible through getenv(), putenv().
|
||||
|
||||
Windows* OS on IA-32 architecture maintained by OS, so there is always only one Windows* OS on
|
||||
IA-32 architecture per process. Changes in Windows* OS on IA-32 architecture are process-visible.
|
||||
putenv() function updates both C and Windows* OS on IA-32 architecture.
|
||||
getenv() function search for variables in C RTL environment only.
|
||||
Windows* OS on IA-32 architecture functions work *only* with Windows* OS on
|
||||
IA-32 architecture.
|
||||
|
||||
C environment maintained by C RTL. Multiple copies of C RTL may be present in the process, and
|
||||
each C RTL maintains its own environment. :-(
|
||||
Windows* OS on IA-32 architecture maintained by OS, so there is always only
|
||||
one Windows* OS on IA-32 architecture per process. Changes in Windows* OS on
|
||||
IA-32 architecture are process-visible.
|
||||
|
||||
Thus, proper way to work with environment on Windows* OS is:
|
||||
C environment maintained by C RTL. Multiple copies of C RTL may be present
|
||||
in the process, and each C RTL maintains its own environment. :-(
|
||||
|
||||
1. Set variables with putenv() function -- both C and Windows* OS on
|
||||
IA-32 architecture are being updated. Windows* OS on
|
||||
IA-32 architecture may be considered as primary target,
|
||||
while updating C RTL environment is a free bonus.
|
||||
Thus, proper way to work with environment on Windows* OS is:
|
||||
|
||||
2. Get variables with GetEnvironmentVariable() -- getenv() does not
|
||||
search Windows* OS on IA-32 architecture, and can not see variables
|
||||
set with SetEnvironmentVariable().
|
||||
1. Set variables with putenv() function -- both C and Windows* OS on IA-32
|
||||
architecture are being updated. Windows* OS on IA-32 architecture may be
|
||||
considered primary target, while updating C RTL environment is free bonus.
|
||||
|
||||
2007-04-05 -- lev
|
||||
------------------------------------------------------------------------------------------------
|
||||
2. Get variables with GetEnvironmentVariable() -- getenv() does not
|
||||
search Windows* OS on IA-32 architecture, and can not see variables
|
||||
set with SetEnvironmentVariable().
|
||||
|
||||
2007-04-05 -- lev
|
||||
*/
|
||||
|
||||
#include "kmp_environment.h"
|
||||
|
||||
#include "kmp_os.h" // KMP_OS_*.
|
||||
#include "kmp.h" //
|
||||
#include "kmp_str.h" // __kmp_str_*().
|
||||
#include "kmp.h" //
|
||||
#include "kmp_i18n.h"
|
||||
#include "kmp_os.h" // KMP_OS_*.
|
||||
#include "kmp_str.h" // __kmp_str_*().
|
||||
|
||||
#if KMP_OS_UNIX
|
||||
#include <stdlib.h> // getenv, setenv, unsetenv.
|
||||
#include <string.h> // strlen, strcpy.
|
||||
#if KMP_OS_DARWIN
|
||||
#include <crt_externs.h>
|
||||
#define environ (*_NSGetEnviron())
|
||||
#else
|
||||
extern char * * environ;
|
||||
#endif
|
||||
#elif KMP_OS_WINDOWS
|
||||
#include <windows.h> // GetEnvironmentVariable, SetEnvironmentVariable, GetLastError.
|
||||
#include <stdlib.h> // getenv, setenv, unsetenv.
|
||||
#include <string.h> // strlen, strcpy.
|
||||
#if KMP_OS_DARWIN
|
||||
#include <crt_externs.h>
|
||||
#define environ (*_NSGetEnviron())
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
extern char **environ;
|
||||
#endif
|
||||
#elif KMP_OS_WINDOWS
|
||||
#include <windows.h> // GetEnvironmentVariable, SetEnvironmentVariable,
|
||||
// GetLastError.
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
|
||||
|
||||
// TODO: Eliminate direct memory allocations, use string operations instead.
|
||||
|
||||
static inline
|
||||
void *
|
||||
allocate(
|
||||
size_t size
|
||||
) {
|
||||
void * ptr = KMP_INTERNAL_MALLOC( size );
|
||||
if ( ptr == NULL ) {
|
||||
KMP_FATAL( MemoryAllocFailed );
|
||||
}; // if
|
||||
return ptr;
|
||||
static inline void *allocate(size_t size) {
|
||||
void *ptr = KMP_INTERNAL_MALLOC(size);
|
||||
if (ptr == NULL) {
|
||||
KMP_FATAL(MemoryAllocFailed);
|
||||
}; // if
|
||||
return ptr;
|
||||
} // allocate
|
||||
|
||||
char *__kmp_env_get(char const *name) {
|
||||
|
||||
char *
|
||||
__kmp_env_get( char const * name ) {
|
||||
char *result = NULL;
|
||||
|
||||
char * result = NULL;
|
||||
#if KMP_OS_UNIX
|
||||
char const *value = getenv(name);
|
||||
if (value != NULL) {
|
||||
size_t len = KMP_STRLEN(value) + 1;
|
||||
result = (char *)KMP_INTERNAL_MALLOC(len);
|
||||
if (result == NULL) {
|
||||
KMP_FATAL(MemoryAllocFailed);
|
||||
}; // if
|
||||
KMP_STRNCPY_S(result, len, value, len);
|
||||
}; // if
|
||||
#elif KMP_OS_WINDOWS
|
||||
/* We use GetEnvironmentVariable for Windows* OS instead of getenv because the
|
||||
act of loading a DLL on Windows* OS makes any user-set environment
|
||||
variables (i.e. with putenv()) unavailable. getenv() apparently gets a
|
||||
clean copy of the env variables as they existed at the start of the run.
|
||||
JH 12/23/2002 */
|
||||
DWORD rc;
|
||||
rc = GetEnvironmentVariable(name, NULL, 0);
|
||||
if (!rc) {
|
||||
DWORD error = GetLastError();
|
||||
if (error != ERROR_ENVVAR_NOT_FOUND) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
// Variable is not found, it's ok, just continue.
|
||||
} else {
|
||||
DWORD len = rc;
|
||||
result = (char *)KMP_INTERNAL_MALLOC(len);
|
||||
if (result == NULL) {
|
||||
KMP_FATAL(MemoryAllocFailed);
|
||||
}; // if
|
||||
rc = GetEnvironmentVariable(name, result, len);
|
||||
if (!rc) {
|
||||
// GetEnvironmentVariable() may return 0 if variable is empty.
|
||||
// In such a case GetLastError() returns ERROR_SUCCESS.
|
||||
DWORD error = GetLastError();
|
||||
if (error != ERROR_SUCCESS) {
|
||||
// Unexpected error. The variable should be in the environment,
|
||||
// and buffer should be large enough.
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
KMP_INTERNAL_FREE((void *)result);
|
||||
result = NULL;
|
||||
}; // if
|
||||
}; // if
|
||||
}; // if
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
|
||||
#if KMP_OS_UNIX
|
||||
char const * value = getenv( name );
|
||||
if ( value != NULL ) {
|
||||
size_t len = KMP_STRLEN( value ) + 1;
|
||||
result = (char *) KMP_INTERNAL_MALLOC( len );
|
||||
if ( result == NULL ) {
|
||||
KMP_FATAL( MemoryAllocFailed );
|
||||
}; // if
|
||||
KMP_STRNCPY_S( result, len, value, len );
|
||||
}; // if
|
||||
#elif KMP_OS_WINDOWS
|
||||
/*
|
||||
We use GetEnvironmentVariable for Windows* OS instead of getenv because the act of
|
||||
loading a DLL on Windows* OS makes any user-set environment variables (i.e. with putenv())
|
||||
unavailable. getenv() apparently gets a clean copy of the env variables as they existed
|
||||
at the start of the run.
|
||||
JH 12/23/2002
|
||||
*/
|
||||
DWORD rc;
|
||||
rc = GetEnvironmentVariable( name, NULL, 0 );
|
||||
if ( ! rc ) {
|
||||
DWORD error = GetLastError();
|
||||
if ( error != ERROR_ENVVAR_NOT_FOUND ) {
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal,
|
||||
KMP_MSG( CantGetEnvVar, name ),
|
||||
KMP_ERR( error ),
|
||||
__kmp_msg_null
|
||||
);
|
||||
}; // if
|
||||
// Variable is not found, it's ok, just continue.
|
||||
} else {
|
||||
DWORD len = rc;
|
||||
result = (char *) KMP_INTERNAL_MALLOC( len );
|
||||
if ( result == NULL ) {
|
||||
KMP_FATAL( MemoryAllocFailed );
|
||||
}; // if
|
||||
rc = GetEnvironmentVariable( name, result, len );
|
||||
if ( ! rc ) {
|
||||
// GetEnvironmentVariable() may return 0 if variable is empty.
|
||||
// In such a case GetLastError() returns ERROR_SUCCESS.
|
||||
DWORD error = GetLastError();
|
||||
if ( error != ERROR_SUCCESS ) {
|
||||
// Unexpected error. The variable should be in the environment,
|
||||
// and buffer should be large enough.
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal,
|
||||
KMP_MSG( CantGetEnvVar, name ),
|
||||
KMP_ERR( error ),
|
||||
__kmp_msg_null
|
||||
);
|
||||
KMP_INTERNAL_FREE( (void *) result );
|
||||
result = NULL;
|
||||
}; // if
|
||||
}; // if
|
||||
}; // if
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
|
||||
return result;
|
||||
return result;
|
||||
|
||||
} // func __kmp_env_get
|
||||
|
||||
|
||||
// TODO: Find and replace all regular free() with __kmp_env_free().
|
||||
|
||||
void
|
||||
__kmp_env_free( char const * * value ) {
|
||||
void __kmp_env_free(char const **value) {
|
||||
|
||||
KMP_DEBUG_ASSERT( value != NULL );
|
||||
KMP_INTERNAL_FREE( (void *) * value );
|
||||
* value = NULL;
|
||||
KMP_DEBUG_ASSERT(value != NULL);
|
||||
KMP_INTERNAL_FREE((void *)*value);
|
||||
*value = NULL;
|
||||
|
||||
} // func __kmp_env_free
|
||||
|
||||
int __kmp_env_exists(char const *name) {
|
||||
|
||||
|
||||
int
|
||||
__kmp_env_exists( char const * name ) {
|
||||
|
||||
#if KMP_OS_UNIX
|
||||
char const * value = getenv( name );
|
||||
return ( ( value == NULL ) ? ( 0 ) : ( 1 ) );
|
||||
#elif KMP_OS_WINDOWS
|
||||
DWORD rc;
|
||||
rc = GetEnvironmentVariable( name, NULL, 0 );
|
||||
if ( rc == 0 ) {
|
||||
DWORD error = GetLastError();
|
||||
if ( error != ERROR_ENVVAR_NOT_FOUND ) {
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal,
|
||||
KMP_MSG( CantGetEnvVar, name ),
|
||||
KMP_ERR( error ),
|
||||
__kmp_msg_null
|
||||
);
|
||||
}; // if
|
||||
return 0;
|
||||
}; // if
|
||||
return 1;
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
#if KMP_OS_UNIX
|
||||
char const *value = getenv(name);
|
||||
return ((value == NULL) ? (0) : (1));
|
||||
#elif KMP_OS_WINDOWS
|
||||
DWORD rc;
|
||||
rc = GetEnvironmentVariable(name, NULL, 0);
|
||||
if (rc == 0) {
|
||||
DWORD error = GetLastError();
|
||||
if (error != ERROR_ENVVAR_NOT_FOUND) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
return 0;
|
||||
}; // if
|
||||
return 1;
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
|
||||
} // func __kmp_env_exists
|
||||
|
||||
void __kmp_env_set(char const *name, char const *value, int overwrite) {
|
||||
|
||||
|
||||
void
|
||||
__kmp_env_set( char const * name, char const * value, int overwrite ) {
|
||||
|
||||
#if KMP_OS_UNIX
|
||||
int rc = setenv( name, value, overwrite );
|
||||
if ( rc != 0 ) {
|
||||
// Dead code. I tried to put too many variables into Linux* OS
|
||||
// environment on IA-32 architecture. When application consumes
|
||||
// more than ~2.5 GB of memory, entire system feels bad. Sometimes
|
||||
// application is killed (by OS?), sometimes system stops
|
||||
// responding... But this error message never appears. --ln
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal,
|
||||
KMP_MSG( CantSetEnvVar, name ),
|
||||
KMP_HNT( NotEnoughMemory ),
|
||||
__kmp_msg_null
|
||||
);
|
||||
}; // if
|
||||
#elif KMP_OS_WINDOWS
|
||||
BOOL rc;
|
||||
if ( ! overwrite ) {
|
||||
rc = GetEnvironmentVariable( name, NULL, 0 );
|
||||
if ( rc ) {
|
||||
// Variable exists, do not overwrite.
|
||||
return;
|
||||
}; // if
|
||||
DWORD error = GetLastError();
|
||||
if ( error != ERROR_ENVVAR_NOT_FOUND ) {
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal,
|
||||
KMP_MSG( CantGetEnvVar, name ),
|
||||
KMP_ERR( error ),
|
||||
__kmp_msg_null
|
||||
);
|
||||
}; // if
|
||||
}; // if
|
||||
rc = SetEnvironmentVariable( name, value );
|
||||
if ( ! rc ) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal,
|
||||
KMP_MSG( CantSetEnvVar, name ),
|
||||
KMP_ERR( error ),
|
||||
__kmp_msg_null
|
||||
);
|
||||
}; // if
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
#if KMP_OS_UNIX
|
||||
int rc = setenv(name, value, overwrite);
|
||||
if (rc != 0) {
|
||||
// Dead code. I tried to put too many variables into Linux* OS
|
||||
// environment on IA-32 architecture. When application consumes
|
||||
// more than ~2.5 GB of memory, entire system feels bad. Sometimes
|
||||
// application is killed (by OS?), sometimes system stops
|
||||
// responding... But this error message never appears. --ln
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEnvVar, name),
|
||||
KMP_HNT(NotEnoughMemory), __kmp_msg_null);
|
||||
}; // if
|
||||
#elif KMP_OS_WINDOWS
|
||||
BOOL rc;
|
||||
if (!overwrite) {
|
||||
rc = GetEnvironmentVariable(name, NULL, 0);
|
||||
if (rc) {
|
||||
// Variable exists, do not overwrite.
|
||||
return;
|
||||
}; // if
|
||||
DWORD error = GetLastError();
|
||||
if (error != ERROR_ENVVAR_NOT_FOUND) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
}; // if
|
||||
rc = SetEnvironmentVariable(name, value);
|
||||
if (!rc) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
|
||||
} // func __kmp_env_set
|
||||
|
||||
void __kmp_env_unset(char const *name) {
|
||||
|
||||
|
||||
void
|
||||
__kmp_env_unset( char const * name ) {
|
||||
|
||||
#if KMP_OS_UNIX
|
||||
unsetenv( name );
|
||||
#elif KMP_OS_WINDOWS
|
||||
BOOL rc = SetEnvironmentVariable( name, NULL );
|
||||
if ( ! rc ) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal,
|
||||
KMP_MSG( CantSetEnvVar, name ),
|
||||
KMP_ERR( error ),
|
||||
__kmp_msg_null
|
||||
);
|
||||
}; // if
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
#if KMP_OS_UNIX
|
||||
unsetenv(name);
|
||||
#elif KMP_OS_WINDOWS
|
||||
BOOL rc = SetEnvironmentVariable(name, NULL);
|
||||
if (!rc) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
|
||||
} // func __kmp_env_unset
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Intel OpenMP RTL string representation of environment: just a string of characters, variables
|
||||
are separated with vertical bars, e. g.:
|
||||
/* Intel OpenMP RTL string representation of environment: just a string of
|
||||
characters, variables are separated with vertical bars, e. g.:
|
||||
|
||||
"KMP_WARNINGS=0|KMP_AFFINITY=compact|"
|
||||
|
||||
Empty variables are allowed and ignored:
|
||||
|
||||
"||KMP_WARNINGS=1||"
|
||||
|
||||
*/
|
||||
|
||||
static
|
||||
void
|
||||
___kmp_env_blk_parse_string(
|
||||
kmp_env_blk_t * block, // M: Env block to fill.
|
||||
char const * env // I: String to parse.
|
||||
) {
|
||||
static void
|
||||
___kmp_env_blk_parse_string(kmp_env_blk_t *block, // M: Env block to fill.
|
||||
char const *env // I: String to parse.
|
||||
) {
|
||||
|
||||
char const chr_delimiter = '|';
|
||||
char const str_delimiter[] = { chr_delimiter, 0 };
|
||||
char const chr_delimiter = '|';
|
||||
char const str_delimiter[] = {chr_delimiter, 0};
|
||||
|
||||
char * bulk = NULL;
|
||||
kmp_env_var_t * vars = NULL;
|
||||
int count = 0; // Number of used elements in vars array.
|
||||
int delimiters = 0; // Number of delimiters in input string.
|
||||
char *bulk = NULL;
|
||||
kmp_env_var_t *vars = NULL;
|
||||
int count = 0; // Number of used elements in vars array.
|
||||
int delimiters = 0; // Number of delimiters in input string.
|
||||
|
||||
// Copy original string, we will modify the copy.
|
||||
bulk = __kmp_str_format( "%s", env );
|
||||
// Copy original string, we will modify the copy.
|
||||
bulk = __kmp_str_format("%s", env);
|
||||
|
||||
// Loop thru all the vars in environment block. Count delimiters (maximum number of variables
|
||||
// is number of delimiters plus one).
|
||||
{
|
||||
char const * ptr = bulk;
|
||||
for ( ; ; ) {
|
||||
ptr = strchr( ptr, chr_delimiter );
|
||||
if ( ptr == NULL ) {
|
||||
break;
|
||||
}; // if
|
||||
++ delimiters;
|
||||
ptr += 1;
|
||||
}; // forever
|
||||
}
|
||||
// Loop thru all the vars in environment block. Count delimiters (maximum
|
||||
// number of variables is number of delimiters plus one).
|
||||
{
|
||||
char const *ptr = bulk;
|
||||
for (;;) {
|
||||
ptr = strchr(ptr, chr_delimiter);
|
||||
if (ptr == NULL) {
|
||||
break;
|
||||
}; // if
|
||||
++delimiters;
|
||||
ptr += 1;
|
||||
}; // forever
|
||||
}
|
||||
|
||||
// Allocate vars array.
|
||||
vars = (kmp_env_var_t *) allocate( ( delimiters + 1 ) * sizeof( kmp_env_var_t ) );
|
||||
// Allocate vars array.
|
||||
vars = (kmp_env_var_t *)allocate((delimiters + 1) * sizeof(kmp_env_var_t));
|
||||
|
||||
// Loop thru all the variables.
|
||||
{
|
||||
char * var; // Pointer to variable (both name and value).
|
||||
char * name; // Pointer to name of variable.
|
||||
char * value; // Pointer to value.
|
||||
char * buf; // Buffer for __kmp_str_token() function.
|
||||
var = __kmp_str_token( bulk, str_delimiter, & buf ); // Get the first var.
|
||||
while ( var != NULL ) {
|
||||
// Save found variable in vars array.
|
||||
__kmp_str_split( var, '=', & name, & value );
|
||||
KMP_DEBUG_ASSERT( count < delimiters + 1 );
|
||||
vars[ count ].name = name;
|
||||
vars[ count ].value = value;
|
||||
++ count;
|
||||
// Get the next var.
|
||||
var = __kmp_str_token( NULL, str_delimiter, & buf );
|
||||
}; // while
|
||||
}
|
||||
// Loop thru all the variables.
|
||||
{
|
||||
char *var; // Pointer to variable (both name and value).
|
||||
char *name; // Pointer to name of variable.
|
||||
char *value; // Pointer to value.
|
||||
char *buf; // Buffer for __kmp_str_token() function.
|
||||
var = __kmp_str_token(bulk, str_delimiter, &buf); // Get the first var.
|
||||
while (var != NULL) {
|
||||
// Save found variable in vars array.
|
||||
__kmp_str_split(var, '=', &name, &value);
|
||||
KMP_DEBUG_ASSERT(count < delimiters + 1);
|
||||
vars[count].name = name;
|
||||
vars[count].value = value;
|
||||
++count;
|
||||
// Get the next var.
|
||||
var = __kmp_str_token(NULL, str_delimiter, &buf);
|
||||
}; // while
|
||||
}
|
||||
|
||||
// Fill out result.
|
||||
block->bulk = bulk;
|
||||
block->vars = vars;
|
||||
block->count = count;
|
||||
// Fill out result.
|
||||
block->bulk = bulk;
|
||||
block->vars = vars;
|
||||
block->count = count;
|
||||
|
||||
}; // ___kmp_env_blk_parse_string
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Windows* OS (actually, DOS) environment block is a piece of memory with environment variables. Each
|
||||
variable is terminated with zero byte, entire block is terminated with one extra zero byte, so
|
||||
we have two zero bytes at the end of environment block, e. g.:
|
||||
/* Windows* OS (actually, DOS) environment block is a piece of memory with
|
||||
environment variables. Each variable is terminated with zero byte, entire
|
||||
block is terminated with one extra zero byte, so we have two zero bytes at
|
||||
the end of environment block, e. g.:
|
||||
|
||||
"HOME=C:\\users\\lev\x00OS=Windows_NT\x00\x00"
|
||||
|
||||
|
|
@ -369,227 +311,201 @@ ___kmp_env_blk_parse_string(
|
|||
*/
|
||||
|
||||
#if KMP_OS_WINDOWS
|
||||
static
|
||||
void
|
||||
___kmp_env_blk_parse_windows(
|
||||
kmp_env_blk_t * block, // M: Env block to fill.
|
||||
char const * env // I: Pointer to Windows* OS (DOS) environment block.
|
||||
) {
|
||||
static void ___kmp_env_blk_parse_windows(
|
||||
kmp_env_blk_t *block, // M: Env block to fill.
|
||||
char const *env // I: Pointer to Windows* OS (DOS) environment block.
|
||||
) {
|
||||
|
||||
char * bulk = NULL;
|
||||
kmp_env_var_t * vars = NULL;
|
||||
int count = 0; // Number of used elements in vars array.
|
||||
int size = 0; // Size of bulk.
|
||||
char *bulk = NULL;
|
||||
kmp_env_var_t *vars = NULL;
|
||||
int count = 0; // Number of used elements in vars array.
|
||||
int size = 0; // Size of bulk.
|
||||
|
||||
char * name; // Pointer to name of variable.
|
||||
char * value; // Pointer to value.
|
||||
char *name; // Pointer to name of variable.
|
||||
char *value; // Pointer to value.
|
||||
|
||||
if ( env != NULL ) {
|
||||
if (env != NULL) {
|
||||
|
||||
// Loop thru all the vars in environment block. Count variables, find size of block.
|
||||
{
|
||||
char const * var; // Pointer to beginning of var.
|
||||
int len; // Length of variable.
|
||||
count = 0;
|
||||
var = env; // The first variable starts and beginning of environment block.
|
||||
len = KMP_STRLEN( var );
|
||||
while ( len != 0 ) {
|
||||
++ count;
|
||||
size = size + len + 1;
|
||||
var = var + len + 1; // Move pointer to the beginning of the next variable.
|
||||
len = KMP_STRLEN( var );
|
||||
}; // while
|
||||
size = size + 1; // Total size of env block, including terminating zero byte.
|
||||
}
|
||||
// Loop thru all the vars in environment block. Count variables, find size
|
||||
// of block.
|
||||
{
|
||||
char const *var; // Pointer to beginning of var.
|
||||
int len; // Length of variable.
|
||||
count = 0;
|
||||
var =
|
||||
env; // The first variable starts and beginning of environment block.
|
||||
len = KMP_STRLEN(var);
|
||||
while (len != 0) {
|
||||
++count;
|
||||
size = size + len + 1;
|
||||
var = var + len +
|
||||
1; // Move pointer to the beginning of the next variable.
|
||||
len = KMP_STRLEN(var);
|
||||
}; // while
|
||||
size =
|
||||
size + 1; // Total size of env block, including terminating zero byte.
|
||||
}
|
||||
|
||||
// Copy original block to bulk, we will modify bulk, not original block.
|
||||
bulk = (char *) allocate( size );
|
||||
KMP_MEMCPY_S( bulk, size, env, size );
|
||||
// Allocate vars array.
|
||||
vars = (kmp_env_var_t *) allocate( count * sizeof( kmp_env_var_t ) );
|
||||
// Copy original block to bulk, we will modify bulk, not original block.
|
||||
bulk = (char *)allocate(size);
|
||||
KMP_MEMCPY_S(bulk, size, env, size);
|
||||
// Allocate vars array.
|
||||
vars = (kmp_env_var_t *)allocate(count * sizeof(kmp_env_var_t));
|
||||
|
||||
// Loop thru all the vars, now in bulk.
|
||||
{
|
||||
char * var; // Pointer to beginning of var.
|
||||
int len; // Length of variable.
|
||||
count = 0;
|
||||
var = bulk;
|
||||
len = KMP_STRLEN( var );
|
||||
while ( len != 0 ) {
|
||||
// Save variable in vars array.
|
||||
__kmp_str_split( var, '=', & name, & value );
|
||||
vars[ count ].name = name;
|
||||
vars[ count ].value = value;
|
||||
++ count;
|
||||
// Get the next var.
|
||||
var = var + len + 1;
|
||||
len = KMP_STRLEN( var );
|
||||
}; // while
|
||||
}
|
||||
// Loop thru all the vars, now in bulk.
|
||||
{
|
||||
char *var; // Pointer to beginning of var.
|
||||
int len; // Length of variable.
|
||||
count = 0;
|
||||
var = bulk;
|
||||
len = KMP_STRLEN(var);
|
||||
while (len != 0) {
|
||||
// Save variable in vars array.
|
||||
__kmp_str_split(var, '=', &name, &value);
|
||||
vars[count].name = name;
|
||||
vars[count].value = value;
|
||||
++count;
|
||||
// Get the next var.
|
||||
var = var + len + 1;
|
||||
len = KMP_STRLEN(var);
|
||||
}; // while
|
||||
}
|
||||
|
||||
}; // if
|
||||
}; // if
|
||||
|
||||
// Fill out result.
|
||||
block->bulk = bulk;
|
||||
block->vars = vars;
|
||||
block->count = count;
|
||||
// Fill out result.
|
||||
block->bulk = bulk;
|
||||
block->vars = vars;
|
||||
block->count = count;
|
||||
|
||||
}; // ___kmp_env_blk_parse_windows
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Unix environment block is a array of pointers to variables, last pointer in array is NULL:
|
||||
/* Unix environment block is a array of pointers to variables, last pointer in
|
||||
array is NULL:
|
||||
|
||||
{ "HOME=/home/lev", "TERM=xterm", NULL }
|
||||
*/
|
||||
|
||||
static
|
||||
void
|
||||
___kmp_env_blk_parse_unix(
|
||||
kmp_env_blk_t * block, // M: Env block to fill.
|
||||
char * * env // I: Unix environment to parse.
|
||||
) {
|
||||
static void
|
||||
___kmp_env_blk_parse_unix(kmp_env_blk_t *block, // M: Env block to fill.
|
||||
char **env // I: Unix environment to parse.
|
||||
) {
|
||||
|
||||
char * bulk = NULL;
|
||||
kmp_env_var_t * vars = NULL;
|
||||
int count = 0;
|
||||
int size = 0; // Size of bulk.
|
||||
char *bulk = NULL;
|
||||
kmp_env_var_t *vars = NULL;
|
||||
int count = 0;
|
||||
int size = 0; // Size of bulk.
|
||||
|
||||
// Count number of variables and length of required bulk.
|
||||
{
|
||||
count = 0;
|
||||
size = 0;
|
||||
while ( env[ count ] != NULL ) {
|
||||
size += KMP_STRLEN( env[ count ] ) + 1;
|
||||
++ count;
|
||||
}; // while
|
||||
}
|
||||
// Count number of variables and length of required bulk.
|
||||
{
|
||||
count = 0;
|
||||
size = 0;
|
||||
while (env[count] != NULL) {
|
||||
size += KMP_STRLEN(env[count]) + 1;
|
||||
++count;
|
||||
}; // while
|
||||
}
|
||||
|
||||
// Allocate memory.
|
||||
bulk = (char *) allocate( size );
|
||||
vars = (kmp_env_var_t *) allocate( count * sizeof( kmp_env_var_t ) );
|
||||
// Allocate memory.
|
||||
bulk = (char *)allocate(size);
|
||||
vars = (kmp_env_var_t *)allocate(count * sizeof(kmp_env_var_t));
|
||||
|
||||
// Loop thru all the vars.
|
||||
{
|
||||
char * var; // Pointer to beginning of var.
|
||||
char * name; // Pointer to name of variable.
|
||||
char * value; // Pointer to value.
|
||||
int len; // Length of variable.
|
||||
int i;
|
||||
var = bulk;
|
||||
for ( i = 0; i < count; ++ i ) {
|
||||
// Copy variable to bulk.
|
||||
len = KMP_STRLEN( env[ i ] );
|
||||
KMP_MEMCPY_S( var, size, env[ i ], len + 1 );
|
||||
// Save found variable in vars array.
|
||||
__kmp_str_split( var, '=', & name, & value );
|
||||
vars[ i ].name = name;
|
||||
vars[ i ].value = value;
|
||||
// Move pointer.
|
||||
var += len + 1;
|
||||
}; // for
|
||||
}
|
||||
// Loop thru all the vars.
|
||||
{
|
||||
char *var; // Pointer to beginning of var.
|
||||
char *name; // Pointer to name of variable.
|
||||
char *value; // Pointer to value.
|
||||
int len; // Length of variable.
|
||||
int i;
|
||||
var = bulk;
|
||||
for (i = 0; i < count; ++i) {
|
||||
// Copy variable to bulk.
|
||||
len = KMP_STRLEN(env[i]);
|
||||
KMP_MEMCPY_S(var, size, env[i], len + 1);
|
||||
// Save found variable in vars array.
|
||||
__kmp_str_split(var, '=', &name, &value);
|
||||
vars[i].name = name;
|
||||
vars[i].value = value;
|
||||
// Move pointer.
|
||||
var += len + 1;
|
||||
}; // for
|
||||
}
|
||||
|
||||
// Fill out result.
|
||||
block->bulk = bulk;
|
||||
block->vars = vars;
|
||||
block->count = count;
|
||||
// Fill out result.
|
||||
block->bulk = bulk;
|
||||
block->vars = vars;
|
||||
block->count = count;
|
||||
|
||||
}; // ___kmp_env_blk_parse_unix
|
||||
|
||||
void __kmp_env_blk_init(kmp_env_blk_t *block, // M: Block to initialize.
|
||||
char const *bulk // I: Initialization string, or NULL.
|
||||
) {
|
||||
|
||||
|
||||
void
|
||||
__kmp_env_blk_init(
|
||||
kmp_env_blk_t * block, // M: Block to initialize.
|
||||
char const * bulk // I: Initialization string, or NULL.
|
||||
) {
|
||||
|
||||
if ( bulk != NULL ) {
|
||||
___kmp_env_blk_parse_string( block, bulk );
|
||||
} else {
|
||||
#if KMP_OS_UNIX
|
||||
___kmp_env_blk_parse_unix( block, environ );
|
||||
#elif KMP_OS_WINDOWS
|
||||
{
|
||||
char * mem = GetEnvironmentStrings();
|
||||
if ( mem == NULL ) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal,
|
||||
KMP_MSG( CantGetEnvironment ),
|
||||
KMP_ERR( error ),
|
||||
__kmp_msg_null
|
||||
);
|
||||
}; // if
|
||||
___kmp_env_blk_parse_windows( block, mem );
|
||||
FreeEnvironmentStrings( mem );
|
||||
}
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
}; // if
|
||||
if (bulk != NULL) {
|
||||
___kmp_env_blk_parse_string(block, bulk);
|
||||
} else {
|
||||
#if KMP_OS_UNIX
|
||||
___kmp_env_blk_parse_unix(block, environ);
|
||||
#elif KMP_OS_WINDOWS
|
||||
{
|
||||
char *mem = GetEnvironmentStrings();
|
||||
if (mem == NULL) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvironment), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
___kmp_env_blk_parse_windows(block, mem);
|
||||
FreeEnvironmentStrings(mem);
|
||||
}
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
}; // if
|
||||
|
||||
} // __kmp_env_blk_init
|
||||
|
||||
|
||||
|
||||
static
|
||||
int
|
||||
___kmp_env_var_cmp( // Comparison function for qsort().
|
||||
kmp_env_var_t const * lhs,
|
||||
kmp_env_var_t const * rhs
|
||||
) {
|
||||
return strcmp( lhs->name, rhs->name );
|
||||
static int ___kmp_env_var_cmp( // Comparison function for qsort().
|
||||
kmp_env_var_t const *lhs, kmp_env_var_t const *rhs) {
|
||||
return strcmp(lhs->name, rhs->name);
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_env_blk_sort(
|
||||
kmp_env_blk_t * block // M: Block of environment variables to sort.
|
||||
) {
|
||||
void __kmp_env_blk_sort(
|
||||
kmp_env_blk_t *block // M: Block of environment variables to sort.
|
||||
) {
|
||||
|
||||
qsort(
|
||||
(void *) block->vars,
|
||||
block->count,
|
||||
sizeof( kmp_env_var_t ),
|
||||
( int ( * )( void const *, void const * ) ) & ___kmp_env_var_cmp
|
||||
);
|
||||
qsort((void *)block->vars, block->count, sizeof(kmp_env_var_t),
|
||||
(int (*)(void const *, void const *)) & ___kmp_env_var_cmp);
|
||||
|
||||
} // __kmp_env_block_sort
|
||||
|
||||
void __kmp_env_blk_free(
|
||||
kmp_env_blk_t *block // M: Block of environment variables to free.
|
||||
) {
|
||||
|
||||
KMP_INTERNAL_FREE((void *)block->vars);
|
||||
__kmp_str_free(&(block->bulk));
|
||||
|
||||
void
|
||||
__kmp_env_blk_free(
|
||||
kmp_env_blk_t * block // M: Block of environment variables to free.
|
||||
) {
|
||||
|
||||
KMP_INTERNAL_FREE( (void *) block->vars );
|
||||
__kmp_str_free(&(block->bulk));
|
||||
|
||||
block->count = 0;
|
||||
block->vars = NULL;
|
||||
block->count = 0;
|
||||
block->vars = NULL;
|
||||
|
||||
} // __kmp_env_blk_free
|
||||
|
||||
char const * // R: Value of variable or NULL if variable does not exist.
|
||||
__kmp_env_blk_var(
|
||||
kmp_env_blk_t *block, // I: Block of environment variables.
|
||||
char const *name // I: Name of variable to find.
|
||||
) {
|
||||
|
||||
|
||||
char const * // R: Value of variable or NULL if variable does not exist.
|
||||
__kmp_env_blk_var(
|
||||
kmp_env_blk_t * block, // I: Block of environment variables.
|
||||
char const * name // I: Name of variable to find.
|
||||
) {
|
||||
|
||||
int i;
|
||||
for ( i = 0; i < block->count; ++ i ) {
|
||||
if ( strcmp( block->vars[ i ].name, name ) == 0 ) {
|
||||
return block->vars[ i ].value;
|
||||
}; // if
|
||||
}; // for
|
||||
return NULL;
|
||||
int i;
|
||||
for (i = 0; i < block->count; ++i) {
|
||||
if (strcmp(block->vars[i].name, name) == 0) {
|
||||
return block->vars[i].value;
|
||||
}; // if
|
||||
}; // for
|
||||
return NULL;
|
||||
|
||||
} // __kmp_env_block_var
|
||||
|
||||
|
||||
// end of file //
|
||||
|
|
|
|||
|
|
@ -20,56 +20,56 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Return a copy of the value of environment variable or NULL if the variable does not exist.
|
||||
// Return a copy of the value of environment variable or NULL if the variable
|
||||
// does not exist.
|
||||
// *Note*: Returned pointed *must* be freed after use with __kmp_env_free().
|
||||
char * __kmp_env_get( char const * name );
|
||||
void __kmp_env_free( char const * * value );
|
||||
char *__kmp_env_get(char const *name);
|
||||
void __kmp_env_free(char const **value);
|
||||
|
||||
// Return 1 if the environment variable exists or 0 if does not exist.
|
||||
int __kmp_env_exists( char const * name );
|
||||
int __kmp_env_exists(char const *name);
|
||||
|
||||
// Set the environment variable.
|
||||
void __kmp_env_set( char const * name, char const * value, int overwrite );
|
||||
void __kmp_env_set(char const *name, char const *value, int overwrite);
|
||||
|
||||
// Unset (remove) environment variable.
|
||||
void __kmp_env_unset( char const * name );
|
||||
void __kmp_env_unset(char const *name);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Working with environment blocks.
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
kmp_env_blk_t is read-only collection of environment variables (or environment-like). Usage:
|
||||
/* kmp_env_blk_t is read-only collection of environment variables (or
|
||||
environment-like). Usage:
|
||||
|
||||
kmp_env_blk_t block;
|
||||
__kmp_env_blk_init( & block, NULL ); // Initialize block from process environment.
|
||||
// or
|
||||
__kmp_env_blk_init( & block, "KMP_WARNING=1|KMP_AFFINITY=none" ); // from string.
|
||||
__kmp_env_blk_sort( & block ); // Optionally, sort list.
|
||||
for ( i = 0; i < block.count; ++ i ) {
|
||||
// Process block.vars[ i ].name and block.vars[ i ].value...
|
||||
}; // for i
|
||||
__kmp_env_block_free( & block );
|
||||
kmp_env_blk_t block;
|
||||
__kmp_env_blk_init( & block, NULL ); // Initialize block from process
|
||||
// environment.
|
||||
// or
|
||||
__kmp_env_blk_init( & block, "KMP_WARNING=1|KMP_AFFINITY=none" ); // from string
|
||||
__kmp_env_blk_sort( & block ); // Optionally, sort list.
|
||||
for ( i = 0; i < block.count; ++ i ) {
|
||||
// Process block.vars[ i ].name and block.vars[ i ].value...
|
||||
}; // for i
|
||||
__kmp_env_block_free( & block );
|
||||
*/
|
||||
|
||||
struct __kmp_env_var {
|
||||
char const * name;
|
||||
char const * value;
|
||||
char const *name;
|
||||
char const *value;
|
||||
};
|
||||
typedef struct __kmp_env_var kmp_env_var_t;
|
||||
|
||||
struct __kmp_env_blk {
|
||||
char const * bulk;
|
||||
kmp_env_var_t const * vars;
|
||||
int count;
|
||||
char const *bulk;
|
||||
kmp_env_var_t const *vars;
|
||||
int count;
|
||||
};
|
||||
typedef struct __kmp_env_blk kmp_env_blk_t;
|
||||
|
||||
void __kmp_env_blk_init( kmp_env_blk_t * block, char const * bulk );
|
||||
void __kmp_env_blk_free( kmp_env_blk_t * block );
|
||||
void __kmp_env_blk_sort( kmp_env_blk_t * block );
|
||||
char const * __kmp_env_blk_var( kmp_env_blk_t * block, char const * name );
|
||||
void __kmp_env_blk_init(kmp_env_blk_t *block, char const *bulk);
|
||||
void __kmp_env_blk_free(kmp_env_blk_t *block);
|
||||
void __kmp_env_blk_sort(kmp_env_blk_t *block);
|
||||
char const *__kmp_env_blk_var(kmp_env_blk_t *block, char const *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
@ -78,4 +78,3 @@ char const * __kmp_env_blk_var( kmp_env_blk_t * block, char const * name );
|
|||
#endif // KMP_ENVIRONMENT_H
|
||||
|
||||
// end of file //
|
||||
|
||||
|
|
|
|||
|
|
@ -14,259 +14,237 @@
|
|||
|
||||
|
||||
#include "kmp.h"
|
||||
#include "kmp_error.h"
|
||||
#include "kmp_i18n.h"
|
||||
#include "kmp_str.h"
|
||||
#include "kmp_error.h"
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#define MIN_STACK 100
|
||||
#define MIN_STACK 100
|
||||
|
||||
|
||||
static char const * cons_text_c[] = {
|
||||
"(none)",
|
||||
"\"parallel\"",
|
||||
"work-sharing", /* this is not called "for" because of lowering of "sections" pragmas */
|
||||
"\"ordered\" work-sharing", /* this is not called "for ordered" because of lowering of "sections" pragmas */
|
||||
static char const *cons_text_c[] = {
|
||||
"(none)", "\"parallel\"", "work-sharing", /* this is not called "for"
|
||||
because of lowering of
|
||||
"sections" pragmas */
|
||||
"\"ordered\" work-sharing", /* this is not called "for ordered" because of
|
||||
lowering of "sections" pragmas */
|
||||
"\"sections\"",
|
||||
"work-sharing", /* this is not called "single" because of lowering of "sections" pragmas */
|
||||
"\"taskq\"",
|
||||
"\"taskq\"",
|
||||
"\"taskq ordered\"",
|
||||
"\"critical\"",
|
||||
"\"ordered\"", /* in PARALLEL */
|
||||
"\"ordered\"", /* in PDO */
|
||||
"\"ordered\"", /* in TASKQ */
|
||||
"\"master\"",
|
||||
"\"reduce\"",
|
||||
"\"barrier\""
|
||||
};
|
||||
"work-sharing", /* this is not called "single" because of lowering of
|
||||
"sections" pragmas */
|
||||
"\"taskq\"", "\"taskq\"", "\"taskq ordered\"", "\"critical\"",
|
||||
"\"ordered\"", /* in PARALLEL */
|
||||
"\"ordered\"", /* in PDO */
|
||||
"\"ordered\"", /* in TASKQ */
|
||||
"\"master\"", "\"reduce\"", "\"barrier\""};
|
||||
|
||||
#define get_src( ident ) ( (ident) == NULL ? NULL : (ident)->psource )
|
||||
#define get_src(ident) ((ident) == NULL ? NULL : (ident)->psource)
|
||||
|
||||
#define PUSH_MSG( ct, ident ) \
|
||||
"\tpushing on stack: %s (%s)\n", cons_text_c[ (ct) ], get_src( (ident) )
|
||||
#define POP_MSG( p ) \
|
||||
"\tpopping off stack: %s (%s)\n", \
|
||||
cons_text_c[ (p)->stack_data[ tos ].type ], \
|
||||
get_src( (p)->stack_data[ tos ].ident )
|
||||
#define PUSH_MSG(ct, ident) \
|
||||
"\tpushing on stack: %s (%s)\n", cons_text_c[(ct)], get_src((ident))
|
||||
#define POP_MSG(p) \
|
||||
"\tpopping off stack: %s (%s)\n", cons_text_c[(p)->stack_data[tos].type], \
|
||||
get_src((p)->stack_data[tos].ident)
|
||||
|
||||
static int const cons_text_c_num = sizeof( cons_text_c ) / sizeof( char const * );
|
||||
static int const cons_text_c_num = sizeof(cons_text_c) / sizeof(char const *);
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* --------------- START OF STATIC LOCAL ROUTINES ------------------------- */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static void
|
||||
__kmp_check_null_func( void )
|
||||
{
|
||||
/* nothing to do */
|
||||
static void __kmp_check_null_func(void) { /* nothing to do */
|
||||
}
|
||||
|
||||
static void
|
||||
__kmp_expand_cons_stack( int gtid, struct cons_header *p )
|
||||
{
|
||||
int i;
|
||||
struct cons_data *d;
|
||||
static void __kmp_expand_cons_stack(int gtid, struct cons_header *p) {
|
||||
int i;
|
||||
struct cons_data *d;
|
||||
|
||||
/* TODO for monitor perhaps? */
|
||||
if (gtid < 0)
|
||||
__kmp_check_null_func();
|
||||
/* TODO for monitor perhaps? */
|
||||
if (gtid < 0)
|
||||
__kmp_check_null_func();
|
||||
|
||||
KE_TRACE( 10, ("expand cons_stack (%d %d)\n", gtid, __kmp_get_gtid() ) );
|
||||
KE_TRACE(10, ("expand cons_stack (%d %d)\n", gtid, __kmp_get_gtid()));
|
||||
|
||||
d = p->stack_data;
|
||||
d = p->stack_data;
|
||||
|
||||
p->stack_size = (p->stack_size * 2) + 100;
|
||||
p->stack_size = (p->stack_size * 2) + 100;
|
||||
|
||||
/* TODO free the old data */
|
||||
p->stack_data = (struct cons_data *) __kmp_allocate( sizeof( struct cons_data ) * (p->stack_size+1) );
|
||||
/* TODO free the old data */
|
||||
p->stack_data = (struct cons_data *)__kmp_allocate(sizeof(struct cons_data) *
|
||||
(p->stack_size + 1));
|
||||
|
||||
for (i = p->stack_top; i >= 0; --i)
|
||||
p->stack_data[i] = d[i];
|
||||
for (i = p->stack_top; i >= 0; --i)
|
||||
p->stack_data[i] = d[i];
|
||||
|
||||
/* NOTE: we do not free the old stack_data */
|
||||
/* NOTE: we do not free the old stack_data */
|
||||
}
|
||||
|
||||
// NOTE: Function returns allocated memory, caller must free it!
|
||||
static char const *
|
||||
__kmp_pragma(
|
||||
int ct,
|
||||
ident_t const * ident
|
||||
) {
|
||||
char const * cons = NULL; // Construct name.
|
||||
char * file = NULL; // File name.
|
||||
char * func = NULL; // Function (routine) name.
|
||||
char * line = NULL; // Line number.
|
||||
kmp_str_buf_t buffer;
|
||||
kmp_msg_t prgm;
|
||||
__kmp_str_buf_init( & buffer );
|
||||
if ( 0 < ct && ct < cons_text_c_num ) {
|
||||
cons = cons_text_c[ ct ];
|
||||
} else {
|
||||
KMP_DEBUG_ASSERT( 0 );
|
||||
};
|
||||
if ( ident != NULL && ident->psource != NULL ) {
|
||||
char * tail = NULL;
|
||||
__kmp_str_buf_print( & buffer, "%s", ident->psource ); // Copy source to buffer.
|
||||
// Split string in buffer to file, func, and line.
|
||||
tail = buffer.str;
|
||||
__kmp_str_split( tail, ';', NULL, & tail );
|
||||
__kmp_str_split( tail, ';', & file, & tail );
|
||||
__kmp_str_split( tail, ';', & func, & tail );
|
||||
__kmp_str_split( tail, ';', & line, & tail );
|
||||
}; // if
|
||||
prgm = __kmp_msg_format( kmp_i18n_fmt_Pragma, cons, file, func, line );
|
||||
__kmp_str_buf_free( & buffer );
|
||||
return prgm.str;
|
||||
static char const *__kmp_pragma(int ct, ident_t const *ident) {
|
||||
char const *cons = NULL; // Construct name.
|
||||
char *file = NULL; // File name.
|
||||
char *func = NULL; // Function (routine) name.
|
||||
char *line = NULL; // Line number.
|
||||
kmp_str_buf_t buffer;
|
||||
kmp_msg_t prgm;
|
||||
__kmp_str_buf_init(&buffer);
|
||||
if (0 < ct && ct < cons_text_c_num) {
|
||||
cons = cons_text_c[ct];
|
||||
} else {
|
||||
KMP_DEBUG_ASSERT(0);
|
||||
};
|
||||
if (ident != NULL && ident->psource != NULL) {
|
||||
char *tail = NULL;
|
||||
__kmp_str_buf_print(&buffer, "%s",
|
||||
ident->psource); // Copy source to buffer.
|
||||
// Split string in buffer to file, func, and line.
|
||||
tail = buffer.str;
|
||||
__kmp_str_split(tail, ';', NULL, &tail);
|
||||
__kmp_str_split(tail, ';', &file, &tail);
|
||||
__kmp_str_split(tail, ';', &func, &tail);
|
||||
__kmp_str_split(tail, ';', &line, &tail);
|
||||
}; // if
|
||||
prgm = __kmp_msg_format(kmp_i18n_fmt_Pragma, cons, file, func, line);
|
||||
__kmp_str_buf_free(&buffer);
|
||||
return prgm.str;
|
||||
} // __kmp_pragma
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ----------------- END OF STATIC LOCAL ROUTINES ------------------------- */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
|
||||
void
|
||||
__kmp_error_construct(
|
||||
kmp_i18n_id_t id, // Message identifier.
|
||||
enum cons_type ct, // Construct type.
|
||||
ident_t const * ident // Construct ident.
|
||||
) {
|
||||
char const * construct = __kmp_pragma( ct, ident );
|
||||
__kmp_msg( kmp_ms_fatal, __kmp_msg_format( id, construct ), __kmp_msg_null );
|
||||
KMP_INTERNAL_FREE( (void *) construct );
|
||||
void __kmp_error_construct(kmp_i18n_id_t id, // Message identifier.
|
||||
enum cons_type ct, // Construct type.
|
||||
ident_t const *ident // Construct ident.
|
||||
) {
|
||||
char const *construct = __kmp_pragma(ct, ident);
|
||||
__kmp_msg(kmp_ms_fatal, __kmp_msg_format(id, construct), __kmp_msg_null);
|
||||
KMP_INTERNAL_FREE((void *)construct);
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_id_t id, // Message identifier.
|
||||
enum cons_type ct, // First construct type.
|
||||
ident_t const * ident, // First construct ident.
|
||||
struct cons_data const * cons // Second construct.
|
||||
) {
|
||||
char const * construct1 = __kmp_pragma( ct, ident );
|
||||
char const * construct2 = __kmp_pragma( cons->type, cons->ident );
|
||||
__kmp_msg( kmp_ms_fatal, __kmp_msg_format( id, construct1, construct2 ), __kmp_msg_null );
|
||||
KMP_INTERNAL_FREE( (void *) construct1 );
|
||||
KMP_INTERNAL_FREE( (void *) construct2 );
|
||||
void __kmp_error_construct2(kmp_i18n_id_t id, // Message identifier.
|
||||
enum cons_type ct, // First construct type.
|
||||
ident_t const *ident, // First construct ident.
|
||||
struct cons_data const *cons // Second construct.
|
||||
) {
|
||||
char const *construct1 = __kmp_pragma(ct, ident);
|
||||
char const *construct2 = __kmp_pragma(cons->type, cons->ident);
|
||||
__kmp_msg(kmp_ms_fatal, __kmp_msg_format(id, construct1, construct2),
|
||||
__kmp_msg_null);
|
||||
KMP_INTERNAL_FREE((void *)construct1);
|
||||
KMP_INTERNAL_FREE((void *)construct2);
|
||||
}
|
||||
|
||||
struct cons_header *__kmp_allocate_cons_stack(int gtid) {
|
||||
struct cons_header *p;
|
||||
|
||||
struct cons_header *
|
||||
__kmp_allocate_cons_stack( int gtid )
|
||||
{
|
||||
struct cons_header *p;
|
||||
/* TODO for monitor perhaps? */
|
||||
if (gtid < 0) {
|
||||
__kmp_check_null_func();
|
||||
}; // if
|
||||
KE_TRACE(10, ("allocate cons_stack (%d)\n", gtid));
|
||||
p = (struct cons_header *)__kmp_allocate(sizeof(struct cons_header));
|
||||
p->p_top = p->w_top = p->s_top = 0;
|
||||
p->stack_data = (struct cons_data *)__kmp_allocate(sizeof(struct cons_data) *
|
||||
(MIN_STACK + 1));
|
||||
p->stack_size = MIN_STACK;
|
||||
p->stack_top = 0;
|
||||
p->stack_data[0].type = ct_none;
|
||||
p->stack_data[0].prev = 0;
|
||||
p->stack_data[0].ident = NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
/* TODO for monitor perhaps? */
|
||||
if ( gtid < 0 ) {
|
||||
__kmp_check_null_func();
|
||||
void __kmp_free_cons_stack(void *ptr) {
|
||||
struct cons_header *p = (struct cons_header *)ptr;
|
||||
if (p != NULL) {
|
||||
if (p->stack_data != NULL) {
|
||||
__kmp_free(p->stack_data);
|
||||
p->stack_data = NULL;
|
||||
}; // if
|
||||
KE_TRACE( 10, ("allocate cons_stack (%d)\n", gtid ) );
|
||||
p = (struct cons_header *) __kmp_allocate( sizeof( struct cons_header ) );
|
||||
p->p_top = p->w_top = p->s_top = 0;
|
||||
p->stack_data = (struct cons_data *) __kmp_allocate( sizeof( struct cons_data ) * (MIN_STACK+1) );
|
||||
p->stack_size = MIN_STACK;
|
||||
p->stack_top = 0;
|
||||
p->stack_data[ 0 ].type = ct_none;
|
||||
p->stack_data[ 0 ].prev = 0;
|
||||
p->stack_data[ 0 ].ident = NULL;
|
||||
return p;
|
||||
__kmp_free(p);
|
||||
}; // if
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_free_cons_stack( void * ptr ) {
|
||||
struct cons_header * p = (struct cons_header *) ptr;
|
||||
if ( p != NULL ) {
|
||||
if ( p->stack_data != NULL ) {
|
||||
__kmp_free( p->stack_data );
|
||||
p->stack_data = NULL;
|
||||
}; // if
|
||||
__kmp_free( p );
|
||||
}; // if
|
||||
}
|
||||
|
||||
|
||||
#if KMP_DEBUG
|
||||
static void
|
||||
dump_cons_stack( int gtid, struct cons_header * p ) {
|
||||
int i;
|
||||
int tos = p->stack_top;
|
||||
kmp_str_buf_t buffer;
|
||||
__kmp_str_buf_init( & buffer );
|
||||
__kmp_str_buf_print( & buffer, "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n" );
|
||||
__kmp_str_buf_print( & buffer, "Begin construct stack with %d items for thread %d\n", tos, gtid );
|
||||
__kmp_str_buf_print( & buffer, " stack_top=%d { P=%d, W=%d, S=%d }\n", tos, p->p_top, p->w_top, p->s_top );
|
||||
for ( i = tos; i > 0; i-- ) {
|
||||
struct cons_data * c = & ( p->stack_data[ i ] );
|
||||
__kmp_str_buf_print( & buffer, " stack_data[%2d] = { %s (%s) %d %p }\n", i, cons_text_c[ c->type ], get_src( c->ident ), c->prev, c->name );
|
||||
}; // for i
|
||||
__kmp_str_buf_print( & buffer, "End construct stack for thread %d\n", gtid );
|
||||
__kmp_str_buf_print( & buffer, "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n" );
|
||||
__kmp_debug_printf( "%s", buffer.str );
|
||||
__kmp_str_buf_free( & buffer );
|
||||
static void dump_cons_stack(int gtid, struct cons_header *p) {
|
||||
int i;
|
||||
int tos = p->stack_top;
|
||||
kmp_str_buf_t buffer;
|
||||
__kmp_str_buf_init(&buffer);
|
||||
__kmp_str_buf_print(
|
||||
&buffer,
|
||||
"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n");
|
||||
__kmp_str_buf_print(&buffer,
|
||||
"Begin construct stack with %d items for thread %d\n",
|
||||
tos, gtid);
|
||||
__kmp_str_buf_print(&buffer, " stack_top=%d { P=%d, W=%d, S=%d }\n", tos,
|
||||
p->p_top, p->w_top, p->s_top);
|
||||
for (i = tos; i > 0; i--) {
|
||||
struct cons_data *c = &(p->stack_data[i]);
|
||||
__kmp_str_buf_print(
|
||||
&buffer, " stack_data[%2d] = { %s (%s) %d %p }\n", i,
|
||||
cons_text_c[c->type], get_src(c->ident), c->prev, c->name);
|
||||
}; // for i
|
||||
__kmp_str_buf_print(&buffer, "End construct stack for thread %d\n", gtid);
|
||||
__kmp_str_buf_print(
|
||||
&buffer,
|
||||
"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n");
|
||||
__kmp_debug_printf("%s", buffer.str);
|
||||
__kmp_str_buf_free(&buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
__kmp_push_parallel( int gtid, ident_t const * ident )
|
||||
{
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
|
||||
void __kmp_push_parallel(int gtid, ident_t const *ident) {
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
|
||||
|
||||
KMP_DEBUG_ASSERT( __kmp_threads[ gtid ]-> th.th_cons );
|
||||
KE_TRACE( 10, ("__kmp_push_parallel (%d %d)\n", gtid, __kmp_get_gtid() ) );
|
||||
KE_TRACE( 100, ( PUSH_MSG( ct_parallel, ident ) ) );
|
||||
if ( p->stack_top >= p->stack_size ) {
|
||||
__kmp_expand_cons_stack( gtid, p );
|
||||
}; // if
|
||||
tos = ++p->stack_top;
|
||||
p->stack_data[ tos ].type = ct_parallel;
|
||||
p->stack_data[ tos ].prev = p->p_top;
|
||||
p->stack_data[ tos ].ident = ident;
|
||||
p->stack_data[ tos ].name = NULL;
|
||||
p->p_top = tos;
|
||||
KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
|
||||
KMP_DEBUG_ASSERT(__kmp_threads[gtid]->th.th_cons);
|
||||
KE_TRACE(10, ("__kmp_push_parallel (%d %d)\n", gtid, __kmp_get_gtid()));
|
||||
KE_TRACE(100, (PUSH_MSG(ct_parallel, ident)));
|
||||
if (p->stack_top >= p->stack_size) {
|
||||
__kmp_expand_cons_stack(gtid, p);
|
||||
}; // if
|
||||
tos = ++p->stack_top;
|
||||
p->stack_data[tos].type = ct_parallel;
|
||||
p->stack_data[tos].prev = p->p_top;
|
||||
p->stack_data[tos].ident = ident;
|
||||
p->stack_data[tos].name = NULL;
|
||||
p->p_top = tos;
|
||||
KE_DUMP(1000, dump_cons_stack(gtid, p));
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_check_workshare( int gtid, enum cons_type ct, ident_t const * ident )
|
||||
{
|
||||
struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
|
||||
void __kmp_check_workshare(int gtid, enum cons_type ct, ident_t const *ident) {
|
||||
struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
|
||||
|
||||
KMP_DEBUG_ASSERT( __kmp_threads[ gtid ]-> th.th_cons );
|
||||
KE_TRACE( 10, ("__kmp_check_workshare (%d %d)\n", gtid, __kmp_get_gtid() ) );
|
||||
KMP_DEBUG_ASSERT(__kmp_threads[gtid]->th.th_cons);
|
||||
KE_TRACE(10, ("__kmp_check_workshare (%d %d)\n", gtid, __kmp_get_gtid()));
|
||||
|
||||
|
||||
if ( p->stack_top >= p->stack_size ) {
|
||||
__kmp_expand_cons_stack( gtid, p );
|
||||
}; // if
|
||||
if ( p->w_top > p->p_top &&
|
||||
!(IS_CONS_TYPE_TASKQ(p->stack_data[ p->w_top ].type) && IS_CONS_TYPE_TASKQ(ct))) {
|
||||
// We are already in a WORKSHARE construct for this PARALLEL region.
|
||||
__kmp_error_construct2( kmp_i18n_msg_CnsInvalidNesting, ct, ident, & p->stack_data[ p->w_top ] );
|
||||
}; // if
|
||||
if ( p->s_top > p->p_top ) {
|
||||
// We are already in a SYNC construct for this PARALLEL region.
|
||||
__kmp_error_construct2( kmp_i18n_msg_CnsInvalidNesting, ct, ident, & p->stack_data[ p->s_top ] );
|
||||
}; // if
|
||||
if (p->stack_top >= p->stack_size) {
|
||||
__kmp_expand_cons_stack(gtid, p);
|
||||
}; // if
|
||||
if (p->w_top > p->p_top &&
|
||||
!(IS_CONS_TYPE_TASKQ(p->stack_data[p->w_top].type) &&
|
||||
IS_CONS_TYPE_TASKQ(ct))) {
|
||||
// We are already in a WORKSHARE construct for this PARALLEL region.
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
|
||||
&p->stack_data[p->w_top]);
|
||||
}; // if
|
||||
if (p->s_top > p->p_top) {
|
||||
// We are already in a SYNC construct for this PARALLEL region.
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
|
||||
&p->stack_data[p->s_top]);
|
||||
}; // if
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_push_workshare( int gtid, enum cons_type ct, ident_t const * ident )
|
||||
{
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
|
||||
KE_TRACE( 10, ("__kmp_push_workshare (%d %d)\n", gtid, __kmp_get_gtid() ) );
|
||||
__kmp_check_workshare( gtid, ct, ident );
|
||||
KE_TRACE( 100, ( PUSH_MSG( ct, ident ) ) );
|
||||
tos = ++p->stack_top;
|
||||
p->stack_data[ tos ].type = ct;
|
||||
p->stack_data[ tos ].prev = p->w_top;
|
||||
p->stack_data[ tos ].ident = ident;
|
||||
p->stack_data[ tos ].name = NULL;
|
||||
p->w_top = tos;
|
||||
KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
|
||||
void __kmp_push_workshare(int gtid, enum cons_type ct, ident_t const *ident) {
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
|
||||
KE_TRACE(10, ("__kmp_push_workshare (%d %d)\n", gtid, __kmp_get_gtid()));
|
||||
__kmp_check_workshare(gtid, ct, ident);
|
||||
KE_TRACE(100, (PUSH_MSG(ct, ident)));
|
||||
tos = ++p->stack_top;
|
||||
p->stack_data[tos].type = ct;
|
||||
p->stack_data[tos].prev = p->w_top;
|
||||
p->stack_data[tos].ident = ident;
|
||||
p->stack_data[tos].name = NULL;
|
||||
p->w_top = tos;
|
||||
KE_DUMP(1000, dump_cons_stack(gtid, p));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -276,98 +254,91 @@ __kmp_check_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_l
|
|||
__kmp_check_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p lck )
|
||||
#endif
|
||||
{
|
||||
struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
|
||||
struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
|
||||
|
||||
KE_TRACE( 10, ("__kmp_check_sync (gtid=%d)\n", __kmp_get_gtid() ) );
|
||||
KE_TRACE(10, ("__kmp_check_sync (gtid=%d)\n", __kmp_get_gtid()));
|
||||
|
||||
if (p->stack_top >= p->stack_size)
|
||||
__kmp_expand_cons_stack( gtid, p );
|
||||
if (p->stack_top >= p->stack_size)
|
||||
__kmp_expand_cons_stack(gtid, p);
|
||||
|
||||
if (ct == ct_ordered_in_parallel || ct == ct_ordered_in_pdo || ct == ct_ordered_in_taskq ) {
|
||||
if (p->w_top <= p->p_top) {
|
||||
/* we are not in a worksharing construct */
|
||||
#ifdef BUILD_PARALLEL_ORDERED
|
||||
/* do not report error messages for PARALLEL ORDERED */
|
||||
KMP_ASSERT( ct == ct_ordered_in_parallel );
|
||||
#else
|
||||
__kmp_error_construct( kmp_i18n_msg_CnsBoundToWorksharing, ct, ident );
|
||||
#endif /* BUILD_PARALLEL_ORDERED */
|
||||
} else {
|
||||
/* inside a WORKSHARING construct for this PARALLEL region */
|
||||
if (!IS_CONS_TYPE_ORDERED(p->stack_data[ p->w_top ].type)) {
|
||||
if (p->stack_data[ p->w_top ].type == ct_taskq) {
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsNotInTaskConstruct,
|
||||
ct, ident,
|
||||
& p->stack_data[ p->w_top ]
|
||||
);
|
||||
} else {
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsNoOrderedClause,
|
||||
ct, ident,
|
||||
& p->stack_data[ p->w_top ]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p->s_top > p->p_top && p->s_top > p->w_top) {
|
||||
/* inside a sync construct which is inside a worksharing construct */
|
||||
int index = p->s_top;
|
||||
enum cons_type stack_type;
|
||||
|
||||
stack_type = p->stack_data[ index ].type;
|
||||
|
||||
if (stack_type == ct_critical ||
|
||||
( ( stack_type == ct_ordered_in_parallel ||
|
||||
stack_type == ct_ordered_in_pdo ||
|
||||
stack_type == ct_ordered_in_taskq ) && /* C doesn't allow named ordered; ordered in ordered gets error */
|
||||
p->stack_data[ index ].ident != NULL &&
|
||||
(p->stack_data[ index ].ident->flags & KMP_IDENT_KMPC ))) {
|
||||
/* we are in ORDERED which is inside an ORDERED or CRITICAL construct */
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsInvalidNesting,
|
||||
ct, ident,
|
||||
& p->stack_data[ index ]
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if ( ct == ct_critical ) {
|
||||
#if KMP_USE_DYNAMIC_LOCK
|
||||
if ( lck != NULL && __kmp_get_user_lock_owner( lck, seq ) == gtid ) { /* this same thread already has lock for this critical section */
|
||||
if (ct == ct_ordered_in_parallel || ct == ct_ordered_in_pdo ||
|
||||
ct == ct_ordered_in_taskq) {
|
||||
if (p->w_top <= p->p_top) {
|
||||
/* we are not in a worksharing construct */
|
||||
#ifdef BUILD_PARALLEL_ORDERED
|
||||
/* do not report error messages for PARALLEL ORDERED */
|
||||
KMP_ASSERT(ct == ct_ordered_in_parallel);
|
||||
#else
|
||||
if ( lck != NULL && __kmp_get_user_lock_owner( lck ) == gtid ) { /* this same thread already has lock for this critical section */
|
||||
__kmp_error_construct(kmp_i18n_msg_CnsBoundToWorksharing, ct, ident);
|
||||
#endif /* BUILD_PARALLEL_ORDERED */
|
||||
} else {
|
||||
/* inside a WORKSHARING construct for this PARALLEL region */
|
||||
if (!IS_CONS_TYPE_ORDERED(p->stack_data[p->w_top].type)) {
|
||||
if (p->stack_data[p->w_top].type == ct_taskq) {
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsNotInTaskConstruct, ct, ident,
|
||||
&p->stack_data[p->w_top]);
|
||||
} else {
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsNoOrderedClause, ct, ident,
|
||||
&p->stack_data[p->w_top]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p->s_top > p->p_top && p->s_top > p->w_top) {
|
||||
/* inside a sync construct which is inside a worksharing construct */
|
||||
int index = p->s_top;
|
||||
enum cons_type stack_type;
|
||||
|
||||
stack_type = p->stack_data[index].type;
|
||||
|
||||
if (stack_type == ct_critical ||
|
||||
((stack_type == ct_ordered_in_parallel ||
|
||||
stack_type == ct_ordered_in_pdo ||
|
||||
stack_type ==
|
||||
ct_ordered_in_taskq) && /* C doesn't allow named ordered;
|
||||
ordered in ordered gets error */
|
||||
p->stack_data[index].ident != NULL &&
|
||||
(p->stack_data[index].ident->flags & KMP_IDENT_KMPC))) {
|
||||
/* we are in ORDERED which is inside an ORDERED or CRITICAL construct */
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
|
||||
&p->stack_data[index]);
|
||||
}
|
||||
}
|
||||
} else if (ct == ct_critical) {
|
||||
#if KMP_USE_DYNAMIC_LOCK
|
||||
if (lck != NULL &&
|
||||
__kmp_get_user_lock_owner(lck, seq) ==
|
||||
gtid) { /* this thread already has lock for this critical section */
|
||||
#else
|
||||
if (lck != NULL &&
|
||||
__kmp_get_user_lock_owner(lck) ==
|
||||
gtid) { /* this thread already has lock for this critical section */
|
||||
#endif
|
||||
int index = p->s_top;
|
||||
struct cons_data cons = { NULL, ct_critical, 0, NULL };
|
||||
/* walk up construct stack and try to find critical with matching name */
|
||||
while ( index != 0 && p->stack_data[ index ].name != lck ) {
|
||||
index = p->stack_data[ index ].prev;
|
||||
}
|
||||
if ( index != 0 ) {
|
||||
/* found match on the stack (may not always because of interleaved critical for Fortran) */
|
||||
cons = p->stack_data[ index ];
|
||||
}
|
||||
/* we are in CRITICAL which is inside a CRITICAL construct of the same name */
|
||||
__kmp_error_construct2( kmp_i18n_msg_CnsNestingSameName, ct, ident, & cons );
|
||||
}
|
||||
} else if ( ct == ct_master || ct == ct_reduce ) {
|
||||
if (p->w_top > p->p_top) {
|
||||
/* inside a WORKSHARING construct for this PARALLEL region */
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsInvalidNesting,
|
||||
ct, ident,
|
||||
& p->stack_data[ p->w_top ]
|
||||
);
|
||||
}
|
||||
if (ct == ct_reduce && p->s_top > p->p_top) {
|
||||
/* inside a another SYNC construct for this PARALLEL region */
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsInvalidNesting,
|
||||
ct, ident,
|
||||
& p->stack_data[ p->s_top ]
|
||||
);
|
||||
}; // if
|
||||
int index = p->s_top;
|
||||
struct cons_data cons = {NULL, ct_critical, 0, NULL};
|
||||
/* walk up construct stack and try to find critical with matching name */
|
||||
while (index != 0 && p->stack_data[index].name != lck) {
|
||||
index = p->stack_data[index].prev;
|
||||
}
|
||||
if (index != 0) {
|
||||
/* found match on the stack (may not always because of interleaved
|
||||
* critical for Fortran) */
|
||||
cons = p->stack_data[index];
|
||||
}
|
||||
/* we are in CRITICAL which is inside a CRITICAL construct of same name */
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsNestingSameName, ct, ident, &cons);
|
||||
}
|
||||
} else if (ct == ct_master || ct == ct_reduce) {
|
||||
if (p->w_top > p->p_top) {
|
||||
/* inside a WORKSHARING construct for this PARALLEL region */
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
|
||||
&p->stack_data[p->w_top]);
|
||||
}
|
||||
if (ct == ct_reduce && p->s_top > p->p_top) {
|
||||
/* inside a another SYNC construct for this PARALLEL region */
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
|
||||
&p->stack_data[p->s_top]);
|
||||
}; // if
|
||||
}; // if
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -377,147 +348,118 @@ __kmp_push_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lo
|
|||
__kmp_push_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p lck )
|
||||
#endif
|
||||
{
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
|
||||
|
||||
KMP_ASSERT( gtid == __kmp_get_gtid() );
|
||||
KE_TRACE( 10, ("__kmp_push_sync (gtid=%d)\n", gtid ) );
|
||||
KMP_ASSERT(gtid == __kmp_get_gtid());
|
||||
KE_TRACE(10, ("__kmp_push_sync (gtid=%d)\n", gtid));
|
||||
#if KMP_USE_DYNAMIC_LOCK
|
||||
__kmp_check_sync( gtid, ct, ident, lck, seq );
|
||||
__kmp_check_sync(gtid, ct, ident, lck, seq);
|
||||
#else
|
||||
__kmp_check_sync( gtid, ct, ident, lck );
|
||||
__kmp_check_sync(gtid, ct, ident, lck);
|
||||
#endif
|
||||
KE_TRACE( 100, ( PUSH_MSG( ct, ident ) ) );
|
||||
tos = ++ p->stack_top;
|
||||
p->stack_data[ tos ].type = ct;
|
||||
p->stack_data[ tos ].prev = p->s_top;
|
||||
p->stack_data[ tos ].ident = ident;
|
||||
p->stack_data[ tos ].name = lck;
|
||||
p->s_top = tos;
|
||||
KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
|
||||
KE_TRACE(100, (PUSH_MSG(ct, ident)));
|
||||
tos = ++p->stack_top;
|
||||
p->stack_data[tos].type = ct;
|
||||
p->stack_data[tos].prev = p->s_top;
|
||||
p->stack_data[tos].ident = ident;
|
||||
p->stack_data[tos].name = lck;
|
||||
p->s_top = tos;
|
||||
KE_DUMP(1000, dump_cons_stack(gtid, p));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void
|
||||
__kmp_pop_parallel( int gtid, ident_t const * ident )
|
||||
{
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
|
||||
tos = p->stack_top;
|
||||
KE_TRACE( 10, ("__kmp_pop_parallel (%d %d)\n", gtid, __kmp_get_gtid() ) );
|
||||
if ( tos == 0 || p->p_top == 0 ) {
|
||||
__kmp_error_construct( kmp_i18n_msg_CnsDetectedEnd, ct_parallel, ident );
|
||||
}
|
||||
if ( tos != p->p_top || p->stack_data[ tos ].type != ct_parallel ) {
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsExpectedEnd,
|
||||
ct_parallel, ident,
|
||||
& p->stack_data[ tos ]
|
||||
);
|
||||
}
|
||||
KE_TRACE( 100, ( POP_MSG( p ) ) );
|
||||
p->p_top = p->stack_data[ tos ].prev;
|
||||
p->stack_data[ tos ].type = ct_none;
|
||||
p->stack_data[ tos ].ident = NULL;
|
||||
p->stack_top = tos - 1;
|
||||
KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
|
||||
void __kmp_pop_parallel(int gtid, ident_t const *ident) {
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
|
||||
tos = p->stack_top;
|
||||
KE_TRACE(10, ("__kmp_pop_parallel (%d %d)\n", gtid, __kmp_get_gtid()));
|
||||
if (tos == 0 || p->p_top == 0) {
|
||||
__kmp_error_construct(kmp_i18n_msg_CnsDetectedEnd, ct_parallel, ident);
|
||||
}
|
||||
if (tos != p->p_top || p->stack_data[tos].type != ct_parallel) {
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsExpectedEnd, ct_parallel, ident,
|
||||
&p->stack_data[tos]);
|
||||
}
|
||||
KE_TRACE(100, (POP_MSG(p)));
|
||||
p->p_top = p->stack_data[tos].prev;
|
||||
p->stack_data[tos].type = ct_none;
|
||||
p->stack_data[tos].ident = NULL;
|
||||
p->stack_top = tos - 1;
|
||||
KE_DUMP(1000, dump_cons_stack(gtid, p));
|
||||
}
|
||||
|
||||
enum cons_type
|
||||
__kmp_pop_workshare( int gtid, enum cons_type ct, ident_t const * ident )
|
||||
{
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
|
||||
enum cons_type __kmp_pop_workshare(int gtid, enum cons_type ct,
|
||||
ident_t const *ident) {
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
|
||||
|
||||
tos = p->stack_top;
|
||||
KE_TRACE( 10, ("__kmp_pop_workshare (%d %d)\n", gtid, __kmp_get_gtid() ) );
|
||||
if ( tos == 0 || p->w_top == 0 ) {
|
||||
__kmp_error_construct( kmp_i18n_msg_CnsDetectedEnd, ct, ident );
|
||||
}
|
||||
tos = p->stack_top;
|
||||
KE_TRACE(10, ("__kmp_pop_workshare (%d %d)\n", gtid, __kmp_get_gtid()));
|
||||
if (tos == 0 || p->w_top == 0) {
|
||||
__kmp_error_construct(kmp_i18n_msg_CnsDetectedEnd, ct, ident);
|
||||
}
|
||||
|
||||
if ( tos != p->w_top ||
|
||||
( p->stack_data[ tos ].type != ct &&
|
||||
/* below are two exceptions to the rule that construct types must match */
|
||||
! ( p->stack_data[ tos ].type == ct_pdo_ordered && ct == ct_pdo ) &&
|
||||
! ( p->stack_data[ tos ].type == ct_task_ordered && ct == ct_task )
|
||||
)
|
||||
) {
|
||||
__kmp_check_null_func();
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsExpectedEnd,
|
||||
ct, ident,
|
||||
& p->stack_data[ tos ]
|
||||
);
|
||||
}
|
||||
KE_TRACE( 100, ( POP_MSG( p ) ) );
|
||||
p->w_top = p->stack_data[ tos ].prev;
|
||||
p->stack_data[ tos ].type = ct_none;
|
||||
p->stack_data[ tos ].ident = NULL;
|
||||
p->stack_top = tos - 1;
|
||||
KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
|
||||
return p->stack_data[ p->w_top ].type;
|
||||
if (tos != p->w_top ||
|
||||
(p->stack_data[tos].type != ct &&
|
||||
// below are two exceptions to the rule that construct types must match
|
||||
!(p->stack_data[tos].type == ct_pdo_ordered && ct == ct_pdo) &&
|
||||
!(p->stack_data[tos].type == ct_task_ordered && ct == ct_task))) {
|
||||
__kmp_check_null_func();
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsExpectedEnd, ct, ident,
|
||||
&p->stack_data[tos]);
|
||||
}
|
||||
KE_TRACE(100, (POP_MSG(p)));
|
||||
p->w_top = p->stack_data[tos].prev;
|
||||
p->stack_data[tos].type = ct_none;
|
||||
p->stack_data[tos].ident = NULL;
|
||||
p->stack_top = tos - 1;
|
||||
KE_DUMP(1000, dump_cons_stack(gtid, p));
|
||||
return p->stack_data[p->w_top].type;
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_pop_sync( int gtid, enum cons_type ct, ident_t const * ident )
|
||||
{
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
|
||||
tos = p->stack_top;
|
||||
KE_TRACE( 10, ("__kmp_pop_sync (%d %d)\n", gtid, __kmp_get_gtid() ) );
|
||||
if ( tos == 0 || p->s_top == 0 ) {
|
||||
__kmp_error_construct( kmp_i18n_msg_CnsDetectedEnd, ct, ident );
|
||||
};
|
||||
if ( tos != p->s_top || p->stack_data[ tos ].type != ct ) {
|
||||
__kmp_check_null_func();
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsExpectedEnd,
|
||||
ct, ident,
|
||||
& p->stack_data[ tos ]
|
||||
);
|
||||
};
|
||||
if ( gtid < 0 ) {
|
||||
__kmp_check_null_func();
|
||||
};
|
||||
KE_TRACE( 100, ( POP_MSG( p ) ) );
|
||||
p->s_top = p->stack_data[ tos ].prev;
|
||||
p->stack_data[ tos ].type = ct_none;
|
||||
p->stack_data[ tos ].ident = NULL;
|
||||
p->stack_top = tos - 1;
|
||||
KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
|
||||
void __kmp_pop_sync(int gtid, enum cons_type ct, ident_t const *ident) {
|
||||
int tos;
|
||||
struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
|
||||
tos = p->stack_top;
|
||||
KE_TRACE(10, ("__kmp_pop_sync (%d %d)\n", gtid, __kmp_get_gtid()));
|
||||
if (tos == 0 || p->s_top == 0) {
|
||||
__kmp_error_construct(kmp_i18n_msg_CnsDetectedEnd, ct, ident);
|
||||
};
|
||||
if (tos != p->s_top || p->stack_data[tos].type != ct) {
|
||||
__kmp_check_null_func();
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsExpectedEnd, ct, ident,
|
||||
&p->stack_data[tos]);
|
||||
};
|
||||
if (gtid < 0) {
|
||||
__kmp_check_null_func();
|
||||
};
|
||||
KE_TRACE(100, (POP_MSG(p)));
|
||||
p->s_top = p->stack_data[tos].prev;
|
||||
p->stack_data[tos].type = ct_none;
|
||||
p->stack_data[tos].ident = NULL;
|
||||
p->stack_top = tos - 1;
|
||||
KE_DUMP(1000, dump_cons_stack(gtid, p));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void
|
||||
__kmp_check_barrier( int gtid, enum cons_type ct, ident_t const * ident )
|
||||
{
|
||||
struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
|
||||
KE_TRACE( 10, ("__kmp_check_barrier (loc: %p, gtid: %d %d)\n", ident, gtid, __kmp_get_gtid() ) );
|
||||
if ( ident != 0 ) {
|
||||
__kmp_check_null_func();
|
||||
}
|
||||
if ( p->w_top > p->p_top ) {
|
||||
/* we are already in a WORKSHARING construct for this PARALLEL region */
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsInvalidNesting,
|
||||
ct, ident,
|
||||
& p->stack_data[ p->w_top ]
|
||||
);
|
||||
}
|
||||
if (p->s_top > p->p_top) {
|
||||
/* we are already in a SYNC construct for this PARALLEL region */
|
||||
__kmp_error_construct2(
|
||||
kmp_i18n_msg_CnsInvalidNesting,
|
||||
ct, ident,
|
||||
& p->stack_data[ p->s_top ]
|
||||
);
|
||||
}
|
||||
void __kmp_check_barrier(int gtid, enum cons_type ct, ident_t const *ident) {
|
||||
struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
|
||||
KE_TRACE(10, ("__kmp_check_barrier (loc: %p, gtid: %d %d)\n", ident, gtid,
|
||||
__kmp_get_gtid()));
|
||||
if (ident != 0) {
|
||||
__kmp_check_null_func();
|
||||
}
|
||||
if (p->w_top > p->p_top) {
|
||||
/* we are already in a WORKSHARING construct for this PARALLEL region */
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
|
||||
&p->stack_data[p->w_top]);
|
||||
}
|
||||
if (p->s_top > p->p_top) {
|
||||
/* we are already in a SYNC construct for this PARALLEL region */
|
||||
__kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
|
||||
&p->stack_data[p->s_top]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -20,38 +20,44 @@
|
|||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void __kmp_error_construct( kmp_i18n_id_t id, enum cons_type ct, ident_t const * ident );
|
||||
void __kmp_error_construct2( kmp_i18n_id_t id, enum cons_type ct, ident_t const * ident, struct cons_data const * cons );
|
||||
void __kmp_error_construct(kmp_i18n_id_t id, enum cons_type ct,
|
||||
ident_t const *ident);
|
||||
void __kmp_error_construct2(kmp_i18n_id_t id, enum cons_type ct,
|
||||
ident_t const *ident, struct cons_data const *cons);
|
||||
|
||||
struct cons_header * __kmp_allocate_cons_stack( int gtid );
|
||||
void __kmp_free_cons_stack( void * ptr );
|
||||
struct cons_header *__kmp_allocate_cons_stack(int gtid);
|
||||
void __kmp_free_cons_stack(void *ptr);
|
||||
|
||||
void __kmp_push_parallel( int gtid, ident_t const * ident );
|
||||
void __kmp_push_workshare( int gtid, enum cons_type ct, ident_t const * ident );
|
||||
void __kmp_push_parallel(int gtid, ident_t const *ident);
|
||||
void __kmp_push_workshare(int gtid, enum cons_type ct, ident_t const *ident);
|
||||
#if KMP_USE_DYNAMIC_LOCK
|
||||
void __kmp_push_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p name, kmp_uint32 );
|
||||
void __kmp_push_sync(int gtid, enum cons_type ct, ident_t const *ident,
|
||||
kmp_user_lock_p name, kmp_uint32);
|
||||
#else
|
||||
void __kmp_push_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p name );
|
||||
void __kmp_push_sync(int gtid, enum cons_type ct, ident_t const *ident,
|
||||
kmp_user_lock_p name);
|
||||
#endif
|
||||
|
||||
void __kmp_check_workshare( int gtid, enum cons_type ct, ident_t const * ident );
|
||||
void __kmp_check_workshare(int gtid, enum cons_type ct, ident_t const *ident);
|
||||
#if KMP_USE_DYNAMIC_LOCK
|
||||
void __kmp_check_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p name, kmp_uint32 );
|
||||
void __kmp_check_sync(int gtid, enum cons_type ct, ident_t const *ident,
|
||||
kmp_user_lock_p name, kmp_uint32);
|
||||
#else
|
||||
void __kmp_check_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p name );
|
||||
void __kmp_check_sync(int gtid, enum cons_type ct, ident_t const *ident,
|
||||
kmp_user_lock_p name);
|
||||
#endif
|
||||
|
||||
void __kmp_pop_parallel( int gtid, ident_t const * ident );
|
||||
enum cons_type __kmp_pop_workshare( int gtid, enum cons_type ct, ident_t const * ident );
|
||||
void __kmp_pop_sync( int gtid, enum cons_type ct, ident_t const * ident );
|
||||
void __kmp_check_barrier( int gtid, enum cons_type ct, ident_t const * ident );
|
||||
void __kmp_pop_parallel(int gtid, ident_t const *ident);
|
||||
enum cons_type __kmp_pop_workshare(int gtid, enum cons_type ct,
|
||||
ident_t const *ident);
|
||||
void __kmp_pop_sync(int gtid, enum cons_type ct, ident_t const *ident);
|
||||
void __kmp_check_barrier(int gtid, enum cons_type ct, ident_t const *ident);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // KMP_ERROR_H
|
||||
|
||||
|
|
|
|||
|
|
@ -17,20 +17,21 @@
|
|||
#include "kmp_affinity.h"
|
||||
|
||||
#if KMP_OS_WINDOWS
|
||||
# if defined KMP_WIN_CDECL || !defined KMP_DYNAMIC_LIB
|
||||
# define KMP_FTN_ENTRIES KMP_FTN_UPPER
|
||||
# endif
|
||||
#if defined KMP_WIN_CDECL || !defined KMP_DYNAMIC_LIB
|
||||
#define KMP_FTN_ENTRIES KMP_FTN_UPPER
|
||||
#endif
|
||||
#elif KMP_OS_UNIX
|
||||
# define KMP_FTN_ENTRIES KMP_FTN_PLAIN
|
||||
#define KMP_FTN_ENTRIES KMP_FTN_PLAIN
|
||||
#endif
|
||||
|
||||
// Note: This string is not printed when KMP_VERSION=1.
|
||||
char const __kmp_version_ftncdecl[] = KMP_VERSION_PREFIX "Fortran __cdecl OMP support: "
|
||||
char const __kmp_version_ftncdecl[] =
|
||||
KMP_VERSION_PREFIX "Fortran __cdecl OMP support: "
|
||||
#ifdef KMP_FTN_ENTRIES
|
||||
"yes";
|
||||
# define FTN_STDCALL /* no stdcall */
|
||||
# include "kmp_ftn_os.h"
|
||||
# include "kmp_ftn_entry.h"
|
||||
"yes";
|
||||
#define FTN_STDCALL /* no stdcall */
|
||||
#include "kmp_ftn_os.h"
|
||||
#include "kmp_ftn_entry.h"
|
||||
#else
|
||||
"no";
|
||||
"no";
|
||||
#endif /* KMP_FTN_ENTRIES */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -17,18 +17,19 @@
|
|||
#include "kmp_affinity.h"
|
||||
|
||||
#if KMP_OS_WINDOWS
|
||||
# define KMP_FTN_ENTRIES KMP_FTN_PLAIN
|
||||
#define KMP_FTN_ENTRIES KMP_FTN_PLAIN
|
||||
#elif KMP_OS_UNIX
|
||||
# define KMP_FTN_ENTRIES KMP_FTN_APPEND
|
||||
#define KMP_FTN_ENTRIES KMP_FTN_APPEND
|
||||
#endif
|
||||
|
||||
// Note: This string is not printed when KMP_VERSION=1.
|
||||
char const __kmp_version_ftnextra[] = KMP_VERSION_PREFIX "Fortran \"extra\" OMP support: "
|
||||
char const __kmp_version_ftnextra[] =
|
||||
KMP_VERSION_PREFIX "Fortran \"extra\" OMP support: "
|
||||
#ifdef KMP_FTN_ENTRIES
|
||||
"yes";
|
||||
# define FTN_STDCALL /* nothing to do */
|
||||
# include "kmp_ftn_os.h"
|
||||
# include "kmp_ftn_entry.h"
|
||||
"yes";
|
||||
#define FTN_STDCALL /* nothing to do */
|
||||
#include "kmp_ftn_os.h"
|
||||
#include "kmp_ftn_entry.h"
|
||||
#else
|
||||
"no";
|
||||
"no";
|
||||
#endif /* KMP_FTN_ENTRIES */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -16,20 +16,20 @@
|
|||
#include "kmp.h"
|
||||
|
||||
// Note: This string is not printed when KMP_VERSION=1.
|
||||
char const __kmp_version_ftnstdcall[] = KMP_VERSION_PREFIX "Fortran __stdcall OMP support: "
|
||||
char const __kmp_version_ftnstdcall[] =
|
||||
KMP_VERSION_PREFIX "Fortran __stdcall OMP support: "
|
||||
#ifdef USE_FTN_STDCALL
|
||||
"yes";
|
||||
"yes";
|
||||
#else
|
||||
"no";
|
||||
"no";
|
||||
#endif
|
||||
|
||||
#ifdef USE_FTN_STDCALL
|
||||
|
||||
#define FTN_STDCALL KMP_STDCALL
|
||||
#define KMP_FTN_ENTRIES USE_FTN_STDCALL
|
||||
#define FTN_STDCALL KMP_STDCALL
|
||||
#define KMP_FTN_ENTRIES USE_FTN_STDCALL
|
||||
|
||||
#include "kmp_ftn_os.h"
|
||||
#include "kmp_ftn_entry.h"
|
||||
#include "kmp_ftn_os.h"
|
||||
|
||||
#endif /* USE_FTN_STDCALL */
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
kmp_key_t __kmp_gtid_threadprivate_key;
|
||||
|
||||
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
|
||||
kmp_cpuinfo_t __kmp_cpuinfo = { 0 }; // Not initialized
|
||||
kmp_cpuinfo_t __kmp_cpuinfo = {0}; // Not initialized
|
||||
#endif
|
||||
|
||||
#if KMP_STATS_ENABLED
|
||||
|
|
@ -27,11 +27,12 @@ kmp_cpuinfo_t __kmp_cpuinfo = { 0 }; // Not initialized
|
|||
// lock for modifying the global __kmp_stats_list
|
||||
kmp_tas_lock_t __kmp_stats_lock;
|
||||
|
||||
// global list of per thread stats, the head is a sentinel node which accumulates all stats produced before __kmp_create_worker is called.
|
||||
kmp_stats_list* __kmp_stats_list;
|
||||
// global list of per thread stats, the head is a sentinel node which
|
||||
// accumulates all stats produced before __kmp_create_worker is called.
|
||||
kmp_stats_list *__kmp_stats_list;
|
||||
|
||||
// thread local pointer to stats node within list
|
||||
__thread kmp_stats_list* __kmp_stats_thread_ptr = NULL;
|
||||
__thread kmp_stats_list *__kmp_stats_thread_ptr = NULL;
|
||||
|
||||
// gives reference tick for all events (considered the 0 tick)
|
||||
tsc_tick_count __kmp_stats_start_time;
|
||||
|
|
@ -40,176 +41,196 @@ tsc_tick_count __kmp_stats_start_time;
|
|||
/* ----------------------------------------------------- */
|
||||
/* INITIALIZATION VARIABLES */
|
||||
/* they are syncronized to write during init, but read anytime */
|
||||
volatile int __kmp_init_serial = FALSE;
|
||||
volatile int __kmp_init_gtid = FALSE;
|
||||
volatile int __kmp_init_common = FALSE;
|
||||
volatile int __kmp_init_middle = FALSE;
|
||||
volatile int __kmp_init_parallel = FALSE;
|
||||
volatile int __kmp_init_serial = FALSE;
|
||||
volatile int __kmp_init_gtid = FALSE;
|
||||
volatile int __kmp_init_common = FALSE;
|
||||
volatile int __kmp_init_middle = FALSE;
|
||||
volatile int __kmp_init_parallel = FALSE;
|
||||
#if KMP_USE_MONITOR
|
||||
volatile int __kmp_init_monitor = 0; /* 1 - launched, 2 - actually started (Windows* OS only) */
|
||||
volatile int __kmp_init_monitor =
|
||||
0; /* 1 - launched, 2 - actually started (Windows* OS only) */
|
||||
#endif
|
||||
volatile int __kmp_init_user_locks = FALSE;
|
||||
volatile int __kmp_init_user_locks = FALSE;
|
||||
|
||||
/* list of address of allocated caches for commons */
|
||||
kmp_cached_addr_t *__kmp_threadpriv_cache_list = NULL;
|
||||
kmp_cached_addr_t *__kmp_threadpriv_cache_list = NULL;
|
||||
|
||||
int __kmp_init_counter = 0;
|
||||
int __kmp_root_counter = 0;
|
||||
int __kmp_version = 0;
|
||||
int __kmp_init_counter = 0;
|
||||
int __kmp_root_counter = 0;
|
||||
int __kmp_version = 0;
|
||||
|
||||
volatile kmp_uint32 __kmp_team_counter = 0;
|
||||
volatile kmp_uint32 __kmp_task_counter = 0;
|
||||
volatile kmp_uint32 __kmp_team_counter = 0;
|
||||
volatile kmp_uint32 __kmp_task_counter = 0;
|
||||
|
||||
unsigned int __kmp_init_wait = KMP_DEFAULT_INIT_WAIT; /* initial number of spin-tests */
|
||||
unsigned int __kmp_next_wait = KMP_DEFAULT_NEXT_WAIT; /* susequent number of spin-tests */
|
||||
unsigned int __kmp_init_wait =
|
||||
KMP_DEFAULT_INIT_WAIT; /* initial number of spin-tests */
|
||||
unsigned int __kmp_next_wait =
|
||||
KMP_DEFAULT_NEXT_WAIT; /* susequent number of spin-tests */
|
||||
|
||||
size_t __kmp_stksize = KMP_DEFAULT_STKSIZE;
|
||||
size_t __kmp_stksize = KMP_DEFAULT_STKSIZE;
|
||||
#if KMP_USE_MONITOR
|
||||
size_t __kmp_monitor_stksize = 0; // auto adjust
|
||||
size_t __kmp_monitor_stksize = 0; // auto adjust
|
||||
#endif
|
||||
size_t __kmp_stkoffset = KMP_DEFAULT_STKOFFSET;
|
||||
int __kmp_stkpadding = KMP_MIN_STKPADDING;
|
||||
size_t __kmp_stkoffset = KMP_DEFAULT_STKOFFSET;
|
||||
int __kmp_stkpadding = KMP_MIN_STKPADDING;
|
||||
|
||||
size_t __kmp_malloc_pool_incr = KMP_DEFAULT_MALLOC_POOL_INCR;
|
||||
size_t __kmp_malloc_pool_incr = KMP_DEFAULT_MALLOC_POOL_INCR;
|
||||
|
||||
/* Barrier method defaults, settings, and strings */
|
||||
/* branch factor = 2^branch_bits (only relevant for tree and hyper barrier types) */
|
||||
// Barrier method defaults, settings, and strings.
|
||||
// branch factor = 2^branch_bits (only relevant for tree & hyper barrier types)
|
||||
#if KMP_ARCH_X86_64
|
||||
kmp_uint32 __kmp_barrier_gather_bb_dflt = 2; /* branch_factor = 4 */ /* hyper2: C78980 */
|
||||
kmp_uint32 __kmp_barrier_release_bb_dflt = 2; /* branch_factor = 4 */ /* hyper2: C78980 */
|
||||
kmp_uint32 __kmp_barrier_gather_bb_dflt = 2;
|
||||
/* branch_factor = 4 */ /* hyper2: C78980 */
|
||||
kmp_uint32 __kmp_barrier_release_bb_dflt = 2;
|
||||
/* branch_factor = 4 */ /* hyper2: C78980 */
|
||||
#else
|
||||
kmp_uint32 __kmp_barrier_gather_bb_dflt = 2; /* branch_factor = 4 */ /* communication in core for MIC */
|
||||
kmp_uint32 __kmp_barrier_release_bb_dflt = 2; /* branch_factor = 4 */ /* communication in core for MIC */
|
||||
kmp_uint32 __kmp_barrier_gather_bb_dflt = 2;
|
||||
/* branch_factor = 4 */ /* communication in core for MIC */
|
||||
kmp_uint32 __kmp_barrier_release_bb_dflt = 2;
|
||||
/* branch_factor = 4 */ /* communication in core for MIC */
|
||||
#endif // KMP_ARCH_X86_64
|
||||
#if KMP_ARCH_X86_64
|
||||
kmp_bar_pat_e __kmp_barrier_gather_pat_dflt = bp_hyper_bar; /* hyper2: C78980 */
|
||||
kmp_bar_pat_e __kmp_barrier_release_pat_dflt = bp_hyper_bar; /* hyper2: C78980 */
|
||||
kmp_bar_pat_e __kmp_barrier_gather_pat_dflt = bp_hyper_bar; /* hyper2: C78980 */
|
||||
kmp_bar_pat_e __kmp_barrier_release_pat_dflt =
|
||||
bp_hyper_bar; /* hyper2: C78980 */
|
||||
#else
|
||||
kmp_bar_pat_e __kmp_barrier_gather_pat_dflt = bp_linear_bar;
|
||||
kmp_bar_pat_e __kmp_barrier_gather_pat_dflt = bp_linear_bar;
|
||||
kmp_bar_pat_e __kmp_barrier_release_pat_dflt = bp_linear_bar;
|
||||
#endif
|
||||
kmp_uint32 __kmp_barrier_gather_branch_bits [ bs_last_barrier ] = { 0 };
|
||||
kmp_uint32 __kmp_barrier_release_branch_bits [ bs_last_barrier ] = { 0 };
|
||||
kmp_bar_pat_e __kmp_barrier_gather_pattern [ bs_last_barrier ] = { bp_linear_bar };
|
||||
kmp_bar_pat_e __kmp_barrier_release_pattern [ bs_last_barrier ] = { bp_linear_bar };
|
||||
char const *__kmp_barrier_branch_bit_env_name [ bs_last_barrier ] =
|
||||
{ "KMP_PLAIN_BARRIER", "KMP_FORKJOIN_BARRIER"
|
||||
#if KMP_FAST_REDUCTION_BARRIER
|
||||
, "KMP_REDUCTION_BARRIER"
|
||||
#endif // KMP_FAST_REDUCTION_BARRIER
|
||||
};
|
||||
char const *__kmp_barrier_pattern_env_name [ bs_last_barrier ] =
|
||||
{ "KMP_PLAIN_BARRIER_PATTERN", "KMP_FORKJOIN_BARRIER_PATTERN"
|
||||
#if KMP_FAST_REDUCTION_BARRIER
|
||||
, "KMP_REDUCTION_BARRIER_PATTERN"
|
||||
#endif // KMP_FAST_REDUCTION_BARRIER
|
||||
};
|
||||
char const *__kmp_barrier_type_name [ bs_last_barrier ] =
|
||||
{ "plain", "forkjoin"
|
||||
#if KMP_FAST_REDUCTION_BARRIER
|
||||
, "reduction"
|
||||
#endif // KMP_FAST_REDUCTION_BARRIER
|
||||
};
|
||||
char const *__kmp_barrier_pattern_name[bp_last_bar] = {"linear","tree","hyper","hierarchical"};
|
||||
kmp_uint32 __kmp_barrier_gather_branch_bits[bs_last_barrier] = {0};
|
||||
kmp_uint32 __kmp_barrier_release_branch_bits[bs_last_barrier] = {0};
|
||||
kmp_bar_pat_e __kmp_barrier_gather_pattern[bs_last_barrier] = {bp_linear_bar};
|
||||
kmp_bar_pat_e __kmp_barrier_release_pattern[bs_last_barrier] = {bp_linear_bar};
|
||||
char const *__kmp_barrier_branch_bit_env_name[bs_last_barrier] = {
|
||||
"KMP_PLAIN_BARRIER", "KMP_FORKJOIN_BARRIER"
|
||||
#if KMP_FAST_REDUCTION_BARRIER
|
||||
,
|
||||
"KMP_REDUCTION_BARRIER"
|
||||
#endif // KMP_FAST_REDUCTION_BARRIER
|
||||
};
|
||||
char const *__kmp_barrier_pattern_env_name[bs_last_barrier] = {
|
||||
"KMP_PLAIN_BARRIER_PATTERN", "KMP_FORKJOIN_BARRIER_PATTERN"
|
||||
#if KMP_FAST_REDUCTION_BARRIER
|
||||
,
|
||||
"KMP_REDUCTION_BARRIER_PATTERN"
|
||||
#endif // KMP_FAST_REDUCTION_BARRIER
|
||||
};
|
||||
char const *__kmp_barrier_type_name[bs_last_barrier] = {"plain", "forkjoin"
|
||||
#if KMP_FAST_REDUCTION_BARRIER
|
||||
,
|
||||
"reduction"
|
||||
#endif // KMP_FAST_REDUCTION_BARRIER
|
||||
};
|
||||
char const *__kmp_barrier_pattern_name[bp_last_bar] = {"linear", "tree",
|
||||
"hyper", "hierarchical"};
|
||||
|
||||
int __kmp_allThreadsSpecified = 0;
|
||||
size_t __kmp_align_alloc = CACHE_LINE;
|
||||
int __kmp_allThreadsSpecified = 0;
|
||||
size_t __kmp_align_alloc = CACHE_LINE;
|
||||
|
||||
|
||||
int __kmp_generate_warnings = kmp_warnings_low;
|
||||
int __kmp_reserve_warn = 0;
|
||||
int __kmp_xproc = 0;
|
||||
int __kmp_avail_proc = 0;
|
||||
size_t __kmp_sys_min_stksize = KMP_MIN_STKSIZE;
|
||||
int __kmp_sys_max_nth = KMP_MAX_NTH;
|
||||
int __kmp_max_nth = 0;
|
||||
int __kmp_threads_capacity = 0;
|
||||
int __kmp_dflt_team_nth = 0;
|
||||
int __kmp_dflt_team_nth_ub = 0;
|
||||
int __kmp_tp_capacity = 0;
|
||||
int __kmp_tp_cached = 0;
|
||||
int __kmp_dflt_nested = FALSE;
|
||||
int __kmp_dispatch_num_buffers = KMP_DFLT_DISP_NUM_BUFF;
|
||||
int __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT; /* max_active_levels limit */
|
||||
int __kmp_generate_warnings = kmp_warnings_low;
|
||||
int __kmp_reserve_warn = 0;
|
||||
int __kmp_xproc = 0;
|
||||
int __kmp_avail_proc = 0;
|
||||
size_t __kmp_sys_min_stksize = KMP_MIN_STKSIZE;
|
||||
int __kmp_sys_max_nth = KMP_MAX_NTH;
|
||||
int __kmp_max_nth = 0;
|
||||
int __kmp_threads_capacity = 0;
|
||||
int __kmp_dflt_team_nth = 0;
|
||||
int __kmp_dflt_team_nth_ub = 0;
|
||||
int __kmp_tp_capacity = 0;
|
||||
int __kmp_tp_cached = 0;
|
||||
int __kmp_dflt_nested = FALSE;
|
||||
int __kmp_dispatch_num_buffers = KMP_DFLT_DISP_NUM_BUFF;
|
||||
int __kmp_dflt_max_active_levels =
|
||||
KMP_MAX_ACTIVE_LEVELS_LIMIT; /* max_active_levels limit */
|
||||
#if KMP_NESTED_HOT_TEAMS
|
||||
int __kmp_hot_teams_mode = 0; /* 0 - free extra threads when reduced */
|
||||
/* 1 - keep extra threads when reduced */
|
||||
int __kmp_hot_teams_max_level = 1; /* nesting level of hot teams */
|
||||
int __kmp_hot_teams_mode = 0; /* 0 - free extra threads when reduced */
|
||||
/* 1 - keep extra threads when reduced */
|
||||
int __kmp_hot_teams_max_level = 1; /* nesting level of hot teams */
|
||||
#endif
|
||||
enum library_type __kmp_library = library_none;
|
||||
enum sched_type __kmp_sched = kmp_sch_default; /* scheduling method for runtime scheduling */
|
||||
enum sched_type __kmp_static = kmp_sch_static_greedy; /* default static scheduling method */
|
||||
enum sched_type __kmp_guided = kmp_sch_guided_iterative_chunked; /* default guided scheduling method */
|
||||
enum sched_type __kmp_auto = kmp_sch_guided_analytical_chunked; /* default auto scheduling method */
|
||||
int __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
|
||||
enum sched_type __kmp_sched =
|
||||
kmp_sch_default; /* scheduling method for runtime scheduling */
|
||||
enum sched_type __kmp_static =
|
||||
kmp_sch_static_greedy; /* default static scheduling method */
|
||||
enum sched_type __kmp_guided =
|
||||
kmp_sch_guided_iterative_chunked; /* default guided scheduling method */
|
||||
enum sched_type __kmp_auto =
|
||||
kmp_sch_guided_analytical_chunked; /* default auto scheduling method */
|
||||
int __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
|
||||
#if KMP_USE_MONITOR
|
||||
int __kmp_monitor_wakeups = KMP_MIN_MONITOR_WAKEUPS;
|
||||
int __kmp_bt_intervals = KMP_INTERVALS_FROM_BLOCKTIME( KMP_DEFAULT_BLOCKTIME, KMP_MIN_MONITOR_WAKEUPS );
|
||||
int __kmp_monitor_wakeups = KMP_MIN_MONITOR_WAKEUPS;
|
||||
int __kmp_bt_intervals = KMP_INTERVALS_FROM_BLOCKTIME(KMP_DEFAULT_BLOCKTIME,
|
||||
KMP_MIN_MONITOR_WAKEUPS);
|
||||
#endif
|
||||
#ifdef KMP_ADJUST_BLOCKTIME
|
||||
int __kmp_zero_bt = FALSE;
|
||||
int __kmp_zero_bt = FALSE;
|
||||
#endif /* KMP_ADJUST_BLOCKTIME */
|
||||
#ifdef KMP_DFLT_NTH_CORES
|
||||
int __kmp_ncores = 0;
|
||||
int __kmp_ncores = 0;
|
||||
#endif
|
||||
int __kmp_chunk = 0;
|
||||
int __kmp_abort_delay = 0;
|
||||
int __kmp_chunk = 0;
|
||||
int __kmp_abort_delay = 0;
|
||||
#if KMP_OS_LINUX && defined(KMP_TDATA_GTID)
|
||||
int __kmp_gtid_mode = 3; /* use __declspec(thread) TLS to store gtid */
|
||||
int __kmp_adjust_gtid_mode = FALSE;
|
||||
int __kmp_gtid_mode = 3; /* use __declspec(thread) TLS to store gtid */
|
||||
int __kmp_adjust_gtid_mode = FALSE;
|
||||
#elif KMP_OS_WINDOWS
|
||||
int __kmp_gtid_mode = 2; /* use TLS functions to store gtid */
|
||||
int __kmp_adjust_gtid_mode = FALSE;
|
||||
int __kmp_gtid_mode = 2; /* use TLS functions to store gtid */
|
||||
int __kmp_adjust_gtid_mode = FALSE;
|
||||
#else
|
||||
int __kmp_gtid_mode = 0; /* select method to get gtid based on #threads */
|
||||
int __kmp_adjust_gtid_mode = TRUE;
|
||||
int __kmp_gtid_mode = 0; /* select method to get gtid based on #threads */
|
||||
int __kmp_adjust_gtid_mode = TRUE;
|
||||
#endif /* KMP_OS_LINUX && defined(KMP_TDATA_GTID) */
|
||||
#ifdef KMP_TDATA_GTID
|
||||
#if KMP_OS_WINDOWS
|
||||
__declspec(thread) int __kmp_gtid = KMP_GTID_DNE;
|
||||
#else
|
||||
__thread int __kmp_gtid = KMP_GTID_DNE;
|
||||
#endif /* KMP_OS_WINDOWS - workaround because Intel(R) Many Integrated Core compiler 20110316 doesn't accept __declspec */
|
||||
#endif /* KMP_OS_WINDOWS - workaround because Intel(R) Many Integrated Core \
|
||||
compiler 20110316 doesn't accept __declspec */
|
||||
#endif /* KMP_TDATA_GTID */
|
||||
int __kmp_tls_gtid_min = INT_MAX;
|
||||
int __kmp_foreign_tp = TRUE;
|
||||
int __kmp_tls_gtid_min = INT_MAX;
|
||||
int __kmp_foreign_tp = TRUE;
|
||||
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
|
||||
int __kmp_inherit_fp_control = TRUE;
|
||||
kmp_int16 __kmp_init_x87_fpu_control_word = 0;
|
||||
kmp_uint32 __kmp_init_mxcsr = 0;
|
||||
int __kmp_inherit_fp_control = TRUE;
|
||||
kmp_int16 __kmp_init_x87_fpu_control_word = 0;
|
||||
kmp_uint32 __kmp_init_mxcsr = 0;
|
||||
#endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
|
||||
|
||||
#ifdef USE_LOAD_BALANCE
|
||||
double __kmp_load_balance_interval = 1.0;
|
||||
double __kmp_load_balance_interval = 1.0;
|
||||
#endif /* USE_LOAD_BALANCE */
|
||||
|
||||
kmp_nested_nthreads_t __kmp_nested_nth = { NULL, 0, 0 };
|
||||
kmp_nested_nthreads_t __kmp_nested_nth = {NULL, 0, 0};
|
||||
|
||||
#if KMP_USE_ADAPTIVE_LOCKS
|
||||
|
||||
kmp_adaptive_backoff_params_t __kmp_adaptive_backoff_params = { 1, 1024 }; // TODO: tune it!
|
||||
kmp_adaptive_backoff_params_t __kmp_adaptive_backoff_params = {
|
||||
1, 1024}; // TODO: tune it!
|
||||
|
||||
#if KMP_DEBUG_ADAPTIVE_LOCKS
|
||||
char * __kmp_speculative_statsfile = "-";
|
||||
char *__kmp_speculative_statsfile = "-";
|
||||
#endif
|
||||
|
||||
#endif // KMP_USE_ADAPTIVE_LOCKS
|
||||
|
||||
#if OMP_40_ENABLED
|
||||
int __kmp_display_env = FALSE;
|
||||
int __kmp_display_env_verbose = FALSE;
|
||||
int __kmp_omp_cancellation = FALSE;
|
||||
int __kmp_display_env = FALSE;
|
||||
int __kmp_display_env_verbose = FALSE;
|
||||
int __kmp_omp_cancellation = FALSE;
|
||||
#endif
|
||||
|
||||
/* map OMP 3.0 schedule types with our internal schedule types */
|
||||
enum sched_type __kmp_sch_map[ kmp_sched_upper - kmp_sched_lower_ext + kmp_sched_upper_std - kmp_sched_lower - 2 ] = {
|
||||
kmp_sch_static_chunked, // ==> kmp_sched_static = 1
|
||||
kmp_sch_dynamic_chunked, // ==> kmp_sched_dynamic = 2
|
||||
kmp_sch_guided_chunked, // ==> kmp_sched_guided = 3
|
||||
kmp_sch_auto, // ==> kmp_sched_auto = 4
|
||||
kmp_sch_trapezoidal // ==> kmp_sched_trapezoidal = 101
|
||||
// will likely not used, introduced here just to debug the code
|
||||
// of public intel extension schedules
|
||||
enum sched_type __kmp_sch_map[kmp_sched_upper - kmp_sched_lower_ext +
|
||||
kmp_sched_upper_std - kmp_sched_lower - 2] = {
|
||||
kmp_sch_static_chunked, // ==> kmp_sched_static = 1
|
||||
kmp_sch_dynamic_chunked, // ==> kmp_sched_dynamic = 2
|
||||
kmp_sch_guided_chunked, // ==> kmp_sched_guided = 3
|
||||
kmp_sch_auto, // ==> kmp_sched_auto = 4
|
||||
kmp_sch_trapezoidal // ==> kmp_sched_trapezoidal = 101
|
||||
// will likely not be used, introduced here just to debug the code
|
||||
// of public intel extension schedules
|
||||
};
|
||||
|
||||
#if KMP_OS_LINUX
|
||||
|
|
@ -223,44 +244,45 @@ enum mic_type __kmp_mic_type = non_mic;
|
|||
|
||||
#if KMP_AFFINITY_SUPPORTED
|
||||
|
||||
KMPAffinity* __kmp_affinity_dispatch = NULL;
|
||||
KMPAffinity *__kmp_affinity_dispatch = NULL;
|
||||
|
||||
# if KMP_USE_HWLOC
|
||||
#if KMP_USE_HWLOC
|
||||
int __kmp_hwloc_error = FALSE;
|
||||
hwloc_topology_t __kmp_hwloc_topology = NULL;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# if KMP_OS_WINDOWS
|
||||
# if KMP_GROUP_AFFINITY
|
||||
#if KMP_OS_WINDOWS
|
||||
#if KMP_GROUP_AFFINITY
|
||||
int __kmp_num_proc_groups = 1;
|
||||
# endif /* KMP_GROUP_AFFINITY */
|
||||
#endif /* KMP_GROUP_AFFINITY */
|
||||
kmp_GetActiveProcessorCount_t __kmp_GetActiveProcessorCount = NULL;
|
||||
kmp_GetActiveProcessorGroupCount_t __kmp_GetActiveProcessorGroupCount = NULL;
|
||||
kmp_GetThreadGroupAffinity_t __kmp_GetThreadGroupAffinity = NULL;
|
||||
kmp_SetThreadGroupAffinity_t __kmp_SetThreadGroupAffinity = NULL;
|
||||
# endif /* KMP_OS_WINDOWS */
|
||||
#endif /* KMP_OS_WINDOWS */
|
||||
|
||||
size_t __kmp_affin_mask_size = 0;
|
||||
size_t __kmp_affin_mask_size = 0;
|
||||
enum affinity_type __kmp_affinity_type = affinity_default;
|
||||
enum affinity_gran __kmp_affinity_gran = affinity_gran_default;
|
||||
int __kmp_affinity_gran_levels = -1;
|
||||
int __kmp_affinity_gran_levels = -1;
|
||||
int __kmp_affinity_dups = TRUE;
|
||||
enum affinity_top_method __kmp_affinity_top_method = affinity_top_method_default;
|
||||
int __kmp_affinity_compact = 0;
|
||||
int __kmp_affinity_offset = 0;
|
||||
int __kmp_affinity_verbose = FALSE;
|
||||
int __kmp_affinity_warnings = TRUE;
|
||||
int __kmp_affinity_respect_mask = affinity_respect_mask_default;
|
||||
char * __kmp_affinity_proclist = NULL;
|
||||
enum affinity_top_method __kmp_affinity_top_method =
|
||||
affinity_top_method_default;
|
||||
int __kmp_affinity_compact = 0;
|
||||
int __kmp_affinity_offset = 0;
|
||||
int __kmp_affinity_verbose = FALSE;
|
||||
int __kmp_affinity_warnings = TRUE;
|
||||
int __kmp_affinity_respect_mask = affinity_respect_mask_default;
|
||||
char *__kmp_affinity_proclist = NULL;
|
||||
kmp_affin_mask_t *__kmp_affinity_masks = NULL;
|
||||
unsigned __kmp_affinity_num_masks = 0;
|
||||
unsigned __kmp_affinity_num_masks = 0;
|
||||
|
||||
char const * __kmp_cpuinfo_file = NULL;
|
||||
char const *__kmp_cpuinfo_file = NULL;
|
||||
|
||||
#endif /* KMP_AFFINITY_SUPPORTED */
|
||||
|
||||
#if OMP_40_ENABLED
|
||||
kmp_nested_proc_bind_t __kmp_nested_proc_bind = { NULL, 0, 0 };
|
||||
kmp_nested_proc_bind_t __kmp_nested_proc_bind = {NULL, 0, 0};
|
||||
int __kmp_affinity_num_places = 0;
|
||||
#endif
|
||||
|
||||
|
|
@ -281,75 +303,87 @@ kmp_tasking_mode_t __kmp_tasking_mode = tskm_task_teams;
|
|||
kmp_int32 __kmp_max_task_priority = 0;
|
||||
#endif
|
||||
|
||||
/* This check ensures that the compiler is passing the correct data type
|
||||
* for the flags formal parameter of the function kmpc_omp_task_alloc().
|
||||
* If the type is not a 4-byte type, then give an error message about
|
||||
* a non-positive length array pointing here. If that happens, the
|
||||
* kmp_tasking_flags_t structure must be redefined to have exactly 32 bits.
|
||||
*/
|
||||
KMP_BUILD_ASSERT( sizeof(kmp_tasking_flags_t) == 4 );
|
||||
/* This check ensures that the compiler is passing the correct data type for the
|
||||
flags formal parameter of the function kmpc_omp_task_alloc(). If the type is
|
||||
not a 4-byte type, then give an error message about a non-positive length
|
||||
array pointing here. If that happens, the kmp_tasking_flags_t structure must
|
||||
be redefined to have exactly 32 bits. */
|
||||
KMP_BUILD_ASSERT(sizeof(kmp_tasking_flags_t) == 4);
|
||||
|
||||
kmp_int32 __kmp_task_stealing_constraint = 1; /* Constrain task stealing by default */
|
||||
kmp_int32 __kmp_task_stealing_constraint =
|
||||
1; /* Constrain task stealing by default */
|
||||
|
||||
#ifdef DEBUG_SUSPEND
|
||||
int __kmp_suspend_count = 0;
|
||||
int __kmp_suspend_count = 0;
|
||||
#endif
|
||||
|
||||
int __kmp_settings = FALSE;
|
||||
int __kmp_duplicate_library_ok = 0;
|
||||
int __kmp_settings = FALSE;
|
||||
int __kmp_duplicate_library_ok = 0;
|
||||
#if USE_ITT_BUILD
|
||||
int __kmp_forkjoin_frames = 1;
|
||||
int __kmp_forkjoin_frames_mode = 3;
|
||||
int __kmp_forkjoin_frames = 1;
|
||||
int __kmp_forkjoin_frames_mode = 3;
|
||||
#endif
|
||||
PACKED_REDUCTION_METHOD_T __kmp_force_reduction_method = reduction_method_not_defined;
|
||||
int __kmp_determ_red = FALSE;
|
||||
PACKED_REDUCTION_METHOD_T __kmp_force_reduction_method =
|
||||
reduction_method_not_defined;
|
||||
int __kmp_determ_red = FALSE;
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
int kmp_a_debug = 0;
|
||||
int kmp_b_debug = 0;
|
||||
int kmp_c_debug = 0;
|
||||
int kmp_d_debug = 0;
|
||||
int kmp_e_debug = 0;
|
||||
int kmp_f_debug = 0;
|
||||
int kmp_diag = 0;
|
||||
int kmp_a_debug = 0;
|
||||
int kmp_b_debug = 0;
|
||||
int kmp_c_debug = 0;
|
||||
int kmp_d_debug = 0;
|
||||
int kmp_e_debug = 0;
|
||||
int kmp_f_debug = 0;
|
||||
int kmp_diag = 0;
|
||||
#endif
|
||||
|
||||
/* For debug information logging using rotating buffer */
|
||||
int __kmp_debug_buf = FALSE; /* TRUE means use buffer, FALSE means print to stderr */
|
||||
int __kmp_debug_buf_lines = KMP_DEBUG_BUF_LINES_INIT; /* Lines of debug stored in buffer */
|
||||
int __kmp_debug_buf_chars = KMP_DEBUG_BUF_CHARS_INIT; /* Characters allowed per line in buffer */
|
||||
int __kmp_debug_buf_atomic = FALSE; /* TRUE means use atomic update of buffer entry pointer */
|
||||
int __kmp_debug_buf =
|
||||
FALSE; /* TRUE means use buffer, FALSE means print to stderr */
|
||||
int __kmp_debug_buf_lines =
|
||||
KMP_DEBUG_BUF_LINES_INIT; /* Lines of debug stored in buffer */
|
||||
int __kmp_debug_buf_chars =
|
||||
KMP_DEBUG_BUF_CHARS_INIT; /* Characters allowed per line in buffer */
|
||||
int __kmp_debug_buf_atomic =
|
||||
FALSE; /* TRUE means use atomic update of buffer entry pointer */
|
||||
|
||||
char *__kmp_debug_buffer = NULL; /* Debug buffer itself */
|
||||
int __kmp_debug_count = 0; /* Counter for number of lines printed in buffer so far */
|
||||
int __kmp_debug_buf_warn_chars = 0; /* Keep track of char increase recommended in warnings */
|
||||
char *__kmp_debug_buffer = NULL; /* Debug buffer itself */
|
||||
int __kmp_debug_count =
|
||||
0; /* Counter for number of lines printed in buffer so far */
|
||||
int __kmp_debug_buf_warn_chars =
|
||||
0; /* Keep track of char increase recommended in warnings */
|
||||
/* end rotating debug buffer */
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
int __kmp_par_range; /* +1 => only go par for constructs in range */
|
||||
/* -1 => only go par for constructs outside range */
|
||||
char __kmp_par_range_routine[KMP_PAR_RANGE_ROUTINE_LEN] = { '\0' };
|
||||
char __kmp_par_range_filename[KMP_PAR_RANGE_FILENAME_LEN] = { '\0' };
|
||||
int __kmp_par_range_lb = 0;
|
||||
int __kmp_par_range_ub = INT_MAX;
|
||||
int __kmp_par_range; /* +1 => only go par for constructs in range */
|
||||
/* -1 => only go par for constructs outside range */
|
||||
char __kmp_par_range_routine[KMP_PAR_RANGE_ROUTINE_LEN] = {'\0'};
|
||||
char __kmp_par_range_filename[KMP_PAR_RANGE_FILENAME_LEN] = {'\0'};
|
||||
int __kmp_par_range_lb = 0;
|
||||
int __kmp_par_range_ub = INT_MAX;
|
||||
#endif /* KMP_DEBUG */
|
||||
|
||||
/* For printing out dynamic storage map for threads and teams */
|
||||
int __kmp_storage_map = FALSE; /* True means print storage map for threads and teams */
|
||||
int __kmp_storage_map_verbose = FALSE; /* True means storage map includes placement info */
|
||||
int __kmp_storage_map_verbose_specified = FALSE;
|
||||
/* Initialize the library data structures when we fork a child process, defaults to TRUE */
|
||||
int __kmp_need_register_atfork = TRUE; /* At initialization, call pthread_atfork to install fork handler */
|
||||
int __kmp_need_register_atfork_specified = TRUE;
|
||||
int __kmp_storage_map =
|
||||
FALSE; /* True means print storage map for threads and teams */
|
||||
int __kmp_storage_map_verbose =
|
||||
FALSE; /* True means storage map includes placement info */
|
||||
int __kmp_storage_map_verbose_specified = FALSE;
|
||||
/* Initialize the library data structures when we fork a child process, defaults
|
||||
* to TRUE */
|
||||
int __kmp_need_register_atfork =
|
||||
TRUE; /* At initialization, call pthread_atfork to install fork handler */
|
||||
int __kmp_need_register_atfork_specified = TRUE;
|
||||
|
||||
int __kmp_env_chunk = FALSE; /* KMP_CHUNK specified? */
|
||||
int __kmp_env_stksize = FALSE; /* KMP_STACKSIZE specified? */
|
||||
int __kmp_env_omp_stksize = FALSE; /* OMP_STACKSIZE specified? */
|
||||
int __kmp_env_all_threads = FALSE;/* KMP_ALL_THREADS or KMP_MAX_THREADS specified? */
|
||||
int __kmp_env_omp_all_threads = FALSE;/* OMP_THREAD_LIMIT specified? */
|
||||
int __kmp_env_blocktime = FALSE; /* KMP_BLOCKTIME specified? */
|
||||
int __kmp_env_checks = FALSE; /* KMP_CHECKS specified? */
|
||||
int __kmp_env_consistency_check = FALSE; /* KMP_CONSISTENCY_CHECK specified? */
|
||||
int __kmp_env_chunk = FALSE; /* KMP_CHUNK specified? */
|
||||
int __kmp_env_stksize = FALSE; /* KMP_STACKSIZE specified? */
|
||||
int __kmp_env_omp_stksize = FALSE; /* OMP_STACKSIZE specified? */
|
||||
int __kmp_env_all_threads =
|
||||
FALSE; /* KMP_ALL_THREADS or KMP_MAX_THREADS specified? */
|
||||
int __kmp_env_omp_all_threads = FALSE; /* OMP_THREAD_LIMIT specified? */
|
||||
int __kmp_env_blocktime = FALSE; /* KMP_BLOCKTIME specified? */
|
||||
int __kmp_env_checks = FALSE; /* KMP_CHECKS specified? */
|
||||
int __kmp_env_consistency_check = FALSE; /* KMP_CONSISTENCY_CHECK specified? */
|
||||
|
||||
kmp_uint32 __kmp_yield_init = KMP_INIT_WAIT;
|
||||
kmp_uint32 __kmp_yield_next = KMP_NEXT_WAIT;
|
||||
|
|
@ -360,42 +394,38 @@ kmp_uint32 __kmp_yielding_on = 1;
|
|||
#if KMP_OS_CNK
|
||||
kmp_uint32 __kmp_yield_cycle = 0;
|
||||
#else
|
||||
kmp_uint32 __kmp_yield_cycle = 1; /* Yield-cycle is on by default */
|
||||
kmp_uint32 __kmp_yield_cycle = 1; /* Yield-cycle is on by default */
|
||||
#endif
|
||||
kmp_int32 __kmp_yield_on_count = 10; /* By default, yielding is on for 10 monitor periods. */
|
||||
kmp_int32 __kmp_yield_off_count = 1; /* By default, yielding is off for 1 monitor periods. */
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
kmp_int32 __kmp_yield_on_count =
|
||||
10; /* By default, yielding is on for 10 monitor periods. */
|
||||
kmp_int32 __kmp_yield_off_count =
|
||||
1; /* By default, yielding is off for 1 monitor periods. */
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
/* STATE mostly syncronized with global lock */
|
||||
/* data written to rarely by masters, read often by workers */
|
||||
/*
|
||||
* SHALL WE EDIT THE COMMENT BELOW IN SOME WAY?
|
||||
* TODO: None of this global padding stuff works consistently because
|
||||
* the order of declaration is not necessarily correlated to storage order.
|
||||
* To fix this, all the important globals must be put in a big structure
|
||||
* instead.
|
||||
*/
|
||||
/* TODO: None of this global padding stuff works consistently because the order
|
||||
of declaration is not necessarily correlated to storage order. To fix this,
|
||||
all the important globals must be put in a big structure instead. */
|
||||
KMP_ALIGN_CACHE
|
||||
kmp_info_t **__kmp_threads = NULL;
|
||||
kmp_root_t **__kmp_root = NULL;
|
||||
kmp_info_t **__kmp_threads = NULL;
|
||||
kmp_root_t **__kmp_root = NULL;
|
||||
|
||||
/* data read/written to often by masters */
|
||||
KMP_ALIGN_CACHE
|
||||
volatile int __kmp_nth = 0;
|
||||
volatile int __kmp_all_nth = 0;
|
||||
int __kmp_thread_pool_nth = 0;
|
||||
volatile kmp_info_t *__kmp_thread_pool = NULL;
|
||||
volatile kmp_team_t *__kmp_team_pool = NULL;
|
||||
volatile int __kmp_nth = 0;
|
||||
volatile int __kmp_all_nth = 0;
|
||||
int __kmp_thread_pool_nth = 0;
|
||||
volatile kmp_info_t *__kmp_thread_pool = NULL;
|
||||
volatile kmp_team_t *__kmp_team_pool = NULL;
|
||||
|
||||
KMP_ALIGN_CACHE
|
||||
volatile int __kmp_thread_pool_active_nth = 0;
|
||||
volatile int __kmp_thread_pool_active_nth = 0;
|
||||
|
||||
/* -------------------------------------------------
|
||||
* GLOBAL/ROOT STATE */
|
||||
KMP_ALIGN_CACHE
|
||||
kmp_global_t __kmp_global = {{ 0 }};
|
||||
kmp_global_t __kmp_global = {{0}};
|
||||
|
||||
/* ----------------------------------------------- */
|
||||
/* GLOBAL SYNCHRONIZATION LOCKS */
|
||||
|
|
@ -406,66 +436,72 @@ kmp_global_t __kmp_global = {{ 0 }};
|
|||
* false sharing if the alignment is not large enough for these locks */
|
||||
KMP_ALIGN_CACHE_INTERNODE
|
||||
|
||||
kmp_bootstrap_lock_t __kmp_initz_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_initz_lock ); /* Control initializations */
|
||||
kmp_bootstrap_lock_t __kmp_initz_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER(
|
||||
__kmp_initz_lock); /* Control initializations */
|
||||
KMP_ALIGN_CACHE_INTERNODE
|
||||
kmp_bootstrap_lock_t __kmp_forkjoin_lock; /* control fork/join access */
|
||||
KMP_ALIGN_CACHE_INTERNODE
|
||||
kmp_bootstrap_lock_t __kmp_exit_lock; /* exit() is not always thread-safe */
|
||||
kmp_bootstrap_lock_t __kmp_exit_lock; /* exit() is not always thread-safe */
|
||||
#if KMP_USE_MONITOR
|
||||
KMP_ALIGN_CACHE_INTERNODE
|
||||
kmp_bootstrap_lock_t __kmp_monitor_lock; /* control monitor thread creation */
|
||||
#endif
|
||||
/* used for the hack to allow threadprivate cache and __kmp_threads expansion
|
||||
to co-exist */
|
||||
KMP_ALIGN_CACHE_INTERNODE
|
||||
kmp_bootstrap_lock_t __kmp_tp_cached_lock; /* used for the hack to allow threadprivate cache and __kmp_threads expansion to co-exist */
|
||||
kmp_bootstrap_lock_t __kmp_tp_cached_lock;
|
||||
|
||||
KMP_ALIGN_CACHE_INTERNODE
|
||||
kmp_lock_t __kmp_global_lock; /* Control OS/global access */
|
||||
kmp_lock_t __kmp_global_lock; /* Control OS/global access */
|
||||
KMP_ALIGN_CACHE_INTERNODE
|
||||
kmp_queuing_lock_t __kmp_dispatch_lock; /* Control dispatch access */
|
||||
kmp_queuing_lock_t __kmp_dispatch_lock; /* Control dispatch access */
|
||||
KMP_ALIGN_CACHE_INTERNODE
|
||||
kmp_lock_t __kmp_debug_lock; /* Control I/O access for KMP_DEBUG */
|
||||
kmp_lock_t __kmp_debug_lock; /* Control I/O access for KMP_DEBUG */
|
||||
#else
|
||||
KMP_ALIGN_CACHE
|
||||
|
||||
kmp_bootstrap_lock_t __kmp_initz_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_initz_lock ); /* Control initializations */
|
||||
kmp_bootstrap_lock_t __kmp_initz_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER(
|
||||
__kmp_initz_lock); /* Control initializations */
|
||||
kmp_bootstrap_lock_t __kmp_forkjoin_lock; /* control fork/join access */
|
||||
kmp_bootstrap_lock_t __kmp_exit_lock; /* exit() is not always thread-safe */
|
||||
kmp_bootstrap_lock_t __kmp_exit_lock; /* exit() is not always thread-safe */
|
||||
#if KMP_USE_MONITOR
|
||||
kmp_bootstrap_lock_t __kmp_monitor_lock; /* control monitor thread creation */
|
||||
#endif
|
||||
kmp_bootstrap_lock_t __kmp_tp_cached_lock; /* used for the hack to allow threadprivate cache and __kmp_threads expansion to co-exist */
|
||||
/* used for the hack to allow threadprivate cache and __kmp_threads expansion
|
||||
to co-exist */
|
||||
kmp_bootstrap_lock_t __kmp_tp_cached_lock;
|
||||
|
||||
KMP_ALIGN(128)
|
||||
kmp_lock_t __kmp_global_lock; /* Control OS/global access */
|
||||
kmp_lock_t __kmp_global_lock; /* Control OS/global access */
|
||||
KMP_ALIGN(128)
|
||||
kmp_queuing_lock_t __kmp_dispatch_lock; /* Control dispatch access */
|
||||
kmp_queuing_lock_t __kmp_dispatch_lock; /* Control dispatch access */
|
||||
KMP_ALIGN(128)
|
||||
kmp_lock_t __kmp_debug_lock; /* Control I/O access for KMP_DEBUG */
|
||||
kmp_lock_t __kmp_debug_lock; /* Control I/O access for KMP_DEBUG */
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------- */
|
||||
|
||||
#if KMP_HANDLE_SIGNALS
|
||||
/*
|
||||
Signal handling is disabled by default, because it confuses users: In case of sigsegv
|
||||
(or other trouble) in user code signal handler catches the signal, which then "appears" in
|
||||
the monitor thread (when the monitor executes raise() function). Users see signal in the
|
||||
monitor thread and blame OpenMP RTL.
|
||||
/* Signal handling is disabled by default, because it confuses users: In case of
|
||||
sigsegv (or other trouble) in user code signal handler catches the signal,
|
||||
which then "appears" in the monitor thread (when the monitor executes raise()
|
||||
function). Users see signal in the monitor thread and blame OpenMP RTL.
|
||||
|
||||
Grant said signal handling required on some older OSes (Irix?) supported by KAI, because
|
||||
bad applications hung but not aborted. Currently it is not a problem for Linux* OS, OS X* and
|
||||
Windows* OS.
|
||||
Grant said signal handling required on some older OSes (Irix?) supported by
|
||||
KAI, because bad applications hung but not aborted. Currently it is not a
|
||||
problem for Linux* OS, OS X* and Windows* OS.
|
||||
|
||||
Grant: Found new hangs for EL4, EL5, and a Fedora Core machine. So I'm putting
|
||||
the default back for now to see if that fixes hangs on those machines.
|
||||
Grant: Found new hangs for EL4, EL5, and a Fedora Core machine. So I'm
|
||||
putting the default back for now to see if that fixes hangs on those
|
||||
machines.
|
||||
|
||||
2010-04013 Lev: It was a bug in Fortran RTL. Fortran RTL prints a kind of stack backtrace
|
||||
when program is aborting, but the code is not signal-safe. When multiple signals raised at
|
||||
the same time (which occurs in dynamic negative tests because all the worker threads detects
|
||||
the same error), Fortran RTL may hang. The bug finally fixed in Fortran RTL library provided
|
||||
by Steve R., and will be available soon.
|
||||
*/
|
||||
int __kmp_handle_signals = FALSE;
|
||||
2010-04013 Lev: It was a bug in Fortran RTL. Fortran RTL prints a kind of
|
||||
stack backtrace when program is aborting, but the code is not signal-safe.
|
||||
When multiple signals raised at the same time (which occurs in dynamic
|
||||
negative tests because all the worker threads detects the same error),
|
||||
Fortran RTL may hang. The bug finally fixed in Fortran RTL library provided
|
||||
by Steve R., and will be available soon. */
|
||||
int __kmp_handle_signals = FALSE;
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------- */
|
||||
|
|
@ -473,27 +509,22 @@ kmp_lock_t __kmp_debug_lock; /* Control I/O access for KMP_DEBUG */
|
|||
kmp_key_t __kmp_tv_key = 0;
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#ifdef DEBUG_SUSPEND
|
||||
int
|
||||
get_suspend_count_( void ) {
|
||||
int count = __kmp_suspend_count;
|
||||
__kmp_suspend_count = 0;
|
||||
return count;
|
||||
}
|
||||
void
|
||||
set_suspend_count_( int * value ) {
|
||||
__kmp_suspend_count = *value;
|
||||
int get_suspend_count_(void) {
|
||||
int count = __kmp_suspend_count;
|
||||
__kmp_suspend_count = 0;
|
||||
return count;
|
||||
}
|
||||
void set_suspend_count_(int *value) { __kmp_suspend_count = *value; }
|
||||
#endif
|
||||
|
||||
// Symbols for MS mutual detection.
|
||||
int _You_must_link_with_exactly_one_OpenMP_library = 1;
|
||||
int _You_must_link_with_Intel_OpenMP_library = 1;
|
||||
#if KMP_OS_WINDOWS && ( KMP_VERSION_MAJOR > 4 )
|
||||
int _You_must_link_with_Microsoft_OpenMP_library = 1;
|
||||
int _You_must_link_with_Intel_OpenMP_library = 1;
|
||||
#if KMP_OS_WINDOWS && (KMP_VERSION_MAJOR > 4)
|
||||
int _You_must_link_with_Microsoft_OpenMP_library = 1;
|
||||
#endif
|
||||
|
||||
// end of file //
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -19,173 +19,164 @@
|
|||
#include "kmp_str.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/*
|
||||
kmp_i18n_id.inc defines kmp_i18n_id_t type. It is an enumeration with identifiers of all the
|
||||
messages in the catalog. There is one special identifier: kmp_i18n_null, which denotes absence
|
||||
of message.
|
||||
*/
|
||||
/* kmp_i18n_id.inc defines kmp_i18n_id_t type. It is an enumeration with
|
||||
identifiers of all the messages in the catalog. There is one special
|
||||
identifier: kmp_i18n_null, which denotes absence of message. */
|
||||
#include "kmp_i18n_id.inc" // Generated file. Do not edit it manually.
|
||||
|
||||
/*
|
||||
Low-level functions handling message catalog. __kmp_i18n_open() opens message catalog,
|
||||
__kmp_i18n_closes() it. Explicit opening is not required: if message catalog is not yet open,
|
||||
__kmp_i18n_catgets() will open it implicitly. However, catalog should be explicitly closed,
|
||||
otherwise resources (mamory, handles) may leak.
|
||||
/* Low-level functions handling message catalog. __kmp_i18n_open() opens message
|
||||
catalog, __kmp_i18n_closes() it. Explicit opening is not required: if message
|
||||
catalog is not yet open, __kmp_i18n_catgets() will open it implicitly.
|
||||
However, catalog should be explicitly closed, otherwise resources (mamory,
|
||||
handles) may leak.
|
||||
|
||||
__kmp_i18n_catgets() returns read-only string. It should not be freed.
|
||||
__kmp_i18n_catgets() returns read-only string. It should not be freed.
|
||||
|
||||
KMP_I18N_STR macro simplifies acces to strings in message catalog a bit. Following two lines are
|
||||
equivalent:
|
||||
KMP_I18N_STR macro simplifies acces to strings in message catalog a bit.
|
||||
Following two lines are equivalent:
|
||||
|
||||
__kmp_i18n_catgets( kmp_i18n_str_Warning )
|
||||
KMP_I18N_STR( Warning )
|
||||
__kmp_i18n_catgets( kmp_i18n_str_Warning )
|
||||
KMP_I18N_STR( Warning )
|
||||
*/
|
||||
|
||||
void __kmp_i18n_catopen();
|
||||
void __kmp_i18n_catclose();
|
||||
char const * __kmp_i18n_catgets( kmp_i18n_id_t id );
|
||||
void __kmp_i18n_catopen();
|
||||
void __kmp_i18n_catclose();
|
||||
char const *__kmp_i18n_catgets(kmp_i18n_id_t id);
|
||||
|
||||
#define KMP_I18N_STR( id ) __kmp_i18n_catgets( kmp_i18n_str_ ## id )
|
||||
#define KMP_I18N_STR(id) __kmp_i18n_catgets(kmp_i18n_str_##id)
|
||||
|
||||
/* High-level interface for printing strings targeted to the user.
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------------------------
|
||||
All the strings are divided into 3 types:
|
||||
* messages,
|
||||
* hints,
|
||||
* system errors.
|
||||
|
||||
High-level interface for printing strings targeted to the user.
|
||||
There are 3 kind of message severities:
|
||||
* informational messages,
|
||||
* warnings (non-fatal errors),
|
||||
* fatal errors.
|
||||
|
||||
All the strings are divided into 3 types:
|
||||
For example:
|
||||
OMP: Warning #2: Cannot open message catalog "libguide.cat": (1)
|
||||
OMP: System error #2: No such file or directory (2)
|
||||
OMP: Hint: Please check NLSPATH environment variable. (3)
|
||||
OMP: Info #3: Default messages will be used. (4)
|
||||
|
||||
* messages,
|
||||
* hints,
|
||||
* system errors.
|
||||
|
||||
There are 3 kind of message severities:
|
||||
|
||||
* informational messages,
|
||||
* warnings (non-fatal errors),
|
||||
* fatal errors.
|
||||
|
||||
For example:
|
||||
|
||||
OMP: Warning #2: Cannot open message catalog "libguide.cat": (1)
|
||||
OMP: System error #2: No such file or directory (2)
|
||||
OMP: Hint: Please check NLSPATH environment variable. (3)
|
||||
OMP: Info #3: Default messages will be used. (4)
|
||||
|
||||
where
|
||||
|
||||
(1) is a message of warning severity,
|
||||
(2) is a system error caused the previous warning,
|
||||
(3) is a hint for the user how to fix the problem,
|
||||
(4) is a message of informational severity.
|
||||
where
|
||||
(1) is a message of warning severity,
|
||||
(2) is a system error caused the previous warning,
|
||||
(3) is a hint for the user how to fix the problem,
|
||||
(4) is a message of informational severity.
|
||||
|
||||
Usage in complex cases (message is accompanied with hints and system errors):
|
||||
|
||||
int error = errno; // We need save errno immediately, because it may be changed.
|
||||
__kmp_msg(
|
||||
kmp_ms_warning, // Severity
|
||||
KMP_MSG( CantOpenMessageCatalog, name ), // Primary message
|
||||
KMP_ERR( error ), // System error
|
||||
KMP_HNT( CheckNLSPATH ), // Hint
|
||||
__kmp_msg_null // Variadic argument list finisher
|
||||
);
|
||||
int error = errno; // We need save errno immediately, because it may
|
||||
// be changed.
|
||||
__kmp_msg(
|
||||
kmp_ms_warning, // Severity
|
||||
KMP_MSG( CantOpenMessageCatalog, name ), // Primary message
|
||||
KMP_ERR( error ), // System error
|
||||
KMP_HNT( CheckNLSPATH ), // Hint
|
||||
__kmp_msg_null // Variadic argument list finisher
|
||||
);
|
||||
|
||||
Usage in simple cases (just a message, no system errors or hints):
|
||||
|
||||
KMP_INFORM( WillUseDefaultMessages );
|
||||
KMP_WARNING( CantOpenMessageCatalog, name );
|
||||
KMP_FATAL( StackOverlap );
|
||||
KMP_SYSFAIL( "pthread_create", status );
|
||||
KMP_CHECK_SYSFAIL( "pthread_create", status );
|
||||
KMP_CHECK_SYSFAIL_ERRNO( "gettimeofday", status );
|
||||
|
||||
------------------------------------------------------------------------------------------------
|
||||
Usage in simple cases (just a message, no system errors or hints):
|
||||
KMP_INFORM( WillUseDefaultMessages );
|
||||
KMP_WARNING( CantOpenMessageCatalog, name );
|
||||
KMP_FATAL( StackOverlap );
|
||||
KMP_SYSFAIL( "pthread_create", status );
|
||||
KMP_CHECK_SYSFAIL( "pthread_create", status );
|
||||
KMP_CHECK_SYSFAIL_ERRNO( "gettimeofday", status );
|
||||
*/
|
||||
|
||||
enum kmp_msg_type {
|
||||
kmp_mt_dummy = 0, // Special type for internal purposes.
|
||||
kmp_mt_mesg = 4, // Primary OpenMP message, could be information, warning, or fatal.
|
||||
kmp_mt_hint = 5, // Hint to the user.
|
||||
kmp_mt_syserr = -1 // System error message.
|
||||
kmp_mt_dummy = 0, // Special type for internal purposes.
|
||||
kmp_mt_mesg =
|
||||
4, // Primary OpenMP message, could be information, warning, or fatal.
|
||||
kmp_mt_hint = 5, // Hint to the user.
|
||||
kmp_mt_syserr = -1 // System error message.
|
||||
}; // enum kmp_msg_type
|
||||
typedef enum kmp_msg_type kmp_msg_type_t;
|
||||
typedef enum kmp_msg_type kmp_msg_type_t;
|
||||
|
||||
struct kmp_msg {
|
||||
kmp_msg_type_t type;
|
||||
int num;
|
||||
char const * str;
|
||||
int len;
|
||||
kmp_msg_type_t type;
|
||||
int num;
|
||||
char const *str;
|
||||
int len;
|
||||
}; // struct kmp_message
|
||||
typedef struct kmp_msg kmp_msg_t;
|
||||
typedef struct kmp_msg kmp_msg_t;
|
||||
|
||||
// Two special messages.
|
||||
extern kmp_msg_t __kmp_msg_empty; // Can be used in place where message is required syntactically.
|
||||
extern kmp_msg_t __kmp_msg_null; // Denotes the end of variadic list of arguments.
|
||||
extern kmp_msg_t __kmp_msg_empty; // Can be used in place where message is
|
||||
// required syntactically.
|
||||
extern kmp_msg_t
|
||||
__kmp_msg_null; // Denotes the end of variadic list of arguments.
|
||||
|
||||
// Helper functions. Creates messages either from message catalog or from system. Note: these
|
||||
// functions allocate memory. You should pass created messages to __kmp_msg() function, it will
|
||||
// print messages and destroy them.
|
||||
kmp_msg_t __kmp_msg_format( unsigned id_arg, ... );
|
||||
kmp_msg_t __kmp_msg_error_code( int code );
|
||||
kmp_msg_t __kmp_msg_error_mesg( char const * mesg );
|
||||
// Helper functions. Creates messages either from message catalog or from
|
||||
// system. Note: these functions allocate memory. You should pass created
|
||||
// messages to __kmp_msg() function, it will print messages and destroy them.
|
||||
kmp_msg_t __kmp_msg_format(unsigned id_arg, ...);
|
||||
kmp_msg_t __kmp_msg_error_code(int code);
|
||||
kmp_msg_t __kmp_msg_error_mesg(char const *mesg);
|
||||
|
||||
// Helper macros to make calls shorter.
|
||||
#define KMP_MSG( ... ) __kmp_msg_format( kmp_i18n_msg_ ## __VA_ARGS__ )
|
||||
#define KMP_HNT( ... ) __kmp_msg_format( kmp_i18n_hnt_ ## __VA_ARGS__ )
|
||||
#define KMP_SYSERRCODE( code ) __kmp_msg_error_code( code )
|
||||
#define KMP_SYSERRMESG( mesg ) __kmp_msg_error_mesg( mesg )
|
||||
#define KMP_MSG(...) __kmp_msg_format(kmp_i18n_msg_##__VA_ARGS__)
|
||||
#define KMP_HNT(...) __kmp_msg_format(kmp_i18n_hnt_##__VA_ARGS__)
|
||||
#define KMP_SYSERRCODE(code) __kmp_msg_error_code(code)
|
||||
#define KMP_SYSERRMESG(mesg) __kmp_msg_error_mesg(mesg)
|
||||
#define KMP_ERR KMP_SYSERRCODE
|
||||
|
||||
// Message severity.
|
||||
enum kmp_msg_severity {
|
||||
kmp_ms_inform, // Just information for the user.
|
||||
kmp_ms_warning, // Non-fatal error, execution continues.
|
||||
kmp_ms_fatal // Fatal error, program aborts.
|
||||
kmp_ms_inform, // Just information for the user.
|
||||
kmp_ms_warning, // Non-fatal error, execution continues.
|
||||
kmp_ms_fatal // Fatal error, program aborts.
|
||||
}; // enum kmp_msg_severity
|
||||
typedef enum kmp_msg_severity kmp_msg_severity_t;
|
||||
typedef enum kmp_msg_severity kmp_msg_severity_t;
|
||||
|
||||
// Primary function for printing messages for the user. The first message is mandatory. Any number
|
||||
// of system errors and hints may be specified. Argument list must be finished with __kmp_msg_null.
|
||||
void __kmp_msg( kmp_msg_severity_t severity, kmp_msg_t message, ... );
|
||||
// Primary function for printing messages for the user. The first message is
|
||||
// mandatory. Any number of system errors and hints may be specified. Argument
|
||||
// list must be finished with __kmp_msg_null.
|
||||
void __kmp_msg(kmp_msg_severity_t severity, kmp_msg_t message, ...);
|
||||
|
||||
// Helper macros to make calls shorter in simple cases.
|
||||
#define KMP_INFORM( ... ) __kmp_msg( kmp_ms_inform, KMP_MSG( __VA_ARGS__ ), __kmp_msg_null )
|
||||
#define KMP_WARNING( ... ) __kmp_msg( kmp_ms_warning, KMP_MSG( __VA_ARGS__ ), __kmp_msg_null )
|
||||
#define KMP_FATAL( ... ) __kmp_msg( kmp_ms_fatal, KMP_MSG( __VA_ARGS__ ), __kmp_msg_null )
|
||||
#define KMP_SYSFAIL( func, error ) \
|
||||
__kmp_msg( \
|
||||
kmp_ms_fatal, \
|
||||
KMP_MSG( FunctionError, func ), \
|
||||
KMP_SYSERRCODE( error ), \
|
||||
__kmp_msg_null \
|
||||
)
|
||||
#define KMP_INFORM(...) \
|
||||
__kmp_msg(kmp_ms_inform, KMP_MSG(__VA_ARGS__), __kmp_msg_null)
|
||||
#define KMP_WARNING(...) \
|
||||
__kmp_msg(kmp_ms_warning, KMP_MSG(__VA_ARGS__), __kmp_msg_null)
|
||||
#define KMP_FATAL(...) \
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(__VA_ARGS__), __kmp_msg_null)
|
||||
#define KMP_SYSFAIL(func, error) \
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FunctionError, func), KMP_SYSERRCODE(error), \
|
||||
__kmp_msg_null)
|
||||
|
||||
// Check error, if not zero, generate fatal error message.
|
||||
#define KMP_CHECK_SYSFAIL( func, error ) \
|
||||
{ \
|
||||
if ( error ) { \
|
||||
KMP_SYSFAIL( func, error ); \
|
||||
}; \
|
||||
}
|
||||
#define KMP_CHECK_SYSFAIL(func, error) \
|
||||
{ \
|
||||
if (error) { \
|
||||
KMP_SYSFAIL(func, error); \
|
||||
}; \
|
||||
}
|
||||
|
||||
// Check status, if not zero, generate fatal error message using errno.
|
||||
#define KMP_CHECK_SYSFAIL_ERRNO( func, status ) \
|
||||
{ \
|
||||
if ( status != 0 ) { \
|
||||
int error = errno; \
|
||||
KMP_SYSFAIL( func, error ); \
|
||||
}; \
|
||||
}
|
||||
#define KMP_CHECK_SYSFAIL_ERRNO(func, status) \
|
||||
{ \
|
||||
if (status != 0) { \
|
||||
int error = errno; \
|
||||
KMP_SYSFAIL(func, error); \
|
||||
}; \
|
||||
}
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
void __kmp_i18n_dump_catalog( kmp_str_buf_t * buffer );
|
||||
void __kmp_i18n_dump_catalog(kmp_str_buf_t *buffer);
|
||||
#endif // KMP_DEBUG
|
||||
|
||||
#ifdef __cplusplus
|
||||
}; // extern "C"
|
||||
}; // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // KMP_I18N_H
|
||||
|
|
|
|||
|
|
@ -13,26 +13,20 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------------------------
|
||||
Object generated from this source file is linked to Windows* OS DLL import library (libompmd.lib)
|
||||
only! It is not a part of regular static or dynamic OpenMP RTL. Any code that just needs to go
|
||||
in the libompmd.lib (but not in libompmt.lib and libompmd.dll) should be placed in this
|
||||
file.
|
||||
------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
/* Object generated from this source file is linked to Windows* OS DLL import
|
||||
library (libompmd.lib) only! It is not a part of regular static or dynamic
|
||||
OpenMP RTL. Any code that just needs to go in the libompmd.lib (but not in
|
||||
libompmt.lib and libompmd.dll) should be placed in this file. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
These symbols are required for mutual exclusion with Microsoft OpenMP RTL (and compatibility
|
||||
with MS Compiler).
|
||||
*/
|
||||
/*These symbols are required for mutual exclusion with Microsoft OpenMP RTL
|
||||
(and compatibility with MS Compiler). */
|
||||
|
||||
int _You_must_link_with_exactly_one_OpenMP_library = 1;
|
||||
int _You_must_link_with_Intel_OpenMP_library = 1;
|
||||
int _You_must_link_with_Intel_OpenMP_library = 1;
|
||||
int _You_must_link_with_Microsoft_OpenMP_library = 1;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -13,236 +13,218 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#ifndef __ABSOFT_WIN
|
||||
# include <sys/types.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include "kmp_os.h"
|
||||
#include "kmp_lock.h"
|
||||
#include "kmp_str.h"
|
||||
#include "kmp_io.h"
|
||||
#include "kmp.h" // KMP_GTID_DNE, __kmp_debug_buf, etc
|
||||
#include "kmp_io.h"
|
||||
#include "kmp_lock.h"
|
||||
#include "kmp_os.h"
|
||||
#include "kmp_str.h"
|
||||
|
||||
#if KMP_OS_WINDOWS
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 271 310 )
|
||||
# include <windows.h>
|
||||
# pragma warning( pop )
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 271 310)
|
||||
#include <windows.h>
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
kmp_bootstrap_lock_t __kmp_stdio_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_stdio_lock ); /* Control stdio functions */
|
||||
kmp_bootstrap_lock_t __kmp_console_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_console_lock ); /* Control console initialization */
|
||||
kmp_bootstrap_lock_t __kmp_stdio_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER(
|
||||
__kmp_stdio_lock); /* Control stdio functions */
|
||||
kmp_bootstrap_lock_t __kmp_console_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER(
|
||||
__kmp_console_lock); /* Control console initialization */
|
||||
|
||||
#if KMP_OS_WINDOWS
|
||||
|
||||
# ifdef KMP_DEBUG
|
||||
/* __kmp_stdout is used only for dev build */
|
||||
static HANDLE __kmp_stdout = NULL;
|
||||
# endif
|
||||
static HANDLE __kmp_stderr = NULL;
|
||||
static int __kmp_console_exists = FALSE;
|
||||
static kmp_str_buf_t __kmp_console_buf;
|
||||
#ifdef KMP_DEBUG
|
||||
/* __kmp_stdout is used only for dev build */
|
||||
static HANDLE __kmp_stdout = NULL;
|
||||
#endif
|
||||
static HANDLE __kmp_stderr = NULL;
|
||||
static int __kmp_console_exists = FALSE;
|
||||
static kmp_str_buf_t __kmp_console_buf;
|
||||
|
||||
static int
|
||||
is_console( void )
|
||||
{
|
||||
char buffer[ 128 ];
|
||||
DWORD rc = 0;
|
||||
DWORD err = 0;
|
||||
// Try to get console title.
|
||||
SetLastError( 0 );
|
||||
// GetConsoleTitle does not reset last error in case of success or short buffer,
|
||||
// so we need to clear it explicitly.
|
||||
rc = GetConsoleTitle( buffer, sizeof( buffer ) );
|
||||
if ( rc == 0 ) {
|
||||
// rc == 0 means getting console title failed. Let us find out why.
|
||||
err = GetLastError();
|
||||
// err == 0 means buffer too short (we suppose console exists).
|
||||
// In Window applications we usually have err == 6 (invalid handle).
|
||||
}; // if
|
||||
return rc > 0 || err == 0;
|
||||
static int is_console(void) {
|
||||
char buffer[128];
|
||||
DWORD rc = 0;
|
||||
DWORD err = 0;
|
||||
// Try to get console title.
|
||||
SetLastError(0);
|
||||
// GetConsoleTitle does not reset last error in case of success or short
|
||||
// buffer, so we need to clear it explicitly.
|
||||
rc = GetConsoleTitle(buffer, sizeof(buffer));
|
||||
if (rc == 0) {
|
||||
// rc == 0 means getting console title failed. Let us find out why.
|
||||
err = GetLastError();
|
||||
// err == 0 means buffer too short (we suppose console exists).
|
||||
// In Window applications we usually have err == 6 (invalid handle).
|
||||
}; // if
|
||||
return rc > 0 || err == 0;
|
||||
}
|
||||
|
||||
void __kmp_close_console(void) {
|
||||
/* wait until user presses return before closing window */
|
||||
/* TODO only close if a window was opened */
|
||||
if (__kmp_console_exists) {
|
||||
#ifdef KMP_DEBUG
|
||||
/* standard out is used only in dev build */
|
||||
__kmp_stdout = NULL;
|
||||
#endif
|
||||
__kmp_stderr = NULL;
|
||||
__kmp_str_buf_free(&__kmp_console_buf);
|
||||
__kmp_console_exists = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* For windows, call this before stdout, stderr, or stdin are used.
|
||||
It opens a console window and starts processing */
|
||||
static void __kmp_redirect_output(void) {
|
||||
__kmp_acquire_bootstrap_lock(&__kmp_console_lock);
|
||||
|
||||
if (!__kmp_console_exists) {
|
||||
#ifdef KMP_DEBUG
|
||||
/* standard out is used only in dev build */
|
||||
HANDLE ho;
|
||||
#endif
|
||||
HANDLE he;
|
||||
|
||||
__kmp_str_buf_init(&__kmp_console_buf);
|
||||
|
||||
AllocConsole();
|
||||
// We do not check the result of AllocConsole because
|
||||
// 1. the call is harmless
|
||||
// 2. it is not clear how to communicate failue
|
||||
// 3. we will detect failure later when we get handle(s)
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
ho = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (ho == INVALID_HANDLE_VALUE || ho == NULL) {
|
||||
|
||||
DWORD err = GetLastError();
|
||||
// TODO: output error somehow (maybe message box)
|
||||
__kmp_stdout = NULL;
|
||||
|
||||
} else {
|
||||
|
||||
__kmp_stdout = ho; // temporary code, need new global for ho
|
||||
}
|
||||
#endif
|
||||
he = GetStdHandle(STD_ERROR_HANDLE);
|
||||
if (he == INVALID_HANDLE_VALUE || he == NULL) {
|
||||
|
||||
void
|
||||
__kmp_close_console( void )
|
||||
{
|
||||
/* wait until user presses return before closing window */
|
||||
/* TODO only close if a window was opened */
|
||||
if( __kmp_console_exists ) {
|
||||
#ifdef KMP_DEBUG
|
||||
/* standard out is used only in dev build */
|
||||
__kmp_stdout = NULL;
|
||||
#endif
|
||||
__kmp_stderr = NULL;
|
||||
__kmp_str_buf_free( &__kmp_console_buf );
|
||||
__kmp_console_exists = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* For windows, call this before stdout, stderr, or stdin are used.
|
||||
* It opens a console window and starts processing */
|
||||
static void
|
||||
__kmp_redirect_output( void )
|
||||
{
|
||||
__kmp_acquire_bootstrap_lock( &__kmp_console_lock );
|
||||
|
||||
if( ! __kmp_console_exists ) {
|
||||
#ifdef KMP_DEBUG
|
||||
/* standard out is used only in dev build */
|
||||
HANDLE ho;
|
||||
#endif
|
||||
HANDLE he;
|
||||
|
||||
__kmp_str_buf_init( &__kmp_console_buf );
|
||||
|
||||
AllocConsole();
|
||||
// We do not check the result of AllocConsole because
|
||||
// 1. the call is harmless
|
||||
// 2. it is not clear how to communicate failue
|
||||
// 3. we will detect failure later when we get handle(s)
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
ho = GetStdHandle( STD_OUTPUT_HANDLE );
|
||||
if ( ho == INVALID_HANDLE_VALUE || ho == NULL ) {
|
||||
|
||||
DWORD err = GetLastError();
|
||||
// TODO: output error somehow (maybe message box)
|
||||
__kmp_stdout = NULL;
|
||||
|
||||
} else {
|
||||
|
||||
__kmp_stdout = ho; // temporary code, need new global for ho
|
||||
|
||||
}
|
||||
#endif
|
||||
he = GetStdHandle( STD_ERROR_HANDLE );
|
||||
if ( he == INVALID_HANDLE_VALUE || he == NULL ) {
|
||||
|
||||
DWORD err = GetLastError();
|
||||
// TODO: output error somehow (maybe message box)
|
||||
__kmp_stderr = NULL;
|
||||
|
||||
} else {
|
||||
|
||||
__kmp_stderr = he; // temporary code, need new global
|
||||
}
|
||||
__kmp_console_exists = TRUE;
|
||||
}
|
||||
__kmp_release_bootstrap_lock( &__kmp_console_lock );
|
||||
DWORD err = GetLastError();
|
||||
// TODO: output error somehow (maybe message box)
|
||||
__kmp_stderr = NULL;
|
||||
|
||||
} else {
|
||||
|
||||
__kmp_stderr = he; // temporary code, need new global
|
||||
}
|
||||
__kmp_console_exists = TRUE;
|
||||
}
|
||||
__kmp_release_bootstrap_lock(&__kmp_console_lock);
|
||||
}
|
||||
|
||||
#else
|
||||
#define __kmp_stderr (stderr)
|
||||
#define __kmp_stderr (stderr)
|
||||
#endif /* KMP_OS_WINDOWS */
|
||||
|
||||
void
|
||||
__kmp_vprintf( enum kmp_io __kmp_io, char const * format, va_list ap )
|
||||
{
|
||||
#if KMP_OS_WINDOWS
|
||||
if( !__kmp_console_exists ) {
|
||||
__kmp_redirect_output();
|
||||
}
|
||||
if( ! __kmp_stderr && __kmp_io == kmp_err ) {
|
||||
return;
|
||||
}
|
||||
#ifdef KMP_DEBUG
|
||||
if( ! __kmp_stdout && __kmp_io == kmp_out ) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif /* KMP_OS_WINDOWS */
|
||||
void __kmp_vprintf(enum kmp_io __kmp_io, char const *format, va_list ap) {
|
||||
#if KMP_OS_WINDOWS
|
||||
if (!__kmp_console_exists) {
|
||||
__kmp_redirect_output();
|
||||
}
|
||||
if (!__kmp_stderr && __kmp_io == kmp_err) {
|
||||
return;
|
||||
}
|
||||
#ifdef KMP_DEBUG
|
||||
if (!__kmp_stdout && __kmp_io == kmp_out) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif /* KMP_OS_WINDOWS */
|
||||
|
||||
if ( __kmp_debug_buf && __kmp_debug_buffer != NULL ) {
|
||||
if (__kmp_debug_buf && __kmp_debug_buffer != NULL) {
|
||||
|
||||
int dc = ( __kmp_debug_buf_atomic ?
|
||||
KMP_TEST_THEN_INC32( & __kmp_debug_count) : __kmp_debug_count++ )
|
||||
% __kmp_debug_buf_lines;
|
||||
char *db = & __kmp_debug_buffer[ dc * __kmp_debug_buf_chars ];
|
||||
int chars = 0;
|
||||
int dc = (__kmp_debug_buf_atomic ? KMP_TEST_THEN_INC32(&__kmp_debug_count)
|
||||
: __kmp_debug_count++) %
|
||||
__kmp_debug_buf_lines;
|
||||
char *db = &__kmp_debug_buffer[dc * __kmp_debug_buf_chars];
|
||||
int chars = 0;
|
||||
|
||||
#ifdef KMP_DEBUG_PIDS
|
||||
chars = KMP_SNPRINTF( db, __kmp_debug_buf_chars, "pid=%d: ", (kmp_int32)getpid() );
|
||||
#endif
|
||||
chars += KMP_VSNPRINTF( db, __kmp_debug_buf_chars, format, ap );
|
||||
#ifdef KMP_DEBUG_PIDS
|
||||
chars = KMP_SNPRINTF(db, __kmp_debug_buf_chars, "pid=%d: ",
|
||||
(kmp_int32)getpid());
|
||||
#endif
|
||||
chars += KMP_VSNPRINTF(db, __kmp_debug_buf_chars, format, ap);
|
||||
|
||||
if ( chars + 1 > __kmp_debug_buf_chars ) {
|
||||
if ( chars + 1 > __kmp_debug_buf_warn_chars ) {
|
||||
#if KMP_OS_WINDOWS
|
||||
DWORD count;
|
||||
__kmp_str_buf_print( &__kmp_console_buf,
|
||||
"OMP warning: Debugging buffer overflow; increase KMP_DEBUG_BUF_CHARS to %d\n",
|
||||
chars + 1 );
|
||||
WriteFile( __kmp_stderr, __kmp_console_buf.str, __kmp_console_buf.used, &count, NULL );
|
||||
__kmp_str_buf_clear( &__kmp_console_buf );
|
||||
#else
|
||||
fprintf( __kmp_stderr,
|
||||
"OMP warning: Debugging buffer overflow; increase KMP_DEBUG_BUF_CHARS to %d\n",
|
||||
chars + 1 );
|
||||
fflush( __kmp_stderr );
|
||||
#endif
|
||||
__kmp_debug_buf_warn_chars = chars + 1;
|
||||
}
|
||||
/* terminate string if overflow occurred */
|
||||
db[ __kmp_debug_buf_chars - 2 ] = '\n';
|
||||
db[ __kmp_debug_buf_chars - 1 ] = '\0';
|
||||
}
|
||||
} else {
|
||||
#if KMP_OS_WINDOWS
|
||||
DWORD count;
|
||||
#ifdef KMP_DEBUG_PIDS
|
||||
__kmp_str_buf_print( &__kmp_console_buf, "pid=%d: ",
|
||||
(kmp_int32)getpid() );
|
||||
#endif
|
||||
__kmp_str_buf_vprint( &__kmp_console_buf, format, ap );
|
||||
WriteFile(
|
||||
__kmp_stderr,
|
||||
__kmp_console_buf.str,
|
||||
__kmp_console_buf.used,
|
||||
&count,
|
||||
NULL
|
||||
);
|
||||
__kmp_str_buf_clear( &__kmp_console_buf );
|
||||
#else
|
||||
#ifdef KMP_DEBUG_PIDS
|
||||
fprintf( __kmp_stderr, "pid=%d: ", (kmp_int32)getpid() );
|
||||
#endif
|
||||
vfprintf( __kmp_stderr, format, ap );
|
||||
fflush( __kmp_stderr );
|
||||
#endif
|
||||
if (chars + 1 > __kmp_debug_buf_chars) {
|
||||
if (chars + 1 > __kmp_debug_buf_warn_chars) {
|
||||
#if KMP_OS_WINDOWS
|
||||
DWORD count;
|
||||
__kmp_str_buf_print(&__kmp_console_buf, "OMP warning: Debugging buffer "
|
||||
"overflow; increase "
|
||||
"KMP_DEBUG_BUF_CHARS to %d\n",
|
||||
chars + 1);
|
||||
WriteFile(__kmp_stderr, __kmp_console_buf.str, __kmp_console_buf.used,
|
||||
&count, NULL);
|
||||
__kmp_str_buf_clear(&__kmp_console_buf);
|
||||
#else
|
||||
fprintf(__kmp_stderr, "OMP warning: Debugging buffer overflow; "
|
||||
"increase KMP_DEBUG_BUF_CHARS to %d\n",
|
||||
chars + 1);
|
||||
fflush(__kmp_stderr);
|
||||
#endif
|
||||
__kmp_debug_buf_warn_chars = chars + 1;
|
||||
}
|
||||
/* terminate string if overflow occurred */
|
||||
db[__kmp_debug_buf_chars - 2] = '\n';
|
||||
db[__kmp_debug_buf_chars - 1] = '\0';
|
||||
}
|
||||
} else {
|
||||
#if KMP_OS_WINDOWS
|
||||
DWORD count;
|
||||
#ifdef KMP_DEBUG_PIDS
|
||||
__kmp_str_buf_print(&__kmp_console_buf, "pid=%d: ", (kmp_int32)getpid());
|
||||
#endif
|
||||
__kmp_str_buf_vprint(&__kmp_console_buf, format, ap);
|
||||
WriteFile(__kmp_stderr, __kmp_console_buf.str, __kmp_console_buf.used,
|
||||
&count, NULL);
|
||||
__kmp_str_buf_clear(&__kmp_console_buf);
|
||||
#else
|
||||
#ifdef KMP_DEBUG_PIDS
|
||||
fprintf(__kmp_stderr, "pid=%d: ", (kmp_int32)getpid());
|
||||
#endif
|
||||
vfprintf(__kmp_stderr, format, ap);
|
||||
fflush(__kmp_stderr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_printf( char const * format, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, format );
|
||||
void __kmp_printf(char const *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
__kmp_acquire_bootstrap_lock( & __kmp_stdio_lock );
|
||||
__kmp_vprintf( kmp_err, format, ap );
|
||||
__kmp_release_bootstrap_lock( & __kmp_stdio_lock );
|
||||
__kmp_acquire_bootstrap_lock(&__kmp_stdio_lock);
|
||||
__kmp_vprintf(kmp_err, format, ap);
|
||||
__kmp_release_bootstrap_lock(&__kmp_stdio_lock);
|
||||
|
||||
va_end( ap );
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_printf_no_lock( char const * format, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, format );
|
||||
void __kmp_printf_no_lock(char const *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
__kmp_vprintf( kmp_err, format, ap );
|
||||
__kmp_vprintf(kmp_err, format, ap);
|
||||
|
||||
va_end( ap );
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -20,25 +20,21 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
enum kmp_io {
|
||||
kmp_out = 0,
|
||||
kmp_err
|
||||
};
|
||||
enum kmp_io { kmp_out = 0, kmp_err };
|
||||
|
||||
extern kmp_bootstrap_lock_t __kmp_stdio_lock; /* Control stdio functions */
|
||||
extern kmp_bootstrap_lock_t __kmp_console_lock; /* Control console initialization */
|
||||
extern kmp_bootstrap_lock_t __kmp_stdio_lock; /* Control stdio functions */
|
||||
extern kmp_bootstrap_lock_t
|
||||
__kmp_console_lock; /* Control console initialization */
|
||||
|
||||
extern void __kmp_vprintf( enum kmp_io __kmp_io, char const * format, va_list ap );
|
||||
extern void __kmp_printf( char const * format, ... );
|
||||
extern void __kmp_printf_no_lock( char const * format, ... );
|
||||
extern void __kmp_close_console( void );
|
||||
extern void __kmp_vprintf(enum kmp_io __kmp_io, char const *format, va_list ap);
|
||||
extern void __kmp_printf(char const *format, ...);
|
||||
extern void __kmp_printf_no_lock(char const *format, ...);
|
||||
extern void __kmp_close_console(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* KMP_IO_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -19,145 +19,133 @@
|
|||
#include "kmp_itt.h"
|
||||
|
||||
#if KMP_DEBUG
|
||||
#include "kmp_itt.inl"
|
||||
#include "kmp_itt.inl"
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_ITT_NOTIFY
|
||||
|
||||
kmp_int32 __kmp_barrier_domain_count;
|
||||
kmp_int32 __kmp_region_domain_count;
|
||||
__itt_domain* __kmp_itt_barrier_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
__itt_domain* __kmp_itt_region_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
__itt_domain* __kmp_itt_imbalance_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
kmp_int32 __kmp_itt_region_team_size[KMP_MAX_FRAME_DOMAINS];
|
||||
__itt_domain * metadata_domain = NULL;
|
||||
__itt_string_handle * string_handle_imbl = NULL;
|
||||
__itt_string_handle * string_handle_loop = NULL;
|
||||
__itt_string_handle * string_handle_sngl = NULL;
|
||||
kmp_int32 __kmp_barrier_domain_count;
|
||||
kmp_int32 __kmp_region_domain_count;
|
||||
__itt_domain *__kmp_itt_barrier_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
__itt_domain *__kmp_itt_region_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
__itt_domain *__kmp_itt_imbalance_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
kmp_int32 __kmp_itt_region_team_size[KMP_MAX_FRAME_DOMAINS];
|
||||
__itt_domain *metadata_domain = NULL;
|
||||
__itt_string_handle *string_handle_imbl = NULL;
|
||||
__itt_string_handle *string_handle_loop = NULL;
|
||||
__itt_string_handle *string_handle_sngl = NULL;
|
||||
|
||||
#include "kmp_version.h"
|
||||
#include "kmp_i18n.h"
|
||||
#include "kmp_str.h"
|
||||
#include "kmp_i18n.h"
|
||||
#include "kmp_str.h"
|
||||
#include "kmp_version.h"
|
||||
|
||||
KMP_BUILD_ASSERT( sizeof( kmp_itt_mark_t ) == sizeof( __itt_mark_type ) );
|
||||
KMP_BUILD_ASSERT(sizeof(kmp_itt_mark_t) == sizeof(__itt_mark_type));
|
||||
|
||||
/*
|
||||
Previously used warnings:
|
||||
/* Previously used warnings:
|
||||
|
||||
KMP_WARNING( IttAllNotifDisabled );
|
||||
KMP_WARNING( IttObjNotifDisabled );
|
||||
KMP_WARNING( IttMarkNotifDisabled );
|
||||
KMP_WARNING( IttUnloadLibFailed, libittnotify );
|
||||
*/
|
||||
KMP_WARNING( IttAllNotifDisabled );
|
||||
KMP_WARNING( IttObjNotifDisabled );
|
||||
KMP_WARNING( IttMarkNotifDisabled );
|
||||
KMP_WARNING( IttUnloadLibFailed, libittnotify );
|
||||
*/
|
||||
|
||||
|
||||
kmp_int32 __kmp_itt_prepare_delay = 0;
|
||||
kmp_bootstrap_lock_t __kmp_itt_debug_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_itt_debug_lock );
|
||||
kmp_int32 __kmp_itt_prepare_delay = 0;
|
||||
kmp_bootstrap_lock_t __kmp_itt_debug_lock =
|
||||
KMP_BOOTSTRAP_LOCK_INITIALIZER(__kmp_itt_debug_lock);
|
||||
|
||||
#endif // USE_ITT_NOTIFY
|
||||
|
||||
void __kmp_itt_initialize() {
|
||||
|
||||
// ITTNotify library is loaded and initialized at first call to any ittnotify function,
|
||||
// so we do not need to explicitly load it any more.
|
||||
// Jusr report OMP RTL version to ITTNotify.
|
||||
// ITTNotify library is loaded and initialized at first call to any ittnotify
|
||||
// function, so we do not need to explicitly load it any more. Just report OMP
|
||||
// RTL version to ITTNotify.
|
||||
|
||||
#if USE_ITT_NOTIFY
|
||||
// Report OpenMP RTL version.
|
||||
kmp_str_buf_t buf;
|
||||
__itt_mark_type version;
|
||||
__kmp_str_buf_init( & buf );
|
||||
__kmp_str_buf_print(
|
||||
& buf,
|
||||
"OMP RTL Version %d.%d.%d",
|
||||
__kmp_version_major,
|
||||
__kmp_version_minor,
|
||||
__kmp_version_build
|
||||
);
|
||||
if ( __itt_api_version_ptr != NULL ) {
|
||||
__kmp_str_buf_print( & buf, ":%s", __itt_api_version() );
|
||||
}; // if
|
||||
version = __itt_mark_create( buf.str );
|
||||
__itt_mark( version, NULL );
|
||||
__kmp_str_buf_free( & buf );
|
||||
#endif
|
||||
#if USE_ITT_NOTIFY
|
||||
// Report OpenMP RTL version.
|
||||
kmp_str_buf_t buf;
|
||||
__itt_mark_type version;
|
||||
__kmp_str_buf_init(&buf);
|
||||
__kmp_str_buf_print(&buf, "OMP RTL Version %d.%d.%d", __kmp_version_major,
|
||||
__kmp_version_minor, __kmp_version_build);
|
||||
if (__itt_api_version_ptr != NULL) {
|
||||
__kmp_str_buf_print(&buf, ":%s", __itt_api_version());
|
||||
}; // if
|
||||
version = __itt_mark_create(buf.str);
|
||||
__itt_mark(version, NULL);
|
||||
__kmp_str_buf_free(&buf);
|
||||
#endif
|
||||
|
||||
} // __kmp_itt_initialize
|
||||
|
||||
|
||||
void __kmp_itt_destroy() {
|
||||
#if USE_ITT_NOTIFY
|
||||
__kmp_itt_fini_ittlib();
|
||||
#endif
|
||||
#if USE_ITT_NOTIFY
|
||||
__kmp_itt_fini_ittlib();
|
||||
#endif
|
||||
} // __kmp_itt_destroy
|
||||
|
||||
extern "C" void __itt_error_handler(__itt_error_code err, va_list args) {
|
||||
|
||||
extern "C"
|
||||
void
|
||||
__itt_error_handler(
|
||||
__itt_error_code err,
|
||||
va_list args
|
||||
) {
|
||||
|
||||
switch ( err ) {
|
||||
case __itt_error_no_module : {
|
||||
char const * library = va_arg( args, char const * );
|
||||
switch (err) {
|
||||
case __itt_error_no_module: {
|
||||
char const *library = va_arg(args, char const *);
|
||||
#if KMP_OS_WINDOWS
|
||||
int sys_err = va_arg( args, int );
|
||||
kmp_msg_t err_code = KMP_SYSERRCODE( sys_err );
|
||||
__kmp_msg( kmp_ms_warning, KMP_MSG( IttLoadLibFailed, library ), err_code, __kmp_msg_null );
|
||||
if (__kmp_generate_warnings == kmp_warnings_off) {
|
||||
__kmp_str_free(&err_code.str);
|
||||
}
|
||||
int sys_err = va_arg(args, int);
|
||||
kmp_msg_t err_code = KMP_SYSERRCODE(sys_err);
|
||||
__kmp_msg(kmp_ms_warning, KMP_MSG(IttLoadLibFailed, library), err_code,
|
||||
__kmp_msg_null);
|
||||
if (__kmp_generate_warnings == kmp_warnings_off) {
|
||||
__kmp_str_free(&err_code.str);
|
||||
}
|
||||
#else
|
||||
char const * sys_err = va_arg( args, char const * );
|
||||
kmp_msg_t err_code = KMP_SYSERRMESG( sys_err );
|
||||
__kmp_msg( kmp_ms_warning, KMP_MSG( IttLoadLibFailed, library ), err_code, __kmp_msg_null );
|
||||
if (__kmp_generate_warnings == kmp_warnings_off) {
|
||||
__kmp_str_free(&err_code.str);
|
||||
}
|
||||
char const *sys_err = va_arg(args, char const *);
|
||||
kmp_msg_t err_code = KMP_SYSERRMESG(sys_err);
|
||||
__kmp_msg(kmp_ms_warning, KMP_MSG(IttLoadLibFailed, library), err_code,
|
||||
__kmp_msg_null);
|
||||
if (__kmp_generate_warnings == kmp_warnings_off) {
|
||||
__kmp_str_free(&err_code.str);
|
||||
}
|
||||
#endif
|
||||
} break;
|
||||
case __itt_error_no_symbol : {
|
||||
char const * library = va_arg( args, char const * );
|
||||
char const * symbol = va_arg( args, char const * );
|
||||
KMP_WARNING( IttLookupFailed, symbol, library );
|
||||
} break;
|
||||
case __itt_error_unknown_group : {
|
||||
char const * var = va_arg( args, char const * );
|
||||
char const * group = va_arg( args, char const * );
|
||||
KMP_WARNING( IttUnknownGroup, var, group );
|
||||
} break;
|
||||
case __itt_error_env_too_long : {
|
||||
char const * var = va_arg( args, char const * );
|
||||
size_t act_len = va_arg( args, size_t );
|
||||
size_t max_len = va_arg( args, size_t );
|
||||
KMP_WARNING( IttEnvVarTooLong, var, (unsigned long) act_len, (unsigned long) max_len );
|
||||
} break;
|
||||
case __itt_error_cant_read_env : {
|
||||
char const * var = va_arg( args, char const * );
|
||||
int sys_err = va_arg( args, int );
|
||||
kmp_msg_t err_code = KMP_ERR( sys_err );
|
||||
__kmp_msg( kmp_ms_warning, KMP_MSG( CantGetEnvVar, var ), err_code, __kmp_msg_null );
|
||||
if (__kmp_generate_warnings == kmp_warnings_off) {
|
||||
__kmp_str_free(&err_code.str);
|
||||
}
|
||||
} break;
|
||||
case __itt_error_system : {
|
||||
char const * func = va_arg( args, char const * );
|
||||
int sys_err = va_arg( args, int );
|
||||
kmp_msg_t err_code = KMP_SYSERRCODE( sys_err );
|
||||
__kmp_msg( kmp_ms_warning, KMP_MSG( IttFunctionError, func ), err_code, __kmp_msg_null );
|
||||
if (__kmp_generate_warnings == kmp_warnings_off) {
|
||||
__kmp_str_free(&err_code.str);
|
||||
}
|
||||
} break;
|
||||
default : {
|
||||
KMP_WARNING( IttUnknownError, err );
|
||||
};
|
||||
}; // switch
|
||||
|
||||
} break;
|
||||
case __itt_error_no_symbol: {
|
||||
char const *library = va_arg(args, char const *);
|
||||
char const *symbol = va_arg(args, char const *);
|
||||
KMP_WARNING(IttLookupFailed, symbol, library);
|
||||
} break;
|
||||
case __itt_error_unknown_group: {
|
||||
char const *var = va_arg(args, char const *);
|
||||
char const *group = va_arg(args, char const *);
|
||||
KMP_WARNING(IttUnknownGroup, var, group);
|
||||
} break;
|
||||
case __itt_error_env_too_long: {
|
||||
char const *var = va_arg(args, char const *);
|
||||
size_t act_len = va_arg(args, size_t);
|
||||
size_t max_len = va_arg(args, size_t);
|
||||
KMP_WARNING(IttEnvVarTooLong, var, (unsigned long)act_len,
|
||||
(unsigned long)max_len);
|
||||
} break;
|
||||
case __itt_error_cant_read_env: {
|
||||
char const *var = va_arg(args, char const *);
|
||||
int sys_err = va_arg(args, int);
|
||||
kmp_msg_t err_code = KMP_ERR(sys_err);
|
||||
__kmp_msg(kmp_ms_warning, KMP_MSG(CantGetEnvVar, var), err_code,
|
||||
__kmp_msg_null);
|
||||
if (__kmp_generate_warnings == kmp_warnings_off) {
|
||||
__kmp_str_free(&err_code.str);
|
||||
}
|
||||
} break;
|
||||
case __itt_error_system: {
|
||||
char const *func = va_arg(args, char const *);
|
||||
int sys_err = va_arg(args, int);
|
||||
kmp_msg_t err_code = KMP_SYSERRCODE(sys_err);
|
||||
__kmp_msg(kmp_ms_warning, KMP_MSG(IttFunctionError, func), err_code,
|
||||
__kmp_msg_null);
|
||||
if (__kmp_generate_warnings == kmp_warnings_off) {
|
||||
__kmp_str_free(&err_code.str);
|
||||
}
|
||||
} break;
|
||||
default: { KMP_WARNING(IttUnknownError, err); };
|
||||
}; // switch
|
||||
} // __itt_error_handler
|
||||
|
||||
#endif /* USE_ITT_BUILD */
|
||||
|
|
|
|||
|
|
@ -24,104 +24,121 @@
|
|||
#include "legacy/ittnotify.h"
|
||||
|
||||
#if KMP_DEBUG
|
||||
#define __kmp_inline // Turn off inlining in debug mode.
|
||||
#define __kmp_inline // Turn off inlining in debug mode.
|
||||
#else
|
||||
#define __kmp_inline static inline
|
||||
#define __kmp_inline static inline
|
||||
#endif
|
||||
|
||||
#if USE_ITT_NOTIFY
|
||||
extern kmp_int32 __kmp_itt_prepare_delay;
|
||||
# ifdef __cplusplus
|
||||
extern "C" void __kmp_itt_fini_ittlib(void);
|
||||
# else
|
||||
extern void __kmp_itt_fini_ittlib(void);
|
||||
# endif
|
||||
extern kmp_int32 __kmp_itt_prepare_delay;
|
||||
#ifdef __cplusplus
|
||||
extern "C" void __kmp_itt_fini_ittlib(void);
|
||||
#else
|
||||
extern void __kmp_itt_fini_ittlib(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Simplify the handling of an argument that is only required when USE_ITT_BUILD is enabled.
|
||||
#define USE_ITT_BUILD_ARG(x) ,x
|
||||
// Simplify the handling of an argument that is only required when USE_ITT_BUILD
|
||||
// is enabled.
|
||||
#define USE_ITT_BUILD_ARG(x) , x
|
||||
|
||||
void __kmp_itt_initialize();
|
||||
void __kmp_itt_destroy();
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// New stuff for reporting high-level constructs.
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
// Note the naming convention:
|
||||
// __kmp_itt_xxxing() function should be called before action, while
|
||||
// __kmp_itt_xxxed() function should be called after action.
|
||||
|
||||
// --- Parallel region reporting ---
|
||||
__kmp_inline void __kmp_itt_region_forking( int gtid, int team_size, int barriers ); // Master only, before forking threads.
|
||||
__kmp_inline void __kmp_itt_region_joined( int gtid ); // Master only, after joining threads.
|
||||
// (*) Note: A thread may execute tasks after this point, though.
|
||||
__kmp_inline void
|
||||
__kmp_itt_region_forking(int gtid, int team_size,
|
||||
int barriers); // Master only, before forking threads.
|
||||
__kmp_inline void
|
||||
__kmp_itt_region_joined(int gtid); // Master only, after joining threads.
|
||||
// (*) Note: A thread may execute tasks after this point, though.
|
||||
|
||||
// --- Frame reporting ---
|
||||
// region = 0 - no regions, region = 1 - parallel, region = 2 - serialized parallel
|
||||
__kmp_inline void __kmp_itt_frame_submit( int gtid, __itt_timestamp begin, __itt_timestamp end, int imbalance, ident_t *loc, int team_size, int region = 0 );
|
||||
// region=0: no regions, region=1: parallel, region=2: serialized parallel
|
||||
__kmp_inline void __kmp_itt_frame_submit(int gtid, __itt_timestamp begin,
|
||||
__itt_timestamp end, int imbalance,
|
||||
ident_t *loc, int team_size,
|
||||
int region = 0);
|
||||
|
||||
// --- Metadata reporting ---
|
||||
// begin/end - begin/end timestamps of a barrier frame, imbalance - aggregated wait time value, reduction -if this is a reduction barrier
|
||||
__kmp_inline void __kmp_itt_metadata_imbalance( int gtid, kmp_uint64 begin, kmp_uint64 end, kmp_uint64 imbalance, kmp_uint64 reduction );
|
||||
// sched_type: 0 - static, 1 - dynamic, 2 - guided, 3 - custom (all others); iterations - loop trip count, chunk - chunk size
|
||||
__kmp_inline void __kmp_itt_metadata_loop( ident_t * loc, kmp_uint64 sched_type, kmp_uint64 iterations, kmp_uint64 chunk );
|
||||
__kmp_inline void __kmp_itt_metadata_single( ident_t * loc );
|
||||
// begin/end - begin/end timestamps of a barrier frame, imbalance - aggregated
|
||||
// wait time value, reduction -if this is a reduction barrier
|
||||
__kmp_inline void __kmp_itt_metadata_imbalance(int gtid, kmp_uint64 begin,
|
||||
kmp_uint64 end,
|
||||
kmp_uint64 imbalance,
|
||||
kmp_uint64 reduction);
|
||||
// sched_type: 0 - static, 1 - dynamic, 2 - guided, 3 - custom (all others);
|
||||
// iterations - loop trip count, chunk - chunk size
|
||||
__kmp_inline void __kmp_itt_metadata_loop(ident_t *loc, kmp_uint64 sched_type,
|
||||
kmp_uint64 iterations,
|
||||
kmp_uint64 chunk);
|
||||
__kmp_inline void __kmp_itt_metadata_single(ident_t *loc);
|
||||
|
||||
// --- Barrier reporting ---
|
||||
__kmp_inline void * __kmp_itt_barrier_object( int gtid, int bt, int set_name = 0, int delta = 0 );
|
||||
__kmp_inline void __kmp_itt_barrier_starting( int gtid, void * object );
|
||||
__kmp_inline void __kmp_itt_barrier_middle( int gtid, void * object );
|
||||
__kmp_inline void __kmp_itt_barrier_finished( int gtid, void * object );
|
||||
__kmp_inline void *__kmp_itt_barrier_object(int gtid, int bt, int set_name = 0,
|
||||
int delta = 0);
|
||||
__kmp_inline void __kmp_itt_barrier_starting(int gtid, void *object);
|
||||
__kmp_inline void __kmp_itt_barrier_middle(int gtid, void *object);
|
||||
__kmp_inline void __kmp_itt_barrier_finished(int gtid, void *object);
|
||||
|
||||
// --- Taskwait reporting ---
|
||||
__kmp_inline void * __kmp_itt_taskwait_object( int gtid );
|
||||
__kmp_inline void __kmp_itt_taskwait_starting( int gtid, void * object );
|
||||
__kmp_inline void __kmp_itt_taskwait_finished( int gtid, void * object );
|
||||
__kmp_inline void *__kmp_itt_taskwait_object(int gtid);
|
||||
__kmp_inline void __kmp_itt_taskwait_starting(int gtid, void *object);
|
||||
__kmp_inline void __kmp_itt_taskwait_finished(int gtid, void *object);
|
||||
|
||||
// --- Task reporting ---
|
||||
__kmp_inline void __kmp_itt_task_starting( void * object );
|
||||
__kmp_inline void __kmp_itt_task_finished( void * object );
|
||||
__kmp_inline void __kmp_itt_task_starting(void *object);
|
||||
__kmp_inline void __kmp_itt_task_finished(void *object);
|
||||
|
||||
// --- Lock reporting ---
|
||||
#if KMP_USE_DYNAMIC_LOCK
|
||||
__kmp_inline void __kmp_itt_lock_creating( kmp_user_lock_p lock, const ident_t * );
|
||||
__kmp_inline void __kmp_itt_lock_creating(kmp_user_lock_p lock,
|
||||
const ident_t *);
|
||||
#else
|
||||
__kmp_inline void __kmp_itt_lock_creating( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_lock_creating(kmp_user_lock_p lock);
|
||||
#endif
|
||||
__kmp_inline void __kmp_itt_lock_acquiring( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_lock_acquired( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_lock_releasing( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_lock_cancelled( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_lock_destroyed( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_lock_acquiring(kmp_user_lock_p lock);
|
||||
__kmp_inline void __kmp_itt_lock_acquired(kmp_user_lock_p lock);
|
||||
__kmp_inline void __kmp_itt_lock_releasing(kmp_user_lock_p lock);
|
||||
__kmp_inline void __kmp_itt_lock_cancelled(kmp_user_lock_p lock);
|
||||
__kmp_inline void __kmp_itt_lock_destroyed(kmp_user_lock_p lock);
|
||||
|
||||
// --- Critical reporting ---
|
||||
#if KMP_USE_DYNAMIC_LOCK
|
||||
__kmp_inline void __kmp_itt_critical_creating( kmp_user_lock_p lock, const ident_t * );
|
||||
__kmp_inline void __kmp_itt_critical_creating(kmp_user_lock_p lock,
|
||||
const ident_t *);
|
||||
#else
|
||||
__kmp_inline void __kmp_itt_critical_creating( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_critical_creating(kmp_user_lock_p lock);
|
||||
#endif
|
||||
__kmp_inline void __kmp_itt_critical_acquiring( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_critical_acquired( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_critical_releasing( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_critical_destroyed( kmp_user_lock_p lock );
|
||||
__kmp_inline void __kmp_itt_critical_acquiring(kmp_user_lock_p lock);
|
||||
__kmp_inline void __kmp_itt_critical_acquired(kmp_user_lock_p lock);
|
||||
__kmp_inline void __kmp_itt_critical_releasing(kmp_user_lock_p lock);
|
||||
__kmp_inline void __kmp_itt_critical_destroyed(kmp_user_lock_p lock);
|
||||
|
||||
// --- Single reporting ---
|
||||
__kmp_inline void __kmp_itt_single_start( int gtid );
|
||||
__kmp_inline void __kmp_itt_single_end( int gtid );
|
||||
__kmp_inline void __kmp_itt_single_start(int gtid);
|
||||
__kmp_inline void __kmp_itt_single_end(int gtid);
|
||||
|
||||
// --- Ordered reporting ---
|
||||
__kmp_inline void __kmp_itt_ordered_init( int gtid );
|
||||
__kmp_inline void __kmp_itt_ordered_prep( int gtid );
|
||||
__kmp_inline void __kmp_itt_ordered_start( int gtid );
|
||||
__kmp_inline void __kmp_itt_ordered_end( int gtid );
|
||||
__kmp_inline void __kmp_itt_ordered_init(int gtid);
|
||||
__kmp_inline void __kmp_itt_ordered_prep(int gtid);
|
||||
__kmp_inline void __kmp_itt_ordered_start(int gtid);
|
||||
__kmp_inline void __kmp_itt_ordered_end(int gtid);
|
||||
|
||||
// --- Threads reporting ---
|
||||
__kmp_inline void __kmp_itt_thread_ignore();
|
||||
__kmp_inline void __kmp_itt_thread_name( int gtid );
|
||||
__kmp_inline void __kmp_itt_thread_ignore();
|
||||
__kmp_inline void __kmp_itt_thread_name(int gtid);
|
||||
|
||||
// --- System objects ---
|
||||
__kmp_inline void __kmp_itt_system_object_created( void * object, char const * name );
|
||||
__kmp_inline void __kmp_itt_system_object_created(void *object,
|
||||
char const *name);
|
||||
|
||||
// --- Stack stitching ---
|
||||
__kmp_inline __itt_caller __kmp_itt_stack_caller_create(void);
|
||||
|
|
@ -129,184 +146,189 @@ __kmp_inline void __kmp_itt_stack_caller_destroy(__itt_caller);
|
|||
__kmp_inline void __kmp_itt_stack_callee_enter(__itt_caller);
|
||||
__kmp_inline void __kmp_itt_stack_callee_leave(__itt_caller);
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Old stuff for reporting low-level internal synchronization.
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
#if USE_ITT_NOTIFY
|
||||
|
||||
/*
|
||||
* Support for SSC marks, which are used by SDE
|
||||
* http://software.intel.com/en-us/articles/intel-software-development-emulator
|
||||
* to mark points in instruction traces that represent spin-loops and are
|
||||
* therefore uninteresting when collecting traces for architecture simulation.
|
||||
*/
|
||||
#ifndef INCLUDE_SSC_MARKS
|
||||
# define INCLUDE_SSC_MARKS (KMP_OS_LINUX && KMP_ARCH_X86_64)
|
||||
#endif
|
||||
/* Support for SSC marks, which are used by SDE
|
||||
http://software.intel.com/en-us/articles/intel-software-development-emulator
|
||||
to mark points in instruction traces that represent spin-loops and are
|
||||
therefore uninteresting when collecting traces for architecture simulation.
|
||||
*/
|
||||
#ifndef INCLUDE_SSC_MARKS
|
||||
#define INCLUDE_SSC_MARKS (KMP_OS_LINUX && KMP_ARCH_X86_64)
|
||||
#endif
|
||||
|
||||
/* Linux 64 only for now */
|
||||
#if (INCLUDE_SSC_MARKS && KMP_OS_LINUX && KMP_ARCH_X86_64)
|
||||
// Portable (at least for gcc and icc) code to insert the necessary instructions
|
||||
// to set %ebx and execute the unlikely no-op.
|
||||
#if defined( __INTEL_COMPILER )
|
||||
# define INSERT_SSC_MARK(tag) __SSC_MARK(tag)
|
||||
#else
|
||||
# define INSERT_SSC_MARK(tag) \
|
||||
__asm__ __volatile__ ("movl %0, %%ebx; .byte 0x64, 0x67, 0x90 " ::"i"(tag):"%ebx")
|
||||
#endif
|
||||
#else
|
||||
# define INSERT_SSC_MARK(tag) ((void)0)
|
||||
#endif
|
||||
/* Linux 64 only for now */
|
||||
#if (INCLUDE_SSC_MARKS && KMP_OS_LINUX && KMP_ARCH_X86_64)
|
||||
// Portable (at least for gcc and icc) code to insert the necessary instructions
|
||||
// to set %ebx and execute the unlikely no-op.
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#define INSERT_SSC_MARK(tag) __SSC_MARK(tag)
|
||||
#else
|
||||
#define INSERT_SSC_MARK(tag) \
|
||||
__asm__ __volatile__("movl %0, %%ebx; .byte 0x64, 0x67, 0x90 " ::"i"(tag) \
|
||||
: "%ebx")
|
||||
#endif
|
||||
#else
|
||||
#define INSERT_SSC_MARK(tag) ((void)0)
|
||||
#endif
|
||||
|
||||
/* Markers for the start and end of regions that represent polling and
|
||||
* are therefore uninteresting to architectural simulations 0x4376 and
|
||||
* 0x4377 are arbitrary numbers that should be unique in the space of
|
||||
* SSC tags, but there is no central issuing authority rather
|
||||
* randomness is expected to work.
|
||||
*/
|
||||
#define SSC_MARK_SPIN_START() INSERT_SSC_MARK(0x4376)
|
||||
#define SSC_MARK_SPIN_END() INSERT_SSC_MARK(0x4377)
|
||||
/* Markers for the start and end of regions that represent polling and are
|
||||
therefore uninteresting to architectural simulations 0x4376 and 0x4377 are
|
||||
arbitrary numbers that should be unique in the space of SSC tags, but there
|
||||
is no central issuing authority rather randomness is expected to work. */
|
||||
#define SSC_MARK_SPIN_START() INSERT_SSC_MARK(0x4376)
|
||||
#define SSC_MARK_SPIN_END() INSERT_SSC_MARK(0x4377)
|
||||
|
||||
// Markers for architecture simulation.
|
||||
// FORKING : Before the master thread forks.
|
||||
// JOINING : At the start of the join.
|
||||
// INVOKING : Before the threads invoke microtasks.
|
||||
// DISPATCH_INIT: At the start of dynamically scheduled loop.
|
||||
// DISPATCH_NEXT: After claming next iteration of dynamically scheduled loop.
|
||||
#define SSC_MARK_FORKING() INSERT_SSC_MARK(0xd693)
|
||||
#define SSC_MARK_JOINING() INSERT_SSC_MARK(0xd694)
|
||||
#define SSC_MARK_INVOKING() INSERT_SSC_MARK(0xd695)
|
||||
#define SSC_MARK_DISPATCH_INIT() INSERT_SSC_MARK(0xd696)
|
||||
#define SSC_MARK_DISPATCH_NEXT() INSERT_SSC_MARK(0xd697)
|
||||
// Markers for architecture simulation.
|
||||
// FORKING : Before the master thread forks.
|
||||
// JOINING : At the start of the join.
|
||||
// INVOKING : Before the threads invoke microtasks.
|
||||
// DISPATCH_INIT: At the start of dynamically scheduled loop.
|
||||
// DISPATCH_NEXT: After claming next iteration of dynamically scheduled loop.
|
||||
#define SSC_MARK_FORKING() INSERT_SSC_MARK(0xd693)
|
||||
#define SSC_MARK_JOINING() INSERT_SSC_MARK(0xd694)
|
||||
#define SSC_MARK_INVOKING() INSERT_SSC_MARK(0xd695)
|
||||
#define SSC_MARK_DISPATCH_INIT() INSERT_SSC_MARK(0xd696)
|
||||
#define SSC_MARK_DISPATCH_NEXT() INSERT_SSC_MARK(0xd697)
|
||||
|
||||
// The object is an address that associates a specific set of the prepare, acquire, release,
|
||||
// and cancel operations.
|
||||
// The object is an address that associates a specific set of the prepare,
|
||||
// acquire, release, and cancel operations.
|
||||
|
||||
/* Sync prepare indicates a thread is going to start waiting for another thread
|
||||
to send a release event. This operation should be done just before the thread
|
||||
begins checking for the existence of the release event */
|
||||
/* Sync prepare indicates a thread is going to start waiting for another thread
|
||||
to send a release event. This operation should be done just before the
|
||||
thread begins checking for the existence of the release event */
|
||||
|
||||
/* Sync cancel indicates a thread is cancelling a wait on another thread anc
|
||||
continuing execution without waiting for the other thread to release it */
|
||||
/* Sync cancel indicates a thread is cancelling a wait on another thread and
|
||||
continuing execution without waiting for the other thread to release it */
|
||||
|
||||
/* Sync acquired indicates a thread has received a release event from another
|
||||
thread and has stopped waiting. This operation must occur only after the release
|
||||
event is received. */
|
||||
/* Sync acquired indicates a thread has received a release event from another
|
||||
thread and has stopped waiting. This operation must occur only after the
|
||||
release event is received. */
|
||||
|
||||
/* Sync release indicates a thread is going to send a release event to another thread
|
||||
so it will stop waiting and continue execution. This operation must just happen before
|
||||
the release event. */
|
||||
/* Sync release indicates a thread is going to send a release event to another
|
||||
thread so it will stop waiting and continue execution. This operation must
|
||||
just happen before the release event. */
|
||||
|
||||
#define KMP_FSYNC_PREPARE( obj ) __itt_fsync_prepare( (void *)( obj ) )
|
||||
#define KMP_FSYNC_CANCEL( obj ) __itt_fsync_cancel( (void *)( obj ) )
|
||||
#define KMP_FSYNC_ACQUIRED( obj ) __itt_fsync_acquired( (void *)( obj ) )
|
||||
#define KMP_FSYNC_RELEASING( obj ) __itt_fsync_releasing( (void *)( obj ) )
|
||||
#define KMP_FSYNC_PREPARE(obj) __itt_fsync_prepare((void *)(obj))
|
||||
#define KMP_FSYNC_CANCEL(obj) __itt_fsync_cancel((void *)(obj))
|
||||
#define KMP_FSYNC_ACQUIRED(obj) __itt_fsync_acquired((void *)(obj))
|
||||
#define KMP_FSYNC_RELEASING(obj) __itt_fsync_releasing((void *)(obj))
|
||||
|
||||
/*
|
||||
In case of waiting in a spin loop, ITT wants KMP_FSYNC_PREPARE() to be called with a delay
|
||||
(and not called at all if waiting time is small). So, in spin loops, do not use
|
||||
KMP_FSYNC_PREPARE(), but use KMP_FSYNC_SPIN_INIT() (before spin loop),
|
||||
KMP_FSYNC_SPIN_PREPARE() (whithin the spin loop), and KMP_FSYNC_SPIN_ACQUIRED().
|
||||
See KMP_WAIT_YIELD() for example.
|
||||
*/
|
||||
/* In case of waiting in a spin loop, ITT wants KMP_FSYNC_PREPARE() to be called
|
||||
with a delay (and not called at all if waiting time is small). So, in spin
|
||||
loops, do not use KMP_FSYNC_PREPARE(), but use KMP_FSYNC_SPIN_INIT() (before
|
||||
spin loop), KMP_FSYNC_SPIN_PREPARE() (whithin the spin loop), and
|
||||
KMP_FSYNC_SPIN_ACQUIRED(). See KMP_WAIT_YIELD() for example. */
|
||||
|
||||
#undef KMP_FSYNC_SPIN_INIT
|
||||
#define KMP_FSYNC_SPIN_INIT( obj, spin ) \
|
||||
int sync_iters = 0; \
|
||||
if ( __itt_fsync_prepare_ptr ) { \
|
||||
if ( obj == NULL ) { \
|
||||
obj = spin; \
|
||||
} /* if */ \
|
||||
} /* if */ \
|
||||
SSC_MARK_SPIN_START()
|
||||
#undef KMP_FSYNC_SPIN_INIT
|
||||
#define KMP_FSYNC_SPIN_INIT(obj, spin) \
|
||||
int sync_iters = 0; \
|
||||
if (__itt_fsync_prepare_ptr) { \
|
||||
if (obj == NULL) { \
|
||||
obj = spin; \
|
||||
} /* if */ \
|
||||
} /* if */ \
|
||||
SSC_MARK_SPIN_START()
|
||||
|
||||
#undef KMP_FSYNC_SPIN_PREPARE
|
||||
#define KMP_FSYNC_SPIN_PREPARE( obj ) do { \
|
||||
if ( __itt_fsync_prepare_ptr && sync_iters < __kmp_itt_prepare_delay ) { \
|
||||
++ sync_iters; \
|
||||
if ( sync_iters >= __kmp_itt_prepare_delay ) { \
|
||||
KMP_FSYNC_PREPARE( (void*) obj ); \
|
||||
} /* if */ \
|
||||
} /* if */ \
|
||||
} while (0)
|
||||
#undef KMP_FSYNC_SPIN_ACQUIRED
|
||||
#define KMP_FSYNC_SPIN_ACQUIRED( obj ) do { \
|
||||
SSC_MARK_SPIN_END(); \
|
||||
if ( sync_iters >= __kmp_itt_prepare_delay ) { \
|
||||
KMP_FSYNC_ACQUIRED( (void*) obj ); \
|
||||
} /* if */ \
|
||||
} while (0)
|
||||
#undef KMP_FSYNC_SPIN_PREPARE
|
||||
#define KMP_FSYNC_SPIN_PREPARE(obj) \
|
||||
do { \
|
||||
if (__itt_fsync_prepare_ptr && sync_iters < __kmp_itt_prepare_delay) { \
|
||||
++sync_iters; \
|
||||
if (sync_iters >= __kmp_itt_prepare_delay) { \
|
||||
KMP_FSYNC_PREPARE((void *)obj); \
|
||||
} /* if */ \
|
||||
} /* if */ \
|
||||
} while (0)
|
||||
#undef KMP_FSYNC_SPIN_ACQUIRED
|
||||
#define KMP_FSYNC_SPIN_ACQUIRED(obj) \
|
||||
do { \
|
||||
SSC_MARK_SPIN_END(); \
|
||||
if (sync_iters >= __kmp_itt_prepare_delay) { \
|
||||
KMP_FSYNC_ACQUIRED((void *)obj); \
|
||||
} /* if */ \
|
||||
} while (0)
|
||||
|
||||
/* ITT will not report objects created within KMP_ITT_IGNORE(), e. g.:
|
||||
KMP_ITT_IGNORE(
|
||||
ptr = malloc( size );
|
||||
);
|
||||
*/
|
||||
#define KMP_ITT_IGNORE( statement ) do { \
|
||||
__itt_state_t __itt_state_; \
|
||||
if ( __itt_state_get_ptr ) { \
|
||||
__itt_state_ = __itt_state_get(); \
|
||||
__itt_obj_mode_set( __itt_obj_prop_ignore, __itt_obj_state_set ); \
|
||||
} /* if */ \
|
||||
{ statement } \
|
||||
if ( __itt_state_get_ptr ) { \
|
||||
__itt_state_set( __itt_state_ ); \
|
||||
} /* if */ \
|
||||
} while (0)
|
||||
/* ITT will not report objects created within KMP_ITT_IGNORE(), e. g.:
|
||||
KMP_ITT_IGNORE(
|
||||
ptr = malloc( size );
|
||||
);
|
||||
*/
|
||||
#define KMP_ITT_IGNORE(statement) \
|
||||
do { \
|
||||
__itt_state_t __itt_state_; \
|
||||
if (__itt_state_get_ptr) { \
|
||||
__itt_state_ = __itt_state_get(); \
|
||||
__itt_obj_mode_set(__itt_obj_prop_ignore, __itt_obj_state_set); \
|
||||
} /* if */ \
|
||||
{ statement } \
|
||||
if (__itt_state_get_ptr) { \
|
||||
__itt_state_set(__itt_state_); \
|
||||
} /* if */ \
|
||||
} while (0)
|
||||
|
||||
const int KMP_MAX_FRAME_DOMAINS = 512; // Maximum number of frame domains to use (maps to
|
||||
// different OpenMP regions in the user source code).
|
||||
extern kmp_int32 __kmp_barrier_domain_count;
|
||||
extern kmp_int32 __kmp_region_domain_count;
|
||||
extern __itt_domain* __kmp_itt_barrier_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
extern __itt_domain* __kmp_itt_region_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
extern __itt_domain* __kmp_itt_imbalance_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
extern kmp_int32 __kmp_itt_region_team_size[KMP_MAX_FRAME_DOMAINS];
|
||||
extern __itt_domain * metadata_domain;
|
||||
extern __itt_string_handle * string_handle_imbl;
|
||||
extern __itt_string_handle * string_handle_loop;
|
||||
extern __itt_string_handle * string_handle_sngl;
|
||||
const int KMP_MAX_FRAME_DOMAINS =
|
||||
512; // Maximum number of frame domains to use (maps to
|
||||
// different OpenMP regions in the user source code).
|
||||
extern kmp_int32 __kmp_barrier_domain_count;
|
||||
extern kmp_int32 __kmp_region_domain_count;
|
||||
extern __itt_domain *__kmp_itt_barrier_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
extern __itt_domain *__kmp_itt_region_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
extern __itt_domain *__kmp_itt_imbalance_domains[KMP_MAX_FRAME_DOMAINS];
|
||||
extern kmp_int32 __kmp_itt_region_team_size[KMP_MAX_FRAME_DOMAINS];
|
||||
extern __itt_domain *metadata_domain;
|
||||
extern __itt_string_handle *string_handle_imbl;
|
||||
extern __itt_string_handle *string_handle_loop;
|
||||
extern __itt_string_handle *string_handle_sngl;
|
||||
|
||||
#else
|
||||
|
||||
// Null definitions of the synchronization tracing functions.
|
||||
# define KMP_FSYNC_PREPARE( obj ) ((void)0)
|
||||
# define KMP_FSYNC_CANCEL( obj ) ((void)0)
|
||||
# define KMP_FSYNC_ACQUIRED( obj ) ((void)0)
|
||||
# define KMP_FSYNC_RELEASING( obj ) ((void)0)
|
||||
#define KMP_FSYNC_PREPARE(obj) ((void)0)
|
||||
#define KMP_FSYNC_CANCEL(obj) ((void)0)
|
||||
#define KMP_FSYNC_ACQUIRED(obj) ((void)0)
|
||||
#define KMP_FSYNC_RELEASING(obj) ((void)0)
|
||||
|
||||
# define KMP_FSYNC_SPIN_INIT( obj, spin ) ((void)0)
|
||||
# define KMP_FSYNC_SPIN_PREPARE( obj ) ((void)0)
|
||||
# define KMP_FSYNC_SPIN_ACQUIRED( obj ) ((void)0)
|
||||
#define KMP_FSYNC_SPIN_INIT(obj, spin) ((void)0)
|
||||
#define KMP_FSYNC_SPIN_PREPARE(obj) ((void)0)
|
||||
#define KMP_FSYNC_SPIN_ACQUIRED(obj) ((void)0)
|
||||
|
||||
# define KMP_ITT_IGNORE(stmt ) do { stmt } while (0)
|
||||
#define KMP_ITT_IGNORE(stmt) \
|
||||
do { \
|
||||
stmt \
|
||||
} while (0)
|
||||
|
||||
#endif // USE_ITT_NOTIFY
|
||||
|
||||
#if ! KMP_DEBUG
|
||||
// In release mode include definitions of inline functions.
|
||||
#include "kmp_itt.inl"
|
||||
#if !KMP_DEBUG
|
||||
// In release mode include definitions of inline functions.
|
||||
#include "kmp_itt.inl"
|
||||
#endif
|
||||
|
||||
#endif // KMP_ITT_H
|
||||
|
||||
#else /* USE_ITT_BUILD */
|
||||
#else /* USE_ITT_BUILD */
|
||||
|
||||
// Null definitions of the synchronization tracing functions.
|
||||
// If USE_ITT_BULID is not enabled, USE_ITT_NOTIFY cannot be either.
|
||||
// By defining these we avoid unpleasant ifdef tests in many places.
|
||||
# define KMP_FSYNC_PREPARE( obj ) ((void)0)
|
||||
# define KMP_FSYNC_CANCEL( obj ) ((void)0)
|
||||
# define KMP_FSYNC_ACQUIRED( obj ) ((void)0)
|
||||
# define KMP_FSYNC_RELEASING( obj ) ((void)0)
|
||||
#define KMP_FSYNC_PREPARE(obj) ((void)0)
|
||||
#define KMP_FSYNC_CANCEL(obj) ((void)0)
|
||||
#define KMP_FSYNC_ACQUIRED(obj) ((void)0)
|
||||
#define KMP_FSYNC_RELEASING(obj) ((void)0)
|
||||
|
||||
# define KMP_FSYNC_SPIN_INIT( obj, spin ) ((void)0)
|
||||
# define KMP_FSYNC_SPIN_PREPARE( obj ) ((void)0)
|
||||
# define KMP_FSYNC_SPIN_ACQUIRED( obj ) ((void)0)
|
||||
#define KMP_FSYNC_SPIN_INIT(obj, spin) ((void)0)
|
||||
#define KMP_FSYNC_SPIN_PREPARE(obj) ((void)0)
|
||||
#define KMP_FSYNC_SPIN_ACQUIRED(obj) ((void)0)
|
||||
|
||||
# define KMP_ITT_IGNORE(stmt ) do { stmt } while (0)
|
||||
#define KMP_ITT_IGNORE(stmt) \
|
||||
do { \
|
||||
stmt \
|
||||
} while (0)
|
||||
|
||||
# define USE_ITT_BUILD_ARG(x)
|
||||
#define USE_ITT_BUILD_ARG(x)
|
||||
|
||||
#endif /* USE_ITT_BUILD */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -16,216 +16,224 @@
|
|||
|
||||
|
||||
/* THIS FILE SHOULD NOT BE MODIFIED IN IDB INTERFACE LIBRARY CODE
|
||||
* It should instead be modified in the OpenMP runtime and copied
|
||||
* to the interface library code. This way we can minimize the
|
||||
* problems that this is sure to cause having two copies of the
|
||||
* same file.
|
||||
*
|
||||
* files live in libomp and libomp_db/src/include
|
||||
*/
|
||||
It should instead be modified in the OpenMP runtime and copied to the
|
||||
interface library code. This way we can minimize the problems that this is
|
||||
sure to cause having two copies of the same file.
|
||||
|
||||
Files live in libomp and libomp_db/src/include */
|
||||
|
||||
/* CHANGE THIS WHEN STRUCTURES BELOW CHANGE
|
||||
* Before we release this to a customer, please don't change this value. After it is released and
|
||||
* stable, then any new updates to the structures or data structure traversal algorithms need to
|
||||
* change this value.
|
||||
*/
|
||||
Before we release this to a customer, please don't change this value. After
|
||||
it is released and stable, then any new updates to the structures or data
|
||||
structure traversal algorithms need to change this value. */
|
||||
#define KMP_OMP_VERSION 9
|
||||
|
||||
typedef struct {
|
||||
kmp_int32 offset;
|
||||
kmp_int32 size;
|
||||
kmp_int32 offset;
|
||||
kmp_int32 size;
|
||||
} offset_and_size_t;
|
||||
|
||||
typedef struct {
|
||||
kmp_uint64 addr;
|
||||
kmp_int32 size;
|
||||
kmp_int32 padding;
|
||||
kmp_uint64 addr;
|
||||
kmp_int32 size;
|
||||
kmp_int32 padding;
|
||||
} addr_and_size_t;
|
||||
|
||||
typedef struct {
|
||||
kmp_uint64 flags; // Flags for future extensions.
|
||||
kmp_uint64 file; // Pointer to name of source file where the parallel region is.
|
||||
kmp_uint64 func; // Pointer to name of routine where the parallel region is.
|
||||
kmp_int32 begin; // Beginning of source line range.
|
||||
kmp_int32 end; // End of source line range.
|
||||
kmp_int32 num_threads; // Specified number of threads.
|
||||
kmp_uint64 flags; // Flags for future extensions.
|
||||
kmp_uint64
|
||||
file; // Pointer to name of source file where the parallel region is.
|
||||
kmp_uint64 func; // Pointer to name of routine where the parallel region is.
|
||||
kmp_int32 begin; // Beginning of source line range.
|
||||
kmp_int32 end; // End of source line range.
|
||||
kmp_int32 num_threads; // Specified number of threads.
|
||||
} kmp_omp_nthr_item_t;
|
||||
|
||||
typedef struct {
|
||||
kmp_int32 num; // Number of items in the arrray.
|
||||
kmp_uint64 array; // Address of array of kmp_omp_num_threads_item_t.
|
||||
kmp_int32 num; // Number of items in the arrray.
|
||||
kmp_uint64 array; // Address of array of kmp_omp_num_threads_item_t.
|
||||
} kmp_omp_nthr_info_t;
|
||||
|
||||
|
||||
/* This structure is known to the idb interface library */
|
||||
typedef struct {
|
||||
|
||||
/* Change this only if you make a fundamental data structure change here */
|
||||
kmp_int32 lib_version;
|
||||
/* Change this only if you make a fundamental data structure change here */
|
||||
kmp_int32 lib_version;
|
||||
|
||||
/* sanity check. Only should be checked if versions are identical
|
||||
* This is also used for backward compatibility to get the runtime
|
||||
* structure size if it the runtime is older than the interface */
|
||||
kmp_int32 sizeof_this_structure;
|
||||
/* sanity check. Only should be checked if versions are identical
|
||||
* This is also used for backward compatibility to get the runtime
|
||||
* structure size if it the runtime is older than the interface */
|
||||
kmp_int32 sizeof_this_structure;
|
||||
|
||||
/* OpenMP RTL version info. */
|
||||
addr_and_size_t major;
|
||||
addr_and_size_t minor;
|
||||
addr_and_size_t build;
|
||||
addr_and_size_t openmp_version;
|
||||
addr_and_size_t banner;
|
||||
/* OpenMP RTL version info. */
|
||||
addr_and_size_t major;
|
||||
addr_and_size_t minor;
|
||||
addr_and_size_t build;
|
||||
addr_and_size_t openmp_version;
|
||||
addr_and_size_t banner;
|
||||
|
||||
/* Various globals. */
|
||||
addr_and_size_t threads; // Pointer to __kmp_threads.
|
||||
addr_and_size_t roots; // Pointer to __kmp_root.
|
||||
addr_and_size_t capacity; // Pointer to __kmp_threads_capacity.
|
||||
addr_and_size_t monitor; // Pointer to __kmp_monitor.
|
||||
#if ! KMP_USE_DYNAMIC_LOCK
|
||||
addr_and_size_t lock_table; // Pointer to __kmp_lock_table.
|
||||
/* Various globals. */
|
||||
addr_and_size_t threads; // Pointer to __kmp_threads.
|
||||
addr_and_size_t roots; // Pointer to __kmp_root.
|
||||
addr_and_size_t capacity; // Pointer to __kmp_threads_capacity.
|
||||
addr_and_size_t monitor; // Pointer to __kmp_monitor.
|
||||
#if !KMP_USE_DYNAMIC_LOCK
|
||||
addr_and_size_t lock_table; // Pointer to __kmp_lock_table.
|
||||
#endif
|
||||
addr_and_size_t func_microtask;
|
||||
addr_and_size_t func_fork;
|
||||
addr_and_size_t func_fork_teams;
|
||||
addr_and_size_t team_counter;
|
||||
addr_and_size_t task_counter;
|
||||
addr_and_size_t nthr_info;
|
||||
kmp_int32 address_width;
|
||||
kmp_int32 indexed_locks;
|
||||
kmp_int32 last_barrier; // The end in enum barrier_type
|
||||
kmp_int32 deque_size; // TASK_DEQUE_SIZE
|
||||
addr_and_size_t func_microtask;
|
||||
addr_and_size_t func_fork;
|
||||
addr_and_size_t func_fork_teams;
|
||||
addr_and_size_t team_counter;
|
||||
addr_and_size_t task_counter;
|
||||
addr_and_size_t nthr_info;
|
||||
kmp_int32 address_width;
|
||||
kmp_int32 indexed_locks;
|
||||
kmp_int32 last_barrier; // The end in enum barrier_type
|
||||
kmp_int32 deque_size; // TASK_DEQUE_SIZE
|
||||
|
||||
/* thread structure information. */
|
||||
kmp_int32 th_sizeof_struct;
|
||||
offset_and_size_t th_info; // descriptor for thread
|
||||
offset_and_size_t th_team; // team for this thread
|
||||
offset_and_size_t th_root; // root for this thread
|
||||
offset_and_size_t th_serial_team; // serial team under this thread
|
||||
offset_and_size_t th_ident; // location for this thread (if available)
|
||||
offset_and_size_t th_spin_here; // is thread waiting for lock (if available)
|
||||
offset_and_size_t th_next_waiting; // next thread waiting for lock (if available)
|
||||
offset_and_size_t th_task_team; // task team struct
|
||||
offset_and_size_t th_current_task; // innermost task being executed
|
||||
offset_and_size_t th_task_state; // alternating 0/1 for task team identification
|
||||
offset_and_size_t th_bar;
|
||||
offset_and_size_t th_b_worker_arrived; // the worker increases it by 1 when it arrives to the barrier
|
||||
/* thread structure information. */
|
||||
kmp_int32 th_sizeof_struct;
|
||||
offset_and_size_t th_info; // descriptor for thread
|
||||
offset_and_size_t th_team; // team for this thread
|
||||
offset_and_size_t th_root; // root for this thread
|
||||
offset_and_size_t th_serial_team; // serial team under this thread
|
||||
offset_and_size_t th_ident; // location for this thread (if available)
|
||||
offset_and_size_t th_spin_here; // is thread waiting for lock (if available)
|
||||
offset_and_size_t
|
||||
th_next_waiting; // next thread waiting for lock (if available)
|
||||
offset_and_size_t th_task_team; // task team struct
|
||||
offset_and_size_t th_current_task; // innermost task being executed
|
||||
offset_and_size_t
|
||||
th_task_state; // alternating 0/1 for task team identification
|
||||
offset_and_size_t th_bar;
|
||||
offset_and_size_t th_b_worker_arrived; // the worker increases it by 1 when it
|
||||
// arrives to the barrier
|
||||
|
||||
#if OMP_40_ENABLED
|
||||
/* teams information */
|
||||
offset_and_size_t th_teams_microtask;// entry address for teams construct
|
||||
offset_and_size_t th_teams_level; // initial level of teams construct
|
||||
offset_and_size_t th_teams_nteams; // number of teams in a league
|
||||
offset_and_size_t th_teams_nth; // number of threads in each team of the league
|
||||
/* teams information */
|
||||
offset_and_size_t th_teams_microtask; // entry address for teams construct
|
||||
offset_and_size_t th_teams_level; // initial level of teams construct
|
||||
offset_and_size_t th_teams_nteams; // number of teams in a league
|
||||
offset_and_size_t
|
||||
th_teams_nth; // number of threads in each team of the league
|
||||
#endif
|
||||
|
||||
/* kmp_desc structure (for info field above) */
|
||||
kmp_int32 ds_sizeof_struct;
|
||||
offset_and_size_t ds_tid; // team thread id
|
||||
offset_and_size_t ds_gtid; // global thread id
|
||||
offset_and_size_t ds_thread; // native thread id
|
||||
/* kmp_desc structure (for info field above) */
|
||||
kmp_int32 ds_sizeof_struct;
|
||||
offset_and_size_t ds_tid; // team thread id
|
||||
offset_and_size_t ds_gtid; // global thread id
|
||||
offset_and_size_t ds_thread; // native thread id
|
||||
|
||||
/* team structure information */
|
||||
kmp_int32 t_sizeof_struct;
|
||||
offset_and_size_t t_master_tid; // tid of master in parent team
|
||||
offset_and_size_t t_ident; // location of parallel region
|
||||
offset_and_size_t t_parent; // parent team
|
||||
offset_and_size_t t_nproc; // # team threads
|
||||
offset_and_size_t t_threads; // array of threads
|
||||
offset_and_size_t t_serialized; // # levels of serialized teams
|
||||
offset_and_size_t t_id; // unique team id
|
||||
offset_and_size_t t_pkfn;
|
||||
offset_and_size_t t_task_team; // task team structure
|
||||
offset_and_size_t t_implicit_task; // taskdata for the thread's implicit task
|
||||
/* team structure information */
|
||||
kmp_int32 t_sizeof_struct;
|
||||
offset_and_size_t t_master_tid; // tid of master in parent team
|
||||
offset_and_size_t t_ident; // location of parallel region
|
||||
offset_and_size_t t_parent; // parent team
|
||||
offset_and_size_t t_nproc; // # team threads
|
||||
offset_and_size_t t_threads; // array of threads
|
||||
offset_and_size_t t_serialized; // # levels of serialized teams
|
||||
offset_and_size_t t_id; // unique team id
|
||||
offset_and_size_t t_pkfn;
|
||||
offset_and_size_t t_task_team; // task team structure
|
||||
offset_and_size_t t_implicit_task; // taskdata for the thread's implicit task
|
||||
#if OMP_40_ENABLED
|
||||
offset_and_size_t t_cancel_request;
|
||||
offset_and_size_t t_cancel_request;
|
||||
#endif
|
||||
offset_and_size_t t_bar;
|
||||
offset_and_size_t t_b_master_arrived; // increased by 1 when master arrives to a barrier
|
||||
offset_and_size_t t_b_team_arrived; // increased by one when all the threads arrived
|
||||
offset_and_size_t t_bar;
|
||||
offset_and_size_t
|
||||
t_b_master_arrived; // increased by 1 when master arrives to a barrier
|
||||
offset_and_size_t
|
||||
t_b_team_arrived; // increased by one when all the threads arrived
|
||||
|
||||
/* root structure information */
|
||||
kmp_int32 r_sizeof_struct;
|
||||
offset_and_size_t r_root_team; // team at root
|
||||
offset_and_size_t r_hot_team; // hot team for this root
|
||||
offset_and_size_t r_uber_thread; // root thread
|
||||
offset_and_size_t r_root_id; // unique root id (if available)
|
||||
/* root structure information */
|
||||
kmp_int32 r_sizeof_struct;
|
||||
offset_and_size_t r_root_team; // team at root
|
||||
offset_and_size_t r_hot_team; // hot team for this root
|
||||
offset_and_size_t r_uber_thread; // root thread
|
||||
offset_and_size_t r_root_id; // unique root id (if available)
|
||||
|
||||
/* ident structure information */
|
||||
kmp_int32 id_sizeof_struct;
|
||||
offset_and_size_t id_psource; /* address of string ";file;func;line1;line2;;". */
|
||||
offset_and_size_t id_flags;
|
||||
/* ident structure information */
|
||||
kmp_int32 id_sizeof_struct;
|
||||
offset_and_size_t
|
||||
id_psource; /* address of string ";file;func;line1;line2;;". */
|
||||
offset_and_size_t id_flags;
|
||||
|
||||
/* lock structure information */
|
||||
kmp_int32 lk_sizeof_struct;
|
||||
offset_and_size_t lk_initialized;
|
||||
offset_and_size_t lk_location;
|
||||
offset_and_size_t lk_tail_id;
|
||||
offset_and_size_t lk_head_id;
|
||||
offset_and_size_t lk_next_ticket;
|
||||
offset_and_size_t lk_now_serving;
|
||||
offset_and_size_t lk_owner_id;
|
||||
offset_and_size_t lk_depth_locked;
|
||||
offset_and_size_t lk_lock_flags;
|
||||
/* lock structure information */
|
||||
kmp_int32 lk_sizeof_struct;
|
||||
offset_and_size_t lk_initialized;
|
||||
offset_and_size_t lk_location;
|
||||
offset_and_size_t lk_tail_id;
|
||||
offset_and_size_t lk_head_id;
|
||||
offset_and_size_t lk_next_ticket;
|
||||
offset_and_size_t lk_now_serving;
|
||||
offset_and_size_t lk_owner_id;
|
||||
offset_and_size_t lk_depth_locked;
|
||||
offset_and_size_t lk_lock_flags;
|
||||
|
||||
#if ! KMP_USE_DYNAMIC_LOCK
|
||||
/* lock_table_t */
|
||||
kmp_int32 lt_size_of_struct; /* Size and layout of kmp_lock_table_t. */
|
||||
offset_and_size_t lt_used;
|
||||
offset_and_size_t lt_allocated;
|
||||
offset_and_size_t lt_table;
|
||||
#if !KMP_USE_DYNAMIC_LOCK
|
||||
/* lock_table_t */
|
||||
kmp_int32 lt_size_of_struct; /* Size and layout of kmp_lock_table_t. */
|
||||
offset_and_size_t lt_used;
|
||||
offset_and_size_t lt_allocated;
|
||||
offset_and_size_t lt_table;
|
||||
#endif
|
||||
|
||||
/* task_team_t */
|
||||
kmp_int32 tt_sizeof_struct;
|
||||
offset_and_size_t tt_threads_data;
|
||||
offset_and_size_t tt_found_tasks;
|
||||
offset_and_size_t tt_nproc;
|
||||
offset_and_size_t tt_unfinished_threads;
|
||||
offset_and_size_t tt_active;
|
||||
/* task_team_t */
|
||||
kmp_int32 tt_sizeof_struct;
|
||||
offset_and_size_t tt_threads_data;
|
||||
offset_and_size_t tt_found_tasks;
|
||||
offset_and_size_t tt_nproc;
|
||||
offset_and_size_t tt_unfinished_threads;
|
||||
offset_and_size_t tt_active;
|
||||
|
||||
/* kmp_taskdata_t */
|
||||
kmp_int32 td_sizeof_struct;
|
||||
offset_and_size_t td_task_id; // task id
|
||||
offset_and_size_t td_flags; // task flags
|
||||
offset_and_size_t td_team; // team for this task
|
||||
offset_and_size_t td_parent; // parent task
|
||||
offset_and_size_t td_level; // task testing level
|
||||
offset_and_size_t td_ident; // task identifier
|
||||
offset_and_size_t td_allocated_child_tasks; // child tasks (+ current task) not yet deallocated
|
||||
offset_and_size_t td_incomplete_child_tasks; // child tasks not yet complete
|
||||
/* kmp_taskdata_t */
|
||||
kmp_int32 td_sizeof_struct;
|
||||
offset_and_size_t td_task_id; // task id
|
||||
offset_and_size_t td_flags; // task flags
|
||||
offset_and_size_t td_team; // team for this task
|
||||
offset_and_size_t td_parent; // parent task
|
||||
offset_and_size_t td_level; // task testing level
|
||||
offset_and_size_t td_ident; // task identifier
|
||||
offset_and_size_t td_allocated_child_tasks; // child tasks (+ current task)
|
||||
// not yet deallocated
|
||||
offset_and_size_t td_incomplete_child_tasks; // child tasks not yet complete
|
||||
|
||||
/* Taskwait */
|
||||
offset_and_size_t td_taskwait_ident;
|
||||
offset_and_size_t td_taskwait_counter;
|
||||
offset_and_size_t td_taskwait_thread; // gtid + 1 of thread encountered taskwait
|
||||
/* Taskwait */
|
||||
offset_and_size_t td_taskwait_ident;
|
||||
offset_and_size_t td_taskwait_counter;
|
||||
offset_and_size_t
|
||||
td_taskwait_thread; // gtid + 1 of thread encountered taskwait
|
||||
|
||||
#if OMP_40_ENABLED
|
||||
/* Taskgroup */
|
||||
offset_and_size_t td_taskgroup; // pointer to the current taskgroup
|
||||
offset_and_size_t td_task_count; // number of allocated and not yet complete tasks
|
||||
offset_and_size_t td_cancel; // request for cancellation of this taskgroup
|
||||
/* Taskgroup */
|
||||
offset_and_size_t td_taskgroup; // pointer to the current taskgroup
|
||||
offset_and_size_t
|
||||
td_task_count; // number of allocated and not yet complete tasks
|
||||
offset_and_size_t td_cancel; // request for cancellation of this taskgroup
|
||||
|
||||
/* Task dependency */
|
||||
offset_and_size_t td_depnode; // pointer to graph node if the task has dependencies
|
||||
offset_and_size_t dn_node;
|
||||
offset_and_size_t dn_next;
|
||||
offset_and_size_t dn_successors;
|
||||
offset_and_size_t dn_task;
|
||||
offset_and_size_t dn_npredecessors;
|
||||
offset_and_size_t dn_nrefs;
|
||||
/* Task dependency */
|
||||
offset_and_size_t
|
||||
td_depnode; // pointer to graph node if the task has dependencies
|
||||
offset_and_size_t dn_node;
|
||||
offset_and_size_t dn_next;
|
||||
offset_and_size_t dn_successors;
|
||||
offset_and_size_t dn_task;
|
||||
offset_and_size_t dn_npredecessors;
|
||||
offset_and_size_t dn_nrefs;
|
||||
#endif
|
||||
offset_and_size_t dn_routine;
|
||||
offset_and_size_t dn_routine;
|
||||
|
||||
/* kmp_thread_data_t */
|
||||
kmp_int32 hd_sizeof_struct;
|
||||
offset_and_size_t hd_deque;
|
||||
offset_and_size_t hd_deque_size;
|
||||
offset_and_size_t hd_deque_head;
|
||||
offset_and_size_t hd_deque_tail;
|
||||
offset_and_size_t hd_deque_ntasks;
|
||||
offset_and_size_t hd_deque_last_stolen;
|
||||
/* kmp_thread_data_t */
|
||||
kmp_int32 hd_sizeof_struct;
|
||||
offset_and_size_t hd_deque;
|
||||
offset_and_size_t hd_deque_size;
|
||||
offset_and_size_t hd_deque_head;
|
||||
offset_and_size_t hd_deque_tail;
|
||||
offset_and_size_t hd_deque_ntasks;
|
||||
offset_and_size_t hd_deque_last_stolen;
|
||||
|
||||
// The last field of stable version.
|
||||
kmp_uint64 last_field;
|
||||
// The last field of stable version.
|
||||
kmp_uint64 last_field;
|
||||
|
||||
} kmp_omp_struct_info_t;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,6 +2,7 @@
|
|||
* kmp_platform.h -- header for determining operating system and architecture
|
||||
*/
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
|
|
@ -11,171 +12,175 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifndef KMP_PLATFORM_H
|
||||
#define KMP_PLATFORM_H
|
||||
|
||||
/* ---------------------- Operating system recognition ------------------- */
|
||||
|
||||
#define KMP_OS_LINUX 0
|
||||
#define KMP_OS_FREEBSD 0
|
||||
#define KMP_OS_NETBSD 0
|
||||
#define KMP_OS_DARWIN 0
|
||||
#define KMP_OS_WINDOWS 0
|
||||
#define KMP_OS_CNK 0
|
||||
#define KMP_OS_UNIX 0 /* disjunction of KMP_OS_LINUX, KMP_OS_DARWIN etc. */
|
||||
|
||||
#define KMP_OS_LINUX 0
|
||||
#define KMP_OS_FREEBSD 0
|
||||
#define KMP_OS_NETBSD 0
|
||||
#define KMP_OS_DARWIN 0
|
||||
#define KMP_OS_WINDOWS 0
|
||||
#define KMP_OS_CNK 0
|
||||
#define KMP_OS_UNIX 0 /* disjunction of KMP_OS_LINUX, KMP_OS_DARWIN etc. */
|
||||
|
||||
#ifdef _WIN32
|
||||
# undef KMP_OS_WINDOWS
|
||||
# define KMP_OS_WINDOWS 1
|
||||
#undef KMP_OS_WINDOWS
|
||||
#define KMP_OS_WINDOWS 1
|
||||
#endif
|
||||
|
||||
#if ( defined __APPLE__ && defined __MACH__ )
|
||||
# undef KMP_OS_DARWIN
|
||||
# define KMP_OS_DARWIN 1
|
||||
#if (defined __APPLE__ && defined __MACH__)
|
||||
#undef KMP_OS_DARWIN
|
||||
#define KMP_OS_DARWIN 1
|
||||
#endif
|
||||
|
||||
// in some ppc64 linux installations, only the second condition is met
|
||||
#if ( defined __linux )
|
||||
# undef KMP_OS_LINUX
|
||||
# define KMP_OS_LINUX 1
|
||||
#elif ( defined __linux__)
|
||||
# undef KMP_OS_LINUX
|
||||
# define KMP_OS_LINUX 1
|
||||
#if (defined __linux)
|
||||
#undef KMP_OS_LINUX
|
||||
#define KMP_OS_LINUX 1
|
||||
#elif (defined __linux__)
|
||||
#undef KMP_OS_LINUX
|
||||
#define KMP_OS_LINUX 1
|
||||
#else
|
||||
#endif
|
||||
|
||||
#if ( defined __FreeBSD__ )
|
||||
# undef KMP_OS_FREEBSD
|
||||
# define KMP_OS_FREEBSD 1
|
||||
#if (defined __FreeBSD__)
|
||||
#undef KMP_OS_FREEBSD
|
||||
#define KMP_OS_FREEBSD 1
|
||||
#endif
|
||||
|
||||
#if ( defined __NetBSD__ )
|
||||
# undef KMP_OS_NETBSD
|
||||
# define KMP_OS_NETBSD 1
|
||||
#if (defined __NetBSD__)
|
||||
#undef KMP_OS_NETBSD
|
||||
#define KMP_OS_NETBSD 1
|
||||
#endif
|
||||
|
||||
#if ( defined __bgq__ )
|
||||
# undef KMP_OS_CNK
|
||||
# define KMP_OS_CNK 1
|
||||
#if (defined __bgq__)
|
||||
#undef KMP_OS_CNK
|
||||
#define KMP_OS_CNK 1
|
||||
#endif
|
||||
|
||||
#if (1 != KMP_OS_LINUX + KMP_OS_FREEBSD + KMP_OS_NETBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS)
|
||||
# error Unknown OS
|
||||
#if (1 != \
|
||||
KMP_OS_LINUX + KMP_OS_FREEBSD + KMP_OS_NETBSD + KMP_OS_DARWIN + \
|
||||
KMP_OS_WINDOWS)
|
||||
#error Unknown OS
|
||||
#endif
|
||||
|
||||
#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_DARWIN
|
||||
# undef KMP_OS_UNIX
|
||||
# define KMP_OS_UNIX 1
|
||||
#undef KMP_OS_UNIX
|
||||
#define KMP_OS_UNIX 1
|
||||
#endif
|
||||
|
||||
/* ---------------------- Architecture recognition ------------------- */
|
||||
|
||||
#define KMP_ARCH_X86 0
|
||||
#define KMP_ARCH_X86_64 0
|
||||
#define KMP_ARCH_AARCH64 0
|
||||
#define KMP_ARCH_PPC64_BE 0
|
||||
#define KMP_ARCH_PPC64_LE 0
|
||||
#define KMP_ARCH_X86 0
|
||||
#define KMP_ARCH_X86_64 0
|
||||
#define KMP_ARCH_AARCH64 0
|
||||
#define KMP_ARCH_PPC64_BE 0
|
||||
#define KMP_ARCH_PPC64_LE 0
|
||||
#define KMP_ARCH_PPC64 (KMP_ARCH_PPC64_LE || KMP_ARCH_PPC64_BE)
|
||||
#define KMP_ARCH_MIPS 0
|
||||
#define KMP_ARCH_MIPS64 0
|
||||
#define KMP_ARCH_MIPS 0
|
||||
#define KMP_ARCH_MIPS64 0
|
||||
|
||||
#if KMP_OS_WINDOWS
|
||||
# if defined _M_AMD64
|
||||
# undef KMP_ARCH_X86_64
|
||||
# define KMP_ARCH_X86_64 1
|
||||
# else
|
||||
# undef KMP_ARCH_X86
|
||||
# define KMP_ARCH_X86 1
|
||||
# endif
|
||||
#if defined _M_AMD64
|
||||
#undef KMP_ARCH_X86_64
|
||||
#define KMP_ARCH_X86_64 1
|
||||
#else
|
||||
#undef KMP_ARCH_X86
|
||||
#define KMP_ARCH_X86 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if KMP_OS_UNIX
|
||||
# if defined __x86_64
|
||||
# undef KMP_ARCH_X86_64
|
||||
# define KMP_ARCH_X86_64 1
|
||||
# elif defined __i386
|
||||
# undef KMP_ARCH_X86
|
||||
# define KMP_ARCH_X86 1
|
||||
# elif defined __powerpc64__
|
||||
# if defined __LITTLE_ENDIAN__
|
||||
# undef KMP_ARCH_PPC64_LE
|
||||
# define KMP_ARCH_PPC64_LE 1
|
||||
# else
|
||||
# undef KMP_ARCH_PPC64_BE
|
||||
# define KMP_ARCH_PPC64_BE 1
|
||||
# endif
|
||||
# elif defined __aarch64__
|
||||
# undef KMP_ARCH_AARCH64
|
||||
# define KMP_ARCH_AARCH64 1
|
||||
# elif defined __mips__
|
||||
# if defined __mips64
|
||||
# undef KMP_ARCH_MIPS64
|
||||
# define KMP_ARCH_MIPS64 1
|
||||
# else
|
||||
# undef KMP_ARCH_MIPS
|
||||
# define KMP_ARCH_MIPS 1
|
||||
# endif
|
||||
# endif
|
||||
#if defined __x86_64
|
||||
#undef KMP_ARCH_X86_64
|
||||
#define KMP_ARCH_X86_64 1
|
||||
#elif defined __i386
|
||||
#undef KMP_ARCH_X86
|
||||
#define KMP_ARCH_X86 1
|
||||
#elif defined __powerpc64__
|
||||
#if defined __LITTLE_ENDIAN__
|
||||
#undef KMP_ARCH_PPC64_LE
|
||||
#define KMP_ARCH_PPC64_LE 1
|
||||
#else
|
||||
#undef KMP_ARCH_PPC64_BE
|
||||
#define KMP_ARCH_PPC64_BE 1
|
||||
#endif
|
||||
#elif defined __aarch64__
|
||||
#undef KMP_ARCH_AARCH64
|
||||
#define KMP_ARCH_AARCH64 1
|
||||
#elif defined __mips__
|
||||
#if defined __mips64
|
||||
#undef KMP_ARCH_MIPS64
|
||||
#define KMP_ARCH_MIPS64 1
|
||||
#else
|
||||
#undef KMP_ARCH_MIPS
|
||||
#define KMP_ARCH_MIPS 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7R__) || \
|
||||
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7R__) || \
|
||||
defined(__ARM_ARCH_7A__)
|
||||
# define KMP_ARCH_ARMV7 1
|
||||
#define KMP_ARCH_ARMV7 1
|
||||
#endif
|
||||
|
||||
#if defined(KMP_ARCH_ARMV7) || defined(__ARM_ARCH_6__) || \
|
||||
defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || \
|
||||
defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6T2__) || \
|
||||
#if defined(KMP_ARCH_ARMV7) || defined(__ARM_ARCH_6__) || \
|
||||
defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || \
|
||||
defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6T2__) || \
|
||||
defined(__ARM_ARCH_6ZK__)
|
||||
# define KMP_ARCH_ARMV6 1
|
||||
#define KMP_ARCH_ARMV6 1
|
||||
#endif
|
||||
|
||||
#if defined(KMP_ARCH_ARMV6) || defined(__ARM_ARCH_5T__) || \
|
||||
defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
|
||||
#if defined(KMP_ARCH_ARMV6) || defined(__ARM_ARCH_5T__) || \
|
||||
defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
|
||||
defined(__ARM_ARCH_5TEJ__)
|
||||
# define KMP_ARCH_ARMV5 1
|
||||
#define KMP_ARCH_ARMV5 1
|
||||
#endif
|
||||
|
||||
#if defined(KMP_ARCH_ARMV5) || defined(__ARM_ARCH_4__) || \
|
||||
#if defined(KMP_ARCH_ARMV5) || defined(__ARM_ARCH_4__) || \
|
||||
defined(__ARM_ARCH_4T__)
|
||||
# define KMP_ARCH_ARMV4 1
|
||||
#define KMP_ARCH_ARMV4 1
|
||||
#endif
|
||||
|
||||
#if defined(KMP_ARCH_ARMV4) || defined(__ARM_ARCH_3__) || \
|
||||
#if defined(KMP_ARCH_ARMV4) || defined(__ARM_ARCH_3__) || \
|
||||
defined(__ARM_ARCH_3M__)
|
||||
# define KMP_ARCH_ARMV3 1
|
||||
#define KMP_ARCH_ARMV3 1
|
||||
#endif
|
||||
|
||||
#if defined(KMP_ARCH_ARMV3) || defined(__ARM_ARCH_2__)
|
||||
# define KMP_ARCH_ARMV2 1
|
||||
#if defined(KMP_ARCH_ARMV3) || defined(__ARM_ARCH_2__)
|
||||
#define KMP_ARCH_ARMV2 1
|
||||
#endif
|
||||
|
||||
#if defined(KMP_ARCH_ARMV2)
|
||||
# define KMP_ARCH_ARM 1
|
||||
#define KMP_ARCH_ARM 1
|
||||
#endif
|
||||
|
||||
#if defined(__MIC__) || defined(__MIC2__)
|
||||
# define KMP_MIC 1
|
||||
# if __MIC2__ || __KNC__
|
||||
# define KMP_MIC1 0
|
||||
# define KMP_MIC2 1
|
||||
# else
|
||||
# define KMP_MIC1 1
|
||||
# define KMP_MIC2 0
|
||||
# endif
|
||||
#define KMP_MIC 1
|
||||
#if __MIC2__ || __KNC__
|
||||
#define KMP_MIC1 0
|
||||
#define KMP_MIC2 1
|
||||
#else
|
||||
# define KMP_MIC 0
|
||||
# define KMP_MIC1 0
|
||||
# define KMP_MIC2 0
|
||||
#define KMP_MIC1 1
|
||||
#define KMP_MIC2 0
|
||||
#endif
|
||||
#else
|
||||
#define KMP_MIC 0
|
||||
#define KMP_MIC1 0
|
||||
#define KMP_MIC2 0
|
||||
#endif
|
||||
|
||||
/* Specify 32 bit architectures here */
|
||||
#define KMP_32_BIT_ARCH (KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS)
|
||||
|
||||
// TODO: Fixme - This is clever, but really fugly
|
||||
#if (1 != KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 + KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64)
|
||||
# error Unknown or unsupported architecture
|
||||
#if (1 != \
|
||||
KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 + \
|
||||
KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64)
|
||||
#error Unknown or unsupported architecture
|
||||
#endif
|
||||
|
||||
#endif // KMP_PLATFORM_H
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -12,50 +12,49 @@
|
|||
#ifndef KMP_SAFE_C_API_H
|
||||
#define KMP_SAFE_C_API_H
|
||||
|
||||
//
|
||||
// Replacement for banned C API
|
||||
//
|
||||
|
||||
// Not every unsafe call listed here is handled now, but keeping everything
|
||||
// in one place should be handy for future maintenance.
|
||||
#if KMP_OS_WINDOWS
|
||||
|
||||
# define RSIZE_MAX_STR ( 4UL << 10 ) // 4KB
|
||||
#define RSIZE_MAX_STR (4UL << 10) // 4KB
|
||||
|
||||
// _malloca was suggested, but it is not a drop-in replacement for _alloca
|
||||
# define KMP_ALLOCA _alloca
|
||||
#define KMP_ALLOCA _alloca
|
||||
|
||||
# define KMP_MEMCPY_S memcpy_s
|
||||
# define KMP_SNPRINTF sprintf_s
|
||||
# define KMP_SSCANF sscanf_s
|
||||
# define KMP_STRCPY_S strcpy_s
|
||||
# define KMP_STRNCPY_S strncpy_s
|
||||
#define KMP_MEMCPY_S memcpy_s
|
||||
#define KMP_SNPRINTF sprintf_s
|
||||
#define KMP_SSCANF sscanf_s
|
||||
#define KMP_STRCPY_S strcpy_s
|
||||
#define KMP_STRNCPY_S strncpy_s
|
||||
|
||||
// Use this only when buffer size is unknown
|
||||
# define KMP_MEMCPY(dst, src, cnt) memcpy_s(dst, cnt, src, cnt)
|
||||
#define KMP_MEMCPY(dst, src, cnt) memcpy_s(dst, cnt, src, cnt)
|
||||
|
||||
# define KMP_STRLEN(str) strnlen_s(str, RSIZE_MAX_STR)
|
||||
#define KMP_STRLEN(str) strnlen_s(str, RSIZE_MAX_STR)
|
||||
|
||||
// Use this only when buffer size is unknown
|
||||
# define KMP_STRNCPY(dst, src, cnt) strncpy_s(dst, cnt, src, cnt)
|
||||
#define KMP_STRNCPY(dst, src, cnt) strncpy_s(dst, cnt, src, cnt)
|
||||
|
||||
// _TRUNCATE insures buffer size > max string to print.
|
||||
# define KMP_VSNPRINTF(dst, cnt, fmt, arg) vsnprintf_s(dst, cnt, _TRUNCATE, fmt, arg)
|
||||
#define KMP_VSNPRINTF(dst, cnt, fmt, arg) \
|
||||
vsnprintf_s(dst, cnt, _TRUNCATE, fmt, arg)
|
||||
|
||||
#else // KMP_OS_WINDOWS
|
||||
|
||||
// For now, these macros use the existing API.
|
||||
|
||||
# define KMP_ALLOCA alloca
|
||||
# define KMP_MEMCPY_S(dst, bsz, src, cnt) memcpy(dst, src, cnt)
|
||||
# define KMP_SNPRINTF snprintf
|
||||
# define KMP_SSCANF sscanf
|
||||
# define KMP_STRCPY_S(dst, bsz, src) strcpy(dst, src)
|
||||
# define KMP_STRNCPY_S(dst, bsz, src, cnt) strncpy(dst, src, cnt)
|
||||
# define KMP_VSNPRINTF vsnprintf
|
||||
# define KMP_STRNCPY strncpy
|
||||
# define KMP_STRLEN strlen
|
||||
# define KMP_MEMCPY memcpy
|
||||
#define KMP_ALLOCA alloca
|
||||
#define KMP_MEMCPY_S(dst, bsz, src, cnt) memcpy(dst, src, cnt)
|
||||
#define KMP_SNPRINTF snprintf
|
||||
#define KMP_SSCANF sscanf
|
||||
#define KMP_STRCPY_S(dst, bsz, src) strcpy(dst, src)
|
||||
#define KMP_STRNCPY_S(dst, bsz, src, cnt) strncpy(dst, src, cnt)
|
||||
#define KMP_VSNPRINTF vsnprintf
|
||||
#define KMP_STRNCPY strncpy
|
||||
#define KMP_STRLEN strlen
|
||||
#define KMP_MEMCPY memcpy
|
||||
|
||||
#endif // KMP_OS_WINDOWS
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -16,35 +16,52 @@
|
|||
#ifndef KMP_SETTINGS_H
|
||||
#define KMP_SETTINGS_H
|
||||
|
||||
void __kmp_reset_global_vars( void );
|
||||
void __kmp_env_initialize( char const * );
|
||||
void __kmp_reset_global_vars(void);
|
||||
void __kmp_env_initialize(char const *);
|
||||
void __kmp_env_print();
|
||||
#if OMP_40_ENABLED
|
||||
void __kmp_env_print_2();
|
||||
#endif // OMP_40_ENABLED
|
||||
|
||||
int __kmp_initial_threads_capacity( int req_nproc );
|
||||
int __kmp_initial_threads_capacity(int req_nproc);
|
||||
void __kmp_init_dflt_team_nth();
|
||||
int __kmp_convert_to_milliseconds( char const * );
|
||||
int __kmp_default_tp_capacity( int, int, int);
|
||||
int __kmp_convert_to_milliseconds(char const *);
|
||||
int __kmp_default_tp_capacity(int, int, int);
|
||||
|
||||
#if KMP_MIC
|
||||
#define KMP_STR_BUF_PRINT_NAME __kmp_str_buf_print( buffer, " %s %s", KMP_I18N_STR(Device), name )
|
||||
#define KMP_STR_BUF_PRINT_NAME_EX(x) __kmp_str_buf_print( buffer, " %s %s='", KMP_I18N_STR(Device), x )
|
||||
#define KMP_STR_BUF_PRINT_BOOL __kmp_str_buf_print( buffer, " %s %s='%s'\n", KMP_I18N_STR(Device), name, value ? "TRUE" : "FALSE" );
|
||||
#define KMP_STR_BUF_PRINT_INT __kmp_str_buf_print( buffer, " %s %s='%d'\n", KMP_I18N_STR(Device), name, value )
|
||||
#define KMP_STR_BUF_PRINT_UINT64 __kmp_str_buf_print( buffer, " %s %s='%" KMP_UINT64_SPEC "'\n", KMP_I18N_STR(Device), name, value );
|
||||
#define KMP_STR_BUF_PRINT_STR __kmp_str_buf_print( buffer, " %s %s='%s'\n", KMP_I18N_STR(Device), name, value )
|
||||
#define KMP_STR_BUF_PRINT_NAME \
|
||||
__kmp_str_buf_print(buffer, " %s %s", KMP_I18N_STR(Device), name)
|
||||
#define KMP_STR_BUF_PRINT_NAME_EX(x) \
|
||||
__kmp_str_buf_print(buffer, " %s %s='", KMP_I18N_STR(Device), x)
|
||||
#define KMP_STR_BUF_PRINT_BOOL \
|
||||
__kmp_str_buf_print(buffer, " %s %s='%s'\n", KMP_I18N_STR(Device), name, \
|
||||
value ? "TRUE" : "FALSE");
|
||||
#define KMP_STR_BUF_PRINT_INT \
|
||||
__kmp_str_buf_print(buffer, " %s %s='%d'\n", KMP_I18N_STR(Device), name, \
|
||||
value)
|
||||
#define KMP_STR_BUF_PRINT_UINT64 \
|
||||
__kmp_str_buf_print(buffer, " %s %s='%" KMP_UINT64_SPEC "'\n", \
|
||||
KMP_I18N_STR(Device), name, value);
|
||||
#define KMP_STR_BUF_PRINT_STR \
|
||||
__kmp_str_buf_print(buffer, " %s %s='%s'\n", KMP_I18N_STR(Device), name, \
|
||||
value)
|
||||
#else
|
||||
#define KMP_STR_BUF_PRINT_NAME __kmp_str_buf_print( buffer, " %s %s", KMP_I18N_STR(Host), name )
|
||||
#define KMP_STR_BUF_PRINT_NAME_EX(x) __kmp_str_buf_print( buffer, " %s %s='", KMP_I18N_STR(Host), x )
|
||||
#define KMP_STR_BUF_PRINT_BOOL __kmp_str_buf_print( buffer, " %s %s='%s'\n", KMP_I18N_STR(Host), name, value ? "TRUE" : "FALSE" );
|
||||
#define KMP_STR_BUF_PRINT_INT __kmp_str_buf_print( buffer, " %s %s='%d'\n", KMP_I18N_STR(Host), name, value )
|
||||
#define KMP_STR_BUF_PRINT_UINT64 __kmp_str_buf_print( buffer, " %s %s='%" KMP_UINT64_SPEC "'\n", KMP_I18N_STR(Host), name, value );
|
||||
#define KMP_STR_BUF_PRINT_STR __kmp_str_buf_print( buffer, " %s %s='%s'\n", KMP_I18N_STR(Host), name, value )
|
||||
#define KMP_STR_BUF_PRINT_NAME \
|
||||
__kmp_str_buf_print(buffer, " %s %s", KMP_I18N_STR(Host), name)
|
||||
#define KMP_STR_BUF_PRINT_NAME_EX(x) \
|
||||
__kmp_str_buf_print(buffer, " %s %s='", KMP_I18N_STR(Host), x)
|
||||
#define KMP_STR_BUF_PRINT_BOOL \
|
||||
__kmp_str_buf_print(buffer, " %s %s='%s'\n", KMP_I18N_STR(Host), name, \
|
||||
value ? "TRUE" : "FALSE");
|
||||
#define KMP_STR_BUF_PRINT_INT \
|
||||
__kmp_str_buf_print(buffer, " %s %s='%d'\n", KMP_I18N_STR(Host), name, value)
|
||||
#define KMP_STR_BUF_PRINT_UINT64 \
|
||||
__kmp_str_buf_print(buffer, " %s %s='%" KMP_UINT64_SPEC "'\n", \
|
||||
KMP_I18N_STR(Host), name, value);
|
||||
#define KMP_STR_BUF_PRINT_STR \
|
||||
__kmp_str_buf_print(buffer, " %s %s='%s'\n", KMP_I18N_STR(Host), name, value)
|
||||
#endif
|
||||
|
||||
#endif // KMP_SETTINGS_H
|
||||
|
||||
// end of file //
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -16,8 +16,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "kmp.h"
|
||||
|
|
@ -26,119 +26,107 @@
|
|||
using namespace std;
|
||||
|
||||
#if KMP_HAVE_TICK_TIME
|
||||
# if KMP_MIC
|
||||
double tsc_tick_count::tick_time()
|
||||
{
|
||||
// pretty bad assumption of 1GHz clock for MIC
|
||||
return 1/((double)1000*1.e6);
|
||||
#if KMP_MIC
|
||||
double tsc_tick_count::tick_time() {
|
||||
// pretty bad assumption of 1GHz clock for MIC
|
||||
return 1 / ((double)1000 * 1.e6);
|
||||
}
|
||||
# elif KMP_ARCH_X86 || KMP_ARCH_X86_64
|
||||
# include <string.h>
|
||||
#elif KMP_ARCH_X86 || KMP_ARCH_X86_64
|
||||
#include <string.h>
|
||||
// Extract the value from the CPUID information
|
||||
double tsc_tick_count::tick_time()
|
||||
{
|
||||
static double result = 0.0;
|
||||
double tsc_tick_count::tick_time() {
|
||||
static double result = 0.0;
|
||||
|
||||
if (result == 0.0)
|
||||
{
|
||||
kmp_cpuid_t cpuinfo;
|
||||
char brand[256];
|
||||
if (result == 0.0) {
|
||||
kmp_cpuid_t cpuinfo;
|
||||
char brand[256];
|
||||
|
||||
__kmp_x86_cpuid(0x80000000, 0, &cpuinfo);
|
||||
memset(brand, 0, sizeof(brand));
|
||||
int ids = cpuinfo.eax;
|
||||
__kmp_x86_cpuid(0x80000000, 0, &cpuinfo);
|
||||
memset(brand, 0, sizeof(brand));
|
||||
int ids = cpuinfo.eax;
|
||||
|
||||
for (unsigned int i=2; i<(ids^0x80000000)+2; i++)
|
||||
__kmp_x86_cpuid(i | 0x80000000, 0, (kmp_cpuid_t*)(brand+(i-2)*sizeof(kmp_cpuid_t)));
|
||||
for (unsigned int i = 2; i < (ids ^ 0x80000000) + 2; i++)
|
||||
__kmp_x86_cpuid(i | 0x80000000, 0,
|
||||
(kmp_cpuid_t *)(brand + (i - 2) * sizeof(kmp_cpuid_t)));
|
||||
|
||||
char * start = &brand[0];
|
||||
for (;*start == ' '; start++)
|
||||
;
|
||||
char *start = &brand[0];
|
||||
for (; *start == ' '; start++)
|
||||
;
|
||||
|
||||
char * end = brand + KMP_STRLEN(brand) - 3;
|
||||
uint64_t multiplier;
|
||||
char *end = brand + KMP_STRLEN(brand) - 3;
|
||||
uint64_t multiplier;
|
||||
|
||||
if (*end == 'M') multiplier = 1000LL*1000LL;
|
||||
else if (*end == 'G') multiplier = 1000LL*1000LL*1000LL;
|
||||
else if (*end == 'T') multiplier = 1000LL*1000LL*1000LL*1000LL;
|
||||
else
|
||||
{
|
||||
cout << "Error determining multiplier '" << *end << "'\n";
|
||||
exit (-1);
|
||||
}
|
||||
*end = 0;
|
||||
while (*end != ' ') end--;
|
||||
end++;
|
||||
|
||||
double freq = strtod(end, &start);
|
||||
if (freq == 0.0)
|
||||
{
|
||||
cout << "Error calculating frequency " << end << "\n";
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
result = ((double)1.0)/(freq * multiplier);
|
||||
if (*end == 'M')
|
||||
multiplier = 1000LL * 1000LL;
|
||||
else if (*end == 'G')
|
||||
multiplier = 1000LL * 1000LL * 1000LL;
|
||||
else if (*end == 'T')
|
||||
multiplier = 1000LL * 1000LL * 1000LL * 1000LL;
|
||||
else {
|
||||
cout << "Error determining multiplier '" << *end << "'\n";
|
||||
exit(-1);
|
||||
}
|
||||
return result;
|
||||
*end = 0;
|
||||
while (*end != ' ')
|
||||
end--;
|
||||
end++;
|
||||
|
||||
double freq = strtod(end, &start);
|
||||
if (freq == 0.0) {
|
||||
cout << "Error calculating frequency " << end << "\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
result = ((double)1.0) / (freq * multiplier);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static bool useSI = true;
|
||||
|
||||
// Return a formatted string after normalising the value into
|
||||
// engineering style and using a suitable unit prefix (e.g. ms, us, ns).
|
||||
std::string formatSI(double interval, int width, char unit)
|
||||
{
|
||||
std::stringstream os;
|
||||
std::string formatSI(double interval, int width, char unit) {
|
||||
std::stringstream os;
|
||||
|
||||
if (useSI)
|
||||
{
|
||||
// Preserve accuracy for small numbers, since we only multiply and the positive powers
|
||||
// of ten are precisely representable.
|
||||
static struct { double scale; char prefix; } ranges[] = {
|
||||
{1.e12,'f'},
|
||||
{1.e9, 'p'},
|
||||
{1.e6, 'n'},
|
||||
{1.e3, 'u'},
|
||||
{1.0, 'm'},
|
||||
{1.e-3,' '},
|
||||
{1.e-6,'k'},
|
||||
{1.e-9,'M'},
|
||||
{1.e-12,'G'},
|
||||
{1.e-15,'T'},
|
||||
{1.e-18,'P'},
|
||||
{1.e-21,'E'},
|
||||
{1.e-24,'Z'},
|
||||
{1.e-27,'Y'}
|
||||
};
|
||||
if (useSI) {
|
||||
// Preserve accuracy for small numbers, since we only multiply and the
|
||||
// positive powers of ten are precisely representable.
|
||||
static struct {
|
||||
double scale;
|
||||
char prefix;
|
||||
} ranges[] = {{1.e12, 'f'}, {1.e9, 'p'}, {1.e6, 'n'}, {1.e3, 'u'},
|
||||
{1.0, 'm'}, {1.e-3, ' '}, {1.e-6, 'k'}, {1.e-9, 'M'},
|
||||
{1.e-12, 'G'}, {1.e-15, 'T'}, {1.e-18, 'P'}, {1.e-21, 'E'},
|
||||
{1.e-24, 'Z'}, {1.e-27, 'Y'}};
|
||||
|
||||
if (interval == 0.0)
|
||||
{
|
||||
os << std::setw(width-3) << std::right << "0.00" << std::setw(3) << unit;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
bool negative = false;
|
||||
if (interval < 0.0)
|
||||
{
|
||||
negative = true;
|
||||
interval = -interval;
|
||||
}
|
||||
|
||||
for (int i=0; i<(int)(sizeof(ranges)/sizeof(ranges[0])); i++)
|
||||
{
|
||||
if (interval*ranges[i].scale < 1.e0)
|
||||
{
|
||||
interval = interval * 1000.e0 * ranges[i].scale;
|
||||
os << std::fixed << std::setprecision(2) << std::setw(width-3) << std::right <<
|
||||
(negative ? -interval : interval) << std::setw(2) << ranges[i].prefix << std::setw(1) << unit;
|
||||
|
||||
return os.str();
|
||||
}
|
||||
}
|
||||
if (interval == 0.0) {
|
||||
os << std::setw(width - 3) << std::right << "0.00" << std::setw(3)
|
||||
<< unit;
|
||||
return os.str();
|
||||
}
|
||||
os << std::setprecision(2) << std::fixed << std::right << std::setw(width-3) << interval << std::setw(3) << unit;
|
||||
|
||||
return os.str();
|
||||
bool negative = false;
|
||||
if (interval < 0.0) {
|
||||
negative = true;
|
||||
interval = -interval;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)(sizeof(ranges) / sizeof(ranges[0])); i++) {
|
||||
if (interval * ranges[i].scale < 1.e0) {
|
||||
interval = interval * 1000.e0 * ranges[i].scale;
|
||||
os << std::fixed << std::setprecision(2) << std::setw(width - 3)
|
||||
<< std::right << (negative ? -interval : interval) << std::setw(2)
|
||||
<< ranges[i].prefix << std::setw(1) << unit;
|
||||
|
||||
return os.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
os << std::setprecision(2) << std::fixed << std::right << std::setw(width - 3)
|
||||
<< interval << std::setw(3) << unit;
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,97 +16,103 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
|
||||
#include "kmp_os.h"
|
||||
#include <limits>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <limits>
|
||||
#include "kmp_os.h"
|
||||
#if KMP_HAVE_X86INTRIN_H
|
||||
# include <x86intrin.h>
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
|
||||
class tsc_tick_count {
|
||||
private:
|
||||
int64_t my_count;
|
||||
private:
|
||||
int64_t my_count;
|
||||
|
||||
public:
|
||||
class tsc_interval_t {
|
||||
int64_t value;
|
||||
explicit tsc_interval_t(int64_t _value) : value(_value) {}
|
||||
|
||||
public:
|
||||
class tsc_interval_t {
|
||||
int64_t value;
|
||||
explicit tsc_interval_t(int64_t _value) : value(_value) {}
|
||||
public:
|
||||
tsc_interval_t() : value(0) {}; // Construct 0 time duration
|
||||
tsc_interval_t() : value(0){}; // Construct 0 time duration
|
||||
#if KMP_HAVE_TICK_TIME
|
||||
double seconds() const; // Return the length of a time interval in seconds
|
||||
double seconds() const; // Return the length of a time interval in seconds
|
||||
#endif
|
||||
double ticks() const { return double(value); }
|
||||
int64_t getValue() const { return value; }
|
||||
tsc_interval_t& operator=(int64_t nvalue) { value = nvalue; return *this; }
|
||||
double ticks() const { return double(value); }
|
||||
int64_t getValue() const { return value; }
|
||||
tsc_interval_t &operator=(int64_t nvalue) {
|
||||
value = nvalue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend class tsc_tick_count;
|
||||
friend class tsc_tick_count;
|
||||
|
||||
friend tsc_interval_t operator-(const tsc_tick_count& t1,
|
||||
const tsc_tick_count& t0);
|
||||
friend tsc_interval_t operator-(const tsc_tick_count::tsc_interval_t& i1,
|
||||
const tsc_tick_count::tsc_interval_t& i0);
|
||||
friend tsc_interval_t& operator+=(tsc_tick_count::tsc_interval_t& i1,
|
||||
const tsc_tick_count::tsc_interval_t& i0);
|
||||
};
|
||||
friend tsc_interval_t operator-(const tsc_tick_count &t1,
|
||||
const tsc_tick_count &t0);
|
||||
friend tsc_interval_t operator-(const tsc_tick_count::tsc_interval_t &i1,
|
||||
const tsc_tick_count::tsc_interval_t &i0);
|
||||
friend tsc_interval_t &operator+=(tsc_tick_count::tsc_interval_t &i1,
|
||||
const tsc_tick_count::tsc_interval_t &i0);
|
||||
};
|
||||
|
||||
#if KMP_HAVE___BUILTIN_READCYCLECOUNTER
|
||||
tsc_tick_count() : my_count(static_cast<int64_t>(__builtin_readcyclecounter())) {}
|
||||
tsc_tick_count()
|
||||
: my_count(static_cast<int64_t>(__builtin_readcyclecounter())) {}
|
||||
#elif KMP_HAVE___RDTSC
|
||||
tsc_tick_count() : my_count(static_cast<int64_t>(__rdtsc())) {};
|
||||
tsc_tick_count() : my_count(static_cast<int64_t>(__rdtsc())){};
|
||||
#else
|
||||
# error Must have high resolution timer defined
|
||||
#error Must have high resolution timer defined
|
||||
#endif
|
||||
tsc_tick_count(int64_t value) : my_count(value) {};
|
||||
int64_t getValue() const { return my_count; }
|
||||
tsc_tick_count later (tsc_tick_count const other) const {
|
||||
return my_count > other.my_count ? (*this) : other;
|
||||
}
|
||||
tsc_tick_count earlier(tsc_tick_count const other) const {
|
||||
return my_count < other.my_count ? (*this) : other;
|
||||
}
|
||||
tsc_tick_count(int64_t value) : my_count(value){};
|
||||
int64_t getValue() const { return my_count; }
|
||||
tsc_tick_count later(tsc_tick_count const other) const {
|
||||
return my_count > other.my_count ? (*this) : other;
|
||||
}
|
||||
tsc_tick_count earlier(tsc_tick_count const other) const {
|
||||
return my_count < other.my_count ? (*this) : other;
|
||||
}
|
||||
#if KMP_HAVE_TICK_TIME
|
||||
static double tick_time(); // returns seconds per cycle (period) of clock
|
||||
static double tick_time(); // returns seconds per cycle (period) of clock
|
||||
#endif
|
||||
static tsc_tick_count now() { return tsc_tick_count(); } // returns the rdtsc register value
|
||||
friend tsc_tick_count::tsc_interval_t operator-(const tsc_tick_count& t1, const tsc_tick_count& t0);
|
||||
static tsc_tick_count now() {
|
||||
return tsc_tick_count();
|
||||
} // returns the rdtsc register value
|
||||
friend tsc_tick_count::tsc_interval_t operator-(const tsc_tick_count &t1,
|
||||
const tsc_tick_count &t0);
|
||||
};
|
||||
|
||||
inline tsc_tick_count::tsc_interval_t operator-(const tsc_tick_count& t1, const tsc_tick_count& t0)
|
||||
{
|
||||
return tsc_tick_count::tsc_interval_t( t1.my_count-t0.my_count );
|
||||
inline tsc_tick_count::tsc_interval_t operator-(const tsc_tick_count &t1,
|
||||
const tsc_tick_count &t0) {
|
||||
return tsc_tick_count::tsc_interval_t(t1.my_count - t0.my_count);
|
||||
}
|
||||
|
||||
inline tsc_tick_count::tsc_interval_t operator-(const tsc_tick_count::tsc_interval_t& i1, const tsc_tick_count::tsc_interval_t& i0)
|
||||
{
|
||||
return tsc_tick_count::tsc_interval_t( i1.value-i0.value );
|
||||
inline tsc_tick_count::tsc_interval_t
|
||||
operator-(const tsc_tick_count::tsc_interval_t &i1,
|
||||
const tsc_tick_count::tsc_interval_t &i0) {
|
||||
return tsc_tick_count::tsc_interval_t(i1.value - i0.value);
|
||||
}
|
||||
|
||||
inline tsc_tick_count::tsc_interval_t& operator+=(tsc_tick_count::tsc_interval_t& i1, const tsc_tick_count::tsc_interval_t& i0)
|
||||
{
|
||||
i1.value += i0.value;
|
||||
return i1;
|
||||
inline tsc_tick_count::tsc_interval_t &
|
||||
operator+=(tsc_tick_count::tsc_interval_t &i1,
|
||||
const tsc_tick_count::tsc_interval_t &i0) {
|
||||
i1.value += i0.value;
|
||||
return i1;
|
||||
}
|
||||
|
||||
#if KMP_HAVE_TICK_TIME
|
||||
inline double tsc_tick_count::tsc_interval_t::seconds() const
|
||||
{
|
||||
return value*tick_time();
|
||||
inline double tsc_tick_count::tsc_interval_t::seconds() const {
|
||||
return value * tick_time();
|
||||
}
|
||||
#endif
|
||||
|
||||
extern std::string formatSI(double interval, int width, char unit);
|
||||
|
||||
inline std::string formatSeconds(double interval, int width)
|
||||
{
|
||||
return formatSI(interval, width, 'S');
|
||||
inline std::string formatSeconds(double interval, int width) {
|
||||
return formatSI(interval, width, 'S');
|
||||
}
|
||||
|
||||
inline std::string formatTicks(double interval, int width)
|
||||
{
|
||||
return formatSI(interval, width, 'T');
|
||||
inline std::string formatTicks(double interval, int width) {
|
||||
return formatSI(interval, width, 'T');
|
||||
}
|
||||
|
||||
#endif // KMP_STATS_TIMING_H
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -16,104 +16,112 @@
|
|||
#ifndef KMP_STR_H
|
||||
#define KMP_STR_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "kmp_os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
#if KMP_OS_WINDOWS
|
||||
# define strdup _strdup
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
|
||||
/* some macros to replace ctype.h functions */
|
||||
#define TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) + 'a' - 'A') : (c))
|
||||
#define TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) + 'a' - 'A') : (c))
|
||||
|
||||
struct kmp_str_buf {
|
||||
char * str; // Pointer to buffer content, read only.
|
||||
unsigned int size; // Do not change this field!
|
||||
int used; // Number of characters printed to buffer, read only.
|
||||
char bulk[ 512 ]; // Do not use this field!
|
||||
char *str; // Pointer to buffer content, read only.
|
||||
unsigned int size; // Do not change this field!
|
||||
int used; // Number of characters printed to buffer, read only.
|
||||
char bulk[512]; // Do not use this field!
|
||||
}; // struct kmp_str_buf
|
||||
typedef struct kmp_str_buf kmp_str_buf_t;
|
||||
typedef struct kmp_str_buf kmp_str_buf_t;
|
||||
|
||||
#define __kmp_str_buf_init( b ) { (b)->str = (b)->bulk; (b)->size = sizeof( (b)->bulk ); (b)->used = 0; (b)->bulk[ 0 ] = 0; }
|
||||
#define __kmp_str_buf_init(b) \
|
||||
{ \
|
||||
(b)->str = (b)->bulk; \
|
||||
(b)->size = sizeof((b)->bulk); \
|
||||
(b)->used = 0; \
|
||||
(b)->bulk[0] = 0; \
|
||||
}
|
||||
|
||||
void __kmp_str_buf_clear( kmp_str_buf_t * buffer );
|
||||
void __kmp_str_buf_reserve( kmp_str_buf_t * buffer, int size );
|
||||
void __kmp_str_buf_detach( kmp_str_buf_t * buffer );
|
||||
void __kmp_str_buf_free( kmp_str_buf_t * buffer );
|
||||
void __kmp_str_buf_cat( kmp_str_buf_t * buffer, char const * str, int len );
|
||||
void __kmp_str_buf_vprint( kmp_str_buf_t * buffer, char const * format, va_list args );
|
||||
void __kmp_str_buf_print( kmp_str_buf_t * buffer, char const * format, ... );
|
||||
void __kmp_str_buf_print_size( kmp_str_buf_t * buffer, size_t size );
|
||||
void __kmp_str_buf_clear(kmp_str_buf_t *buffer);
|
||||
void __kmp_str_buf_reserve(kmp_str_buf_t *buffer, int size);
|
||||
void __kmp_str_buf_detach(kmp_str_buf_t *buffer);
|
||||
void __kmp_str_buf_free(kmp_str_buf_t *buffer);
|
||||
void __kmp_str_buf_cat(kmp_str_buf_t *buffer, char const *str, int len);
|
||||
void __kmp_str_buf_vprint(kmp_str_buf_t *buffer, char const *format,
|
||||
va_list args);
|
||||
void __kmp_str_buf_print(kmp_str_buf_t *buffer, char const *format, ...);
|
||||
void __kmp_str_buf_print_size(kmp_str_buf_t *buffer, size_t size);
|
||||
|
||||
/*
|
||||
File name parser. Usage:
|
||||
|
||||
kmp_str_fname_t fname = __kmp_str_fname_init( path );
|
||||
// Use fname.path (copy of original path ), fname.dir, fname.base.
|
||||
// Note fname.dir concatenated with fname.base gives exact copy of path.
|
||||
__kmp_str_fname_free( & fname );
|
||||
/* File name parser.
|
||||
Usage:
|
||||
|
||||
kmp_str_fname_t fname = __kmp_str_fname_init( path );
|
||||
// Use fname.path (copy of original path ), fname.dir, fname.base.
|
||||
// Note fname.dir concatenated with fname.base gives exact copy of path.
|
||||
__kmp_str_fname_free( & fname );
|
||||
*/
|
||||
struct kmp_str_fname {
|
||||
char * path;
|
||||
char * dir;
|
||||
char * base;
|
||||
char *path;
|
||||
char *dir;
|
||||
char *base;
|
||||
}; // struct kmp_str_fname
|
||||
typedef struct kmp_str_fname kmp_str_fname_t;
|
||||
void __kmp_str_fname_init( kmp_str_fname_t * fname, char const * path );
|
||||
void __kmp_str_fname_free( kmp_str_fname_t * fname );
|
||||
// Compares file name with specified patern. If pattern is NULL, any fname matched.
|
||||
int __kmp_str_fname_match( kmp_str_fname_t const * fname, char const * pattern );
|
||||
void __kmp_str_fname_init(kmp_str_fname_t *fname, char const *path);
|
||||
void __kmp_str_fname_free(kmp_str_fname_t *fname);
|
||||
// Compares file name with specified patern. If pattern is NULL, any fname
|
||||
// matched.
|
||||
int __kmp_str_fname_match(kmp_str_fname_t const *fname, char const *pattern);
|
||||
|
||||
/*
|
||||
The compiler provides source locations in string form ";file;func;line;col;;". It not not
|
||||
convenient for manupulation. These structure keeps source location in more convenient form.
|
||||
Usage:
|
||||
/* The compiler provides source locations in string form
|
||||
";file;func;line;col;;". It is not convenient for manupulation. This
|
||||
structure keeps source location in more convenient form.
|
||||
Usage:
|
||||
|
||||
kmp_str_loc_t loc = __kmp_str_loc_init( ident->psource, 0 );
|
||||
// use loc.file, loc.func, loc.line, loc.col.
|
||||
// loc.fname is available if the second argument of __kmp_str_loc_init is true.
|
||||
__kmp_str_loc_free( & loc );
|
||||
kmp_str_loc_t loc = __kmp_str_loc_init( ident->psource, 0 );
|
||||
// use loc.file, loc.func, loc.line, loc.col.
|
||||
// loc.fname is available if second argument of __kmp_str_loc_init is true.
|
||||
__kmp_str_loc_free( & loc );
|
||||
|
||||
If psource is NULL or does not follow format above, file and/or func may be NULL pointers.
|
||||
If psource is NULL or does not follow format above, file and/or func may be
|
||||
NULL pointers.
|
||||
*/
|
||||
struct kmp_str_loc {
|
||||
char * _bulk; // Do not use thid field.
|
||||
kmp_str_fname_t fname; // Will be initialized if init_fname is true.
|
||||
char * file;
|
||||
char * func;
|
||||
int line;
|
||||
int col;
|
||||
char *_bulk; // Do not use thid field.
|
||||
kmp_str_fname_t fname; // Will be initialized if init_fname is true.
|
||||
char *file;
|
||||
char *func;
|
||||
int line;
|
||||
int col;
|
||||
}; // struct kmp_str_loc
|
||||
typedef struct kmp_str_loc kmp_str_loc_t;
|
||||
kmp_str_loc_t __kmp_str_loc_init( char const * psource, int init_fname );
|
||||
void __kmp_str_loc_free( kmp_str_loc_t * loc );
|
||||
kmp_str_loc_t __kmp_str_loc_init(char const *psource, int init_fname);
|
||||
void __kmp_str_loc_free(kmp_str_loc_t *loc);
|
||||
|
||||
int __kmp_str_eqf( char const * lhs, char const * rhs );
|
||||
char * __kmp_str_format( char const * format, ... );
|
||||
void __kmp_str_free( char const * * str );
|
||||
int __kmp_str_match( char const * target, int len, char const * data );
|
||||
int __kmp_str_match_false( char const * data );
|
||||
int __kmp_str_match_true( char const * data );
|
||||
void __kmp_str_replace( char * str, char search_for, char replace_with );
|
||||
void __kmp_str_split( char * str, char delim, char ** head, char ** tail );
|
||||
char * __kmp_str_token( char * str, char const * delim, char ** buf );
|
||||
int __kmp_str_to_int( char const * str, char sentinel );
|
||||
int __kmp_str_eqf(char const *lhs, char const *rhs);
|
||||
char *__kmp_str_format(char const *format, ...);
|
||||
void __kmp_str_free(char const **str);
|
||||
int __kmp_str_match(char const *target, int len, char const *data);
|
||||
int __kmp_str_match_false(char const *data);
|
||||
int __kmp_str_match_true(char const *data);
|
||||
void __kmp_str_replace(char *str, char search_for, char replace_with);
|
||||
void __kmp_str_split(char *str, char delim, char **head, char **tail);
|
||||
char *__kmp_str_token(char *str, char const *delim, char **buf);
|
||||
int __kmp_str_to_int(char const *str, char sentinel);
|
||||
|
||||
void __kmp_str_to_size( char const * str, size_t * out, size_t dfactor, char const * * error );
|
||||
void __kmp_str_to_uint( char const * str, kmp_uint64 * out, char const * * error );
|
||||
void __kmp_str_to_size(char const *str, size_t *out, size_t dfactor,
|
||||
char const **error);
|
||||
void __kmp_str_to_uint(char const *str, kmp_uint64 *out, char const **error);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // KMP_STR_H
|
||||
|
||||
// end of file //
|
||||
|
||||
|
|
|
|||
|
|
@ -13,258 +13,304 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "omp.h" // Function renamings.
|
||||
#include "kmp.h" // KMP_DEFAULT_STKSIZE
|
||||
#include "kmp.h" // KMP_DEFAULT_STKSIZE
|
||||
#include "kmp_stub.h"
|
||||
#include "omp.h" // Function renamings.
|
||||
|
||||
#if KMP_OS_WINDOWS
|
||||
#include <windows.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
// Moved from omp.h
|
||||
#define omp_set_max_active_levels ompc_set_max_active_levels
|
||||
#define omp_set_schedule ompc_set_schedule
|
||||
#define omp_get_ancestor_thread_num ompc_get_ancestor_thread_num
|
||||
#define omp_get_team_size ompc_get_team_size
|
||||
#define omp_set_max_active_levels ompc_set_max_active_levels
|
||||
#define omp_set_schedule ompc_set_schedule
|
||||
#define omp_get_ancestor_thread_num ompc_get_ancestor_thread_num
|
||||
#define omp_get_team_size ompc_get_team_size
|
||||
|
||||
#define omp_set_num_threads ompc_set_num_threads
|
||||
#define omp_set_dynamic ompc_set_dynamic
|
||||
#define omp_set_nested ompc_set_nested
|
||||
#define kmp_set_stacksize kmpc_set_stacksize
|
||||
#define kmp_set_stacksize_s kmpc_set_stacksize_s
|
||||
#define kmp_set_blocktime kmpc_set_blocktime
|
||||
#define kmp_set_library kmpc_set_library
|
||||
#define kmp_set_defaults kmpc_set_defaults
|
||||
#define kmp_set_disp_num_buffers kmpc_set_disp_num_buffers
|
||||
#define kmp_malloc kmpc_malloc
|
||||
#define kmp_aligned_malloc kmpc_aligned_malloc
|
||||
#define kmp_calloc kmpc_calloc
|
||||
#define kmp_realloc kmpc_realloc
|
||||
#define kmp_free kmpc_free
|
||||
#define omp_set_num_threads ompc_set_num_threads
|
||||
#define omp_set_dynamic ompc_set_dynamic
|
||||
#define omp_set_nested ompc_set_nested
|
||||
#define kmp_set_stacksize kmpc_set_stacksize
|
||||
#define kmp_set_stacksize_s kmpc_set_stacksize_s
|
||||
#define kmp_set_blocktime kmpc_set_blocktime
|
||||
#define kmp_set_library kmpc_set_library
|
||||
#define kmp_set_defaults kmpc_set_defaults
|
||||
#define kmp_set_disp_num_buffers kmpc_set_disp_num_buffers
|
||||
#define kmp_malloc kmpc_malloc
|
||||
#define kmp_aligned_malloc kmpc_aligned_malloc
|
||||
#define kmp_calloc kmpc_calloc
|
||||
#define kmp_realloc kmpc_realloc
|
||||
#define kmp_free kmpc_free
|
||||
|
||||
static double frequency = 0.0;
|
||||
|
||||
// Helper functions.
|
||||
static size_t __kmps_init() {
|
||||
static int initialized = 0;
|
||||
static size_t dummy = 0;
|
||||
if ( ! initialized ) {
|
||||
static int initialized = 0;
|
||||
static size_t dummy = 0;
|
||||
if (!initialized) {
|
||||
// TODO: Analyze KMP_VERSION environment variable, print
|
||||
// __kmp_version_copyright and __kmp_version_build_time.
|
||||
// WARNING: Do not use "fprintf(stderr, ...)" because it will cause
|
||||
// unresolved "__iob" symbol (see C70080). We need to extract __kmp_printf()
|
||||
// stuff from kmp_runtime.cpp and use it.
|
||||
|
||||
// TODO: Analyze KMP_VERSION environment variable, print
|
||||
// __kmp_version_copyright and __kmp_version_build_time.
|
||||
// WARNING: Do not use "fprintf( stderr, ... )" because it will cause
|
||||
// unresolved "__iob" symbol (see C70080). We need to extract
|
||||
// __kmp_printf() stuff from kmp_runtime.cpp and use it.
|
||||
// Trick with dummy variable forces linker to keep __kmp_version_copyright
|
||||
// and __kmp_version_build_time strings in executable file (in case of
|
||||
// static linkage). When KMP_VERSION analysis is implemented, dummy
|
||||
// variable should be deleted, function should return void.
|
||||
dummy = __kmp_version_copyright - __kmp_version_build_time;
|
||||
|
||||
// Trick with dummy variable forces linker to keep __kmp_version_copyright
|
||||
// and __kmp_version_build_time strings in executable file (in case of
|
||||
// static linkage). When KMP_VERSION analysis is implemented, dummy
|
||||
// variable should be deleted, function should return void.
|
||||
dummy = __kmp_version_copyright - __kmp_version_build_time;
|
||||
|
||||
#if KMP_OS_WINDOWS
|
||||
LARGE_INTEGER freq;
|
||||
BOOL status = QueryPerformanceFrequency( & freq );
|
||||
if ( status ) {
|
||||
frequency = double( freq.QuadPart );
|
||||
}; // if
|
||||
#endif
|
||||
|
||||
initialized = 1;
|
||||
#if KMP_OS_WINDOWS
|
||||
LARGE_INTEGER freq;
|
||||
BOOL status = QueryPerformanceFrequency(&freq);
|
||||
if (status) {
|
||||
frequency = double(freq.QuadPart);
|
||||
}; // if
|
||||
return dummy;
|
||||
#endif
|
||||
|
||||
initialized = 1;
|
||||
}; // if
|
||||
return dummy;
|
||||
}; // __kmps_init
|
||||
|
||||
#define i __kmps_init();
|
||||
|
||||
/* set API functions */
|
||||
void omp_set_num_threads( omp_int_t num_threads ) { i; }
|
||||
void omp_set_dynamic( omp_int_t dynamic ) { i; __kmps_set_dynamic( dynamic ); }
|
||||
void omp_set_nested( omp_int_t nested ) { i; __kmps_set_nested( nested ); }
|
||||
void omp_set_max_active_levels( omp_int_t max_active_levels ) { i; }
|
||||
void omp_set_schedule( omp_sched_t kind, omp_int_t modifier ) { i; __kmps_set_schedule( (kmp_sched_t)kind, modifier ); }
|
||||
int omp_get_ancestor_thread_num( omp_int_t level ) { i; return ( level ) ? ( -1 ) : ( 0 ); }
|
||||
int omp_get_team_size( omp_int_t level ) { i; return ( level ) ? ( -1 ) : ( 1 ); }
|
||||
int kmpc_set_affinity_mask_proc( int proc, void **mask ) { i; return -1; }
|
||||
int kmpc_unset_affinity_mask_proc( int proc, void **mask ) { i; return -1; }
|
||||
int kmpc_get_affinity_mask_proc( int proc, void **mask ) { i; return -1; }
|
||||
void omp_set_num_threads(omp_int_t num_threads) { i; }
|
||||
void omp_set_dynamic(omp_int_t dynamic) {
|
||||
i;
|
||||
__kmps_set_dynamic(dynamic);
|
||||
}
|
||||
void omp_set_nested(omp_int_t nested) {
|
||||
i;
|
||||
__kmps_set_nested(nested);
|
||||
}
|
||||
void omp_set_max_active_levels(omp_int_t max_active_levels) { i; }
|
||||
void omp_set_schedule(omp_sched_t kind, omp_int_t modifier) {
|
||||
i;
|
||||
__kmps_set_schedule((kmp_sched_t)kind, modifier);
|
||||
}
|
||||
int omp_get_ancestor_thread_num(omp_int_t level) {
|
||||
i;
|
||||
return (level) ? (-1) : (0);
|
||||
}
|
||||
int omp_get_team_size(omp_int_t level) {
|
||||
i;
|
||||
return (level) ? (-1) : (1);
|
||||
}
|
||||
int kmpc_set_affinity_mask_proc(int proc, void **mask) {
|
||||
i;
|
||||
return -1;
|
||||
}
|
||||
int kmpc_unset_affinity_mask_proc(int proc, void **mask) {
|
||||
i;
|
||||
return -1;
|
||||
}
|
||||
int kmpc_get_affinity_mask_proc(int proc, void **mask) {
|
||||
i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* kmp API functions */
|
||||
void kmp_set_stacksize( omp_int_t arg ) { i; __kmps_set_stacksize( arg ); }
|
||||
void kmp_set_stacksize_s( size_t arg ) { i; __kmps_set_stacksize( arg ); }
|
||||
void kmp_set_blocktime( omp_int_t arg ) { i; __kmps_set_blocktime( arg ); }
|
||||
void kmp_set_library( omp_int_t arg ) { i; __kmps_set_library( arg ); }
|
||||
void kmp_set_defaults( char const * str ) { i; }
|
||||
void kmp_set_disp_num_buffers( omp_int_t arg ) { i; }
|
||||
void kmp_set_stacksize(omp_int_t arg) {
|
||||
i;
|
||||
__kmps_set_stacksize(arg);
|
||||
}
|
||||
void kmp_set_stacksize_s(size_t arg) {
|
||||
i;
|
||||
__kmps_set_stacksize(arg);
|
||||
}
|
||||
void kmp_set_blocktime(omp_int_t arg) {
|
||||
i;
|
||||
__kmps_set_blocktime(arg);
|
||||
}
|
||||
void kmp_set_library(omp_int_t arg) {
|
||||
i;
|
||||
__kmps_set_library(arg);
|
||||
}
|
||||
void kmp_set_defaults(char const *str) { i; }
|
||||
void kmp_set_disp_num_buffers(omp_int_t arg) { i; }
|
||||
|
||||
/* KMP memory management functions. */
|
||||
void * kmp_malloc( size_t size ) { i; return malloc( size ); }
|
||||
void * kmp_aligned_malloc( size_t sz, size_t a ) {
|
||||
i;
|
||||
void *kmp_malloc(size_t size) {
|
||||
i;
|
||||
return malloc(size);
|
||||
}
|
||||
void *kmp_aligned_malloc(size_t sz, size_t a) {
|
||||
i;
|
||||
#if KMP_OS_WINDOWS
|
||||
errno = ENOSYS; // not supported
|
||||
return NULL; // no standard aligned allocator on Windows (pre - C11)
|
||||
errno = ENOSYS; // not supported
|
||||
return NULL; // no standard aligned allocator on Windows (pre - C11)
|
||||
#else
|
||||
void *res;
|
||||
int err;
|
||||
if( err = posix_memalign( &res, a, sz ) ) {
|
||||
errno = err; // can be EINVAL or ENOMEM
|
||||
return NULL;
|
||||
}
|
||||
return res;
|
||||
void *res;
|
||||
int err;
|
||||
if (err = posix_memalign(&res, a, sz)) {
|
||||
errno = err; // can be EINVAL or ENOMEM
|
||||
return NULL;
|
||||
}
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
void * kmp_calloc( size_t nelem, size_t elsize ) { i; return calloc( nelem, elsize ); }
|
||||
void * kmp_realloc( void *ptr, size_t size ) { i; return realloc( ptr, size ); }
|
||||
void kmp_free( void * ptr ) { i; free( ptr ); }
|
||||
void *kmp_calloc(size_t nelem, size_t elsize) {
|
||||
i;
|
||||
return calloc(nelem, elsize);
|
||||
}
|
||||
void *kmp_realloc(void *ptr, size_t size) {
|
||||
i;
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
void kmp_free(void *ptr) {
|
||||
i;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static int __kmps_blocktime = INT_MAX;
|
||||
|
||||
void __kmps_set_blocktime( int arg ) {
|
||||
i;
|
||||
__kmps_blocktime = arg;
|
||||
void __kmps_set_blocktime(int arg) {
|
||||
i;
|
||||
__kmps_blocktime = arg;
|
||||
} // __kmps_set_blocktime
|
||||
|
||||
int __kmps_get_blocktime( void ) {
|
||||
i;
|
||||
return __kmps_blocktime;
|
||||
int __kmps_get_blocktime(void) {
|
||||
i;
|
||||
return __kmps_blocktime;
|
||||
} // __kmps_get_blocktime
|
||||
|
||||
static int __kmps_dynamic = 0;
|
||||
|
||||
void __kmps_set_dynamic( int arg ) {
|
||||
i;
|
||||
__kmps_dynamic = arg;
|
||||
void __kmps_set_dynamic(int arg) {
|
||||
i;
|
||||
__kmps_dynamic = arg;
|
||||
} // __kmps_set_dynamic
|
||||
|
||||
int __kmps_get_dynamic( void ) {
|
||||
i;
|
||||
return __kmps_dynamic;
|
||||
int __kmps_get_dynamic(void) {
|
||||
i;
|
||||
return __kmps_dynamic;
|
||||
} // __kmps_get_dynamic
|
||||
|
||||
static int __kmps_library = 1000;
|
||||
|
||||
void __kmps_set_library( int arg ) {
|
||||
i;
|
||||
__kmps_library = arg;
|
||||
void __kmps_set_library(int arg) {
|
||||
i;
|
||||
__kmps_library = arg;
|
||||
} // __kmps_set_library
|
||||
|
||||
int __kmps_get_library( void ) {
|
||||
i;
|
||||
return __kmps_library;
|
||||
int __kmps_get_library(void) {
|
||||
i;
|
||||
return __kmps_library;
|
||||
} // __kmps_get_library
|
||||
|
||||
static int __kmps_nested = 0;
|
||||
|
||||
void __kmps_set_nested( int arg ) {
|
||||
i;
|
||||
__kmps_nested = arg;
|
||||
void __kmps_set_nested(int arg) {
|
||||
i;
|
||||
__kmps_nested = arg;
|
||||
} // __kmps_set_nested
|
||||
|
||||
int __kmps_get_nested( void ) {
|
||||
i;
|
||||
return __kmps_nested;
|
||||
int __kmps_get_nested(void) {
|
||||
i;
|
||||
return __kmps_nested;
|
||||
} // __kmps_get_nested
|
||||
|
||||
static size_t __kmps_stacksize = KMP_DEFAULT_STKSIZE;
|
||||
|
||||
void __kmps_set_stacksize( int arg ) {
|
||||
i;
|
||||
__kmps_stacksize = arg;
|
||||
void __kmps_set_stacksize(int arg) {
|
||||
i;
|
||||
__kmps_stacksize = arg;
|
||||
} // __kmps_set_stacksize
|
||||
|
||||
int __kmps_get_stacksize( void ) {
|
||||
i;
|
||||
return __kmps_stacksize;
|
||||
int __kmps_get_stacksize(void) {
|
||||
i;
|
||||
return __kmps_stacksize;
|
||||
} // __kmps_get_stacksize
|
||||
|
||||
static kmp_sched_t __kmps_sched_kind = kmp_sched_default;
|
||||
static int __kmps_sched_modifier = 0;
|
||||
static kmp_sched_t __kmps_sched_kind = kmp_sched_default;
|
||||
static int __kmps_sched_modifier = 0;
|
||||
|
||||
void __kmps_set_schedule( kmp_sched_t kind, int modifier ) {
|
||||
i;
|
||||
__kmps_sched_kind = kind;
|
||||
__kmps_sched_modifier = modifier;
|
||||
} // __kmps_set_schedule
|
||||
void __kmps_set_schedule(kmp_sched_t kind, int modifier) {
|
||||
i;
|
||||
__kmps_sched_kind = kind;
|
||||
__kmps_sched_modifier = modifier;
|
||||
} // __kmps_set_schedule
|
||||
|
||||
void __kmps_get_schedule( kmp_sched_t *kind, int *modifier ) {
|
||||
i;
|
||||
*kind = __kmps_sched_kind;
|
||||
*modifier = __kmps_sched_modifier;
|
||||
} // __kmps_get_schedule
|
||||
void __kmps_get_schedule(kmp_sched_t *kind, int *modifier) {
|
||||
i;
|
||||
*kind = __kmps_sched_kind;
|
||||
*modifier = __kmps_sched_modifier;
|
||||
} // __kmps_get_schedule
|
||||
|
||||
#if OMP_40_ENABLED
|
||||
|
||||
static kmp_proc_bind_t __kmps_proc_bind = proc_bind_false;
|
||||
|
||||
void __kmps_set_proc_bind( kmp_proc_bind_t arg ) {
|
||||
i;
|
||||
__kmps_proc_bind = arg;
|
||||
void __kmps_set_proc_bind(kmp_proc_bind_t arg) {
|
||||
i;
|
||||
__kmps_proc_bind = arg;
|
||||
} // __kmps_set_proc_bind
|
||||
|
||||
kmp_proc_bind_t __kmps_get_proc_bind( void ) {
|
||||
i;
|
||||
return __kmps_proc_bind;
|
||||
kmp_proc_bind_t __kmps_get_proc_bind(void) {
|
||||
i;
|
||||
return __kmps_proc_bind;
|
||||
} // __kmps_get_proc_bind
|
||||
|
||||
#endif /* OMP_40_ENABLED */
|
||||
|
||||
double __kmps_get_wtime( void ) {
|
||||
// Elapsed wall clock time (in second) from "sometime in the past".
|
||||
double wtime = 0.0;
|
||||
i;
|
||||
#if KMP_OS_WINDOWS
|
||||
if ( frequency > 0.0 ) {
|
||||
LARGE_INTEGER now;
|
||||
BOOL status = QueryPerformanceCounter( & now );
|
||||
if ( status ) {
|
||||
wtime = double( now.QuadPart ) / frequency;
|
||||
}; // if
|
||||
}; // if
|
||||
#else
|
||||
// gettimeofday() returns seconds and microseconds since the Epoch.
|
||||
struct timeval tval;
|
||||
int rc;
|
||||
rc = gettimeofday( & tval, NULL );
|
||||
if ( rc == 0 ) {
|
||||
wtime = (double)( tval.tv_sec ) + 1.0E-06 * (double)( tval.tv_usec );
|
||||
} else {
|
||||
// TODO: Assert or abort here.
|
||||
}; // if
|
||||
#endif
|
||||
return wtime;
|
||||
double __kmps_get_wtime(void) {
|
||||
// Elapsed wall clock time (in second) from "sometime in the past".
|
||||
double wtime = 0.0;
|
||||
i;
|
||||
#if KMP_OS_WINDOWS
|
||||
if (frequency > 0.0) {
|
||||
LARGE_INTEGER now;
|
||||
BOOL status = QueryPerformanceCounter(&now);
|
||||
if (status) {
|
||||
wtime = double(now.QuadPart) / frequency;
|
||||
}; // if
|
||||
}; // if
|
||||
#else
|
||||
// gettimeofday() returns seconds and microseconds since the Epoch.
|
||||
struct timeval tval;
|
||||
int rc;
|
||||
rc = gettimeofday(&tval, NULL);
|
||||
if (rc == 0) {
|
||||
wtime = (double)(tval.tv_sec) + 1.0E-06 * (double)(tval.tv_usec);
|
||||
} else {
|
||||
// TODO: Assert or abort here.
|
||||
}; // if
|
||||
#endif
|
||||
return wtime;
|
||||
}; // __kmps_get_wtime
|
||||
|
||||
double __kmps_get_wtick( void ) {
|
||||
// Number of seconds between successive clock ticks.
|
||||
double wtick = 0.0;
|
||||
i;
|
||||
#if KMP_OS_WINDOWS
|
||||
{
|
||||
DWORD increment;
|
||||
DWORD adjustment;
|
||||
BOOL disabled;
|
||||
BOOL rc;
|
||||
rc = GetSystemTimeAdjustment( & adjustment, & increment, & disabled );
|
||||
if ( rc ) {
|
||||
wtick = 1.0E-07 * (double)( disabled ? increment : adjustment );
|
||||
} else {
|
||||
// TODO: Assert or abort here.
|
||||
wtick = 1.0E-03;
|
||||
}; // if
|
||||
}
|
||||
#else
|
||||
// TODO: gettimeofday() returns in microseconds, but what the precision?
|
||||
wtick = 1.0E-06;
|
||||
#endif
|
||||
return wtick;
|
||||
double __kmps_get_wtick(void) {
|
||||
// Number of seconds between successive clock ticks.
|
||||
double wtick = 0.0;
|
||||
i;
|
||||
#if KMP_OS_WINDOWS
|
||||
{
|
||||
DWORD increment;
|
||||
DWORD adjustment;
|
||||
BOOL disabled;
|
||||
BOOL rc;
|
||||
rc = GetSystemTimeAdjustment(&adjustment, &increment, &disabled);
|
||||
if (rc) {
|
||||
wtick = 1.0E-07 * (double)(disabled ? increment : adjustment);
|
||||
} else {
|
||||
// TODO: Assert or abort here.
|
||||
wtick = 1.0E-03;
|
||||
}; // if
|
||||
}
|
||||
#else
|
||||
// TODO: gettimeofday() returns in microseconds, but what the precision?
|
||||
wtick = 1.0E-06;
|
||||
#endif
|
||||
return wtick;
|
||||
}; // __kmps_get_wtick
|
||||
|
||||
// end of file //
|
||||
|
||||
|
|
|
|||
|
|
@ -17,43 +17,43 @@
|
|||
#define KMP_STUB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void __kmps_set_blocktime( int arg );
|
||||
int __kmps_get_blocktime( void );
|
||||
void __kmps_set_dynamic( int arg );
|
||||
int __kmps_get_dynamic( void );
|
||||
void __kmps_set_library( int arg );
|
||||
int __kmps_get_library( void );
|
||||
void __kmps_set_nested( int arg );
|
||||
int __kmps_get_nested( void );
|
||||
void __kmps_set_stacksize( int arg );
|
||||
int __kmps_get_stacksize();
|
||||
void __kmps_set_blocktime(int arg);
|
||||
int __kmps_get_blocktime(void);
|
||||
void __kmps_set_dynamic(int arg);
|
||||
int __kmps_get_dynamic(void);
|
||||
void __kmps_set_library(int arg);
|
||||
int __kmps_get_library(void);
|
||||
void __kmps_set_nested(int arg);
|
||||
int __kmps_get_nested(void);
|
||||
void __kmps_set_stacksize(int arg);
|
||||
int __kmps_get_stacksize();
|
||||
|
||||
#ifndef KMP_SCHED_TYPE_DEFINED
|
||||
#define KMP_SCHED_TYPE_DEFINED
|
||||
typedef enum kmp_sched {
|
||||
kmp_sched_static = 1, // mapped to kmp_sch_static_chunked (33)
|
||||
kmp_sched_dynamic = 2, // mapped to kmp_sch_dynamic_chunked (35)
|
||||
kmp_sched_guided = 3, // mapped to kmp_sch_guided_chunked (36)
|
||||
kmp_sched_auto = 4, // mapped to kmp_sch_auto (38)
|
||||
kmp_sched_default = kmp_sched_static // default scheduling
|
||||
kmp_sched_static = 1, // mapped to kmp_sch_static_chunked (33)
|
||||
kmp_sched_dynamic = 2, // mapped to kmp_sch_dynamic_chunked (35)
|
||||
kmp_sched_guided = 3, // mapped to kmp_sch_guided_chunked (36)
|
||||
kmp_sched_auto = 4, // mapped to kmp_sch_auto (38)
|
||||
kmp_sched_default = kmp_sched_static // default scheduling
|
||||
} kmp_sched_t;
|
||||
#endif
|
||||
void __kmps_set_schedule( kmp_sched_t kind, int modifier );
|
||||
void __kmps_get_schedule( kmp_sched_t *kind, int *modifier );
|
||||
void __kmps_set_schedule(kmp_sched_t kind, int modifier);
|
||||
void __kmps_get_schedule(kmp_sched_t *kind, int *modifier);
|
||||
|
||||
#if OMP_40_ENABLED
|
||||
void __kmps_set_proc_bind( kmp_proc_bind_t arg );
|
||||
kmp_proc_bind_t __kmps_get_proc_bind( void );
|
||||
void __kmps_set_proc_bind(kmp_proc_bind_t arg);
|
||||
kmp_proc_bind_t __kmps_get_proc_bind(void);
|
||||
#endif /* OMP_40_ENABLED */
|
||||
|
||||
double __kmps_get_wtime();
|
||||
double __kmps_get_wtick();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // KMP_STUB_H
|
||||
|
|
|
|||
|
|
@ -21,511 +21,543 @@
|
|||
|
||||
#if OMP_40_ENABLED
|
||||
|
||||
//TODO: Improve memory allocation? keep a list of pre-allocated structures? allocate in blocks? re-use list finished list entries?
|
||||
//TODO: don't use atomic ref counters for stack-allocated nodes.
|
||||
//TODO: find an alternate to atomic refs for heap-allocated nodes?
|
||||
//TODO: Finish graph output support
|
||||
//TODO: kmp_lock_t seems a tad to big (and heavy weight) for this. Check other runtime locks
|
||||
//TODO: Any ITT support needed?
|
||||
// TODO: Improve memory allocation? keep a list of pre-allocated structures?
|
||||
// allocate in blocks? re-use list finished list entries?
|
||||
// TODO: don't use atomic ref counters for stack-allocated nodes.
|
||||
// TODO: find an alternate to atomic refs for heap-allocated nodes?
|
||||
// TODO: Finish graph output support
|
||||
// TODO: kmp_lock_t seems a tad to big (and heavy weight) for this. Check other
|
||||
// runtime locks
|
||||
// TODO: Any ITT support needed?
|
||||
|
||||
#ifdef KMP_SUPPORT_GRAPH_OUTPUT
|
||||
static kmp_int32 kmp_node_id_seed = 0;
|
||||
#endif
|
||||
|
||||
static void
|
||||
__kmp_init_node ( kmp_depnode_t *node )
|
||||
{
|
||||
node->dn.task = NULL; // set to null initially, it will point to the right task once dependences have been processed
|
||||
node->dn.successors = NULL;
|
||||
__kmp_init_lock(&node->dn.lock);
|
||||
node->dn.nrefs = 1; // init creates the first reference to the node
|
||||
static void __kmp_init_node(kmp_depnode_t *node) {
|
||||
node->dn.task = NULL; // set to null initially, it will point to the right
|
||||
// task once dependences have been processed
|
||||
node->dn.successors = NULL;
|
||||
__kmp_init_lock(&node->dn.lock);
|
||||
node->dn.nrefs = 1; // init creates the first reference to the node
|
||||
#ifdef KMP_SUPPORT_GRAPH_OUTPUT
|
||||
node->dn.id = KMP_TEST_THEN_INC32(&kmp_node_id_seed);
|
||||
node->dn.id = KMP_TEST_THEN_INC32(&kmp_node_id_seed);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline kmp_depnode_t *
|
||||
__kmp_node_ref ( kmp_depnode_t *node )
|
||||
{
|
||||
KMP_TEST_THEN_INC32(&node->dn.nrefs);
|
||||
return node;
|
||||
static inline kmp_depnode_t *__kmp_node_ref(kmp_depnode_t *node) {
|
||||
KMP_TEST_THEN_INC32(&node->dn.nrefs);
|
||||
return node;
|
||||
}
|
||||
|
||||
static inline void
|
||||
__kmp_node_deref ( kmp_info_t *thread, kmp_depnode_t *node )
|
||||
{
|
||||
if (!node) return;
|
||||
static inline void __kmp_node_deref(kmp_info_t *thread, kmp_depnode_t *node) {
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
kmp_int32 n = KMP_TEST_THEN_DEC32(&node->dn.nrefs) - 1;
|
||||
if ( n == 0 ) {
|
||||
KMP_ASSERT(node->dn.nrefs == 0);
|
||||
kmp_int32 n = KMP_TEST_THEN_DEC32(&node->dn.nrefs) - 1;
|
||||
if (n == 0) {
|
||||
KMP_ASSERT(node->dn.nrefs == 0);
|
||||
#if USE_FAST_MEMORY
|
||||
__kmp_fast_free(thread,node);
|
||||
__kmp_fast_free(thread, node);
|
||||
#else
|
||||
__kmp_thread_free(thread,node);
|
||||
__kmp_thread_free(thread, node);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define KMP_ACQUIRE_DEPNODE(gtid,n) __kmp_acquire_lock(&(n)->dn.lock,(gtid))
|
||||
#define KMP_RELEASE_DEPNODE(gtid,n) __kmp_release_lock(&(n)->dn.lock,(gtid))
|
||||
#define KMP_ACQUIRE_DEPNODE(gtid, n) __kmp_acquire_lock(&(n)->dn.lock, (gtid))
|
||||
#define KMP_RELEASE_DEPNODE(gtid, n) __kmp_release_lock(&(n)->dn.lock, (gtid))
|
||||
|
||||
static void
|
||||
__kmp_depnode_list_free ( kmp_info_t *thread, kmp_depnode_list *list );
|
||||
static void __kmp_depnode_list_free(kmp_info_t *thread, kmp_depnode_list *list);
|
||||
|
||||
enum {
|
||||
KMP_DEPHASH_OTHER_SIZE = 97,
|
||||
KMP_DEPHASH_MASTER_SIZE = 997
|
||||
};
|
||||
enum { KMP_DEPHASH_OTHER_SIZE = 97, KMP_DEPHASH_MASTER_SIZE = 997 };
|
||||
|
||||
static inline kmp_int32
|
||||
__kmp_dephash_hash ( kmp_intptr_t addr, size_t hsize )
|
||||
{
|
||||
//TODO alternate to try: set = (((Addr64)(addrUsefulBits * 9.618)) % m_num_sets );
|
||||
return ((addr >> 6) ^ (addr >> 2)) % hsize;
|
||||
static inline kmp_int32 __kmp_dephash_hash(kmp_intptr_t addr, size_t hsize) {
|
||||
// TODO alternate to try: set = (((Addr64)(addrUsefulBits * 9.618)) %
|
||||
// m_num_sets );
|
||||
return ((addr >> 6) ^ (addr >> 2)) % hsize;
|
||||
}
|
||||
|
||||
static kmp_dephash_t *
|
||||
__kmp_dephash_create ( kmp_info_t *thread, kmp_taskdata_t *current_task )
|
||||
{
|
||||
kmp_dephash_t *h;
|
||||
static kmp_dephash_t *__kmp_dephash_create(kmp_info_t *thread,
|
||||
kmp_taskdata_t *current_task) {
|
||||
kmp_dephash_t *h;
|
||||
|
||||
size_t h_size;
|
||||
size_t h_size;
|
||||
|
||||
if ( current_task->td_flags.tasktype == TASK_IMPLICIT )
|
||||
h_size = KMP_DEPHASH_MASTER_SIZE;
|
||||
else
|
||||
h_size = KMP_DEPHASH_OTHER_SIZE;
|
||||
if (current_task->td_flags.tasktype == TASK_IMPLICIT)
|
||||
h_size = KMP_DEPHASH_MASTER_SIZE;
|
||||
else
|
||||
h_size = KMP_DEPHASH_OTHER_SIZE;
|
||||
|
||||
kmp_int32 size =
|
||||
h_size * sizeof(kmp_dephash_entry_t *) + sizeof(kmp_dephash_t);
|
||||
kmp_int32 size =
|
||||
h_size * sizeof(kmp_dephash_entry_t *) + sizeof(kmp_dephash_t);
|
||||
|
||||
#if USE_FAST_MEMORY
|
||||
h = (kmp_dephash_t *) __kmp_fast_allocate( thread, size );
|
||||
h = (kmp_dephash_t *)__kmp_fast_allocate(thread, size);
|
||||
#else
|
||||
h = (kmp_dephash_t *) __kmp_thread_malloc( thread, size );
|
||||
h = (kmp_dephash_t *)__kmp_thread_malloc(thread, size);
|
||||
#endif
|
||||
h->size = h_size;
|
||||
h->size = h_size;
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
h->nelements = 0;
|
||||
h->nconflicts = 0;
|
||||
h->nelements = 0;
|
||||
h->nconflicts = 0;
|
||||
#endif
|
||||
h->buckets = (kmp_dephash_entry **)(h+1);
|
||||
h->buckets = (kmp_dephash_entry **)(h + 1);
|
||||
|
||||
for ( size_t i = 0; i < h_size; i++ )
|
||||
h->buckets[i] = 0;
|
||||
for (size_t i = 0; i < h_size; i++)
|
||||
h->buckets[i] = 0;
|
||||
|
||||
return h;
|
||||
return h;
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_dephash_free_entries(kmp_info_t *thread, kmp_dephash_t *h)
|
||||
{
|
||||
for (size_t i = 0; i < h->size; i++) {
|
||||
if (h->buckets[i]) {
|
||||
kmp_dephash_entry_t *next;
|
||||
for (kmp_dephash_entry_t *entry = h->buckets[i]; entry; entry = next) {
|
||||
next = entry->next_in_bucket;
|
||||
__kmp_depnode_list_free(thread,entry->last_ins);
|
||||
__kmp_node_deref(thread,entry->last_out);
|
||||
void __kmp_dephash_free_entries(kmp_info_t *thread, kmp_dephash_t *h) {
|
||||
for (size_t i = 0; i < h->size; i++) {
|
||||
if (h->buckets[i]) {
|
||||
kmp_dephash_entry_t *next;
|
||||
for (kmp_dephash_entry_t *entry = h->buckets[i]; entry; entry = next) {
|
||||
next = entry->next_in_bucket;
|
||||
__kmp_depnode_list_free(thread, entry->last_ins);
|
||||
__kmp_node_deref(thread, entry->last_out);
|
||||
#if USE_FAST_MEMORY
|
||||
__kmp_fast_free(thread,entry);
|
||||
__kmp_fast_free(thread, entry);
|
||||
#else
|
||||
__kmp_thread_free(thread,entry);
|
||||
__kmp_thread_free(thread, entry);
|
||||
#endif
|
||||
}
|
||||
h->buckets[i] = 0;
|
||||
}
|
||||
}
|
||||
h->buckets[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_dephash_free(kmp_info_t *thread, kmp_dephash_t *h)
|
||||
{
|
||||
__kmp_dephash_free_entries(thread, h);
|
||||
void __kmp_dephash_free(kmp_info_t *thread, kmp_dephash_t *h) {
|
||||
__kmp_dephash_free_entries(thread, h);
|
||||
#if USE_FAST_MEMORY
|
||||
__kmp_fast_free(thread,h);
|
||||
__kmp_fast_free(thread, h);
|
||||
#else
|
||||
__kmp_thread_free(thread,h);
|
||||
__kmp_thread_free(thread, h);
|
||||
#endif
|
||||
}
|
||||
|
||||
static kmp_dephash_entry *
|
||||
__kmp_dephash_find ( kmp_info_t *thread, kmp_dephash_t *h, kmp_intptr_t addr )
|
||||
{
|
||||
kmp_int32 bucket = __kmp_dephash_hash(addr,h->size);
|
||||
__kmp_dephash_find(kmp_info_t *thread, kmp_dephash_t *h, kmp_intptr_t addr) {
|
||||
kmp_int32 bucket = __kmp_dephash_hash(addr, h->size);
|
||||
|
||||
kmp_dephash_entry_t *entry;
|
||||
for ( entry = h->buckets[bucket]; entry; entry = entry->next_in_bucket )
|
||||
if ( entry->addr == addr ) break;
|
||||
kmp_dephash_entry_t *entry;
|
||||
for (entry = h->buckets[bucket]; entry; entry = entry->next_in_bucket)
|
||||
if (entry->addr == addr)
|
||||
break;
|
||||
|
||||
if ( entry == NULL ) {
|
||||
// create entry. This is only done by one thread so no locking required
|
||||
if (entry == NULL) {
|
||||
// create entry. This is only done by one thread so no locking required
|
||||
#if USE_FAST_MEMORY
|
||||
entry = (kmp_dephash_entry_t *) __kmp_fast_allocate( thread, sizeof(kmp_dephash_entry_t) );
|
||||
entry = (kmp_dephash_entry_t *)__kmp_fast_allocate(
|
||||
thread, sizeof(kmp_dephash_entry_t));
|
||||
#else
|
||||
entry = (kmp_dephash_entry_t *) __kmp_thread_malloc( thread, sizeof(kmp_dephash_entry_t) );
|
||||
entry = (kmp_dephash_entry_t *)__kmp_thread_malloc(
|
||||
thread, sizeof(kmp_dephash_entry_t));
|
||||
#endif
|
||||
entry->addr = addr;
|
||||
entry->last_out = NULL;
|
||||
entry->last_ins = NULL;
|
||||
entry->next_in_bucket = h->buckets[bucket];
|
||||
h->buckets[bucket] = entry;
|
||||
entry->addr = addr;
|
||||
entry->last_out = NULL;
|
||||
entry->last_ins = NULL;
|
||||
entry->next_in_bucket = h->buckets[bucket];
|
||||
h->buckets[bucket] = entry;
|
||||
#ifdef KMP_DEBUG
|
||||
h->nelements++;
|
||||
if ( entry->next_in_bucket ) h->nconflicts++;
|
||||
h->nelements++;
|
||||
if (entry->next_in_bucket)
|
||||
h->nconflicts++;
|
||||
#endif
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
static kmp_depnode_list_t *
|
||||
__kmp_add_node ( kmp_info_t *thread, kmp_depnode_list_t *list, kmp_depnode_t *node )
|
||||
{
|
||||
kmp_depnode_list_t *new_head;
|
||||
static kmp_depnode_list_t *__kmp_add_node(kmp_info_t *thread,
|
||||
kmp_depnode_list_t *list,
|
||||
kmp_depnode_t *node) {
|
||||
kmp_depnode_list_t *new_head;
|
||||
|
||||
#if USE_FAST_MEMORY
|
||||
new_head = (kmp_depnode_list_t *) __kmp_fast_allocate(thread,sizeof(kmp_depnode_list_t));
|
||||
new_head = (kmp_depnode_list_t *)__kmp_fast_allocate(
|
||||
thread, sizeof(kmp_depnode_list_t));
|
||||
#else
|
||||
new_head = (kmp_depnode_list_t *) __kmp_thread_malloc(thread,sizeof(kmp_depnode_list_t));
|
||||
new_head = (kmp_depnode_list_t *)__kmp_thread_malloc(
|
||||
thread, sizeof(kmp_depnode_list_t));
|
||||
#endif
|
||||
|
||||
new_head->node = __kmp_node_ref(node);
|
||||
new_head->next = list;
|
||||
new_head->node = __kmp_node_ref(node);
|
||||
new_head->next = list;
|
||||
|
||||
return new_head;
|
||||
return new_head;
|
||||
}
|
||||
|
||||
static void
|
||||
__kmp_depnode_list_free ( kmp_info_t *thread, kmp_depnode_list *list )
|
||||
{
|
||||
kmp_depnode_list *next;
|
||||
static void __kmp_depnode_list_free(kmp_info_t *thread,
|
||||
kmp_depnode_list *list) {
|
||||
kmp_depnode_list *next;
|
||||
|
||||
for ( ; list ; list = next ) {
|
||||
next = list->next;
|
||||
for (; list; list = next) {
|
||||
next = list->next;
|
||||
|
||||
__kmp_node_deref(thread,list->node);
|
||||
__kmp_node_deref(thread, list->node);
|
||||
#if USE_FAST_MEMORY
|
||||
__kmp_fast_free(thread,list);
|
||||
__kmp_fast_free(thread, list);
|
||||
#else
|
||||
__kmp_thread_free(thread,list);
|
||||
__kmp_thread_free(thread, list);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
__kmp_track_dependence ( kmp_depnode_t *source, kmp_depnode_t *sink,
|
||||
kmp_task_t *sink_task )
|
||||
{
|
||||
static inline void __kmp_track_dependence(kmp_depnode_t *source,
|
||||
kmp_depnode_t *sink,
|
||||
kmp_task_t *sink_task) {
|
||||
#ifdef KMP_SUPPORT_GRAPH_OUTPUT
|
||||
kmp_taskdata_t * task_source = KMP_TASK_TO_TASKDATA(source->dn.task);
|
||||
// do not use sink->dn.task as that is only filled after the dependencies
|
||||
// are already processed!
|
||||
kmp_taskdata_t * task_sink = KMP_TASK_TO_TASKDATA(sink_task);
|
||||
kmp_taskdata_t *task_source = KMP_TASK_TO_TASKDATA(source->dn.task);
|
||||
// do not use sink->dn.task as that is only filled after the dependencies
|
||||
// are already processed!
|
||||
kmp_taskdata_t *task_sink = KMP_TASK_TO_TASKDATA(sink_task);
|
||||
|
||||
__kmp_printf("%d(%s) -> %d(%s)\n", source->dn.id, task_source->td_ident->psource, sink->dn.id, task_sink->td_ident->psource);
|
||||
__kmp_printf("%d(%s) -> %d(%s)\n", source->dn.id,
|
||||
task_source->td_ident->psource, sink->dn.id,
|
||||
task_sink->td_ident->psource);
|
||||
#endif
|
||||
#if OMPT_SUPPORT && OMPT_TRACE
|
||||
/* OMPT tracks dependences between task (a=source, b=sink) in which
|
||||
task a blocks the execution of b through the ompt_new_dependence_callback */
|
||||
if (ompt_enabled &&
|
||||
ompt_callbacks.ompt_callback(ompt_event_task_dependence_pair))
|
||||
{
|
||||
kmp_taskdata_t * task_source = KMP_TASK_TO_TASKDATA(source->dn.task);
|
||||
kmp_taskdata_t * task_sink = KMP_TASK_TO_TASKDATA(sink_task);
|
||||
// OMPT tracks dependences between task (a=source, b=sink) in which
|
||||
// task a blocks the execution of b through the ompt_new_dependence_callback
|
||||
if (ompt_enabled &&
|
||||
ompt_callbacks.ompt_callback(ompt_event_task_dependence_pair)) {
|
||||
kmp_taskdata_t *task_source = KMP_TASK_TO_TASKDATA(source->dn.task);
|
||||
kmp_taskdata_t *task_sink = KMP_TASK_TO_TASKDATA(sink_task);
|
||||
|
||||
ompt_callbacks.ompt_callback(ompt_event_task_dependence_pair)(
|
||||
task_source->ompt_task_info.task_id,
|
||||
task_sink->ompt_task_info.task_id);
|
||||
}
|
||||
ompt_callbacks.ompt_callback(ompt_event_task_dependence_pair)(
|
||||
task_source->ompt_task_info.task_id, task_sink->ompt_task_info.task_id);
|
||||
}
|
||||
#endif /* OMPT_SUPPORT && OMPT_TRACE */
|
||||
}
|
||||
|
||||
template< bool filter >
|
||||
template <bool filter>
|
||||
static inline kmp_int32
|
||||
__kmp_process_deps ( kmp_int32 gtid, kmp_depnode_t *node, kmp_dephash_t *hash,
|
||||
bool dep_barrier,kmp_int32 ndeps, kmp_depend_info_t *dep_list,
|
||||
kmp_task_t *task )
|
||||
{
|
||||
KA_TRACE(30, ("__kmp_process_deps<%d>: T#%d processing %d dependencies : dep_barrier = %d\n", filter, gtid, ndeps, dep_barrier ) );
|
||||
__kmp_process_deps(kmp_int32 gtid, kmp_depnode_t *node, kmp_dephash_t *hash,
|
||||
bool dep_barrier, kmp_int32 ndeps,
|
||||
kmp_depend_info_t *dep_list, kmp_task_t *task) {
|
||||
KA_TRACE(30, ("__kmp_process_deps<%d>: T#%d processing %d dependencies : "
|
||||
"dep_barrier = %d\n",
|
||||
filter, gtid, ndeps, dep_barrier));
|
||||
|
||||
kmp_info_t *thread = __kmp_threads[ gtid ];
|
||||
kmp_int32 npredecessors=0;
|
||||
for ( kmp_int32 i = 0; i < ndeps ; i++ ) {
|
||||
const kmp_depend_info_t * dep = &dep_list[i];
|
||||
kmp_info_t *thread = __kmp_threads[gtid];
|
||||
kmp_int32 npredecessors = 0;
|
||||
for (kmp_int32 i = 0; i < ndeps; i++) {
|
||||
const kmp_depend_info_t *dep = &dep_list[i];
|
||||
|
||||
KMP_DEBUG_ASSERT(dep->flags.in);
|
||||
KMP_DEBUG_ASSERT(dep->flags.in);
|
||||
|
||||
if ( filter && dep->base_addr == 0 ) continue; // skip filtered entries
|
||||
if (filter && dep->base_addr == 0)
|
||||
continue; // skip filtered entries
|
||||
|
||||
kmp_dephash_entry_t *info = __kmp_dephash_find(thread,hash,dep->base_addr);
|
||||
kmp_depnode_t *last_out = info->last_out;
|
||||
kmp_dephash_entry_t *info =
|
||||
__kmp_dephash_find(thread, hash, dep->base_addr);
|
||||
kmp_depnode_t *last_out = info->last_out;
|
||||
|
||||
if ( dep->flags.out && info->last_ins ) {
|
||||
for ( kmp_depnode_list_t * p = info->last_ins; p; p = p->next ) {
|
||||
kmp_depnode_t * indep = p->node;
|
||||
if ( indep->dn.task ) {
|
||||
KMP_ACQUIRE_DEPNODE(gtid,indep);
|
||||
if ( indep->dn.task ) {
|
||||
__kmp_track_dependence(indep,node,task);
|
||||
indep->dn.successors = __kmp_add_node(thread, indep->dn.successors, node);
|
||||
KA_TRACE(40,("__kmp_process_deps<%d>: T#%d adding dependence from %p to %p\n",
|
||||
filter,gtid, KMP_TASK_TO_TASKDATA(indep->dn.task), KMP_TASK_TO_TASKDATA(task)));
|
||||
npredecessors++;
|
||||
}
|
||||
KMP_RELEASE_DEPNODE(gtid,indep);
|
||||
}
|
||||
}
|
||||
|
||||
__kmp_depnode_list_free(thread,info->last_ins);
|
||||
info->last_ins = NULL;
|
||||
|
||||
} else if ( last_out && last_out->dn.task ) {
|
||||
KMP_ACQUIRE_DEPNODE(gtid,last_out);
|
||||
if ( last_out->dn.task ) {
|
||||
__kmp_track_dependence(last_out,node,task);
|
||||
last_out->dn.successors = __kmp_add_node(thread, last_out->dn.successors, node);
|
||||
KA_TRACE(40,("__kmp_process_deps<%d>: T#%d adding dependence from %p to %p\n",
|
||||
filter,gtid, KMP_TASK_TO_TASKDATA(last_out->dn.task), KMP_TASK_TO_TASKDATA(task)));
|
||||
|
||||
npredecessors++;
|
||||
}
|
||||
KMP_RELEASE_DEPNODE(gtid,last_out);
|
||||
if (dep->flags.out && info->last_ins) {
|
||||
for (kmp_depnode_list_t *p = info->last_ins; p; p = p->next) {
|
||||
kmp_depnode_t *indep = p->node;
|
||||
if (indep->dn.task) {
|
||||
KMP_ACQUIRE_DEPNODE(gtid, indep);
|
||||
if (indep->dn.task) {
|
||||
__kmp_track_dependence(indep, node, task);
|
||||
indep->dn.successors =
|
||||
__kmp_add_node(thread, indep->dn.successors, node);
|
||||
KA_TRACE(40, ("__kmp_process_deps<%d>: T#%d adding dependence from "
|
||||
"%p to %p\n",
|
||||
filter, gtid, KMP_TASK_TO_TASKDATA(indep->dn.task),
|
||||
KMP_TASK_TO_TASKDATA(task)));
|
||||
npredecessors++;
|
||||
}
|
||||
KMP_RELEASE_DEPNODE(gtid, indep);
|
||||
}
|
||||
}
|
||||
|
||||
if ( dep_barrier ) {
|
||||
// if this is a sync point in the serial sequence, then the previous outputs are guaranteed to be completed after
|
||||
// the execution of this task so the previous output nodes can be cleared.
|
||||
__kmp_node_deref(thread,last_out);
|
||||
info->last_out = NULL;
|
||||
} else {
|
||||
if ( dep->flags.out ) {
|
||||
__kmp_node_deref(thread,last_out);
|
||||
info->last_out = __kmp_node_ref(node);
|
||||
} else
|
||||
info->last_ins = __kmp_add_node(thread, info->last_ins, node);
|
||||
}
|
||||
__kmp_depnode_list_free(thread, info->last_ins);
|
||||
info->last_ins = NULL;
|
||||
|
||||
} else if (last_out && last_out->dn.task) {
|
||||
KMP_ACQUIRE_DEPNODE(gtid, last_out);
|
||||
if (last_out->dn.task) {
|
||||
__kmp_track_dependence(last_out, node, task);
|
||||
last_out->dn.successors =
|
||||
__kmp_add_node(thread, last_out->dn.successors, node);
|
||||
KA_TRACE(
|
||||
40,
|
||||
("__kmp_process_deps<%d>: T#%d adding dependence from %p to %p\n",
|
||||
filter, gtid, KMP_TASK_TO_TASKDATA(last_out->dn.task),
|
||||
KMP_TASK_TO_TASKDATA(task)));
|
||||
|
||||
npredecessors++;
|
||||
}
|
||||
KMP_RELEASE_DEPNODE(gtid, last_out);
|
||||
}
|
||||
|
||||
KA_TRACE(30, ("__kmp_process_deps<%d>: T#%d found %d predecessors\n", filter, gtid, npredecessors ) );
|
||||
if (dep_barrier) {
|
||||
// if this is a sync point in the serial sequence, then the previous
|
||||
// outputs are guaranteed to be completed after
|
||||
// the execution of this task so the previous output nodes can be cleared.
|
||||
__kmp_node_deref(thread, last_out);
|
||||
info->last_out = NULL;
|
||||
} else {
|
||||
if (dep->flags.out) {
|
||||
__kmp_node_deref(thread, last_out);
|
||||
info->last_out = __kmp_node_ref(node);
|
||||
} else
|
||||
info->last_ins = __kmp_add_node(thread, info->last_ins, node);
|
||||
}
|
||||
}
|
||||
|
||||
return npredecessors;
|
||||
KA_TRACE(30, ("__kmp_process_deps<%d>: T#%d found %d predecessors\n", filter,
|
||||
gtid, npredecessors));
|
||||
|
||||
return npredecessors;
|
||||
}
|
||||
|
||||
#define NO_DEP_BARRIER (false)
|
||||
#define DEP_BARRIER (true)
|
||||
|
||||
// returns true if the task has any outstanding dependence
|
||||
static bool
|
||||
__kmp_check_deps ( kmp_int32 gtid, kmp_depnode_t *node, kmp_task_t *task, kmp_dephash_t *hash, bool dep_barrier,
|
||||
kmp_int32 ndeps, kmp_depend_info_t *dep_list,
|
||||
kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list )
|
||||
{
|
||||
int i;
|
||||
static bool __kmp_check_deps(kmp_int32 gtid, kmp_depnode_t *node,
|
||||
kmp_task_t *task, kmp_dephash_t *hash,
|
||||
bool dep_barrier, kmp_int32 ndeps,
|
||||
kmp_depend_info_t *dep_list,
|
||||
kmp_int32 ndeps_noalias,
|
||||
kmp_depend_info_t *noalias_dep_list) {
|
||||
int i;
|
||||
|
||||
#if KMP_DEBUG
|
||||
kmp_taskdata_t * taskdata = KMP_TASK_TO_TASKDATA(task);
|
||||
kmp_taskdata_t *taskdata = KMP_TASK_TO_TASKDATA(task);
|
||||
#endif
|
||||
KA_TRACE(20, ("__kmp_check_deps: T#%d checking dependencies for task %p : %d possibly aliased dependencies, %d non-aliased depedencies : dep_barrier=%d .\n", gtid, taskdata, ndeps, ndeps_noalias, dep_barrier ) );
|
||||
KA_TRACE(20, ("__kmp_check_deps: T#%d checking dependencies for task %p : %d "
|
||||
"possibly aliased dependencies, %d non-aliased depedencies : "
|
||||
"dep_barrier=%d .\n",
|
||||
gtid, taskdata, ndeps, ndeps_noalias, dep_barrier));
|
||||
|
||||
// Filter deps in dep_list
|
||||
// TODO: Different algorithm for large dep_list ( > 10 ? )
|
||||
for ( i = 0; i < ndeps; i ++ ) {
|
||||
if ( dep_list[i].base_addr != 0 )
|
||||
for ( int j = i+1; j < ndeps; j++ )
|
||||
if ( dep_list[i].base_addr == dep_list[j].base_addr ) {
|
||||
dep_list[i].flags.in |= dep_list[j].flags.in;
|
||||
dep_list[i].flags.out |= dep_list[j].flags.out;
|
||||
dep_list[j].base_addr = 0; // Mark j element as void
|
||||
}
|
||||
}
|
||||
// Filter deps in dep_list
|
||||
// TODO: Different algorithm for large dep_list ( > 10 ? )
|
||||
for (i = 0; i < ndeps; i++) {
|
||||
if (dep_list[i].base_addr != 0)
|
||||
for (int j = i + 1; j < ndeps; j++)
|
||||
if (dep_list[i].base_addr == dep_list[j].base_addr) {
|
||||
dep_list[i].flags.in |= dep_list[j].flags.in;
|
||||
dep_list[i].flags.out |= dep_list[j].flags.out;
|
||||
dep_list[j].base_addr = 0; // Mark j element as void
|
||||
}
|
||||
}
|
||||
|
||||
// doesn't need to be atomic as no other thread is going to be accessing this node just yet
|
||||
// npredecessors is set -1 to ensure that none of the releasing tasks queues this task before we have finished processing all the dependencies
|
||||
node->dn.npredecessors = -1;
|
||||
// doesn't need to be atomic as no other thread is going to be accessing this
|
||||
// node just yet.
|
||||
// npredecessors is set -1 to ensure that none of the releasing tasks queues
|
||||
// this task before we have finished processing all the dependencies
|
||||
node->dn.npredecessors = -1;
|
||||
|
||||
// used to pack all npredecessors additions into a single atomic operation at the end
|
||||
int npredecessors;
|
||||
// used to pack all npredecessors additions into a single atomic operation at
|
||||
// the end
|
||||
int npredecessors;
|
||||
|
||||
npredecessors = __kmp_process_deps<true>(gtid, node, hash, dep_barrier,
|
||||
ndeps, dep_list, task);
|
||||
npredecessors += __kmp_process_deps<false>(gtid, node, hash, dep_barrier,
|
||||
ndeps_noalias, noalias_dep_list, task);
|
||||
npredecessors = __kmp_process_deps<true>(gtid, node, hash, dep_barrier, ndeps,
|
||||
dep_list, task);
|
||||
npredecessors += __kmp_process_deps<false>(
|
||||
gtid, node, hash, dep_barrier, ndeps_noalias, noalias_dep_list, task);
|
||||
|
||||
node->dn.task = task;
|
||||
KMP_MB();
|
||||
node->dn.task = task;
|
||||
KMP_MB();
|
||||
|
||||
// Account for our initial fake value
|
||||
npredecessors++;
|
||||
// Account for our initial fake value
|
||||
npredecessors++;
|
||||
|
||||
// Update predecessors and obtain current value to check if there are still any outstandig dependences (some tasks may have finished while we processed the dependences)
|
||||
npredecessors = KMP_TEST_THEN_ADD32(&node->dn.npredecessors, npredecessors) + npredecessors;
|
||||
// Update predecessors and obtain current value to check if there are still
|
||||
// any outstandig dependences (some tasks may have finished while we processed
|
||||
// the dependences)
|
||||
npredecessors = KMP_TEST_THEN_ADD32(&node->dn.npredecessors, npredecessors) +
|
||||
npredecessors;
|
||||
|
||||
KA_TRACE(20, ("__kmp_check_deps: T#%d found %d predecessors for task %p \n", gtid, npredecessors, taskdata ) );
|
||||
KA_TRACE(20, ("__kmp_check_deps: T#%d found %d predecessors for task %p \n",
|
||||
gtid, npredecessors, taskdata));
|
||||
|
||||
// beyond this point the task could be queued (and executed) by a releasing task...
|
||||
return npredecessors > 0 ? true : false;
|
||||
// beyond this point the task could be queued (and executed) by a releasing
|
||||
// task...
|
||||
return npredecessors > 0 ? true : false;
|
||||
}
|
||||
|
||||
void
|
||||
__kmp_release_deps ( kmp_int32 gtid, kmp_taskdata_t *task )
|
||||
{
|
||||
kmp_info_t *thread = __kmp_threads[ gtid ];
|
||||
kmp_depnode_t *node = task->td_depnode;
|
||||
void __kmp_release_deps(kmp_int32 gtid, kmp_taskdata_t *task) {
|
||||
kmp_info_t *thread = __kmp_threads[gtid];
|
||||
kmp_depnode_t *node = task->td_depnode;
|
||||
|
||||
if ( task->td_dephash ) {
|
||||
KA_TRACE(40, ("__kmp_release_deps: T#%d freeing dependencies hash of task %p.\n", gtid, task ) );
|
||||
__kmp_dephash_free(thread,task->td_dephash);
|
||||
task->td_dephash = NULL;
|
||||
if (task->td_dephash) {
|
||||
KA_TRACE(
|
||||
40, ("__kmp_release_deps: T#%d freeing dependencies hash of task %p.\n",
|
||||
gtid, task));
|
||||
__kmp_dephash_free(thread, task->td_dephash);
|
||||
task->td_dephash = NULL;
|
||||
}
|
||||
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
KA_TRACE(20, ("__kmp_release_deps: T#%d notifying successors of task %p.\n",
|
||||
gtid, task));
|
||||
|
||||
KMP_ACQUIRE_DEPNODE(gtid, node);
|
||||
node->dn.task =
|
||||
NULL; // mark this task as finished, so no new dependencies are generated
|
||||
KMP_RELEASE_DEPNODE(gtid, node);
|
||||
|
||||
kmp_depnode_list_t *next;
|
||||
for (kmp_depnode_list_t *p = node->dn.successors; p; p = next) {
|
||||
kmp_depnode_t *successor = p->node;
|
||||
kmp_int32 npredecessors =
|
||||
KMP_TEST_THEN_DEC32(&successor->dn.npredecessors) - 1;
|
||||
|
||||
// successor task can be NULL for wait_depends or because deps are still
|
||||
// being processed
|
||||
if (npredecessors == 0) {
|
||||
KMP_MB();
|
||||
if (successor->dn.task) {
|
||||
KA_TRACE(20, ("__kmp_release_deps: T#%d successor %p of %p scheduled "
|
||||
"for execution.\n",
|
||||
gtid, successor->dn.task, task));
|
||||
__kmp_omp_task(gtid, successor->dn.task, false);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !node ) return;
|
||||
|
||||
KA_TRACE(20, ("__kmp_release_deps: T#%d notifying successors of task %p.\n", gtid, task ) );
|
||||
|
||||
KMP_ACQUIRE_DEPNODE(gtid,node);
|
||||
node->dn.task = NULL; // mark this task as finished, so no new dependencies are generated
|
||||
KMP_RELEASE_DEPNODE(gtid,node);
|
||||
|
||||
kmp_depnode_list_t *next;
|
||||
for ( kmp_depnode_list_t *p = node->dn.successors; p; p = next ) {
|
||||
kmp_depnode_t *successor = p->node;
|
||||
kmp_int32 npredecessors = KMP_TEST_THEN_DEC32(&successor->dn.npredecessors) - 1;
|
||||
|
||||
// successor task can be NULL for wait_depends or because deps are still being processed
|
||||
if ( npredecessors == 0 ) {
|
||||
KMP_MB();
|
||||
if ( successor->dn.task ) {
|
||||
KA_TRACE(20, ("__kmp_release_deps: T#%d successor %p of %p scheduled for execution.\n", gtid, successor->dn.task, task ) );
|
||||
__kmp_omp_task(gtid,successor->dn.task,false);
|
||||
}
|
||||
}
|
||||
|
||||
next = p->next;
|
||||
__kmp_node_deref(thread,p->node);
|
||||
next = p->next;
|
||||
__kmp_node_deref(thread, p->node);
|
||||
#if USE_FAST_MEMORY
|
||||
__kmp_fast_free(thread,p);
|
||||
__kmp_fast_free(thread, p);
|
||||
#else
|
||||
__kmp_thread_free(thread,p);
|
||||
__kmp_thread_free(thread, p);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__kmp_node_deref(thread,node);
|
||||
__kmp_node_deref(thread, node);
|
||||
|
||||
KA_TRACE(20, ("__kmp_release_deps: T#%d all successors of %p notified of completion\n", gtid, task ) );
|
||||
KA_TRACE(
|
||||
20,
|
||||
("__kmp_release_deps: T#%d all successors of %p notified of completion\n",
|
||||
gtid, task));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ingroup TASKING
|
||||
@param loc_ref location of the original task directive
|
||||
@param gtid Global Thread ID of encountering thread
|
||||
@param new_task task thunk allocated by __kmp_omp_task_alloc() for the ''new task''
|
||||
@param new_task task thunk allocated by __kmp_omp_task_alloc() for the ''new
|
||||
task''
|
||||
@param ndeps Number of depend items with possible aliasing
|
||||
@param dep_list List of depend items with possible aliasing
|
||||
@param ndeps_noalias Number of depend items with no aliasing
|
||||
@param noalias_dep_list List of depend items with no aliasing
|
||||
|
||||
@return Returns either TASK_CURRENT_NOT_QUEUED if the current task was not suspendend and queued, or TASK_CURRENT_QUEUED if it was suspended and queued
|
||||
@return Returns either TASK_CURRENT_NOT_QUEUED if the current task was not
|
||||
suspendend and queued, or TASK_CURRENT_QUEUED if it was suspended and queued
|
||||
|
||||
Schedule a non-thread-switchable task with dependences for execution
|
||||
*/
|
||||
kmp_int32
|
||||
__kmpc_omp_task_with_deps( ident_t *loc_ref, kmp_int32 gtid, kmp_task_t * new_task,
|
||||
kmp_int32 ndeps, kmp_depend_info_t *dep_list,
|
||||
kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list )
|
||||
{
|
||||
kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid,
|
||||
kmp_task_t *new_task, kmp_int32 ndeps,
|
||||
kmp_depend_info_t *dep_list,
|
||||
kmp_int32 ndeps_noalias,
|
||||
kmp_depend_info_t *noalias_dep_list) {
|
||||
|
||||
kmp_taskdata_t * new_taskdata = KMP_TASK_TO_TASKDATA(new_task);
|
||||
KA_TRACE(10, ("__kmpc_omp_task_with_deps(enter): T#%d loc=%p task=%p\n",
|
||||
gtid, loc_ref, new_taskdata ) );
|
||||
kmp_taskdata_t *new_taskdata = KMP_TASK_TO_TASKDATA(new_task);
|
||||
KA_TRACE(10, ("__kmpc_omp_task_with_deps(enter): T#%d loc=%p task=%p\n", gtid,
|
||||
loc_ref, new_taskdata));
|
||||
|
||||
kmp_info_t *thread = __kmp_threads[ gtid ];
|
||||
kmp_taskdata_t * current_task = thread->th.th_current_task;
|
||||
kmp_info_t *thread = __kmp_threads[gtid];
|
||||
kmp_taskdata_t *current_task = thread->th.th_current_task;
|
||||
|
||||
#if OMPT_SUPPORT && OMPT_TRACE
|
||||
/* OMPT grab all dependences if requested by the tool */
|
||||
if (ompt_enabled && ndeps+ndeps_noalias > 0 &&
|
||||
ompt_callbacks.ompt_callback(ompt_event_task_dependences))
|
||||
{
|
||||
kmp_int32 i;
|
||||
/* OMPT grab all dependences if requested by the tool */
|
||||
if (ompt_enabled && ndeps + ndeps_noalias > 0 &&
|
||||
ompt_callbacks.ompt_callback(ompt_event_task_dependences)) {
|
||||
kmp_int32 i;
|
||||
|
||||
new_taskdata->ompt_task_info.ndeps = ndeps+ndeps_noalias;
|
||||
new_taskdata->ompt_task_info.deps = (ompt_task_dependence_t *)
|
||||
KMP_OMPT_DEPS_ALLOC(thread,
|
||||
(ndeps+ndeps_noalias)*sizeof(ompt_task_dependence_t));
|
||||
new_taskdata->ompt_task_info.ndeps = ndeps + ndeps_noalias;
|
||||
new_taskdata->ompt_task_info.deps =
|
||||
(ompt_task_dependence_t *)KMP_OMPT_DEPS_ALLOC(
|
||||
thread, (ndeps + ndeps_noalias) * sizeof(ompt_task_dependence_t));
|
||||
|
||||
KMP_ASSERT(new_taskdata->ompt_task_info.deps != NULL);
|
||||
KMP_ASSERT(new_taskdata->ompt_task_info.deps != NULL);
|
||||
|
||||
for (i = 0; i < ndeps; i++)
|
||||
{
|
||||
new_taskdata->ompt_task_info.deps[i].variable_addr =
|
||||
(void*) dep_list[i].base_addr;
|
||||
if (dep_list[i].flags.in && dep_list[i].flags.out)
|
||||
new_taskdata->ompt_task_info.deps[i].dependence_flags =
|
||||
ompt_task_dependence_type_inout;
|
||||
else if (dep_list[i].flags.out)
|
||||
new_taskdata->ompt_task_info.deps[i].dependence_flags =
|
||||
ompt_task_dependence_type_out;
|
||||
else if (dep_list[i].flags.in)
|
||||
new_taskdata->ompt_task_info.deps[i].dependence_flags =
|
||||
ompt_task_dependence_type_in;
|
||||
}
|
||||
for (i = 0; i < ndeps_noalias; i++)
|
||||
{
|
||||
new_taskdata->ompt_task_info.deps[ndeps+i].variable_addr =
|
||||
(void*) noalias_dep_list[i].base_addr;
|
||||
if (noalias_dep_list[i].flags.in && noalias_dep_list[i].flags.out)
|
||||
new_taskdata->ompt_task_info.deps[ndeps+i].dependence_flags =
|
||||
ompt_task_dependence_type_inout;
|
||||
else if (noalias_dep_list[i].flags.out)
|
||||
new_taskdata->ompt_task_info.deps[ndeps+i].dependence_flags =
|
||||
ompt_task_dependence_type_out;
|
||||
else if (noalias_dep_list[i].flags.in)
|
||||
new_taskdata->ompt_task_info.deps[ndeps+i].dependence_flags =
|
||||
ompt_task_dependence_type_in;
|
||||
}
|
||||
for (i = 0; i < ndeps; i++) {
|
||||
new_taskdata->ompt_task_info.deps[i].variable_addr =
|
||||
(void *)dep_list[i].base_addr;
|
||||
if (dep_list[i].flags.in && dep_list[i].flags.out)
|
||||
new_taskdata->ompt_task_info.deps[i].dependence_flags =
|
||||
ompt_task_dependence_type_inout;
|
||||
else if (dep_list[i].flags.out)
|
||||
new_taskdata->ompt_task_info.deps[i].dependence_flags =
|
||||
ompt_task_dependence_type_out;
|
||||
else if (dep_list[i].flags.in)
|
||||
new_taskdata->ompt_task_info.deps[i].dependence_flags =
|
||||
ompt_task_dependence_type_in;
|
||||
}
|
||||
for (i = 0; i < ndeps_noalias; i++) {
|
||||
new_taskdata->ompt_task_info.deps[ndeps + i].variable_addr =
|
||||
(void *)noalias_dep_list[i].base_addr;
|
||||
if (noalias_dep_list[i].flags.in && noalias_dep_list[i].flags.out)
|
||||
new_taskdata->ompt_task_info.deps[ndeps + i].dependence_flags =
|
||||
ompt_task_dependence_type_inout;
|
||||
else if (noalias_dep_list[i].flags.out)
|
||||
new_taskdata->ompt_task_info.deps[ndeps + i].dependence_flags =
|
||||
ompt_task_dependence_type_out;
|
||||
else if (noalias_dep_list[i].flags.in)
|
||||
new_taskdata->ompt_task_info.deps[ndeps + i].dependence_flags =
|
||||
ompt_task_dependence_type_in;
|
||||
}
|
||||
}
|
||||
#endif /* OMPT_SUPPORT && OMPT_TRACE */
|
||||
|
||||
bool serial = current_task->td_flags.team_serial || current_task->td_flags.tasking_ser || current_task->td_flags.final;
|
||||
bool serial = current_task->td_flags.team_serial ||
|
||||
current_task->td_flags.tasking_ser ||
|
||||
current_task->td_flags.final;
|
||||
#if OMP_45_ENABLED
|
||||
kmp_task_team_t * task_team = thread->th.th_task_team;
|
||||
serial = serial && !(task_team && task_team->tt.tt_found_proxy_tasks);
|
||||
kmp_task_team_t *task_team = thread->th.th_task_team;
|
||||
serial = serial && !(task_team && task_team->tt.tt_found_proxy_tasks);
|
||||
#endif
|
||||
|
||||
if ( !serial && ( ndeps > 0 || ndeps_noalias > 0 )) {
|
||||
/* if no dependencies have been tracked yet, create the dependence hash */
|
||||
if ( current_task->td_dephash == NULL )
|
||||
current_task->td_dephash = __kmp_dephash_create(thread, current_task);
|
||||
if (!serial && (ndeps > 0 || ndeps_noalias > 0)) {
|
||||
/* if no dependencies have been tracked yet, create the dependence hash */
|
||||
if (current_task->td_dephash == NULL)
|
||||
current_task->td_dephash = __kmp_dephash_create(thread, current_task);
|
||||
|
||||
#if USE_FAST_MEMORY
|
||||
kmp_depnode_t *node = (kmp_depnode_t *) __kmp_fast_allocate(thread,sizeof(kmp_depnode_t));
|
||||
kmp_depnode_t *node =
|
||||
(kmp_depnode_t *)__kmp_fast_allocate(thread, sizeof(kmp_depnode_t));
|
||||
#else
|
||||
kmp_depnode_t *node = (kmp_depnode_t *) __kmp_thread_malloc(thread,sizeof(kmp_depnode_t));
|
||||
kmp_depnode_t *node =
|
||||
(kmp_depnode_t *)__kmp_thread_malloc(thread, sizeof(kmp_depnode_t));
|
||||
#endif
|
||||
|
||||
__kmp_init_node(node);
|
||||
new_taskdata->td_depnode = node;
|
||||
__kmp_init_node(node);
|
||||
new_taskdata->td_depnode = node;
|
||||
|
||||
if ( __kmp_check_deps( gtid, node, new_task, current_task->td_dephash, NO_DEP_BARRIER,
|
||||
ndeps, dep_list, ndeps_noalias,noalias_dep_list ) ) {
|
||||
KA_TRACE(10, ("__kmpc_omp_task_with_deps(exit): T#%d task had blocking dependencies: "
|
||||
"loc=%p task=%p, return: TASK_CURRENT_NOT_QUEUED\n", gtid, loc_ref,
|
||||
new_taskdata ) );
|
||||
return TASK_CURRENT_NOT_QUEUED;
|
||||
}
|
||||
} else {
|
||||
KA_TRACE(10, ("__kmpc_omp_task_with_deps(exit): T#%d ignored dependencies for task (serialized)"
|
||||
"loc=%p task=%p\n", gtid, loc_ref, new_taskdata ) );
|
||||
if (__kmp_check_deps(gtid, node, new_task, current_task->td_dephash,
|
||||
NO_DEP_BARRIER, ndeps, dep_list, ndeps_noalias,
|
||||
noalias_dep_list)) {
|
||||
KA_TRACE(10, ("__kmpc_omp_task_with_deps(exit): T#%d task had blocking "
|
||||
"dependencies: "
|
||||
"loc=%p task=%p, return: TASK_CURRENT_NOT_QUEUED\n",
|
||||
gtid, loc_ref, new_taskdata));
|
||||
return TASK_CURRENT_NOT_QUEUED;
|
||||
}
|
||||
} else {
|
||||
KA_TRACE(10, ("__kmpc_omp_task_with_deps(exit): T#%d ignored dependencies "
|
||||
"for task (serialized)"
|
||||
"loc=%p task=%p\n",
|
||||
gtid, loc_ref, new_taskdata));
|
||||
}
|
||||
|
||||
KA_TRACE(10, ("__kmpc_omp_task_with_deps(exit): T#%d task had no blocking dependencies : "
|
||||
"loc=%p task=%p, transferring to __kmpc_omp_task\n", gtid, loc_ref,
|
||||
new_taskdata ) );
|
||||
KA_TRACE(10, ("__kmpc_omp_task_with_deps(exit): T#%d task had no blocking "
|
||||
"dependencies : "
|
||||
"loc=%p task=%p, transferring to __kmpc_omp_task\n",
|
||||
gtid, loc_ref, new_taskdata));
|
||||
|
||||
return __kmpc_omp_task(loc_ref,gtid,new_task);
|
||||
return __kmpc_omp_task(loc_ref, gtid, new_task);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -539,55 +571,64 @@ __kmpc_omp_task_with_deps( ident_t *loc_ref, kmp_int32 gtid, kmp_task_t * new_ta
|
|||
|
||||
Blocks the current task until all specifies dependencies have been fulfilled.
|
||||
*/
|
||||
void
|
||||
__kmpc_omp_wait_deps ( ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps, kmp_depend_info_t *dep_list,
|
||||
kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list )
|
||||
{
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(enter): T#%d loc=%p\n", gtid, loc_ref) );
|
||||
void __kmpc_omp_wait_deps(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps,
|
||||
kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias,
|
||||
kmp_depend_info_t *noalias_dep_list) {
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(enter): T#%d loc=%p\n", gtid, loc_ref));
|
||||
|
||||
if ( ndeps == 0 && ndeps_noalias == 0 ) {
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no dependencies to wait upon : loc=%p\n", gtid, loc_ref) );
|
||||
return;
|
||||
}
|
||||
if (ndeps == 0 && ndeps_noalias == 0) {
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no dependencies to "
|
||||
"wait upon : loc=%p\n",
|
||||
gtid, loc_ref));
|
||||
return;
|
||||
}
|
||||
|
||||
kmp_info_t *thread = __kmp_threads[ gtid ];
|
||||
kmp_taskdata_t * current_task = thread->th.th_current_task;
|
||||
kmp_info_t *thread = __kmp_threads[gtid];
|
||||
kmp_taskdata_t *current_task = thread->th.th_current_task;
|
||||
|
||||
// We can return immediately as:
|
||||
// - dependences are not computed in serial teams (except if we have proxy tasks)
|
||||
// - if the dephash is not yet created it means we have nothing to wait for
|
||||
bool ignore = current_task->td_flags.team_serial || current_task->td_flags.tasking_ser || current_task->td_flags.final;
|
||||
// We can return immediately as:
|
||||
// - dependences are not computed in serial teams (except with proxy tasks)
|
||||
// - if the dephash is not yet created it means we have nothing to wait for
|
||||
bool ignore = current_task->td_flags.team_serial ||
|
||||
current_task->td_flags.tasking_ser ||
|
||||
current_task->td_flags.final;
|
||||
#if OMP_45_ENABLED
|
||||
ignore = ignore && thread->th.th_task_team != NULL && thread->th.th_task_team->tt.tt_found_proxy_tasks == FALSE;
|
||||
ignore = ignore && thread->th.th_task_team != NULL &&
|
||||
thread->th.th_task_team->tt.tt_found_proxy_tasks == FALSE;
|
||||
#endif
|
||||
ignore = ignore || current_task->td_dephash == NULL;
|
||||
ignore = ignore || current_task->td_dephash == NULL;
|
||||
|
||||
if ( ignore ) {
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking dependencies : loc=%p\n", gtid, loc_ref) );
|
||||
return;
|
||||
}
|
||||
if (ignore) {
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking "
|
||||
"dependencies : loc=%p\n",
|
||||
gtid, loc_ref));
|
||||
return;
|
||||
}
|
||||
|
||||
kmp_depnode_t node;
|
||||
__kmp_init_node(&node);
|
||||
kmp_depnode_t node;
|
||||
__kmp_init_node(&node);
|
||||
|
||||
if (!__kmp_check_deps( gtid, &node, NULL, current_task->td_dephash, DEP_BARRIER,
|
||||
ndeps, dep_list, ndeps_noalias, noalias_dep_list )) {
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking dependencies : loc=%p\n", gtid, loc_ref) );
|
||||
return;
|
||||
}
|
||||
if (!__kmp_check_deps(gtid, &node, NULL, current_task->td_dephash,
|
||||
DEP_BARRIER, ndeps, dep_list, ndeps_noalias,
|
||||
noalias_dep_list)) {
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking "
|
||||
"dependencies : loc=%p\n",
|
||||
gtid, loc_ref));
|
||||
return;
|
||||
}
|
||||
|
||||
int thread_finished = FALSE;
|
||||
kmp_flag_32 flag((volatile kmp_uint32 *)&(node.dn.npredecessors), 0U);
|
||||
while ( node.dn.npredecessors > 0 ) {
|
||||
flag.execute_tasks(thread, gtid, FALSE, &thread_finished,
|
||||
int thread_finished = FALSE;
|
||||
kmp_flag_32 flag((volatile kmp_uint32 *)&(node.dn.npredecessors), 0U);
|
||||
while (node.dn.npredecessors > 0) {
|
||||
flag.execute_tasks(thread, gtid, FALSE, &thread_finished,
|
||||
#if USE_ITT_BUILD
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
__kmp_task_stealing_constraint );
|
||||
}
|
||||
__kmp_task_stealing_constraint);
|
||||
}
|
||||
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d finished waiting : loc=%p\n", gtid, loc_ref) );
|
||||
KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d finished waiting : loc=%p\n",
|
||||
gtid, loc_ref));
|
||||
}
|
||||
|
||||
#endif /* OMP_40_ENABLED */
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -14,416 +14,396 @@
|
|||
|
||||
|
||||
#include "kmp.h"
|
||||
#include "kmp_wrapper_getpid.h"
|
||||
#include "kmp_str.h"
|
||||
#include <float.h>
|
||||
#include "kmp_i18n.h"
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
#include "kmp_str.h"
|
||||
#include "kmp_wrapper_getpid.h"
|
||||
#include <float.h>
|
||||
|
||||
static const char *unknown = "unknown";
|
||||
|
||||
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
|
||||
|
||||
/* NOTE: If called before serial_initialize (i.e. from runtime_initialize), then */
|
||||
/* the debugging package has not been initialized yet, and only "0" will print */
|
||||
/* debugging output since the environment variables have not been read. */
|
||||
/* NOTE: If called before serial_initialize (i.e. from runtime_initialize), then
|
||||
the debugging package has not been initialized yet, and only "0" will print
|
||||
debugging output since the environment variables have not been read. */
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
static int trace_level = 5;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* LOG_ID_BITS = ( 1 + floor( log_2( max( log_per_phy - 1, 1 ))))
|
||||
/* LOG_ID_BITS = ( 1 + floor( log_2( max( log_per_phy - 1, 1 ))))
|
||||
* APIC_ID = (PHY_ID << LOG_ID_BITS) | LOG_ID
|
||||
* PHY_ID = APIC_ID >> LOG_ID_BITS
|
||||
*/
|
||||
int
|
||||
__kmp_get_physical_id( int log_per_phy, int apic_id )
|
||||
{
|
||||
int index_lsb, index_msb, temp;
|
||||
int __kmp_get_physical_id(int log_per_phy, int apic_id) {
|
||||
int index_lsb, index_msb, temp;
|
||||
|
||||
if (log_per_phy > 1) {
|
||||
index_lsb = 0;
|
||||
index_msb = 31;
|
||||
if (log_per_phy > 1) {
|
||||
index_lsb = 0;
|
||||
index_msb = 31;
|
||||
|
||||
temp = log_per_phy;
|
||||
while ( (temp & 1) == 0 ) {
|
||||
temp >>= 1;
|
||||
index_lsb++;
|
||||
}
|
||||
temp = log_per_phy;
|
||||
while ((temp & 1) == 0) {
|
||||
temp >>= 1;
|
||||
index_lsb++;
|
||||
}
|
||||
|
||||
temp = log_per_phy;
|
||||
while ( (temp & 0x80000000)==0 ) {
|
||||
temp <<= 1;
|
||||
index_msb--;
|
||||
}
|
||||
temp = log_per_phy;
|
||||
while ((temp & 0x80000000) == 0) {
|
||||
temp <<= 1;
|
||||
index_msb--;
|
||||
}
|
||||
|
||||
/* If >1 bits were set in log_per_phy, choose next higher power of 2 */
|
||||
if (index_lsb != index_msb) index_msb++;
|
||||
/* If >1 bits were set in log_per_phy, choose next higher power of 2 */
|
||||
if (index_lsb != index_msb)
|
||||
index_msb++;
|
||||
|
||||
return ( (int) (apic_id >> index_msb) );
|
||||
}
|
||||
return ((int)(apic_id >> index_msb));
|
||||
}
|
||||
|
||||
return apic_id;
|
||||
return apic_id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* LOG_ID_BITS = ( 1 + floor( log_2( max( log_per_phy - 1, 1 ))))
|
||||
* APIC_ID = (PHY_ID << LOG_ID_BITS) | LOG_ID
|
||||
* LOG_ID = APIC_ID & (( 1 << LOG_ID_BITS ) - 1 )
|
||||
*/
|
||||
int
|
||||
__kmp_get_logical_id( int log_per_phy, int apic_id )
|
||||
{
|
||||
unsigned current_bit;
|
||||
int bits_seen;
|
||||
int __kmp_get_logical_id(int log_per_phy, int apic_id) {
|
||||
unsigned current_bit;
|
||||
int bits_seen;
|
||||
|
||||
if (log_per_phy <= 1) return ( 0 );
|
||||
if (log_per_phy <= 1)
|
||||
return (0);
|
||||
|
||||
bits_seen = 0;
|
||||
bits_seen = 0;
|
||||
|
||||
for (current_bit = 1; log_per_phy != 0; current_bit <<= 1) {
|
||||
if ( log_per_phy & current_bit ) {
|
||||
log_per_phy &= ~current_bit;
|
||||
bits_seen++;
|
||||
}
|
||||
}
|
||||
for (current_bit = 1; log_per_phy != 0; current_bit <<= 1) {
|
||||
if (log_per_phy & current_bit) {
|
||||
log_per_phy &= ~current_bit;
|
||||
bits_seen++;
|
||||
}
|
||||
}
|
||||
|
||||
/* If exactly 1 bit was set in log_per_phy, choose next lower power of 2 */
|
||||
if (bits_seen == 1) {
|
||||
current_bit >>= 1;
|
||||
}
|
||||
/* If exactly 1 bit was set in log_per_phy, choose next lower power of 2 */
|
||||
if (bits_seen == 1) {
|
||||
current_bit >>= 1;
|
||||
}
|
||||
|
||||
return ( (int) ((current_bit - 1) & apic_id) );
|
||||
return ((int)((current_bit - 1) & apic_id));
|
||||
}
|
||||
|
||||
static kmp_uint64 __kmp_parse_frequency( // R: Frequency in Hz.
|
||||
char const *frequency // I: Float number and unit: MHz, GHz, or TGz.
|
||||
) {
|
||||
|
||||
static
|
||||
kmp_uint64
|
||||
__kmp_parse_frequency( // R: Frequency in Hz.
|
||||
char const * frequency // I: Float number and unit: MHz, GHz, or TGz.
|
||||
) {
|
||||
double value = 0.0;
|
||||
char const *unit = NULL;
|
||||
kmp_uint64 result = 0; /* Zero is a better unknown value than all ones. */
|
||||
|
||||
double value = 0.0;
|
||||
char const * unit = NULL;
|
||||
kmp_uint64 result = 0; /* Zero is a better unknown value than all ones. */
|
||||
|
||||
if ( frequency == NULL ) {
|
||||
return result;
|
||||
}; // if
|
||||
value = strtod( frequency, (char * *) & unit ); // strtod() does not like "char const *".
|
||||
if ( 0 < value && value <= DBL_MAX ) { // Good value (not overflow, underflow, etc).
|
||||
if ( strcmp( unit, "MHz" ) == 0 ) {
|
||||
value = value * 1.0E+6;
|
||||
} else if ( strcmp( unit, "GHz" ) == 0 ) {
|
||||
value = value * 1.0E+9;
|
||||
} else if ( strcmp( unit, "THz" ) == 0 ) {
|
||||
value = value * 1.0E+12;
|
||||
} else { // Wrong unit.
|
||||
return result;
|
||||
}; // if
|
||||
result = value;
|
||||
}; // if
|
||||
if (frequency == NULL) {
|
||||
return result;
|
||||
}; // if
|
||||
value = strtod(frequency,
|
||||
(char **)&unit); // strtod() does not like "char const *".
|
||||
if (0 < value &&
|
||||
value <= DBL_MAX) { // Good value (not overflow, underflow, etc).
|
||||
if (strcmp(unit, "MHz") == 0) {
|
||||
value = value * 1.0E+6;
|
||||
} else if (strcmp(unit, "GHz") == 0) {
|
||||
value = value * 1.0E+9;
|
||||
} else if (strcmp(unit, "THz") == 0) {
|
||||
value = value * 1.0E+12;
|
||||
} else { // Wrong unit.
|
||||
return result;
|
||||
}; // if
|
||||
result = value;
|
||||
}; // if
|
||||
return result;
|
||||
|
||||
}; // func __kmp_parse_cpu_frequency
|
||||
|
||||
void
|
||||
__kmp_query_cpuid( kmp_cpuinfo_t *p )
|
||||
{
|
||||
struct kmp_cpuid buf;
|
||||
int max_arg;
|
||||
int log_per_phy;
|
||||
void __kmp_query_cpuid(kmp_cpuinfo_t *p) {
|
||||
struct kmp_cpuid buf;
|
||||
int max_arg;
|
||||
int log_per_phy;
|
||||
#ifdef KMP_DEBUG
|
||||
int cflush_size;
|
||||
int cflush_size;
|
||||
#endif
|
||||
|
||||
p->initialized = 1;
|
||||
p->initialized = 1;
|
||||
|
||||
p->sse2 = 1; // Assume SSE2 by default.
|
||||
p->sse2 = 1; // Assume SSE2 by default.
|
||||
|
||||
__kmp_x86_cpuid( 0, 0, &buf );
|
||||
__kmp_x86_cpuid(0, 0, &buf);
|
||||
|
||||
KA_TRACE( trace_level, ("INFO: CPUID %d: EAX=0x%08X EBX=0x%08X ECX=0x%08X EDX=0x%08X\n",
|
||||
0, buf.eax, buf.ebx, buf.ecx, buf.edx ) );
|
||||
KA_TRACE(trace_level,
|
||||
("INFO: CPUID %d: EAX=0x%08X EBX=0x%08X ECX=0x%08X EDX=0x%08X\n", 0,
|
||||
buf.eax, buf.ebx, buf.ecx, buf.edx));
|
||||
|
||||
max_arg = buf.eax;
|
||||
max_arg = buf.eax;
|
||||
|
||||
p->apic_id = -1;
|
||||
p->apic_id = -1;
|
||||
|
||||
if (max_arg >= 1) {
|
||||
int i;
|
||||
kmp_uint32 t, data[ 4 ];
|
||||
if (max_arg >= 1) {
|
||||
int i;
|
||||
kmp_uint32 t, data[4];
|
||||
|
||||
__kmp_x86_cpuid( 1, 0, &buf );
|
||||
KA_TRACE( trace_level, ("INFO: CPUID %d: EAX=0x%08X EBX=0x%08X ECX=0x%08X EDX=0x%08X\n",
|
||||
1, buf.eax, buf.ebx, buf.ecx, buf.edx ) );
|
||||
__kmp_x86_cpuid(1, 0, &buf);
|
||||
KA_TRACE(trace_level,
|
||||
("INFO: CPUID %d: EAX=0x%08X EBX=0x%08X ECX=0x%08X EDX=0x%08X\n",
|
||||
1, buf.eax, buf.ebx, buf.ecx, buf.edx));
|
||||
|
||||
{
|
||||
#define get_value(reg,lo,mask) ( ( ( reg ) >> ( lo ) ) & ( mask ) )
|
||||
{
|
||||
#define get_value(reg, lo, mask) (((reg) >> (lo)) & (mask))
|
||||
|
||||
p->signature = buf.eax;
|
||||
p->family = get_value( buf.eax, 20, 0xff ) + get_value( buf.eax, 8, 0x0f );
|
||||
p->model = ( get_value( buf.eax, 16, 0x0f ) << 4 ) + get_value( buf.eax, 4, 0x0f );
|
||||
p->stepping = get_value( buf.eax, 0, 0x0f );
|
||||
p->signature = buf.eax;
|
||||
p->family = get_value(buf.eax, 20, 0xff) + get_value(buf.eax, 8, 0x0f);
|
||||
p->model =
|
||||
(get_value(buf.eax, 16, 0x0f) << 4) + get_value(buf.eax, 4, 0x0f);
|
||||
p->stepping = get_value(buf.eax, 0, 0x0f);
|
||||
|
||||
#undef get_value
|
||||
|
||||
KA_TRACE( trace_level, (" family = %d, model = %d, stepping = %d\n", p->family, p->model, p->stepping ) );
|
||||
}
|
||||
KA_TRACE(trace_level, (" family = %d, model = %d, stepping = %d\n",
|
||||
p->family, p->model, p->stepping));
|
||||
}
|
||||
|
||||
for ( t = buf.ebx, i = 0; i < 4; t >>= 8, ++i ) {
|
||||
data[ i ] = (t & 0xff);
|
||||
}; // for
|
||||
for (t = buf.ebx, i = 0; i < 4; t >>= 8, ++i) {
|
||||
data[i] = (t & 0xff);
|
||||
}; // for
|
||||
|
||||
p->sse2 = ( buf.edx >> 26 ) & 1;
|
||||
p->sse2 = (buf.edx >> 26) & 1;
|
||||
|
||||
#ifdef KMP_DEBUG
|
||||
|
||||
if ( (buf.edx >> 4) & 1 ) {
|
||||
/* TSC - Timestamp Counter Available */
|
||||
KA_TRACE( trace_level, (" TSC" ) );
|
||||
}
|
||||
if ( (buf.edx >> 8) & 1 ) {
|
||||
/* CX8 - CMPXCHG8B Instruction Available */
|
||||
KA_TRACE( trace_level, (" CX8" ) );
|
||||
}
|
||||
if ( (buf.edx >> 9) & 1 ) {
|
||||
/* APIC - Local APIC Present (multi-processor operation support */
|
||||
KA_TRACE( trace_level, (" APIC" ) );
|
||||
}
|
||||
if ( (buf.edx >> 15) & 1 ) {
|
||||
/* CMOV - Conditional MOVe Instruction Available */
|
||||
KA_TRACE( trace_level, (" CMOV" ) );
|
||||
}
|
||||
if ( (buf.edx >> 18) & 1 ) {
|
||||
/* PSN - Processor Serial Number Available */
|
||||
KA_TRACE( trace_level, (" PSN" ) );
|
||||
}
|
||||
if ( (buf.edx >> 19) & 1 ) {
|
||||
/* CLFULSH - Cache Flush Instruction Available */
|
||||
cflush_size = data[ 1 ] * 8; /* Bits 15-08: CLFLUSH line size = 8 (64 bytes) */
|
||||
KA_TRACE( trace_level, (" CLFLUSH(%db)", cflush_size ) );
|
||||
|
||||
}
|
||||
if ( (buf.edx >> 21) & 1 ) {
|
||||
/* DTES - Debug Trace & EMON Store */
|
||||
KA_TRACE( trace_level, (" DTES" ) );
|
||||
}
|
||||
if ( (buf.edx >> 22) & 1 ) {
|
||||
/* ACPI - ACPI Support Available */
|
||||
KA_TRACE( trace_level, (" ACPI" ) );
|
||||
}
|
||||
if ( (buf.edx >> 23) & 1 ) {
|
||||
/* MMX - Multimedia Extensions */
|
||||
KA_TRACE( trace_level, (" MMX" ) );
|
||||
}
|
||||
if ( (buf.edx >> 25) & 1 ) {
|
||||
/* SSE - SSE Instructions */
|
||||
KA_TRACE( trace_level, (" SSE" ) );
|
||||
}
|
||||
if ( (buf.edx >> 26) & 1 ) {
|
||||
/* SSE2 - SSE2 Instructions */
|
||||
KA_TRACE( trace_level, (" SSE2" ) );
|
||||
}
|
||||
if ( (buf.edx >> 27) & 1 ) {
|
||||
/* SLFSNP - Self-Snooping Cache */
|
||||
KA_TRACE( trace_level, (" SLFSNP" ) );
|
||||
}
|
||||
if ((buf.edx >> 4) & 1) {
|
||||
/* TSC - Timestamp Counter Available */
|
||||
KA_TRACE(trace_level, (" TSC"));
|
||||
}
|
||||
if ((buf.edx >> 8) & 1) {
|
||||
/* CX8 - CMPXCHG8B Instruction Available */
|
||||
KA_TRACE(trace_level, (" CX8"));
|
||||
}
|
||||
if ((buf.edx >> 9) & 1) {
|
||||
/* APIC - Local APIC Present (multi-processor operation support */
|
||||
KA_TRACE(trace_level, (" APIC"));
|
||||
}
|
||||
if ((buf.edx >> 15) & 1) {
|
||||
/* CMOV - Conditional MOVe Instruction Available */
|
||||
KA_TRACE(trace_level, (" CMOV"));
|
||||
}
|
||||
if ((buf.edx >> 18) & 1) {
|
||||
/* PSN - Processor Serial Number Available */
|
||||
KA_TRACE(trace_level, (" PSN"));
|
||||
}
|
||||
if ((buf.edx >> 19) & 1) {
|
||||
/* CLFULSH - Cache Flush Instruction Available */
|
||||
cflush_size =
|
||||
data[1] * 8; /* Bits 15-08: CLFLUSH line size = 8 (64 bytes) */
|
||||
KA_TRACE(trace_level, (" CLFLUSH(%db)", cflush_size));
|
||||
}
|
||||
if ((buf.edx >> 21) & 1) {
|
||||
/* DTES - Debug Trace & EMON Store */
|
||||
KA_TRACE(trace_level, (" DTES"));
|
||||
}
|
||||
if ((buf.edx >> 22) & 1) {
|
||||
/* ACPI - ACPI Support Available */
|
||||
KA_TRACE(trace_level, (" ACPI"));
|
||||
}
|
||||
if ((buf.edx >> 23) & 1) {
|
||||
/* MMX - Multimedia Extensions */
|
||||
KA_TRACE(trace_level, (" MMX"));
|
||||
}
|
||||
if ((buf.edx >> 25) & 1) {
|
||||
/* SSE - SSE Instructions */
|
||||
KA_TRACE(trace_level, (" SSE"));
|
||||
}
|
||||
if ((buf.edx >> 26) & 1) {
|
||||
/* SSE2 - SSE2 Instructions */
|
||||
KA_TRACE(trace_level, (" SSE2"));
|
||||
}
|
||||
if ((buf.edx >> 27) & 1) {
|
||||
/* SLFSNP - Self-Snooping Cache */
|
||||
KA_TRACE(trace_level, (" SLFSNP"));
|
||||
}
|
||||
#endif /* KMP_DEBUG */
|
||||
|
||||
if ( (buf.edx >> 28) & 1 ) {
|
||||
/* Bits 23-16: Logical Processors per Physical Processor (1 for P4) */
|
||||
log_per_phy = data[ 2 ];
|
||||
p->apic_id = data[ 3 ]; /* Bits 31-24: Processor Initial APIC ID (X) */
|
||||
KA_TRACE( trace_level, (" HT(%d TPUs)", log_per_phy ) );
|
||||
if ((buf.edx >> 28) & 1) {
|
||||
/* Bits 23-16: Logical Processors per Physical Processor (1 for P4) */
|
||||
log_per_phy = data[2];
|
||||
p->apic_id = data[3]; /* Bits 31-24: Processor Initial APIC ID (X) */
|
||||
KA_TRACE(trace_level, (" HT(%d TPUs)", log_per_phy));
|
||||
|
||||
if( log_per_phy > 1 ) {
|
||||
/* default to 1k FOR JT-enabled processors (4k on OS X*) */
|
||||
if (log_per_phy > 1) {
|
||||
/* default to 1k FOR JT-enabled processors (4k on OS X*) */
|
||||
#if KMP_OS_DARWIN
|
||||
p->cpu_stackoffset = 4 * 1024;
|
||||
p->cpu_stackoffset = 4 * 1024;
|
||||
#else
|
||||
p->cpu_stackoffset = 1 * 1024;
|
||||
p->cpu_stackoffset = 1 * 1024;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
p->physical_id = __kmp_get_physical_id( log_per_phy, p->apic_id );
|
||||
p->logical_id = __kmp_get_logical_id( log_per_phy, p->apic_id );
|
||||
}
|
||||
p->physical_id = __kmp_get_physical_id(log_per_phy, p->apic_id);
|
||||
p->logical_id = __kmp_get_logical_id(log_per_phy, p->apic_id);
|
||||
}
|
||||
#ifdef KMP_DEBUG
|
||||
if ( (buf.edx >> 29) & 1 ) {
|
||||
/* ATHROTL - Automatic Throttle Control */
|
||||
KA_TRACE( trace_level, (" ATHROTL" ) );
|
||||
}
|
||||
KA_TRACE( trace_level, (" ]\n" ) );
|
||||
if ((buf.edx >> 29) & 1) {
|
||||
/* ATHROTL - Automatic Throttle Control */
|
||||
KA_TRACE(trace_level, (" ATHROTL"));
|
||||
}
|
||||
KA_TRACE(trace_level, (" ]\n"));
|
||||
|
||||
for (i = 2; i <= max_arg; ++i) {
|
||||
__kmp_x86_cpuid( i, 0, &buf );
|
||||
KA_TRACE( trace_level,
|
||||
( "INFO: CPUID %d: EAX=0x%08X EBX=0x%08X ECX=0x%08X EDX=0x%08X\n",
|
||||
i, buf.eax, buf.ebx, buf.ecx, buf.edx ) );
|
||||
}
|
||||
for (i = 2; i <= max_arg; ++i) {
|
||||
__kmp_x86_cpuid(i, 0, &buf);
|
||||
KA_TRACE(trace_level,
|
||||
("INFO: CPUID %d: EAX=0x%08X EBX=0x%08X ECX=0x%08X EDX=0x%08X\n",
|
||||
i, buf.eax, buf.ebx, buf.ecx, buf.edx));
|
||||
}
|
||||
#endif
|
||||
#if KMP_USE_ADAPTIVE_LOCKS
|
||||
p->rtm = 0;
|
||||
if (max_arg > 7)
|
||||
{
|
||||
/* RTM bit CPUID.07:EBX, bit 11 */
|
||||
__kmp_x86_cpuid(7, 0, &buf);
|
||||
p->rtm = (buf.ebx >> 11) & 1;
|
||||
KA_TRACE( trace_level, (" RTM" ) );
|
||||
}
|
||||
#endif
|
||||
}; // if
|
||||
|
||||
{ // Parse CPU brand string for frequency, saving the string for later.
|
||||
int i;
|
||||
kmp_cpuid_t * base = (kmp_cpuid_t *)&p->name[0];
|
||||
|
||||
// Get CPU brand string.
|
||||
for ( i = 0; i < 3; ++ i ) {
|
||||
__kmp_x86_cpuid( 0x80000002 + i, 0, base+i );
|
||||
}; // for
|
||||
p->name[ sizeof(p->name) - 1 ] = 0; // Just in case. ;-)
|
||||
KA_TRACE( trace_level, ( "cpu brand string: \"%s\"\n", &p->name[0] ) );
|
||||
|
||||
// Parse frequency.
|
||||
p->frequency = __kmp_parse_frequency( strrchr( &p->name[0], ' ' ) );
|
||||
KA_TRACE( trace_level, ( "cpu frequency from brand string: %" KMP_UINT64_SPEC "\n", p->frequency ) );
|
||||
p->rtm = 0;
|
||||
if (max_arg > 7) {
|
||||
/* RTM bit CPUID.07:EBX, bit 11 */
|
||||
__kmp_x86_cpuid(7, 0, &buf);
|
||||
p->rtm = (buf.ebx >> 11) & 1;
|
||||
KA_TRACE(trace_level, (" RTM"));
|
||||
}
|
||||
#endif
|
||||
}; // if
|
||||
|
||||
{ // Parse CPU brand string for frequency, saving the string for later.
|
||||
int i;
|
||||
kmp_cpuid_t *base = (kmp_cpuid_t *)&p->name[0];
|
||||
|
||||
// Get CPU brand string.
|
||||
for (i = 0; i < 3; ++i) {
|
||||
__kmp_x86_cpuid(0x80000002 + i, 0, base + i);
|
||||
}; // for
|
||||
p->name[sizeof(p->name) - 1] = 0; // Just in case. ;-)
|
||||
KA_TRACE(trace_level, ("cpu brand string: \"%s\"\n", &p->name[0]));
|
||||
|
||||
// Parse frequency.
|
||||
p->frequency = __kmp_parse_frequency(strrchr(&p->name[0], ' '));
|
||||
KA_TRACE(trace_level,
|
||||
("cpu frequency from brand string: %" KMP_UINT64_SPEC "\n",
|
||||
p->frequency));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
|
||||
|
||||
/* ------------------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------------------ */
|
||||
|
||||
void
|
||||
__kmp_expand_host_name( char *buffer, size_t size )
|
||||
{
|
||||
KMP_DEBUG_ASSERT(size >= sizeof(unknown));
|
||||
void __kmp_expand_host_name(char *buffer, size_t size) {
|
||||
KMP_DEBUG_ASSERT(size >= sizeof(unknown));
|
||||
#if KMP_OS_WINDOWS
|
||||
{
|
||||
DWORD s = size;
|
||||
{
|
||||
DWORD s = size;
|
||||
|
||||
if (! GetComputerNameA( buffer, & s ))
|
||||
KMP_STRCPY_S( buffer, size, unknown );
|
||||
}
|
||||
if (!GetComputerNameA(buffer, &s))
|
||||
KMP_STRCPY_S(buffer, size, unknown);
|
||||
}
|
||||
#else
|
||||
buffer[size - 2] = 0;
|
||||
if (gethostname( buffer, size ) || buffer[size - 2] != 0)
|
||||
KMP_STRCPY_S( buffer, size, unknown );
|
||||
buffer[size - 2] = 0;
|
||||
if (gethostname(buffer, size) || buffer[size - 2] != 0)
|
||||
KMP_STRCPY_S(buffer, size, unknown);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Expand the meta characters in the filename:
|
||||
*
|
||||
* Currently defined characters are:
|
||||
*
|
||||
* %H the hostname
|
||||
* %P the number of threads used.
|
||||
* %I the unique identifier for this run.
|
||||
*/
|
||||
|
||||
void
|
||||
__kmp_expand_file_name( char *result, size_t rlen, char *pattern )
|
||||
{
|
||||
char *pos = result, *end = result + rlen - 1;
|
||||
char buffer[256];
|
||||
int default_cpu_width = 1;
|
||||
int snp_result;
|
||||
void __kmp_expand_file_name(char *result, size_t rlen, char *pattern) {
|
||||
char *pos = result, *end = result + rlen - 1;
|
||||
char buffer[256];
|
||||
int default_cpu_width = 1;
|
||||
int snp_result;
|
||||
|
||||
KMP_DEBUG_ASSERT(rlen > 0);
|
||||
*end = 0;
|
||||
{
|
||||
int i;
|
||||
for(i = __kmp_xproc; i >= 10; i /= 10, ++default_cpu_width);
|
||||
KMP_DEBUG_ASSERT(rlen > 0);
|
||||
*end = 0;
|
||||
{
|
||||
int i;
|
||||
for (i = __kmp_xproc; i >= 10; i /= 10, ++default_cpu_width)
|
||||
;
|
||||
}
|
||||
|
||||
if (pattern != NULL) {
|
||||
while (*pattern != '\0' && pos < end) {
|
||||
if (*pattern != '%') {
|
||||
*pos++ = *pattern++;
|
||||
} else {
|
||||
char *old_pattern = pattern;
|
||||
int width = 1;
|
||||
int cpu_width = default_cpu_width;
|
||||
|
||||
++pattern;
|
||||
|
||||
if (*pattern >= '0' && *pattern <= '9') {
|
||||
width = 0;
|
||||
do {
|
||||
width = (width * 10) + *pattern++ - '0';
|
||||
} while (*pattern >= '0' && *pattern <= '9');
|
||||
if (width < 0 || width > 1024)
|
||||
width = 1;
|
||||
|
||||
cpu_width = width;
|
||||
}
|
||||
|
||||
switch (*pattern) {
|
||||
case 'H':
|
||||
case 'h': {
|
||||
__kmp_expand_host_name(buffer, sizeof(buffer));
|
||||
KMP_STRNCPY(pos, buffer, end - pos + 1);
|
||||
if (*end == 0) {
|
||||
while (*pos)
|
||||
++pos;
|
||||
++pattern;
|
||||
} else
|
||||
pos = end;
|
||||
} break;
|
||||
case 'P':
|
||||
case 'p': {
|
||||
snp_result = KMP_SNPRINTF(pos, end - pos + 1, "%0*d", cpu_width,
|
||||
__kmp_dflt_team_nth);
|
||||
if (snp_result >= 0 && snp_result <= end - pos) {
|
||||
while (*pos)
|
||||
++pos;
|
||||
++pattern;
|
||||
} else
|
||||
pos = end;
|
||||
} break;
|
||||
case 'I':
|
||||
case 'i': {
|
||||
pid_t id = getpid();
|
||||
snp_result = KMP_SNPRINTF(pos, end - pos + 1, "%0*d", width, id);
|
||||
if (snp_result >= 0 && snp_result <= end - pos) {
|
||||
while (*pos)
|
||||
++pos;
|
||||
++pattern;
|
||||
} else
|
||||
pos = end;
|
||||
break;
|
||||
}
|
||||
case '%': {
|
||||
*pos++ = '%';
|
||||
++pattern;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*pos++ = '%';
|
||||
pattern = old_pattern + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* TODO: How do we get rid of this? */
|
||||
if (*pattern != '\0')
|
||||
KMP_FATAL(FileNameTooLong);
|
||||
}
|
||||
|
||||
if (pattern != NULL) {
|
||||
while (*pattern != '\0' && pos < end) {
|
||||
if (*pattern != '%') {
|
||||
*pos++ = *pattern++;
|
||||
} else {
|
||||
char *old_pattern = pattern;
|
||||
int width = 1;
|
||||
int cpu_width = default_cpu_width;
|
||||
|
||||
++pattern;
|
||||
|
||||
if (*pattern >= '0' && *pattern <= '9') {
|
||||
width = 0;
|
||||
do {
|
||||
width = (width * 10) + *pattern++ - '0';
|
||||
} while (*pattern >= '0' && *pattern <= '9');
|
||||
if (width < 0 || width > 1024)
|
||||
width = 1;
|
||||
|
||||
cpu_width = width;
|
||||
}
|
||||
|
||||
switch (*pattern) {
|
||||
case 'H':
|
||||
case 'h':
|
||||
{
|
||||
__kmp_expand_host_name( buffer, sizeof( buffer ) );
|
||||
KMP_STRNCPY( pos, buffer, end - pos + 1);
|
||||
if(*end == 0) {
|
||||
while ( *pos )
|
||||
++pos;
|
||||
++pattern;
|
||||
} else
|
||||
pos = end;
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
case 'p':
|
||||
{
|
||||
snp_result = KMP_SNPRINTF( pos, end - pos + 1, "%0*d", cpu_width, __kmp_dflt_team_nth );
|
||||
if(snp_result >= 0 && snp_result <= end - pos) {
|
||||
while ( *pos )
|
||||
++pos;
|
||||
++pattern;
|
||||
} else
|
||||
pos = end;
|
||||
}
|
||||
break;
|
||||
case 'I':
|
||||
case 'i':
|
||||
{
|
||||
pid_t id = getpid();
|
||||
snp_result = KMP_SNPRINTF( pos, end - pos + 1, "%0*d", width, id );
|
||||
if(snp_result >= 0 && snp_result <= end - pos) {
|
||||
while ( *pos )
|
||||
++pos;
|
||||
++pattern;
|
||||
} else
|
||||
pos = end;
|
||||
break;
|
||||
}
|
||||
case '%':
|
||||
{
|
||||
*pos++ = '%';
|
||||
++pattern;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
*pos++ = '%';
|
||||
pattern = old_pattern + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* TODO: How do we get rid of this? */
|
||||
if(*pattern != '\0')
|
||||
KMP_FATAL( FileNameTooLong );
|
||||
}
|
||||
|
||||
*pos = '\0';
|
||||
*pos = '\0';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,199 +18,191 @@
|
|||
#include "kmp_version.h"
|
||||
|
||||
// Replace with snapshot date YYYYMMDD for promotion build.
|
||||
#define KMP_VERSION_BUILD 20140926
|
||||
#define KMP_VERSION_BUILD 20140926
|
||||
|
||||
// Helper macros to convert value of macro to string literal.
|
||||
#define _stringer( x ) #x
|
||||
#define stringer( x ) _stringer( x )
|
||||
#define _stringer(x) #x
|
||||
#define stringer(x) _stringer(x)
|
||||
|
||||
// Detect compiler.
|
||||
#if KMP_COMPILER_ICC
|
||||
#if __INTEL_COMPILER == 1010
|
||||
#define KMP_COMPILER "Intel C++ Compiler 10.1"
|
||||
#elif __INTEL_COMPILER == 1100
|
||||
#define KMP_COMPILER "Intel C++ Compiler 11.0"
|
||||
#elif __INTEL_COMPILER == 1110
|
||||
#define KMP_COMPILER "Intel C++ Compiler 11.1"
|
||||
#elif __INTEL_COMPILER == 1200
|
||||
#define KMP_COMPILER "Intel C++ Compiler 12.0"
|
||||
#elif __INTEL_COMPILER == 1210
|
||||
#define KMP_COMPILER "Intel C++ Compiler 12.1"
|
||||
#elif __INTEL_COMPILER == 1300
|
||||
#define KMP_COMPILER "Intel C++ Compiler 13.0"
|
||||
#elif __INTEL_COMPILER == 1310
|
||||
#define KMP_COMPILER "Intel C++ Compiler 13.1"
|
||||
#elif __INTEL_COMPILER == 1400
|
||||
#define KMP_COMPILER "Intel C++ Compiler 14.0"
|
||||
#elif __INTEL_COMPILER == 1410
|
||||
#define KMP_COMPILER "Intel C++ Compiler 14.1"
|
||||
#elif __INTEL_COMPILER == 1500
|
||||
#define KMP_COMPILER "Intel C++ Compiler 15.0"
|
||||
#elif __INTEL_COMPILER == 1600
|
||||
#define KMP_COMPILER "Intel C++ Compiler 16.0"
|
||||
#elif __INTEL_COMPILER == 1700
|
||||
#define KMP_COMPILER "Intel C++ Compiler 17.0"
|
||||
#elif __INTEL_COMPILER == 9998
|
||||
#define KMP_COMPILER "Intel C++ Compiler mainline"
|
||||
#elif __INTEL_COMPILER == 9999
|
||||
#define KMP_COMPILER "Intel C++ Compiler mainline"
|
||||
#endif
|
||||
#if __INTEL_COMPILER == 1010
|
||||
#define KMP_COMPILER "Intel C++ Compiler 10.1"
|
||||
#elif __INTEL_COMPILER == 1100
|
||||
#define KMP_COMPILER "Intel C++ Compiler 11.0"
|
||||
#elif __INTEL_COMPILER == 1110
|
||||
#define KMP_COMPILER "Intel C++ Compiler 11.1"
|
||||
#elif __INTEL_COMPILER == 1200
|
||||
#define KMP_COMPILER "Intel C++ Compiler 12.0"
|
||||
#elif __INTEL_COMPILER == 1210
|
||||
#define KMP_COMPILER "Intel C++ Compiler 12.1"
|
||||
#elif __INTEL_COMPILER == 1300
|
||||
#define KMP_COMPILER "Intel C++ Compiler 13.0"
|
||||
#elif __INTEL_COMPILER == 1310
|
||||
#define KMP_COMPILER "Intel C++ Compiler 13.1"
|
||||
#elif __INTEL_COMPILER == 1400
|
||||
#define KMP_COMPILER "Intel C++ Compiler 14.0"
|
||||
#elif __INTEL_COMPILER == 1410
|
||||
#define KMP_COMPILER "Intel C++ Compiler 14.1"
|
||||
#elif __INTEL_COMPILER == 1500
|
||||
#define KMP_COMPILER "Intel C++ Compiler 15.0"
|
||||
#elif __INTEL_COMPILER == 1600
|
||||
#define KMP_COMPILER "Intel C++ Compiler 16.0"
|
||||
#elif __INTEL_COMPILER == 1700
|
||||
#define KMP_COMPILER "Intel C++ Compiler 17.0"
|
||||
#elif __INTEL_COMPILER == 9998
|
||||
#define KMP_COMPILER "Intel C++ Compiler mainline"
|
||||
#elif __INTEL_COMPILER == 9999
|
||||
#define KMP_COMPILER "Intel C++ Compiler mainline"
|
||||
#endif
|
||||
#elif KMP_COMPILER_CLANG
|
||||
#define KMP_COMPILER "Clang " stringer( __clang_major__ ) "." stringer( __clang_minor__ )
|
||||
#define KMP_COMPILER \
|
||||
"Clang " stringer(__clang_major__) "." stringer(__clang_minor__)
|
||||
#elif KMP_COMPILER_GCC
|
||||
#define KMP_COMPILER "GCC " stringer( __GNUC__ ) "." stringer( __GNUC_MINOR__ )
|
||||
#define KMP_COMPILER "GCC " stringer(__GNUC__) "." stringer(__GNUC_MINOR__)
|
||||
#elif KMP_COMPILER_MSVC
|
||||
#define KMP_COMPILER "MSVC " stringer( _MSC_FULL_VER )
|
||||
#define KMP_COMPILER "MSVC " stringer(_MSC_FULL_VER)
|
||||
#endif
|
||||
#ifndef KMP_COMPILER
|
||||
#warning "Unknown compiler"
|
||||
#define KMP_COMPILER "unknown compiler"
|
||||
#warning "Unknown compiler"
|
||||
#define KMP_COMPILER "unknown compiler"
|
||||
#endif
|
||||
|
||||
// Detect librray type (perf, stub).
|
||||
#ifdef KMP_STUB
|
||||
#define KMP_LIB_TYPE "stub"
|
||||
#define KMP_LIB_TYPE "stub"
|
||||
#else
|
||||
#define KMP_LIB_TYPE "performance"
|
||||
#define KMP_LIB_TYPE "performance"
|
||||
#endif // KMP_LIB_TYPE
|
||||
|
||||
// Detect link type (static, dynamic).
|
||||
#ifdef KMP_DYNAMIC_LIB
|
||||
#define KMP_LINK_TYPE "dynamic"
|
||||
#define KMP_LINK_TYPE "dynamic"
|
||||
#else
|
||||
#define KMP_LINK_TYPE "static"
|
||||
#define KMP_LINK_TYPE "static"
|
||||
#endif // KMP_LINK_TYPE
|
||||
|
||||
// Finally, define strings.
|
||||
#define KMP_LIBRARY KMP_LIB_TYPE " library (" KMP_LINK_TYPE ")"
|
||||
#define KMP_LIBRARY KMP_LIB_TYPE " library (" KMP_LINK_TYPE ")"
|
||||
#define KMP_COPYRIGHT ""
|
||||
|
||||
int const __kmp_version_major = KMP_VERSION_MAJOR;
|
||||
int const __kmp_version_minor = KMP_VERSION_MINOR;
|
||||
int const __kmp_version_build = KMP_VERSION_BUILD;
|
||||
int const __kmp_openmp_version =
|
||||
#if OMP_50_ENABLED
|
||||
201611;
|
||||
#elif OMP_45_ENABLED
|
||||
201511;
|
||||
#elif OMP_40_ENABLED
|
||||
201307;
|
||||
#else
|
||||
201107;
|
||||
#endif
|
||||
|
||||
/* Do NOT change the format of this string! Intel(R) Thread Profiler checks for a
|
||||
specific format some changes in the recognition routine there need to
|
||||
be made before this is changed.
|
||||
*/
|
||||
char const __kmp_copyright[] =
|
||||
KMP_VERSION_PREFIX KMP_LIBRARY
|
||||
" ver. " stringer( KMP_VERSION_MAJOR ) "." stringer( KMP_VERSION_MINOR )
|
||||
"." stringer( KMP_VERSION_BUILD ) " "
|
||||
KMP_COPYRIGHT;
|
||||
|
||||
char const __kmp_version_copyright[] = KMP_VERSION_PREFIX KMP_COPYRIGHT;
|
||||
char const __kmp_version_lib_ver[] = KMP_VERSION_PREFIX "version: " stringer( KMP_VERSION_MAJOR ) "." stringer( KMP_VERSION_MINOR ) "." stringer( KMP_VERSION_BUILD );
|
||||
char const __kmp_version_lib_type[] = KMP_VERSION_PREFIX "library type: " KMP_LIB_TYPE;
|
||||
char const __kmp_version_link_type[] = KMP_VERSION_PREFIX "link type: " KMP_LINK_TYPE;
|
||||
char const __kmp_version_build_time[] = KMP_VERSION_PREFIX "build time: " "no_timestamp";
|
||||
#if KMP_MIC2
|
||||
char const __kmp_version_target_env[] = KMP_VERSION_PREFIX "target environment: MIC2";
|
||||
#if OMP_50_ENABLED
|
||||
201611;
|
||||
#elif OMP_45_ENABLED
|
||||
201511;
|
||||
#elif OMP_40_ENABLED
|
||||
201307;
|
||||
#else
|
||||
201107;
|
||||
#endif
|
||||
char const __kmp_version_build_compiler[] = KMP_VERSION_PREFIX "build compiler: " KMP_COMPILER;
|
||||
|
||||
//
|
||||
/* Do NOT change the format of this string! Intel(R) Thread Profiler checks for
|
||||
a specific format some changes in the recognition routine there need to be
|
||||
made before this is changed. */
|
||||
char const __kmp_copyright[] = KMP_VERSION_PREFIX KMP_LIBRARY
|
||||
" ver. " stringer(KMP_VERSION_MAJOR) "." stringer(
|
||||
KMP_VERSION_MINOR) "." stringer(KMP_VERSION_BUILD) " " KMP_COPYRIGHT;
|
||||
|
||||
char const __kmp_version_copyright[] = KMP_VERSION_PREFIX KMP_COPYRIGHT;
|
||||
char const __kmp_version_lib_ver[] =
|
||||
KMP_VERSION_PREFIX "version: " stringer(KMP_VERSION_MAJOR) "." stringer(
|
||||
KMP_VERSION_MINOR) "." stringer(KMP_VERSION_BUILD);
|
||||
char const __kmp_version_lib_type[] =
|
||||
KMP_VERSION_PREFIX "library type: " KMP_LIB_TYPE;
|
||||
char const __kmp_version_link_type[] =
|
||||
KMP_VERSION_PREFIX "link type: " KMP_LINK_TYPE;
|
||||
char const __kmp_version_build_time[] = KMP_VERSION_PREFIX "build time: "
|
||||
"no_timestamp";
|
||||
#if KMP_MIC2
|
||||
char const __kmp_version_target_env[] =
|
||||
KMP_VERSION_PREFIX "target environment: MIC2";
|
||||
#endif
|
||||
char const __kmp_version_build_compiler[] =
|
||||
KMP_VERSION_PREFIX "build compiler: " KMP_COMPILER;
|
||||
|
||||
// Called at serial initialization time.
|
||||
//
|
||||
static int __kmp_version_1_printed = FALSE;
|
||||
|
||||
void
|
||||
__kmp_print_version_1( void )
|
||||
{
|
||||
if ( __kmp_version_1_printed ) {
|
||||
return;
|
||||
}; // if
|
||||
__kmp_version_1_printed = TRUE;
|
||||
void __kmp_print_version_1(void) {
|
||||
if (__kmp_version_1_printed) {
|
||||
return;
|
||||
}; // if
|
||||
__kmp_version_1_printed = TRUE;
|
||||
|
||||
#ifndef KMP_STUB
|
||||
kmp_str_buf_t buffer;
|
||||
__kmp_str_buf_init( & buffer );
|
||||
// Print version strings skipping initial magic.
|
||||
__kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_lib_ver[ KMP_VERSION_MAGIC_LEN ] );
|
||||
__kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_lib_type[ KMP_VERSION_MAGIC_LEN ] );
|
||||
__kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_link_type[ KMP_VERSION_MAGIC_LEN ] );
|
||||
__kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_build_time[ KMP_VERSION_MAGIC_LEN ] );
|
||||
#if KMP_MIC
|
||||
__kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_target_env[ KMP_VERSION_MAGIC_LEN ] );
|
||||
#endif
|
||||
__kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_build_compiler[ KMP_VERSION_MAGIC_LEN ] );
|
||||
#if defined(KMP_GOMP_COMPAT)
|
||||
__kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_alt_comp[ KMP_VERSION_MAGIC_LEN ] );
|
||||
#endif /* defined(KMP_GOMP_COMPAT) */
|
||||
__kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_omp_api[ KMP_VERSION_MAGIC_LEN ] );
|
||||
__kmp_str_buf_print( & buffer, "%sdynamic error checking: %s\n", KMP_VERSION_PREF_STR, ( __kmp_env_consistency_check ? "yes" : "no" ) );
|
||||
#ifdef KMP_DEBUG
|
||||
for ( int i = bs_plain_barrier; i < bs_last_barrier; ++ i ) {
|
||||
__kmp_str_buf_print(
|
||||
& buffer,
|
||||
"%s%s barrier branch bits: gather=%u, release=%u\n",
|
||||
KMP_VERSION_PREF_STR,
|
||||
__kmp_barrier_type_name[ i ],
|
||||
__kmp_barrier_gather_branch_bits[ i ],
|
||||
__kmp_barrier_release_branch_bits[ i ]
|
||||
); // __kmp_str_buf_print
|
||||
}; // for i
|
||||
for ( int i = bs_plain_barrier; i < bs_last_barrier; ++ i ) {
|
||||
__kmp_str_buf_print(
|
||||
& buffer,
|
||||
"%s%s barrier pattern: gather=%s, release=%s\n",
|
||||
KMP_VERSION_PREF_STR,
|
||||
__kmp_barrier_type_name[ i ],
|
||||
__kmp_barrier_pattern_name[ __kmp_barrier_gather_pattern[ i ] ],
|
||||
__kmp_barrier_pattern_name[ __kmp_barrier_release_pattern[ i ] ]
|
||||
); // __kmp_str_buf_print
|
||||
}; // for i
|
||||
__kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_lock[ KMP_VERSION_MAGIC_LEN ] );
|
||||
#endif
|
||||
__kmp_str_buf_print(
|
||||
& buffer,
|
||||
"%sthread affinity support: %s\n",
|
||||
KMP_VERSION_PREF_STR,
|
||||
#if KMP_AFFINITY_SUPPORTED
|
||||
(
|
||||
KMP_AFFINITY_CAPABLE()
|
||||
?
|
||||
(
|
||||
__kmp_affinity_type == affinity_none
|
||||
?
|
||||
"not used"
|
||||
:
|
||||
"yes"
|
||||
)
|
||||
:
|
||||
"no"
|
||||
)
|
||||
#else
|
||||
"no"
|
||||
#endif
|
||||
);
|
||||
__kmp_printf( "%s", buffer.str );
|
||||
__kmp_str_buf_free( & buffer );
|
||||
K_DIAG( 1, ( "KMP_VERSION is true\n" ) );
|
||||
#endif // KMP_STUB
|
||||
#ifndef KMP_STUB
|
||||
kmp_str_buf_t buffer;
|
||||
__kmp_str_buf_init(&buffer);
|
||||
// Print version strings skipping initial magic.
|
||||
__kmp_str_buf_print(&buffer, "%s\n",
|
||||
&__kmp_version_lib_ver[KMP_VERSION_MAGIC_LEN]);
|
||||
__kmp_str_buf_print(&buffer, "%s\n",
|
||||
&__kmp_version_lib_type[KMP_VERSION_MAGIC_LEN]);
|
||||
__kmp_str_buf_print(&buffer, "%s\n",
|
||||
&__kmp_version_link_type[KMP_VERSION_MAGIC_LEN]);
|
||||
__kmp_str_buf_print(&buffer, "%s\n",
|
||||
&__kmp_version_build_time[KMP_VERSION_MAGIC_LEN]);
|
||||
#if KMP_MIC
|
||||
__kmp_str_buf_print(&buffer, "%s\n",
|
||||
&__kmp_version_target_env[KMP_VERSION_MAGIC_LEN]);
|
||||
#endif
|
||||
__kmp_str_buf_print(&buffer, "%s\n",
|
||||
&__kmp_version_build_compiler[KMP_VERSION_MAGIC_LEN]);
|
||||
#if defined(KMP_GOMP_COMPAT)
|
||||
__kmp_str_buf_print(&buffer, "%s\n",
|
||||
&__kmp_version_alt_comp[KMP_VERSION_MAGIC_LEN]);
|
||||
#endif /* defined(KMP_GOMP_COMPAT) */
|
||||
__kmp_str_buf_print(&buffer, "%s\n",
|
||||
&__kmp_version_omp_api[KMP_VERSION_MAGIC_LEN]);
|
||||
__kmp_str_buf_print(&buffer, "%sdynamic error checking: %s\n",
|
||||
KMP_VERSION_PREF_STR,
|
||||
(__kmp_env_consistency_check ? "yes" : "no"));
|
||||
#ifdef KMP_DEBUG
|
||||
for (int i = bs_plain_barrier; i < bs_last_barrier; ++i) {
|
||||
__kmp_str_buf_print(
|
||||
&buffer, "%s%s barrier branch bits: gather=%u, release=%u\n",
|
||||
KMP_VERSION_PREF_STR, __kmp_barrier_type_name[i],
|
||||
__kmp_barrier_gather_branch_bits[i],
|
||||
__kmp_barrier_release_branch_bits[i]); // __kmp_str_buf_print
|
||||
}; // for i
|
||||
for (int i = bs_plain_barrier; i < bs_last_barrier; ++i) {
|
||||
__kmp_str_buf_print(
|
||||
&buffer, "%s%s barrier pattern: gather=%s, release=%s\n",
|
||||
KMP_VERSION_PREF_STR, __kmp_barrier_type_name[i],
|
||||
__kmp_barrier_pattern_name[__kmp_barrier_gather_pattern[i]],
|
||||
__kmp_barrier_pattern_name
|
||||
[__kmp_barrier_release_pattern[i]]); // __kmp_str_buf_print
|
||||
}; // for i
|
||||
__kmp_str_buf_print(&buffer, "%s\n",
|
||||
&__kmp_version_lock[KMP_VERSION_MAGIC_LEN]);
|
||||
#endif
|
||||
__kmp_str_buf_print(
|
||||
&buffer, "%sthread affinity support: %s\n", KMP_VERSION_PREF_STR,
|
||||
#if KMP_AFFINITY_SUPPORTED
|
||||
(KMP_AFFINITY_CAPABLE()
|
||||
? (__kmp_affinity_type == affinity_none ? "not used" : "yes")
|
||||
: "no")
|
||||
#else
|
||||
"no"
|
||||
#endif
|
||||
);
|
||||
__kmp_printf("%s", buffer.str);
|
||||
__kmp_str_buf_free(&buffer);
|
||||
K_DIAG(1, ("KMP_VERSION is true\n"));
|
||||
#endif // KMP_STUB
|
||||
} // __kmp_print_version_1
|
||||
|
||||
//
|
||||
// Called at parallel initialization time.
|
||||
//
|
||||
static int __kmp_version_2_printed = FALSE;
|
||||
|
||||
void
|
||||
__kmp_print_version_2( void ) {
|
||||
if ( __kmp_version_2_printed ) {
|
||||
return;
|
||||
}; // if
|
||||
__kmp_version_2_printed = TRUE;
|
||||
void __kmp_print_version_2(void) {
|
||||
if (__kmp_version_2_printed) {
|
||||
return;
|
||||
}; // if
|
||||
__kmp_version_2_printed = TRUE;
|
||||
} // __kmp_print_version_2
|
||||
|
||||
// end of file //
|
||||
|
|
|
|||
|
|
@ -17,31 +17,32 @@
|
|||
#define KMP_VERSION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifndef KMP_VERSION_MAJOR
|
||||
#error KMP_VERSION_MAJOR macro is not defined.
|
||||
#error KMP_VERSION_MAJOR macro is not defined.
|
||||
#endif
|
||||
#define KMP_VERSION_MINOR 0
|
||||
/*
|
||||
Using "magic" prefix in all the version strings is rather convenient to get static version info
|
||||
from binaries by using standard utilities "strings" and "grep", e. g.:
|
||||
#define KMP_VERSION_MINOR 0
|
||||
/* Using "magic" prefix in all the version strings is rather convenient to get
|
||||
static version info from binaries by using standard utilities "strings" and
|
||||
"grep", e. g.:
|
||||
$ strings libomp.so | grep "@(#)"
|
||||
gives clean list of all version strings in the library. Leading zero helps to keep version
|
||||
string separate from printable characters which may occurs just before version string.
|
||||
*/
|
||||
#define KMP_VERSION_MAGIC_STR "\x00@(#) "
|
||||
#define KMP_VERSION_MAGIC_LEN 6 // Length of KMP_VERSION_MAGIC_STR.
|
||||
#define KMP_VERSION_PREF_STR "Intel(R) OMP "
|
||||
#define KMP_VERSION_PREFIX KMP_VERSION_MAGIC_STR KMP_VERSION_PREF_STR
|
||||
gives clean list of all version strings in the library. Leading zero helps
|
||||
to keep version string separate from printable characters which may occurs
|
||||
just before version string. */
|
||||
#define KMP_VERSION_MAGIC_STR "\x00@(#) "
|
||||
#define KMP_VERSION_MAGIC_LEN 6 // Length of KMP_VERSION_MAGIC_STR.
|
||||
#define KMP_VERSION_PREF_STR "Intel(R) OMP "
|
||||
#define KMP_VERSION_PREFIX KMP_VERSION_MAGIC_STR KMP_VERSION_PREF_STR
|
||||
|
||||
/* declare all the version string constants for KMP_VERSION env. variable */
|
||||
extern int const __kmp_version_major;
|
||||
extern int const __kmp_version_minor;
|
||||
extern int const __kmp_version_build;
|
||||
extern int const __kmp_openmp_version;
|
||||
extern char const __kmp_copyright[]; // Old variable, kept for compatibility with ITC and ITP.
|
||||
extern int const __kmp_version_major;
|
||||
extern int const __kmp_version_minor;
|
||||
extern int const __kmp_version_build;
|
||||
extern int const __kmp_openmp_version;
|
||||
extern char const
|
||||
__kmp_copyright[]; // Old variable, kept for compatibility with ITC and ITP.
|
||||
extern char const __kmp_version_copyright[];
|
||||
extern char const __kmp_version_lib_ver[];
|
||||
extern char const __kmp_version_lib_type[];
|
||||
|
|
@ -58,11 +59,11 @@ extern char const __kmp_version_ftnstdcall[];
|
|||
extern char const __kmp_version_ftncdecl[];
|
||||
extern char const __kmp_version_ftnextra[];
|
||||
|
||||
void __kmp_print_version_1( void );
|
||||
void __kmp_print_version_2( void );
|
||||
void __kmp_print_version_1(void);
|
||||
void __kmp_print_version_2(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif /* KMP_VERSION_H */
|
||||
|
|
|
|||
|
|
@ -14,13 +14,10 @@
|
|||
|
||||
#include "kmp_wait_release.h"
|
||||
|
||||
void __kmp_wait_64(kmp_info_t *this_thr, kmp_flag_64 *flag, int final_spin
|
||||
USE_ITT_BUILD_ARG(void * itt_sync_obj) )
|
||||
{
|
||||
__kmp_wait_template(this_thr, flag, final_spin
|
||||
USE_ITT_BUILD_ARG(itt_sync_obj) );
|
||||
void __kmp_wait_64(kmp_info_t *this_thr, kmp_flag_64 *flag,
|
||||
int final_spin USE_ITT_BUILD_ARG(void *itt_sync_obj)) {
|
||||
__kmp_wait_template(this_thr, flag,
|
||||
final_spin USE_ITT_BUILD_ARG(itt_sync_obj));
|
||||
}
|
||||
|
||||
void __kmp_release_64(kmp_flag_64 *flag) {
|
||||
__kmp_release_template(flag);
|
||||
}
|
||||
void __kmp_release_64(kmp_flag_64 *flag) { __kmp_release_template(flag); }
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -18,50 +18,52 @@
|
|||
|
||||
#if KMP_OS_UNIX
|
||||
|
||||
// On Unix-like systems (Linux* OS and OS X*) getpid() is declared in standard headers.
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#if KMP_OS_DARWIN
|
||||
//OS X
|
||||
#define __kmp_gettid() syscall(SYS_thread_selfid)
|
||||
#elif defined(SYS_gettid)
|
||||
// Hopefully other Unix systems define SYS_gettid syscall for getting os thread id
|
||||
#define __kmp_gettid() syscall(SYS_gettid)
|
||||
#else
|
||||
#warning No gettid found, use getpid instead
|
||||
#define __kmp_gettid() getpid()
|
||||
#endif
|
||||
// On Unix-like systems (Linux* OS and OS X*) getpid() is declared in standard
|
||||
// headers.
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#if KMP_OS_DARWIN
|
||||
// OS X
|
||||
#define __kmp_gettid() syscall(SYS_thread_selfid)
|
||||
#elif defined(SYS_gettid)
|
||||
// Hopefully other Unix systems define SYS_gettid syscall for getting os thread
|
||||
// id
|
||||
#define __kmp_gettid() syscall(SYS_gettid)
|
||||
#else
|
||||
#warning No gettid found, use getpid instead
|
||||
#define __kmp_gettid() getpid()
|
||||
#endif
|
||||
|
||||
#elif KMP_OS_WINDOWS
|
||||
|
||||
// On Windows* OS _getpid() returns int (not pid_t) and is declared in "process.h".
|
||||
#include <process.h>
|
||||
// Let us simulate Unix.
|
||||
typedef int pid_t;
|
||||
#define getpid _getpid
|
||||
#define __kmp_gettid() GetCurrentThreadId()
|
||||
// On Windows* OS _getpid() returns int (not pid_t) and is declared in
|
||||
// "process.h".
|
||||
#include <process.h>
|
||||
// Let us simulate Unix.
|
||||
typedef int pid_t;
|
||||
#define getpid _getpid
|
||||
#define __kmp_gettid() GetCurrentThreadId()
|
||||
|
||||
#else
|
||||
|
||||
#error Unknown or unsupported OS.
|
||||
#error Unknown or unsupported OS.
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
TODO: All the libomp source code uses pid_t type for storing the result of getpid(), it is good.
|
||||
But often it printed as "%d", that is not good, because it ignores pid_t definition (may pid_t
|
||||
be longer that int?). It seems all pid prints should be rewritten as
|
||||
/* TODO: All the libomp source code uses pid_t type for storing the result of
|
||||
getpid(), it is good. But often it printed as "%d", that is not good, because
|
||||
it ignores pid_t definition (may pid_t be longer that int?). It seems all pid
|
||||
prints should be rewritten as:
|
||||
|
||||
printf( "%" KMP_UINT64_SPEC, (kmp_uint64) pid );
|
||||
printf( "%" KMP_UINT64_SPEC, (kmp_uint64) pid );
|
||||
|
||||
or (at least) as
|
||||
or (at least) as
|
||||
|
||||
printf( "%" KMP_UINT32_SPEC, (kmp_uint32) pid );
|
||||
printf( "%" KMP_UINT32_SPEC, (kmp_uint32) pid );
|
||||
|
||||
(kmp_uint32, kmp_uint64, KMP_UINT64_SPEC, and KMP_UNIT32_SPEC are defined in "kmp_os.h".)
|
||||
|
||||
*/
|
||||
(kmp_uint32, kmp_uint64, KMP_UINT64_SPEC, and KMP_UNIT32_SPEC are defined in
|
||||
"kmp_os.h".) */
|
||||
|
||||
#endif // KMP_WRAPPER_GETPID_H
|
||||
|
||||
|
|
|
|||
|
|
@ -17,21 +17,18 @@
|
|||
#ifndef KMP_WRAPPER_MALLOC_H
|
||||
#define KMP_WRAPPER_MALLOC_H
|
||||
|
||||
/*
|
||||
This header serves for 3 purposes:
|
||||
/* This header serves for 3 purposes:
|
||||
1. Declaring standard memory allocation rourines in OS-independent way.
|
||||
2. Passing source location info through memory allocation wrappers.
|
||||
3. Enabling native memory debugging capabilities.
|
||||
|
||||
1. Declaring standard memory allocation rourines in OS-independent way.
|
||||
2. Passing source location info through memory allocation wrappers.
|
||||
3. Enabling native memory debugging capabilities.
|
||||
|
||||
|
||||
1. Declaring standard memory allocation rourines in OS-independent way.
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
On Linux* OS, alloca() function is declared in <alloca.h> header, while on Windows* OS there is no
|
||||
<alloca.h> header, function _alloca() (note underscore!) is declared in <malloc.h>. This header
|
||||
eliminates these differences, so client code incluiding "kmp_wrapper_malloc.h" can rely on
|
||||
following routines:
|
||||
1. Declaring standard memory allocation rourines in OS-independent way.
|
||||
-----------------------------------------------------------------------
|
||||
On Linux* OS, alloca() function is declared in <alloca.h> header, while on
|
||||
Windows* OS there is no <alloca.h> header, function _alloca() (note
|
||||
underscore!) is declared in <malloc.h>. This header eliminates these
|
||||
differences, so client code incluiding "kmp_wrapper_malloc.h" can rely on
|
||||
following routines:
|
||||
|
||||
malloc
|
||||
calloc
|
||||
|
|
@ -39,60 +36,56 @@
|
|||
free
|
||||
alloca
|
||||
|
||||
in OS-independent way. It also enables memory tracking capabilities in debug build. (Currently
|
||||
it is available only on Windows* OS.)
|
||||
in OS-independent way. It also enables memory tracking capabilities in debug
|
||||
build. (Currently it is available only on Windows* OS.)
|
||||
|
||||
2. Passing source location info through memory allocation wrappers.
|
||||
-------------------------------------------------------------------
|
||||
Some tools may help debugging memory errors, for example, report memory
|
||||
leaks. However, memory allocation wrappers may hinder source location.
|
||||
For example:
|
||||
|
||||
2. Passing source location info through memory allocation wrappers.
|
||||
-------------------------------------------------------------------
|
||||
void * aligned_malloc( int size ) {
|
||||
void * ptr = malloc( size ); // All the memory leaks will be reported at
|
||||
// this line.
|
||||
// some adjustments...
|
||||
return ptr;
|
||||
};
|
||||
|
||||
Some tools may help debugging memory errors, for example, report memory leaks. However, memory
|
||||
allocation wrappers may hinder source location.
|
||||
ptr = aligned_malloc( size ); // Memory leak will *not* be detected here. :-(
|
||||
|
||||
For example:
|
||||
To overcome the problem, information about original source location should
|
||||
be passed through all the memory allocation wrappers, for example:
|
||||
|
||||
void * aligned_malloc( int size ) {
|
||||
void * ptr = malloc( size ); // All the memory leaks will be reported at this line.
|
||||
// some adjustments...
|
||||
return ptr;
|
||||
};
|
||||
void * aligned_malloc( int size, char const * file, int line ) {
|
||||
void * ptr = _malloc_dbg( size, file, line );
|
||||
// some adjustments...
|
||||
return ptr;
|
||||
};
|
||||
void * ptr = aligned_malloc( size, __FILE__, __LINE__ );
|
||||
|
||||
ptr = aligned_malloc( size ); // Memory leak will *not* be detected here. :-(
|
||||
This is a good idea for debug, but passing additional arguments impacts
|
||||
performance. Disabling extra arguments in release version of the software
|
||||
introduces too many conditional compilation, which makes code unreadable.
|
||||
This header defines few macros and functions facilitating it:
|
||||
|
||||
To overcome the problem, information about original source location should be passed through all
|
||||
the memory allocation wrappers, for example:
|
||||
void * _aligned_malloc( int size KMP_SRC_LOC_DECL ) {
|
||||
void * ptr = malloc_src_loc( size KMP_SRC_LOC_PARM );
|
||||
// some adjustments...
|
||||
return ptr;
|
||||
};
|
||||
#define aligned_malloc( size ) _aligned_malloc( (size) KMP_SRC_LOC_CURR )
|
||||
// Use macro instead of direct call to function.
|
||||
|
||||
void * aligned_malloc( int size, char const * file, int line ) {
|
||||
void * ptr = _malloc_dbg( size, file, line );
|
||||
// some adjustments...
|
||||
return ptr;
|
||||
};
|
||||
|
||||
void * ptr = aligned_malloc( size, __FILE__, __LINE__ );
|
||||
|
||||
This is a good idea for debug, but passing additional arguments impacts performance. Disabling
|
||||
extra arguments in release version of the software introduces too many conditional compilation,
|
||||
which makes code unreadable. This header defines few macros and functions facilitating it:
|
||||
|
||||
void * _aligned_malloc( int size KMP_SRC_LOC_DECL ) {
|
||||
void * ptr = malloc_src_loc( size KMP_SRC_LOC_PARM );
|
||||
// some adjustments...
|
||||
return ptr;
|
||||
};
|
||||
#define aligned_malloc( size ) _aligned_malloc( (size) KMP_SRC_LOC_CURR )
|
||||
// Use macro instead of direct call to function.
|
||||
|
||||
void * ptr = aligned_malloc( size ); // Bingo! Memory leak will be reported at this line.
|
||||
|
||||
|
||||
3. Enabling native memory debugging capabilities.
|
||||
-------------------------------------------------
|
||||
|
||||
Some platforms may offer memory debugging capabilities. For example, debug version of Microsoft
|
||||
RTL tracks all memory allocations and can report memory leaks. This header enables this, and
|
||||
makes report more useful (see "Passing source location info through memory allocation
|
||||
wrappers").
|
||||
void * ptr = aligned_malloc( size ); // Bingo! Memory leak will be
|
||||
// reported at this line.
|
||||
|
||||
3. Enabling native memory debugging capabilities.
|
||||
-------------------------------------------------
|
||||
Some platforms may offer memory debugging capabilities. For example, debug
|
||||
version of Microsoft RTL tracks all memory allocations and can report memory
|
||||
leaks. This header enables this, and makes report more useful (see "Passing
|
||||
source location info through memory allocation wrappers").
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
@ -101,102 +94,101 @@
|
|||
|
||||
// Include alloca() declaration.
|
||||
#if KMP_OS_WINDOWS
|
||||
#include <malloc.h> // Windows* OS: _alloca() declared in "malloc.h".
|
||||
#define alloca _alloca // Allow to use alloca() with no underscore.
|
||||
#include <malloc.h> // Windows* OS: _alloca() declared in "malloc.h".
|
||||
#define alloca _alloca // Allow to use alloca() with no underscore.
|
||||
#elif KMP_OS_FREEBSD || KMP_OS_NETBSD
|
||||
// Declared in "stdlib.h".
|
||||
// Declared in "stdlib.h".
|
||||
#elif KMP_OS_UNIX
|
||||
#include <alloca.h> // Linux* OS and OS X*: alloc() declared in "alloca".
|
||||
#include <alloca.h> // Linux* OS and OS X*: alloc() declared in "alloca".
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
#error Unknown or unsupported OS.
|
||||
#endif
|
||||
|
||||
/*
|
||||
KMP_SRC_LOC_DECL -- Declaring source location paramemters, to be used in function declaration.
|
||||
KMP_SRC_LOC_PARM -- Source location paramemters, to be used to pass parameters to underlying
|
||||
levels.
|
||||
KMP_SRC_LOC_CURR -- Source location arguments describing current location, to be used at
|
||||
top-level.
|
||||
/* KMP_SRC_LOC_DECL -- Declaring source location paramemters, to be used in
|
||||
function declaration.
|
||||
KMP_SRC_LOC_PARM -- Source location paramemters, to be used to pass
|
||||
parameters to underlying levels.
|
||||
KMP_SRC_LOC_CURR -- Source location arguments describing current location,
|
||||
to be used at top-level.
|
||||
|
||||
Typical usage:
|
||||
|
||||
void * _aligned_malloc( int size KMP_SRC_LOC_DECL ) {
|
||||
// Note: Comma is missed before KMP_SRC_LOC_DECL.
|
||||
KE_TRACE( 25, ( "called from %s:%d\n", KMP_SRC_LOC_PARM ) );
|
||||
...
|
||||
}
|
||||
#define aligned_malloc( size ) _aligned_malloc( (size) KMP_SRC_LOC_CURR )
|
||||
// Use macro instead of direct call to function -- macro passes info about current
|
||||
// source location to the func.
|
||||
Typical usage:
|
||||
void * _aligned_malloc( int size KMP_SRC_LOC_DECL ) {
|
||||
// Note: Comma is missed before KMP_SRC_LOC_DECL.
|
||||
KE_TRACE( 25, ( "called from %s:%d\n", KMP_SRC_LOC_PARM ) );
|
||||
...
|
||||
}
|
||||
#define aligned_malloc( size ) _aligned_malloc( (size) KMP_SRC_LOC_CURR )
|
||||
// Use macro instead of direct call to function -- macro passes info
|
||||
// about current source location to the func.
|
||||
*/
|
||||
#if KMP_DEBUG
|
||||
#define KMP_SRC_LOC_DECL , char const * _file_, int _line_
|
||||
#define KMP_SRC_LOC_PARM , _file_, _line_
|
||||
#define KMP_SRC_LOC_CURR , __FILE__, __LINE__
|
||||
#define KMP_SRC_LOC_DECL , char const *_file_, int _line_
|
||||
#define KMP_SRC_LOC_PARM , _file_, _line_
|
||||
#define KMP_SRC_LOC_CURR , __FILE__, __LINE__
|
||||
#else
|
||||
#define KMP_SRC_LOC_DECL
|
||||
#define KMP_SRC_LOC_PARM
|
||||
#define KMP_SRC_LOC_CURR
|
||||
#define KMP_SRC_LOC_DECL
|
||||
#define KMP_SRC_LOC_PARM
|
||||
#define KMP_SRC_LOC_CURR
|
||||
#endif // KMP_DEBUG
|
||||
|
||||
/*
|
||||
malloc_src_loc() and free_src_loc() are pseudo-functions (really macros) with accepts extra
|
||||
arguments (source location info) in debug mode. They should be used in place of malloc() and
|
||||
free(), this allows enabling native memory debugging capabilities (if any).
|
||||
|
||||
Typical usage:
|
||||
|
||||
ptr = malloc_src_loc( size KMP_SRC_LOC_PARM );
|
||||
// Inside memory allocation wrapper, or
|
||||
ptr = malloc_src_loc( size KMP_SRC_LOC_CURR );
|
||||
// Outside of memory allocation wrapper.
|
||||
|
||||
/* malloc_src_loc() and free_src_loc() are pseudo-functions (really macros)
|
||||
with accepts extra arguments (source location info) in debug mode. They
|
||||
should be used in place of malloc() and free(), this allows enabling native
|
||||
memory debugging capabilities (if any).
|
||||
|
||||
Typical usage:
|
||||
ptr = malloc_src_loc( size KMP_SRC_LOC_PARM );
|
||||
// Inside memory allocation wrapper, or
|
||||
ptr = malloc_src_loc( size KMP_SRC_LOC_CURR );
|
||||
// Outside of memory allocation wrapper.
|
||||
*/
|
||||
#define malloc_src_loc( args ) _malloc_src_loc( args )
|
||||
#define free_src_loc( args ) _free_src_loc( args )
|
||||
/*
|
||||
Depending on build mode (debug or release), malloc_src_loc is declared with 1 or 3
|
||||
parameters, but calls to malloc_src_loc() are always the same:
|
||||
#define malloc_src_loc(args) _malloc_src_loc(args)
|
||||
#define free_src_loc(args) _free_src_loc(args)
|
||||
/* Depending on build mode (debug or release), malloc_src_loc is declared with
|
||||
1 or 3 parameters, but calls to malloc_src_loc() are always the same:
|
||||
|
||||
... malloc_src_loc( size KMP_SRC_LOC_PARM ); // or KMP_SRC_LOC_CURR
|
||||
... malloc_src_loc( size KMP_SRC_LOC_PARM ); // or KMP_SRC_LOC_CURR
|
||||
|
||||
Compiler issues warning/error "too few arguments in macro invocation". Declaring two
|
||||
macroses, malloc_src_loc() and _malloc_src_loc() overcomes the problem.
|
||||
*/
|
||||
Compiler issues warning/error "too few arguments in macro invocation".
|
||||
Declaring two macros, malloc_src_loc() and _malloc_src_loc(), overcomes the
|
||||
problem. */
|
||||
|
||||
#if KMP_DEBUG
|
||||
|
||||
#if KMP_OS_WINDOWS && _DEBUG
|
||||
// KMP_DEBUG != _DEBUG. MS debug RTL is available only if _DEBUG is defined.
|
||||
#if KMP_OS_WINDOWS && _DEBUG
|
||||
// KMP_DEBUG != _DEBUG. MS debug RTL is available only if _DEBUG is defined.
|
||||
|
||||
// Windows* OS has native memory debugging capabilities. Enable them.
|
||||
// Windows* OS has native memory debugging capabilities. Enable them.
|
||||
|
||||
#include <crtdbg.h>
|
||||
#include <crtdbg.h>
|
||||
|
||||
#define KMP_MEM_BLOCK _CLIENT_BLOCK
|
||||
#define malloc( size ) _malloc_dbg( (size), KMP_MEM_BLOCK, __FILE__, __LINE__ )
|
||||
#define calloc( num, size ) _calloc_dbg( (num), (size), KMP_MEM_BLOCK, __FILE__, __LINE__ )
|
||||
#define realloc( ptr, size ) _realloc_dbg( (ptr), (size), KMP_MEM_BLOCK, __FILE__, __LINE__ )
|
||||
#define free( ptr ) _free_dbg( (ptr), KMP_MEM_BLOCK )
|
||||
#define KMP_MEM_BLOCK _CLIENT_BLOCK
|
||||
#define malloc(size) _malloc_dbg((size), KMP_MEM_BLOCK, __FILE__, __LINE__)
|
||||
#define calloc(num, size) \
|
||||
_calloc_dbg((num), (size), KMP_MEM_BLOCK, __FILE__, __LINE__)
|
||||
#define realloc(ptr, size) \
|
||||
_realloc_dbg((ptr), (size), KMP_MEM_BLOCK, __FILE__, __LINE__)
|
||||
#define free(ptr) _free_dbg((ptr), KMP_MEM_BLOCK)
|
||||
|
||||
#define _malloc_src_loc( size, file, line ) _malloc_dbg( (size), KMP_MEM_BLOCK, (file), (line) )
|
||||
#define _free_src_loc( ptr, file, line ) _free_dbg( (ptr), KMP_MEM_BLOCK )
|
||||
|
||||
#else
|
||||
|
||||
// Linux* OS, OS X*, or non-debug Windows* OS.
|
||||
|
||||
#define _malloc_src_loc( size, file, line ) malloc( (size) )
|
||||
#define _free_src_loc( ptr, file, line ) free( (ptr) )
|
||||
|
||||
#endif
|
||||
#define _malloc_src_loc(size, file, line) \
|
||||
_malloc_dbg((size), KMP_MEM_BLOCK, (file), (line))
|
||||
#define _free_src_loc(ptr, file, line) _free_dbg((ptr), KMP_MEM_BLOCK)
|
||||
|
||||
#else
|
||||
|
||||
// In release build malloc_src_loc() and free_src_loc() do not have extra parameters.
|
||||
#define _malloc_src_loc( size ) malloc( (size) )
|
||||
#define _free_src_loc( ptr ) free( (ptr) )
|
||||
// Linux* OS, OS X*, or non-debug Windows* OS.
|
||||
|
||||
#define _malloc_src_loc(size, file, line) malloc((size))
|
||||
#define _free_src_loc(ptr, file, line) free((ptr))
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// In release build malloc_src_loc() and free_src_loc() do not have extra
|
||||
// parameters.
|
||||
#define _malloc_src_loc(size) malloc((size))
|
||||
#define _free_src_loc(ptr) free((ptr))
|
||||
|
||||
#endif // KMP_DEBUG
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __OMPT_EVENT_SPECIFIC_H__
|
||||
#define __OMPT_EVENT_SPECIFIC_H__
|
||||
#ifndef __OMPT_EVENT_SPECIFIC_H__
|
||||
#define __OMPT_EVENT_SPECIFIC_H__
|
||||
|
||||
/******************************************************************************
|
||||
* File: ompt-event-specific.h
|
||||
|
|
@ -10,10 +10,9 @@
|
|||
* and the level of their implementation by a runtime system.
|
||||
*****************************************************************************/
|
||||
|
||||
#define _ompt_tokenpaste_helper(x,y) x ## y
|
||||
#define _ompt_tokenpaste(x,y) _ompt_tokenpaste_helper(x,y)
|
||||
#define ompt_event_implementation_status(e) _ompt_tokenpaste(e,_implemented)
|
||||
|
||||
#define _ompt_tokenpaste_helper(x, y) x##y
|
||||
#define _ompt_tokenpaste(x, y) _ompt_tokenpaste_helper(x, y)
|
||||
#define ompt_event_implementation_status(e) _ompt_tokenpaste(e, _implemented)
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Specify whether an event may occur or not, and whether event callbacks
|
||||
|
|
@ -23,130 +22,132 @@
|
|||
| the OMPT TR. They are exposed to tools through ompt_set_callback.
|
||||
+--------------------------------------------------------------------------*/
|
||||
|
||||
#define ompt_event_NEVER ompt_set_result_event_never_occurs
|
||||
#define ompt_event_UNIMPLEMENTED ompt_set_result_event_may_occur_no_callback
|
||||
#define ompt_event_MAY_CONVENIENT ompt_set_result_event_may_occur_callback_some
|
||||
#define ompt_event_MAY_ALWAYS ompt_set_result_event_may_occur_callback_always
|
||||
#define ompt_event_NEVER ompt_set_result_event_never_occurs
|
||||
#define ompt_event_UNIMPLEMENTED ompt_set_result_event_may_occur_no_callback
|
||||
#define ompt_event_MAY_CONVENIENT ompt_set_result_event_may_occur_callback_some
|
||||
#define ompt_event_MAY_ALWAYS ompt_set_result_event_may_occur_callback_always
|
||||
|
||||
#if OMPT_TRACE
|
||||
#define ompt_event_MAY_ALWAYS_TRACE ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_MAY_ALWAYS_TRACE ompt_event_MAY_ALWAYS
|
||||
#else
|
||||
#define ompt_event_MAY_ALWAYS_TRACE ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_MAY_ALWAYS_TRACE ompt_event_UNIMPLEMENTED
|
||||
#endif
|
||||
|
||||
#if OMPT_BLAME
|
||||
#define ompt_event_MAY_ALWAYS_BLAME ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_MAY_ALWAYS_BLAME ompt_event_MAY_ALWAYS
|
||||
#else
|
||||
#define ompt_event_MAY_ALWAYS_BLAME ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_MAY_ALWAYS_BLAME ompt_event_UNIMPLEMENTED
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Mandatory Events
|
||||
+--------------------------------------------------------------------------*/
|
||||
|
||||
#define ompt_event_parallel_begin_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_parallel_end_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_parallel_begin_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_parallel_end_implemented ompt_event_MAY_ALWAYS
|
||||
|
||||
#define ompt_event_task_begin_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_task_end_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_task_begin_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_task_end_implemented ompt_event_MAY_ALWAYS
|
||||
|
||||
#define ompt_event_thread_begin_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_thread_end_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_thread_begin_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_thread_end_implemented ompt_event_MAY_ALWAYS
|
||||
|
||||
#define ompt_event_control_implemented ompt_event_MAY_ALWAYS
|
||||
|
||||
#define ompt_event_runtime_shutdown_implemented ompt_event_MAY_ALWAYS
|
||||
#define ompt_event_control_implemented ompt_event_MAY_ALWAYS
|
||||
|
||||
#define ompt_event_runtime_shutdown_implemented ompt_event_MAY_ALWAYS
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Optional Events (blame shifting)
|
||||
+--------------------------------------------------------------------------*/
|
||||
|
||||
#define ompt_event_idle_begin_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_idle_end_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_idle_begin_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_idle_end_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
|
||||
#define ompt_event_wait_barrier_begin_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_wait_barrier_end_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_wait_barrier_begin_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_wait_barrier_end_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
|
||||
#define ompt_event_wait_taskwait_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_taskwait_end_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_taskwait_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_taskwait_end_implemented ompt_event_UNIMPLEMENTED
|
||||
|
||||
#define ompt_event_wait_taskgroup_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_taskgroup_end_implemented ompt_event_UNIMPLEMENTED
|
||||
|
||||
#define ompt_event_release_lock_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_release_nest_lock_last_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_release_critical_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_release_atomic_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_release_ordered_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_wait_taskgroup_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_taskgroup_end_implemented ompt_event_UNIMPLEMENTED
|
||||
|
||||
#define ompt_event_release_lock_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_release_nest_lock_last_implemented \
|
||||
ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_release_critical_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_release_atomic_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
#define ompt_event_release_ordered_implemented ompt_event_MAY_ALWAYS_BLAME
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Optional Events (synchronous events)
|
||||
+--------------------------------------------------------------------------*/
|
||||
|
||||
#define ompt_event_implicit_task_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_implicit_task_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_implicit_task_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_implicit_task_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_initial_task_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_initial_task_end_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_initial_task_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_initial_task_end_implemented ompt_event_UNIMPLEMENTED
|
||||
|
||||
#define ompt_event_task_switch_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_task_switch_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_loop_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_loop_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_loop_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_loop_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_sections_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_sections_end_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_sections_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_sections_end_implemented ompt_event_UNIMPLEMENTED
|
||||
|
||||
#define ompt_event_single_in_block_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_single_in_block_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_single_others_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_single_others_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_single_in_block_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_single_in_block_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_single_others_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_single_others_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_workshare_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_workshare_end_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_workshare_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_workshare_end_implemented ompt_event_UNIMPLEMENTED
|
||||
|
||||
#define ompt_event_master_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_master_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_master_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_master_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_barrier_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_barrier_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_barrier_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_barrier_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_taskwait_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_taskwait_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_taskwait_begin_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_taskwait_end_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_taskgroup_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_taskgroup_end_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_taskgroup_begin_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_taskgroup_end_implemented ompt_event_UNIMPLEMENTED
|
||||
|
||||
#define ompt_event_release_nest_lock_prev_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_wait_lock_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_nest_lock_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_critical_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_atomic_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_wait_ordered_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_release_nest_lock_prev_implemented \
|
||||
ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_wait_lock_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_nest_lock_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_critical_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_wait_atomic_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_wait_ordered_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_acquired_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_acquired_nest_lock_first_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_acquired_nest_lock_next_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_acquired_critical_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_acquired_atomic_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_acquired_ordered_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_acquired_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_acquired_nest_lock_first_implemented \
|
||||
ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_acquired_nest_lock_next_implemented \
|
||||
ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_acquired_critical_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_acquired_atomic_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_acquired_ordered_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_init_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_init_nest_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_init_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_init_nest_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_destroy_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_destroy_nest_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_destroy_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_destroy_nest_lock_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
|
||||
#define ompt_event_flush_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_flush_implemented ompt_event_UNIMPLEMENTED
|
||||
|
||||
#if OMP_40_ENABLED
|
||||
# define ompt_event_task_dependences_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
# define ompt_event_task_dependence_pair_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_task_dependences_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#define ompt_event_task_dependence_pair_implemented ompt_event_MAY_ALWAYS_TRACE
|
||||
#else
|
||||
# define ompt_event_task_dependences_implemented ompt_event_UNIMPLEMENTED
|
||||
# define ompt_event_task_dependence_pair_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_task_dependences_implemented ompt_event_UNIMPLEMENTED
|
||||
#define ompt_event_task_dependence_pair_implemented ompt_event_UNIMPLEMENTED
|
||||
#endif /* OMP_40_ENABLED */
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,16 +9,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* ompt include files
|
||||
****************************************************************************/
|
||||
|
||||
#include "ompt-specific.cpp"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* macros
|
||||
****************************************************************************/
|
||||
|
|
@ -34,32 +30,25 @@
|
|||
#define OMPT_STR_MATCH(haystack, needle) (!strcasecmp(haystack, needle))
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* types
|
||||
****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
const char *state_name;
|
||||
ompt_state_t state_id;
|
||||
const char *state_name;
|
||||
ompt_state_t state_id;
|
||||
} ompt_state_info_t;
|
||||
|
||||
|
||||
enum tool_setting_e {
|
||||
omp_tool_error,
|
||||
omp_tool_unset,
|
||||
omp_tool_disabled,
|
||||
omp_tool_enabled
|
||||
omp_tool_error,
|
||||
omp_tool_unset,
|
||||
omp_tool_disabled,
|
||||
omp_tool_enabled
|
||||
};
|
||||
|
||||
|
||||
typedef void (*ompt_initialize_t) (
|
||||
ompt_function_lookup_t ompt_fn_lookup,
|
||||
const char *version,
|
||||
unsigned int ompt_version
|
||||
);
|
||||
|
||||
|
||||
typedef void (*ompt_initialize_t)(ompt_function_lookup_t ompt_fn_lookup,
|
||||
const char *version,
|
||||
unsigned int ompt_version);
|
||||
|
||||
/*****************************************************************************
|
||||
* global variables
|
||||
|
|
@ -68,16 +57,14 @@ typedef void (*ompt_initialize_t) (
|
|||
int ompt_enabled = 0;
|
||||
|
||||
ompt_state_info_t ompt_state_info[] = {
|
||||
#define ompt_state_macro(state, code) { # state, state },
|
||||
#define ompt_state_macro(state, code) {#state, state},
|
||||
FOREACH_OMPT_STATE(ompt_state_macro)
|
||||
#undef ompt_state_macro
|
||||
};
|
||||
|
||||
ompt_callbacks_t ompt_callbacks;
|
||||
|
||||
static ompt_initialize_t ompt_initialize_fn = NULL;
|
||||
|
||||
|
||||
static ompt_initialize_t ompt_initialize_fn = NULL;
|
||||
|
||||
/*****************************************************************************
|
||||
* forward declarations
|
||||
|
|
@ -87,7 +74,6 @@ static ompt_interface_fn_t ompt_fn_lookup(const char *s);
|
|||
|
||||
OMPT_API_ROUTINE ompt_thread_id_t ompt_get_thread_id(void);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* initialization and finalization (private operations)
|
||||
****************************************************************************/
|
||||
|
|
@ -102,13 +88,11 @@ OMPT_API_ROUTINE ompt_thread_id_t ompt_get_thread_id(void);
|
|||
* NULL is returned and OMPT won't be enabled */
|
||||
#if OMPT_HAVE_WEAK_ATTRIBUTE
|
||||
_OMP_EXTERN
|
||||
__attribute__ (( weak ))
|
||||
ompt_initialize_t ompt_tool()
|
||||
{
|
||||
__attribute__((weak)) ompt_initialize_t ompt_tool() {
|
||||
#if OMPT_DEBUG
|
||||
printf("ompt_tool() is called from the RTL\n");
|
||||
printf("ompt_tool() is called from the RTL\n");
|
||||
#endif
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#elif OMPT_HAVE_PSAPI
|
||||
|
|
@ -120,161 +104,154 @@ ompt_initialize_t ompt_tool()
|
|||
// The number of loaded modules to start enumeration with EnumProcessModules()
|
||||
#define NUM_MODULES 128
|
||||
|
||||
static
|
||||
ompt_initialize_t ompt_tool_windows()
|
||||
{
|
||||
int i;
|
||||
DWORD needed, new_size;
|
||||
HMODULE *modules;
|
||||
HANDLE process = GetCurrentProcess();
|
||||
modules = (HMODULE*)malloc( NUM_MODULES * sizeof(HMODULE) );
|
||||
ompt_initialize_t (*ompt_tool_p)() = NULL;
|
||||
static ompt_initialize_t ompt_tool_windows() {
|
||||
int i;
|
||||
DWORD needed, new_size;
|
||||
HMODULE *modules;
|
||||
HANDLE process = GetCurrentProcess();
|
||||
modules = (HMODULE *)malloc(NUM_MODULES * sizeof(HMODULE));
|
||||
ompt_initialize_t (*ompt_tool_p)() = NULL;
|
||||
|
||||
#if OMPT_DEBUG
|
||||
printf("ompt_tool_windows(): looking for ompt_tool\n");
|
||||
printf("ompt_tool_windows(): looking for ompt_tool\n");
|
||||
#endif
|
||||
if (!EnumProcessModules( process, modules, NUM_MODULES * sizeof(HMODULE),
|
||||
&needed)) {
|
||||
// Regardless of the error reason use the stub initialization function
|
||||
free(modules);
|
||||
return NULL;
|
||||
}
|
||||
// Check if NUM_MODULES is enough to list all modules
|
||||
new_size = needed / sizeof(HMODULE);
|
||||
if (new_size > NUM_MODULES) {
|
||||
if (!EnumProcessModules(process, modules, NUM_MODULES * sizeof(HMODULE),
|
||||
&needed)) {
|
||||
// Regardless of the error reason use the stub initialization function
|
||||
free(modules);
|
||||
return NULL;
|
||||
}
|
||||
// Check if NUM_MODULES is enough to list all modules
|
||||
new_size = needed / sizeof(HMODULE);
|
||||
if (new_size > NUM_MODULES) {
|
||||
#if OMPT_DEBUG
|
||||
printf("ompt_tool_windows(): resize buffer to %d bytes\n", needed);
|
||||
#endif
|
||||
modules = (HMODULE*)realloc( modules, needed );
|
||||
// If resizing failed use the stub function.
|
||||
if (!EnumProcessModules(process, modules, needed, &needed)) {
|
||||
free(modules);
|
||||
return NULL;
|
||||
}
|
||||
modules = (HMODULE *)realloc(modules, needed);
|
||||
// If resizing failed use the stub function.
|
||||
if (!EnumProcessModules(process, modules, needed, &needed)) {
|
||||
free(modules);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < new_size; ++i) {
|
||||
(FARPROC &)ompt_tool_p = GetProcAddress(modules[i], "ompt_tool");
|
||||
if (ompt_tool_p) {
|
||||
}
|
||||
for (i = 0; i < new_size; ++i) {
|
||||
(FARPROC &)ompt_tool_p = GetProcAddress(modules[i], "ompt_tool");
|
||||
if (ompt_tool_p) {
|
||||
#if OMPT_DEBUG
|
||||
TCHAR modName[MAX_PATH];
|
||||
if (GetModuleFileName(modules[i], modName, MAX_PATH))
|
||||
printf("ompt_tool_windows(): ompt_tool found in module %s\n",
|
||||
modName);
|
||||
#endif
|
||||
free(modules);
|
||||
return ompt_tool_p();
|
||||
}
|
||||
#if OMPT_DEBUG
|
||||
else {
|
||||
TCHAR modName[MAX_PATH];
|
||||
if (GetModuleFileName(modules[i], modName, MAX_PATH))
|
||||
printf("ompt_tool_windows(): ompt_tool not found in module %s\n",
|
||||
modName);
|
||||
}
|
||||
TCHAR modName[MAX_PATH];
|
||||
if (GetModuleFileName(modules[i], modName, MAX_PATH))
|
||||
printf("ompt_tool_windows(): ompt_tool found in module %s\n", modName);
|
||||
#endif
|
||||
free(modules);
|
||||
return ompt_tool_p();
|
||||
}
|
||||
free(modules);
|
||||
return NULL;
|
||||
#if OMPT_DEBUG
|
||||
else {
|
||||
TCHAR modName[MAX_PATH];
|
||||
if (GetModuleFileName(modules[i], modName, MAX_PATH))
|
||||
printf("ompt_tool_windows(): ompt_tool not found in module %s\n",
|
||||
modName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
free(modules);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
# error Either __attribute__((weak)) or psapi.dll are required for OMPT support
|
||||
#error Either __attribute__((weak)) or psapi.dll are required for OMPT support
|
||||
#endif // OMPT_HAVE_WEAK_ATTRIBUTE
|
||||
|
||||
void ompt_pre_init()
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// Execute the pre-initialization logic only once.
|
||||
//--------------------------------------------------
|
||||
static int ompt_pre_initialized = 0;
|
||||
void ompt_pre_init() {
|
||||
//--------------------------------------------------
|
||||
// Execute the pre-initialization logic only once.
|
||||
//--------------------------------------------------
|
||||
static int ompt_pre_initialized = 0;
|
||||
|
||||
if (ompt_pre_initialized) return;
|
||||
if (ompt_pre_initialized)
|
||||
return;
|
||||
|
||||
ompt_pre_initialized = 1;
|
||||
ompt_pre_initialized = 1;
|
||||
|
||||
//--------------------------------------------------
|
||||
// Use a tool iff a tool is enabled and available.
|
||||
//--------------------------------------------------
|
||||
const char *ompt_env_var = getenv("OMP_TOOL");
|
||||
tool_setting_e tool_setting = omp_tool_error;
|
||||
//--------------------------------------------------
|
||||
// Use a tool iff a tool is enabled and available.
|
||||
//--------------------------------------------------
|
||||
const char *ompt_env_var = getenv("OMP_TOOL");
|
||||
tool_setting_e tool_setting = omp_tool_error;
|
||||
|
||||
if (!ompt_env_var || !strcmp(ompt_env_var, ""))
|
||||
tool_setting = omp_tool_unset;
|
||||
else if (OMPT_STR_MATCH(ompt_env_var, "disabled"))
|
||||
tool_setting = omp_tool_disabled;
|
||||
else if (OMPT_STR_MATCH(ompt_env_var, "enabled"))
|
||||
tool_setting = omp_tool_enabled;
|
||||
if (!ompt_env_var || !strcmp(ompt_env_var, ""))
|
||||
tool_setting = omp_tool_unset;
|
||||
else if (OMPT_STR_MATCH(ompt_env_var, "disabled"))
|
||||
tool_setting = omp_tool_disabled;
|
||||
else if (OMPT_STR_MATCH(ompt_env_var, "enabled"))
|
||||
tool_setting = omp_tool_enabled;
|
||||
|
||||
#if OMPT_DEBUG
|
||||
printf("ompt_pre_init(): tool_setting = %d\n", tool_setting);
|
||||
printf("ompt_pre_init(): tool_setting = %d\n", tool_setting);
|
||||
#endif
|
||||
switch(tool_setting) {
|
||||
case omp_tool_disabled:
|
||||
break;
|
||||
switch (tool_setting) {
|
||||
case omp_tool_disabled:
|
||||
break;
|
||||
|
||||
case omp_tool_unset:
|
||||
case omp_tool_enabled:
|
||||
ompt_initialize_fn = ompt_tool();
|
||||
if (ompt_initialize_fn) {
|
||||
ompt_enabled = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case omp_tool_error:
|
||||
fprintf(stderr,
|
||||
"Warning: OMP_TOOL has invalid value \"%s\".\n"
|
||||
" legal values are (NULL,\"\",\"disabled\","
|
||||
"\"enabled\").\n", ompt_env_var);
|
||||
break;
|
||||
case omp_tool_unset:
|
||||
case omp_tool_enabled:
|
||||
ompt_initialize_fn = ompt_tool();
|
||||
if (ompt_initialize_fn) {
|
||||
ompt_enabled = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case omp_tool_error:
|
||||
fprintf(stderr, "Warning: OMP_TOOL has invalid value \"%s\".\n"
|
||||
" legal values are (NULL,\"\",\"disabled\","
|
||||
"\"enabled\").\n",
|
||||
ompt_env_var);
|
||||
break;
|
||||
}
|
||||
#if OMPT_DEBUG
|
||||
printf("ompt_pre_init(): ompt_enabled = %d\n", ompt_enabled);
|
||||
printf("ompt_pre_init(): ompt_enabled = %d\n", ompt_enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ompt_post_init() {
|
||||
//--------------------------------------------------
|
||||
// Execute the post-initialization logic only once.
|
||||
//--------------------------------------------------
|
||||
static int ompt_post_initialized = 0;
|
||||
|
||||
void ompt_post_init()
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// Execute the post-initialization logic only once.
|
||||
//--------------------------------------------------
|
||||
static int ompt_post_initialized = 0;
|
||||
if (ompt_post_initialized)
|
||||
return;
|
||||
|
||||
if (ompt_post_initialized) return;
|
||||
ompt_post_initialized = 1;
|
||||
|
||||
ompt_post_initialized = 1;
|
||||
//--------------------------------------------------
|
||||
// Initialize the tool if so indicated.
|
||||
//--------------------------------------------------
|
||||
if (ompt_enabled) {
|
||||
ompt_initialize_fn(ompt_fn_lookup, ompt_get_runtime_version(),
|
||||
OMPT_VERSION);
|
||||
|
||||
//--------------------------------------------------
|
||||
// Initialize the tool if so indicated.
|
||||
//--------------------------------------------------
|
||||
if (ompt_enabled) {
|
||||
ompt_initialize_fn(ompt_fn_lookup, ompt_get_runtime_version(),
|
||||
OMPT_VERSION);
|
||||
ompt_thread_t *root_thread = ompt_get_thread();
|
||||
|
||||
ompt_thread_t *root_thread = ompt_get_thread();
|
||||
ompt_set_thread_state(root_thread, ompt_state_overhead);
|
||||
|
||||
ompt_set_thread_state(root_thread, ompt_state_overhead);
|
||||
|
||||
if (ompt_callbacks.ompt_callback(ompt_event_thread_begin)) {
|
||||
ompt_callbacks.ompt_callback(ompt_event_thread_begin)
|
||||
(ompt_thread_initial, ompt_get_thread_id());
|
||||
}
|
||||
|
||||
ompt_set_thread_state(root_thread, ompt_state_work_serial);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ompt_fini()
|
||||
{
|
||||
if (ompt_enabled) {
|
||||
if (ompt_callbacks.ompt_callback(ompt_event_runtime_shutdown)) {
|
||||
ompt_callbacks.ompt_callback(ompt_event_runtime_shutdown)();
|
||||
}
|
||||
if (ompt_callbacks.ompt_callback(ompt_event_thread_begin)) {
|
||||
ompt_callbacks.ompt_callback(ompt_event_thread_begin)(
|
||||
ompt_thread_initial, ompt_get_thread_id());
|
||||
}
|
||||
|
||||
ompt_enabled = 0;
|
||||
ompt_set_thread_state(root_thread, ompt_state_work_serial);
|
||||
}
|
||||
}
|
||||
|
||||
void ompt_fini() {
|
||||
if (ompt_enabled) {
|
||||
if (ompt_callbacks.ompt_callback(ompt_event_runtime_shutdown)) {
|
||||
ompt_callbacks.ompt_callback(ompt_event_runtime_shutdown)();
|
||||
}
|
||||
}
|
||||
|
||||
ompt_enabled = 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* interface operations
|
||||
|
|
@ -285,148 +262,122 @@ void ompt_fini()
|
|||
****************************************************************************/
|
||||
|
||||
OMPT_API_ROUTINE int ompt_enumerate_state(int current_state, int *next_state,
|
||||
const char **next_state_name)
|
||||
{
|
||||
const static int len = sizeof(ompt_state_info) / sizeof(ompt_state_info_t);
|
||||
int i = 0;
|
||||
const char **next_state_name) {
|
||||
const static int len = sizeof(ompt_state_info) / sizeof(ompt_state_info_t);
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < len - 1; i++) {
|
||||
if (ompt_state_info[i].state_id == current_state) {
|
||||
*next_state = ompt_state_info[i+1].state_id;
|
||||
*next_state_name = ompt_state_info[i+1].state_name;
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < len - 1; i++) {
|
||||
if (ompt_state_info[i].state_id == current_state) {
|
||||
*next_state = ompt_state_info[i + 1].state_id;
|
||||
*next_state_name = ompt_state_info[i + 1].state_name;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* callbacks
|
||||
****************************************************************************/
|
||||
|
||||
OMPT_API_ROUTINE int ompt_set_callback(ompt_event_t evid, ompt_callback_t cb)
|
||||
{
|
||||
switch (evid) {
|
||||
OMPT_API_ROUTINE int ompt_set_callback(ompt_event_t evid, ompt_callback_t cb) {
|
||||
switch (evid) {
|
||||
|
||||
#define ompt_event_macro(event_name, callback_type, event_id) \
|
||||
case event_name: \
|
||||
if (ompt_event_implementation_status(event_name)) { \
|
||||
ompt_callbacks.ompt_callback(event_name) = (callback_type) cb; \
|
||||
} \
|
||||
return ompt_event_implementation_status(event_name);
|
||||
case event_name: \
|
||||
if (ompt_event_implementation_status(event_name)) { \
|
||||
ompt_callbacks.ompt_callback(event_name) = (callback_type)cb; \
|
||||
} \
|
||||
return ompt_event_implementation_status(event_name);
|
||||
|
||||
FOREACH_OMPT_EVENT(ompt_event_macro)
|
||||
|
||||
#undef ompt_event_macro
|
||||
|
||||
default: return ompt_set_result_registration_error;
|
||||
}
|
||||
default:
|
||||
return ompt_set_result_registration_error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_ROUTINE int ompt_get_callback(ompt_event_t evid, ompt_callback_t *cb)
|
||||
{
|
||||
switch (evid) {
|
||||
OMPT_API_ROUTINE int ompt_get_callback(ompt_event_t evid, ompt_callback_t *cb) {
|
||||
switch (evid) {
|
||||
|
||||
#define ompt_event_macro(event_name, callback_type, event_id) \
|
||||
case event_name: \
|
||||
if (ompt_event_implementation_status(event_name)) { \
|
||||
ompt_callback_t mycb = \
|
||||
(ompt_callback_t) ompt_callbacks.ompt_callback(event_name); \
|
||||
if (mycb) { \
|
||||
*cb = mycb; \
|
||||
return ompt_get_callback_success; \
|
||||
} \
|
||||
} \
|
||||
return ompt_get_callback_failure;
|
||||
case event_name: \
|
||||
if (ompt_event_implementation_status(event_name)) { \
|
||||
ompt_callback_t mycb = \
|
||||
(ompt_callback_t)ompt_callbacks.ompt_callback(event_name); \
|
||||
if (mycb) { \
|
||||
*cb = mycb; \
|
||||
return ompt_get_callback_success; \
|
||||
} \
|
||||
} \
|
||||
return ompt_get_callback_failure;
|
||||
|
||||
FOREACH_OMPT_EVENT(ompt_event_macro)
|
||||
|
||||
#undef ompt_event_macro
|
||||
|
||||
default: return ompt_get_callback_failure;
|
||||
}
|
||||
default:
|
||||
return ompt_get_callback_failure;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* parallel regions
|
||||
****************************************************************************/
|
||||
|
||||
OMPT_API_ROUTINE ompt_parallel_id_t ompt_get_parallel_id(int ancestor_level)
|
||||
{
|
||||
return __ompt_get_parallel_id_internal(ancestor_level);
|
||||
OMPT_API_ROUTINE ompt_parallel_id_t ompt_get_parallel_id(int ancestor_level) {
|
||||
return __ompt_get_parallel_id_internal(ancestor_level);
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_ROUTINE int ompt_get_parallel_team_size(int ancestor_level)
|
||||
{
|
||||
return __ompt_get_parallel_team_size_internal(ancestor_level);
|
||||
OMPT_API_ROUTINE int ompt_get_parallel_team_size(int ancestor_level) {
|
||||
return __ompt_get_parallel_team_size_internal(ancestor_level);
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_ROUTINE void *ompt_get_parallel_function(int ancestor_level)
|
||||
{
|
||||
return __ompt_get_parallel_function_internal(ancestor_level);
|
||||
OMPT_API_ROUTINE void *ompt_get_parallel_function(int ancestor_level) {
|
||||
return __ompt_get_parallel_function_internal(ancestor_level);
|
||||
}
|
||||
|
||||
OMPT_API_ROUTINE ompt_state_t ompt_get_state(ompt_wait_id_t *ompt_wait_id) {
|
||||
ompt_state_t thread_state = __ompt_get_state_internal(ompt_wait_id);
|
||||
|
||||
OMPT_API_ROUTINE ompt_state_t ompt_get_state(ompt_wait_id_t *ompt_wait_id)
|
||||
{
|
||||
ompt_state_t thread_state = __ompt_get_state_internal(ompt_wait_id);
|
||||
if (thread_state == ompt_state_undefined) {
|
||||
thread_state = ompt_state_work_serial;
|
||||
}
|
||||
|
||||
if (thread_state == ompt_state_undefined) {
|
||||
thread_state = ompt_state_work_serial;
|
||||
}
|
||||
|
||||
return thread_state;
|
||||
return thread_state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* threads
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
OMPT_API_ROUTINE void *ompt_get_idle_frame()
|
||||
{
|
||||
return __ompt_get_idle_frame_internal();
|
||||
OMPT_API_ROUTINE void *ompt_get_idle_frame() {
|
||||
return __ompt_get_idle_frame_internal();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* tasks
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
OMPT_API_ROUTINE ompt_thread_id_t ompt_get_thread_id(void)
|
||||
{
|
||||
return __ompt_get_thread_id_internal();
|
||||
OMPT_API_ROUTINE ompt_thread_id_t ompt_get_thread_id(void) {
|
||||
return __ompt_get_thread_id_internal();
|
||||
}
|
||||
|
||||
OMPT_API_ROUTINE ompt_task_id_t ompt_get_task_id(int depth)
|
||||
{
|
||||
return __ompt_get_task_id_internal(depth);
|
||||
OMPT_API_ROUTINE ompt_task_id_t ompt_get_task_id(int depth) {
|
||||
return __ompt_get_task_id_internal(depth);
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_ROUTINE ompt_frame_t *ompt_get_task_frame(int depth)
|
||||
{
|
||||
return __ompt_get_task_frame_internal(depth);
|
||||
OMPT_API_ROUTINE ompt_frame_t *ompt_get_task_frame(int depth) {
|
||||
return __ompt_get_task_frame_internal(depth);
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_ROUTINE void *ompt_get_task_function(int depth)
|
||||
{
|
||||
return __ompt_get_task_function_internal(depth);
|
||||
OMPT_API_ROUTINE void *ompt_get_task_function(int depth) {
|
||||
return __ompt_get_task_function_internal(depth);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* placeholders
|
||||
****************************************************************************/
|
||||
|
|
@ -440,96 +391,76 @@ OMPT_API_ROUTINE void *ompt_get_task_function(int depth)
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
OMPT_API_PLACEHOLDER void ompt_idle(void)
|
||||
{
|
||||
// This function is a placeholder used to represent the calling context of
|
||||
// idle OpenMP worker threads. It is not meant to be invoked.
|
||||
assert(0);
|
||||
OMPT_API_PLACEHOLDER void ompt_idle(void) {
|
||||
// This function is a placeholder used to represent the calling context of
|
||||
// idle OpenMP worker threads. It is not meant to be invoked.
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_PLACEHOLDER void ompt_overhead(void)
|
||||
{
|
||||
// This function is a placeholder used to represent the OpenMP context of
|
||||
// threads working in the OpenMP runtime. It is not meant to be invoked.
|
||||
assert(0);
|
||||
OMPT_API_PLACEHOLDER void ompt_overhead(void) {
|
||||
// This function is a placeholder used to represent the OpenMP context of
|
||||
// threads working in the OpenMP runtime. It is not meant to be invoked.
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_PLACEHOLDER void ompt_barrier_wait(void)
|
||||
{
|
||||
// This function is a placeholder used to represent the OpenMP context of
|
||||
// threads waiting for a barrier in the OpenMP runtime. It is not meant
|
||||
// to be invoked.
|
||||
assert(0);
|
||||
OMPT_API_PLACEHOLDER void ompt_barrier_wait(void) {
|
||||
// This function is a placeholder used to represent the OpenMP context of
|
||||
// threads waiting for a barrier in the OpenMP runtime. It is not meant
|
||||
// to be invoked.
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_PLACEHOLDER void ompt_task_wait(void)
|
||||
{
|
||||
// This function is a placeholder used to represent the OpenMP context of
|
||||
// threads waiting for a task in the OpenMP runtime. It is not meant
|
||||
// to be invoked.
|
||||
assert(0);
|
||||
OMPT_API_PLACEHOLDER void ompt_task_wait(void) {
|
||||
// This function is a placeholder used to represent the OpenMP context of
|
||||
// threads waiting for a task in the OpenMP runtime. It is not meant
|
||||
// to be invoked.
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_PLACEHOLDER void ompt_mutex_wait(void)
|
||||
{
|
||||
// This function is a placeholder used to represent the OpenMP context of
|
||||
// threads waiting for a mutex in the OpenMP runtime. It is not meant
|
||||
// to be invoked.
|
||||
assert(0);
|
||||
OMPT_API_PLACEHOLDER void ompt_mutex_wait(void) {
|
||||
// This function is a placeholder used to represent the OpenMP context of
|
||||
// threads waiting for a mutex in the OpenMP runtime. It is not meant
|
||||
// to be invoked.
|
||||
assert(0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* compatability
|
||||
****************************************************************************/
|
||||
|
||||
OMPT_API_ROUTINE int ompt_get_ompt_version()
|
||||
{
|
||||
return OMPT_VERSION;
|
||||
}
|
||||
|
||||
|
||||
OMPT_API_ROUTINE int ompt_get_ompt_version() { return OMPT_VERSION; }
|
||||
|
||||
/*****************************************************************************
|
||||
* application-facing API
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| control
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
_OMP_EXTERN void ompt_control(uint64_t command, uint64_t modifier)
|
||||
{
|
||||
if (ompt_enabled && ompt_callbacks.ompt_callback(ompt_event_control)) {
|
||||
ompt_callbacks.ompt_callback(ompt_event_control)(command, modifier);
|
||||
}
|
||||
_OMP_EXTERN void ompt_control(uint64_t command, uint64_t modifier) {
|
||||
if (ompt_enabled && ompt_callbacks.ompt_callback(ompt_event_control)) {
|
||||
ompt_callbacks.ompt_callback(ompt_event_control)(command, modifier);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* API inquiry for tool
|
||||
****************************************************************************/
|
||||
|
||||
static ompt_interface_fn_t ompt_fn_lookup(const char *s)
|
||||
{
|
||||
static ompt_interface_fn_t ompt_fn_lookup(const char *s) {
|
||||
|
||||
#define ompt_interface_fn(fn) \
|
||||
if (strcmp(s, #fn) == 0) return (ompt_interface_fn_t) fn;
|
||||
#define ompt_interface_fn(fn) \
|
||||
if (strcmp(s, #fn) == 0) \
|
||||
return (ompt_interface_fn_t)fn;
|
||||
|
||||
FOREACH_OMPT_INQUIRY_FN(ompt_interface_fn)
|
||||
FOREACH_OMPT_INQUIRY_FN(ompt_interface_fn)
|
||||
|
||||
FOREACH_OMPT_PLACEHOLDER_FN(ompt_interface_fn)
|
||||
FOREACH_OMPT_PLACEHOLDER_FN(ompt_interface_fn)
|
||||
|
||||
return (ompt_interface_fn_t) 0;
|
||||
return (ompt_interface_fn_t)0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,79 +1,71 @@
|
|||
#ifndef __OMPT_INTERNAL_H__
|
||||
#define __OMPT_INTERNAL_H__
|
||||
|
||||
#include "ompt.h"
|
||||
#include "ompt-event-specific.h"
|
||||
#include "ompt.h"
|
||||
|
||||
#define OMPT_VERSION 1
|
||||
|
||||
#define _OMP_EXTERN extern "C"
|
||||
|
||||
#define OMPT_INVOKER(x) \
|
||||
#define OMPT_INVOKER(x) \
|
||||
((x == fork_context_gnu) ? ompt_invoker_program : ompt_invoker_runtime)
|
||||
|
||||
|
||||
#define ompt_callback(e) e ## _callback
|
||||
|
||||
#define ompt_callback(e) e##_callback
|
||||
|
||||
typedef struct ompt_callbacks_s {
|
||||
#define ompt_event_macro(event, callback, eventid) callback ompt_callback(event);
|
||||
#define ompt_event_macro(event, callback, eventid) \
|
||||
callback ompt_callback(event);
|
||||
|
||||
FOREACH_OMPT_EVENT(ompt_event_macro)
|
||||
FOREACH_OMPT_EVENT(ompt_event_macro)
|
||||
|
||||
#undef ompt_event_macro
|
||||
} ompt_callbacks_t;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
ompt_frame_t frame;
|
||||
void* function;
|
||||
ompt_task_id_t task_id;
|
||||
ompt_frame_t frame;
|
||||
void *function;
|
||||
ompt_task_id_t task_id;
|
||||
#if OMP_40_ENABLED
|
||||
int ndeps;
|
||||
ompt_task_dependence_t *deps;
|
||||
int ndeps;
|
||||
ompt_task_dependence_t *deps;
|
||||
#endif /* OMP_40_ENABLED */
|
||||
} ompt_task_info_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
ompt_parallel_id_t parallel_id;
|
||||
void *microtask;
|
||||
ompt_parallel_id_t parallel_id;
|
||||
void *microtask;
|
||||
} ompt_team_info_t;
|
||||
|
||||
|
||||
typedef struct ompt_lw_taskteam_s {
|
||||
ompt_team_info_t ompt_team_info;
|
||||
ompt_task_info_t ompt_task_info;
|
||||
struct ompt_lw_taskteam_s *parent;
|
||||
ompt_team_info_t ompt_team_info;
|
||||
ompt_task_info_t ompt_task_info;
|
||||
struct ompt_lw_taskteam_s *parent;
|
||||
} ompt_lw_taskteam_t;
|
||||
|
||||
|
||||
typedef struct ompt_parallel_info_s {
|
||||
ompt_task_id_t parent_task_id; /* id of parent task */
|
||||
ompt_parallel_id_t parallel_id; /* id of parallel region */
|
||||
ompt_frame_t *parent_task_frame; /* frame data of parent task */
|
||||
void *parallel_function; /* pointer to outlined function */
|
||||
ompt_task_id_t parent_task_id; /* id of parent task */
|
||||
ompt_parallel_id_t parallel_id; /* id of parallel region */
|
||||
ompt_frame_t *parent_task_frame; /* frame data of parent task */
|
||||
void *parallel_function; /* pointer to outlined function */
|
||||
} ompt_parallel_info_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
ompt_state_t state;
|
||||
ompt_wait_id_t wait_id;
|
||||
void *idle_frame;
|
||||
ompt_state_t state;
|
||||
ompt_wait_id_t wait_id;
|
||||
void *idle_frame;
|
||||
} ompt_thread_info_t;
|
||||
|
||||
|
||||
extern ompt_callbacks_t ompt_callbacks;
|
||||
|
||||
#if OMP_40_ENABLED && OMPT_SUPPORT && OMPT_TRACE
|
||||
#if USE_FAST_MEMORY
|
||||
# define KMP_OMPT_DEPS_ALLOC __kmp_fast_allocate
|
||||
# define KMP_OMPT_DEPS_FREE __kmp_fast_free
|
||||
# else
|
||||
# define KMP_OMPT_DEPS_ALLOC __kmp_thread_malloc
|
||||
# define KMP_OMPT_DEPS_FREE __kmp_thread_free
|
||||
# endif
|
||||
#define KMP_OMPT_DEPS_ALLOC __kmp_fast_allocate
|
||||
#define KMP_OMPT_DEPS_FREE __kmp_fast_free
|
||||
#else
|
||||
#define KMP_OMPT_DEPS_ALLOC __kmp_thread_malloc
|
||||
#define KMP_OMPT_DEPS_FREE __kmp_thread_free
|
||||
#endif
|
||||
#endif /* OMP_40_ENABLED && OMPT_SUPPORT && OMPT_TRACE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
// macros
|
||||
//******************************************************************************
|
||||
|
||||
#define GTID_TO_OMPT_THREAD_ID(id) ((ompt_thread_id_t) (id >=0) ? id + 1: 0)
|
||||
#define GTID_TO_OMPT_THREAD_ID(id) ((ompt_thread_id_t)(id >= 0) ? id + 1 : 0)
|
||||
|
||||
#define LWT_FROM_TEAM(team) (team)->t.ompt_serialized_team_info;
|
||||
|
||||
|
|
@ -26,10 +26,10 @@
|
|||
// when using fetch_and_add to generate the IDs, there isn't any reason to waste
|
||||
// bits for thread id.
|
||||
#if 0
|
||||
#define NEXT_ID(id_ptr,tid) \
|
||||
#define NEXT_ID(id_ptr, tid) \
|
||||
((KMP_TEST_THEN_INC64(id_ptr) << OMPT_THREAD_ID_BITS) | (tid))
|
||||
#else
|
||||
#define NEXT_ID(id_ptr,tid) (KMP_TEST_THEN_INC64((volatile kmp_int64 *)id_ptr))
|
||||
#define NEXT_ID(id_ptr, tid) (KMP_TEST_THEN_INC64((volatile kmp_int64 *)id_ptr))
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
|
|
@ -43,89 +43,87 @@
|
|||
// kept consistent
|
||||
//----------------------------------------------------------
|
||||
|
||||
ompt_team_info_t *
|
||||
__ompt_get_teaminfo(int depth, int *size)
|
||||
{
|
||||
kmp_info_t *thr = ompt_get_thread();
|
||||
ompt_team_info_t *__ompt_get_teaminfo(int depth, int *size) {
|
||||
kmp_info_t *thr = ompt_get_thread();
|
||||
|
||||
if (thr) {
|
||||
kmp_team *team = thr->th.th_team;
|
||||
if (team == NULL) return NULL;
|
||||
if (thr) {
|
||||
kmp_team *team = thr->th.th_team;
|
||||
if (team == NULL)
|
||||
return NULL;
|
||||
|
||||
ompt_lw_taskteam_t *lwt = LWT_FROM_TEAM(team);
|
||||
ompt_lw_taskteam_t *lwt = LWT_FROM_TEAM(team);
|
||||
|
||||
while(depth > 0) {
|
||||
// next lightweight team (if any)
|
||||
if (lwt) lwt = lwt->parent;
|
||||
while (depth > 0) {
|
||||
// next lightweight team (if any)
|
||||
if (lwt)
|
||||
lwt = lwt->parent;
|
||||
|
||||
// next heavyweight team (if any) after
|
||||
// lightweight teams are exhausted
|
||||
if (!lwt && team) {
|
||||
team=team->t.t_parent;
|
||||
if (team) {
|
||||
lwt = LWT_FROM_TEAM(team);
|
||||
}
|
||||
}
|
||||
|
||||
depth--;
|
||||
// next heavyweight team (if any) after
|
||||
// lightweight teams are exhausted
|
||||
if (!lwt && team) {
|
||||
team = team->t.t_parent;
|
||||
if (team) {
|
||||
lwt = LWT_FROM_TEAM(team);
|
||||
}
|
||||
}
|
||||
|
||||
if (lwt) {
|
||||
// lightweight teams have one task
|
||||
if (size) *size = 1;
|
||||
|
||||
// return team info for lightweight team
|
||||
return &lwt->ompt_team_info;
|
||||
} else if (team) {
|
||||
// extract size from heavyweight team
|
||||
if (size) *size = team->t.t_nproc;
|
||||
|
||||
// return team info for heavyweight team
|
||||
return &team->t.ompt_team_info;
|
||||
}
|
||||
depth--;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
if (lwt) {
|
||||
// lightweight teams have one task
|
||||
if (size)
|
||||
*size = 1;
|
||||
|
||||
// return team info for lightweight team
|
||||
return &lwt->ompt_team_info;
|
||||
} else if (team) {
|
||||
// extract size from heavyweight team
|
||||
if (size)
|
||||
*size = team->t.t_nproc;
|
||||
|
||||
// return team info for heavyweight team
|
||||
return &team->t.ompt_team_info;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ompt_task_info_t *__ompt_get_taskinfo(int depth) {
|
||||
ompt_task_info_t *info = NULL;
|
||||
kmp_info_t *thr = ompt_get_thread();
|
||||
|
||||
ompt_task_info_t *
|
||||
__ompt_get_taskinfo(int depth)
|
||||
{
|
||||
ompt_task_info_t *info = NULL;
|
||||
kmp_info_t *thr = ompt_get_thread();
|
||||
if (thr) {
|
||||
kmp_taskdata_t *taskdata = thr->th.th_current_task;
|
||||
ompt_lw_taskteam_t *lwt = LWT_FROM_TEAM(taskdata->td_team);
|
||||
|
||||
if (thr) {
|
||||
kmp_taskdata_t *taskdata = thr->th.th_current_task;
|
||||
ompt_lw_taskteam_t *lwt = LWT_FROM_TEAM(taskdata->td_team);
|
||||
while (depth > 0) {
|
||||
// next lightweight team (if any)
|
||||
if (lwt)
|
||||
lwt = lwt->parent;
|
||||
|
||||
while (depth > 0) {
|
||||
// next lightweight team (if any)
|
||||
if (lwt) lwt = lwt->parent;
|
||||
|
||||
// next heavyweight team (if any) after
|
||||
// lightweight teams are exhausted
|
||||
if (!lwt && taskdata) {
|
||||
taskdata = taskdata->td_parent;
|
||||
if (taskdata) {
|
||||
lwt = LWT_FROM_TEAM(taskdata->td_team);
|
||||
}
|
||||
}
|
||||
depth--;
|
||||
}
|
||||
|
||||
if (lwt) {
|
||||
info = &lwt->ompt_task_info;
|
||||
} else if (taskdata) {
|
||||
info = &taskdata->ompt_task_info;
|
||||
// next heavyweight team (if any) after
|
||||
// lightweight teams are exhausted
|
||||
if (!lwt && taskdata) {
|
||||
taskdata = taskdata->td_parent;
|
||||
if (taskdata) {
|
||||
lwt = LWT_FROM_TEAM(taskdata->td_team);
|
||||
}
|
||||
}
|
||||
depth--;
|
||||
}
|
||||
|
||||
return info;
|
||||
if (lwt) {
|
||||
info = &lwt->ompt_task_info;
|
||||
} else if (taskdata) {
|
||||
info = &taskdata->ompt_task_info;
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// interface operations
|
||||
//******************************************************************************
|
||||
|
|
@ -134,204 +132,151 @@ __ompt_get_taskinfo(int depth)
|
|||
// thread support
|
||||
//----------------------------------------------------------
|
||||
|
||||
ompt_parallel_id_t
|
||||
__ompt_thread_id_new()
|
||||
{
|
||||
static uint64_t ompt_thread_id = 1;
|
||||
return NEXT_ID(&ompt_thread_id, 0);
|
||||
ompt_parallel_id_t __ompt_thread_id_new() {
|
||||
static uint64_t ompt_thread_id = 1;
|
||||
return NEXT_ID(&ompt_thread_id, 0);
|
||||
}
|
||||
|
||||
void
|
||||
__ompt_thread_begin(ompt_thread_type_t thread_type, int gtid)
|
||||
{
|
||||
ompt_callbacks.ompt_callback(ompt_event_thread_begin)(
|
||||
thread_type, GTID_TO_OMPT_THREAD_ID(gtid));
|
||||
void __ompt_thread_begin(ompt_thread_type_t thread_type, int gtid) {
|
||||
ompt_callbacks.ompt_callback(ompt_event_thread_begin)(
|
||||
thread_type, GTID_TO_OMPT_THREAD_ID(gtid));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__ompt_thread_end(ompt_thread_type_t thread_type, int gtid)
|
||||
{
|
||||
ompt_callbacks.ompt_callback(ompt_event_thread_end)(
|
||||
thread_type, GTID_TO_OMPT_THREAD_ID(gtid));
|
||||
void __ompt_thread_end(ompt_thread_type_t thread_type, int gtid) {
|
||||
ompt_callbacks.ompt_callback(ompt_event_thread_end)(
|
||||
thread_type, GTID_TO_OMPT_THREAD_ID(gtid));
|
||||
}
|
||||
|
||||
ompt_thread_id_t __ompt_get_thread_id_internal() {
|
||||
// FIXME: until we have a better way of assigning ids, use __kmp_get_gtid
|
||||
// since the return value might be negative, we need to test that before
|
||||
// assigning it to an ompt_thread_id_t, which is unsigned.
|
||||
int id = __kmp_get_gtid();
|
||||
assert(id >= 0);
|
||||
|
||||
ompt_thread_id_t
|
||||
__ompt_get_thread_id_internal()
|
||||
{
|
||||
// FIXME
|
||||
// until we have a better way of assigning ids, use __kmp_get_gtid
|
||||
// since the return value might be negative, we need to test that before
|
||||
// assigning it to an ompt_thread_id_t, which is unsigned.
|
||||
int id = __kmp_get_gtid();
|
||||
assert(id >= 0);
|
||||
|
||||
return GTID_TO_OMPT_THREAD_ID(id);
|
||||
return GTID_TO_OMPT_THREAD_ID(id);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// state support
|
||||
//----------------------------------------------------------
|
||||
|
||||
void
|
||||
__ompt_thread_assign_wait_id(void *variable)
|
||||
{
|
||||
int gtid = __kmp_gtid_get_specific();
|
||||
kmp_info_t *ti = ompt_get_thread_gtid(gtid);
|
||||
void __ompt_thread_assign_wait_id(void *variable) {
|
||||
int gtid = __kmp_gtid_get_specific();
|
||||
kmp_info_t *ti = ompt_get_thread_gtid(gtid);
|
||||
|
||||
ti->th.ompt_thread_info.wait_id = (ompt_wait_id_t) variable;
|
||||
ti->th.ompt_thread_info.wait_id = (ompt_wait_id_t)variable;
|
||||
}
|
||||
|
||||
ompt_state_t
|
||||
__ompt_get_state_internal(ompt_wait_id_t *ompt_wait_id)
|
||||
{
|
||||
kmp_info_t *ti = ompt_get_thread();
|
||||
ompt_state_t __ompt_get_state_internal(ompt_wait_id_t *ompt_wait_id) {
|
||||
kmp_info_t *ti = ompt_get_thread();
|
||||
|
||||
if (ti) {
|
||||
if (ompt_wait_id)
|
||||
*ompt_wait_id = ti->th.ompt_thread_info.wait_id;
|
||||
return ti->th.ompt_thread_info.state;
|
||||
}
|
||||
return ompt_state_undefined;
|
||||
if (ti) {
|
||||
if (ompt_wait_id)
|
||||
*ompt_wait_id = ti->th.ompt_thread_info.wait_id;
|
||||
return ti->th.ompt_thread_info.state;
|
||||
}
|
||||
return ompt_state_undefined;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// idle frame support
|
||||
//----------------------------------------------------------
|
||||
|
||||
void *
|
||||
__ompt_get_idle_frame_internal(void)
|
||||
{
|
||||
kmp_info_t *ti = ompt_get_thread();
|
||||
return ti ? ti->th.ompt_thread_info.idle_frame : NULL;
|
||||
void *__ompt_get_idle_frame_internal(void) {
|
||||
kmp_info_t *ti = ompt_get_thread();
|
||||
return ti ? ti->th.ompt_thread_info.idle_frame : NULL;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// parallel region support
|
||||
//----------------------------------------------------------
|
||||
|
||||
ompt_parallel_id_t
|
||||
__ompt_parallel_id_new(int gtid)
|
||||
{
|
||||
static uint64_t ompt_parallel_id = 1;
|
||||
return gtid >= 0 ? NEXT_ID(&ompt_parallel_id, gtid) : 0;
|
||||
ompt_parallel_id_t __ompt_parallel_id_new(int gtid) {
|
||||
static uint64_t ompt_parallel_id = 1;
|
||||
return gtid >= 0 ? NEXT_ID(&ompt_parallel_id, gtid) : 0;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
__ompt_get_parallel_function_internal(int depth)
|
||||
{
|
||||
ompt_team_info_t *info = __ompt_get_teaminfo(depth, NULL);
|
||||
void *function = info ? info->microtask : NULL;
|
||||
return function;
|
||||
void *__ompt_get_parallel_function_internal(int depth) {
|
||||
ompt_team_info_t *info = __ompt_get_teaminfo(depth, NULL);
|
||||
void *function = info ? info->microtask : NULL;
|
||||
return function;
|
||||
}
|
||||
|
||||
|
||||
ompt_parallel_id_t
|
||||
__ompt_get_parallel_id_internal(int depth)
|
||||
{
|
||||
ompt_team_info_t *info = __ompt_get_teaminfo(depth, NULL);
|
||||
ompt_parallel_id_t id = info ? info->parallel_id : 0;
|
||||
return id;
|
||||
ompt_parallel_id_t __ompt_get_parallel_id_internal(int depth) {
|
||||
ompt_team_info_t *info = __ompt_get_teaminfo(depth, NULL);
|
||||
ompt_parallel_id_t id = info ? info->parallel_id : 0;
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
__ompt_get_parallel_team_size_internal(int depth)
|
||||
{
|
||||
// initialize the return value with the error value.
|
||||
// if there is a team at the specified depth, the default
|
||||
// value will be overwritten the size of that team.
|
||||
int size = -1;
|
||||
(void) __ompt_get_teaminfo(depth, &size);
|
||||
return size;
|
||||
int __ompt_get_parallel_team_size_internal(int depth) {
|
||||
// initialize the return value with the error value.
|
||||
// if there is a team at the specified depth, the default
|
||||
// value will be overwritten the size of that team.
|
||||
int size = -1;
|
||||
(void)__ompt_get_teaminfo(depth, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// lightweight task team support
|
||||
//----------------------------------------------------------
|
||||
|
||||
void
|
||||
__ompt_lw_taskteam_init(ompt_lw_taskteam_t *lwt, kmp_info_t *thr,
|
||||
int gtid, void *microtask,
|
||||
ompt_parallel_id_t ompt_pid)
|
||||
{
|
||||
lwt->ompt_team_info.parallel_id = ompt_pid;
|
||||
lwt->ompt_team_info.microtask = microtask;
|
||||
lwt->ompt_task_info.task_id = 0;
|
||||
lwt->ompt_task_info.frame.reenter_runtime_frame = NULL;
|
||||
lwt->ompt_task_info.frame.exit_runtime_frame = NULL;
|
||||
lwt->ompt_task_info.function = NULL;
|
||||
lwt->parent = 0;
|
||||
void __ompt_lw_taskteam_init(ompt_lw_taskteam_t *lwt, kmp_info_t *thr, int gtid,
|
||||
void *microtask, ompt_parallel_id_t ompt_pid) {
|
||||
lwt->ompt_team_info.parallel_id = ompt_pid;
|
||||
lwt->ompt_team_info.microtask = microtask;
|
||||
lwt->ompt_task_info.task_id = 0;
|
||||
lwt->ompt_task_info.frame.reenter_runtime_frame = NULL;
|
||||
lwt->ompt_task_info.frame.exit_runtime_frame = NULL;
|
||||
lwt->ompt_task_info.function = NULL;
|
||||
lwt->parent = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__ompt_lw_taskteam_link(ompt_lw_taskteam_t *lwt, kmp_info_t *thr)
|
||||
{
|
||||
ompt_lw_taskteam_t *my_parent = thr->th.th_team->t.ompt_serialized_team_info;
|
||||
lwt->parent = my_parent;
|
||||
thr->th.th_team->t.ompt_serialized_team_info = lwt;
|
||||
void __ompt_lw_taskteam_link(ompt_lw_taskteam_t *lwt, kmp_info_t *thr) {
|
||||
ompt_lw_taskteam_t *my_parent = thr->th.th_team->t.ompt_serialized_team_info;
|
||||
lwt->parent = my_parent;
|
||||
thr->th.th_team->t.ompt_serialized_team_info = lwt;
|
||||
}
|
||||
|
||||
|
||||
ompt_lw_taskteam_t *
|
||||
__ompt_lw_taskteam_unlink(kmp_info_t *thr)
|
||||
{
|
||||
ompt_lw_taskteam_t *lwtask = thr->th.th_team->t.ompt_serialized_team_info;
|
||||
if (lwtask) thr->th.th_team->t.ompt_serialized_team_info = lwtask->parent;
|
||||
return lwtask;
|
||||
ompt_lw_taskteam_t *__ompt_lw_taskteam_unlink(kmp_info_t *thr) {
|
||||
ompt_lw_taskteam_t *lwtask = thr->th.th_team->t.ompt_serialized_team_info;
|
||||
if (lwtask)
|
||||
thr->th.th_team->t.ompt_serialized_team_info = lwtask->parent;
|
||||
return lwtask;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// task support
|
||||
//----------------------------------------------------------
|
||||
|
||||
ompt_task_id_t
|
||||
__ompt_task_id_new(int gtid)
|
||||
{
|
||||
static uint64_t ompt_task_id = 1;
|
||||
return NEXT_ID(&ompt_task_id, gtid);
|
||||
ompt_task_id_t __ompt_task_id_new(int gtid) {
|
||||
static uint64_t ompt_task_id = 1;
|
||||
return NEXT_ID(&ompt_task_id, gtid);
|
||||
}
|
||||
|
||||
|
||||
ompt_task_id_t
|
||||
__ompt_get_task_id_internal(int depth)
|
||||
{
|
||||
ompt_task_info_t *info = __ompt_get_taskinfo(depth);
|
||||
ompt_task_id_t task_id = info ? info->task_id : 0;
|
||||
return task_id;
|
||||
ompt_task_id_t __ompt_get_task_id_internal(int depth) {
|
||||
ompt_task_info_t *info = __ompt_get_taskinfo(depth);
|
||||
ompt_task_id_t task_id = info ? info->task_id : 0;
|
||||
return task_id;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
__ompt_get_task_function_internal(int depth)
|
||||
{
|
||||
ompt_task_info_t *info = __ompt_get_taskinfo(depth);
|
||||
void *function = info ? info->function : NULL;
|
||||
return function;
|
||||
void *__ompt_get_task_function_internal(int depth) {
|
||||
ompt_task_info_t *info = __ompt_get_taskinfo(depth);
|
||||
void *function = info ? info->function : NULL;
|
||||
return function;
|
||||
}
|
||||
|
||||
|
||||
ompt_frame_t *
|
||||
__ompt_get_task_frame_internal(int depth)
|
||||
{
|
||||
ompt_task_info_t *info = __ompt_get_taskinfo(depth);
|
||||
ompt_frame_t *frame = info ? frame = &info->frame : NULL;
|
||||
return frame;
|
||||
ompt_frame_t *__ompt_get_task_frame_internal(int depth) {
|
||||
ompt_task_info_t *info = __ompt_get_taskinfo(depth);
|
||||
ompt_frame_t *frame = info ? frame = &info->frame : NULL;
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// team support
|
||||
//----------------------------------------------------------
|
||||
|
||||
void
|
||||
__ompt_team_assign_id(kmp_team_t *team, ompt_parallel_id_t ompt_pid)
|
||||
{
|
||||
team->t.ompt_team_info.parallel_id = ompt_pid;
|
||||
void __ompt_team_assign_id(kmp_team_t *team, ompt_parallel_id_t ompt_pid) {
|
||||
team->t.ompt_team_info.parallel_id = ompt_pid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
typedef kmp_info_t ompt_thread_t;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* forward declarations
|
||||
****************************************************************************/
|
||||
|
|
@ -22,9 +20,9 @@ void __ompt_lw_taskteam_init(ompt_lw_taskteam_t *lwt, ompt_thread_t *thr,
|
|||
int gtid, void *microtask,
|
||||
ompt_parallel_id_t ompt_pid);
|
||||
|
||||
void __ompt_lw_taskteam_link(ompt_lw_taskteam_t *lwt, ompt_thread_t *thr);
|
||||
void __ompt_lw_taskteam_link(ompt_lw_taskteam_t *lwt, ompt_thread_t *thr);
|
||||
|
||||
ompt_lw_taskteam_t * __ompt_lw_taskteam_unlink(ompt_thread_t *thr);
|
||||
ompt_lw_taskteam_t *__ompt_lw_taskteam_unlink(ompt_thread_t *thr);
|
||||
|
||||
ompt_parallel_id_t __ompt_parallel_id_new(int gtid);
|
||||
ompt_task_id_t __ompt_task_id_new(int gtid);
|
||||
|
|
@ -43,8 +41,6 @@ ompt_task_id_t __ompt_get_task_id_internal(int depth);
|
|||
|
||||
ompt_frame_t *__ompt_get_task_frame_internal(int depth);
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* macros
|
||||
****************************************************************************/
|
||||
|
|
@ -53,38 +49,25 @@ ompt_frame_t *__ompt_get_task_frame_internal(int depth);
|
|||
#define OMPT_HAVE_PSAPI KMP_HAVE_PSAPI
|
||||
#define OMPT_STR_MATCH(haystack, needle) __kmp_str_match(haystack, 0, needle)
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// inline functions
|
||||
//******************************************************************************
|
||||
|
||||
inline ompt_thread_t *
|
||||
ompt_get_thread_gtid(int gtid)
|
||||
{
|
||||
return (gtid >= 0) ? __kmp_thread_from_gtid(gtid) : NULL;
|
||||
inline ompt_thread_t *ompt_get_thread_gtid(int gtid) {
|
||||
return (gtid >= 0) ? __kmp_thread_from_gtid(gtid) : NULL;
|
||||
}
|
||||
|
||||
|
||||
inline ompt_thread_t *
|
||||
ompt_get_thread()
|
||||
{
|
||||
int gtid = __kmp_get_gtid();
|
||||
return ompt_get_thread_gtid(gtid);
|
||||
inline ompt_thread_t *ompt_get_thread() {
|
||||
int gtid = __kmp_get_gtid();
|
||||
return ompt_get_thread_gtid(gtid);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
ompt_set_thread_state(ompt_thread_t *thread, ompt_state_t state)
|
||||
{
|
||||
thread->th.ompt_thread_info.state = state;
|
||||
inline void ompt_set_thread_state(ompt_thread_t *thread, ompt_state_t state) {
|
||||
thread->th.ompt_thread_info.state = state;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
ompt_get_runtime_version()
|
||||
{
|
||||
return &__kmp_version_lib_ver[KMP_VERSION_MAGIC_LEN];
|
||||
inline const char *ompt_get_runtime_version() {
|
||||
return &__kmp_version_lib_ver[KMP_VERSION_MAGIC_LEN];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
* race detection in OpenMP programs.
|
||||
*/
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
|
|
@ -18,46 +17,92 @@
|
|||
#include <stdio.h>
|
||||
|
||||
typedef unsigned long uptr;
|
||||
typedef signed long sptr;
|
||||
typedef signed long sptr;
|
||||
|
||||
extern "C" __attribute__((weak)) void AnnotateHappensBefore(const char *f, int l, uptr addr) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateHappensAfter(const char *f, int l, uptr addr) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateCondVarSignal(const char *f, int l, uptr cv) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateCondVarSignalAll(const char *f, int l, uptr cv) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateMutexIsNotPHB(const char *f, int l, uptr mu) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateCondVarWait(const char *f, int l, uptr cv, uptr lock) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateRWLockCreate(const char *f, int l, uptr m) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateRWLockCreateStatic(const char *f, int l, uptr m) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateRWLockDestroy(const char *f, int l, uptr m) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateRWLockAcquired(const char *f, int l, uptr m, uptr is_w) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateRWLockReleased(const char *f, int l, uptr m, uptr is_w) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateTraceMemory(const char *f, int l, uptr mem) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateFlushState(const char *f, int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateNewMemory(const char *f, int l, uptr mem, uptr size) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateNoOp(const char *f, int l, uptr mem) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateFlushExpectedRaces(const char *f, int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateEnableRaceDetection( const char *f, int l, int enable) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateMutexIsUsedAsCondVar( const char *f, int l, uptr mu) {}
|
||||
extern "C" __attribute__((weak)) void AnnotatePCQGet( const char *f, int l, uptr pcq) {}
|
||||
extern "C" __attribute__((weak)) void AnnotatePCQPut( const char *f, int l, uptr pcq) {}
|
||||
extern "C" __attribute__((weak)) void AnnotatePCQDestroy( const char *f, int l, uptr pcq) {}
|
||||
extern "C" __attribute__((weak)) void AnnotatePCQCreate( const char *f, int l, uptr pcq) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateExpectRace( const char *f, int l, uptr mem, char *desc) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateBenignRaceSized( const char *f, int l, uptr mem, uptr size, char *desc) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateBenignRace( const char *f, int l, uptr mem, char *desc) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreReadsBegin(const char *f, int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreReadsEnd(const char *f, int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreWritesBegin(const char *f, int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreWritesEnd(const char *f, int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreSyncBegin(const char *f, int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreSyncEnd(const char *f, int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotatePublishMemoryRange( const char *f, int l, uptr addr, uptr size) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateUnpublishMemoryRange( const char *f, int l, uptr addr, uptr size) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateThreadName( const char *f, int l, char *name) {}
|
||||
extern "C" __attribute__((weak)) void WTFAnnotateHappensBefore(const char *f, int l, uptr addr) {}
|
||||
extern "C" __attribute__((weak)) void WTFAnnotateHappensAfter(const char *f, int l, uptr addr) {}
|
||||
extern "C" __attribute__((weak)) void WTFAnnotateBenignRaceSized( const char *f, int l, uptr mem, uptr sz, char *desc) {}
|
||||
extern "C" __attribute__((weak)) int RunningOnValgrind() {return 0;}
|
||||
extern "C" __attribute__((weak)) double ValgrindSlowdown(void) {return 0;}
|
||||
extern "C" __attribute__((weak)) const char __attribute__((weak))* ThreadSanitizerQuery(const char *query) {return 0;}
|
||||
extern "C" __attribute__((weak)) void AnnotateMemoryIsInitialized(const char *f, int l, uptr mem, uptr sz) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateHappensBefore(const char *f,
|
||||
int l, uptr addr) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateHappensAfter(const char *f, int l,
|
||||
uptr addr) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateCondVarSignal(const char *f,
|
||||
int l, uptr cv) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateCondVarSignalAll(const char *f,
|
||||
int l, uptr cv) {
|
||||
}
|
||||
extern "C" __attribute__((weak)) void AnnotateMutexIsNotPHB(const char *f,
|
||||
int l, uptr mu) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateCondVarWait(const char *f, int l,
|
||||
uptr cv, uptr lock) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateRWLockCreate(const char *f, int l,
|
||||
uptr m) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
AnnotateRWLockCreateStatic(const char *f, int l, uptr m) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateRWLockDestroy(const char *f,
|
||||
int l, uptr m) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
AnnotateRWLockAcquired(const char *f, int l, uptr m, uptr is_w) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
AnnotateRWLockReleased(const char *f, int l, uptr m, uptr is_w) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateTraceMemory(const char *f, int l,
|
||||
uptr mem) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateFlushState(const char *f, int l) {
|
||||
}
|
||||
extern "C" __attribute__((weak)) void AnnotateNewMemory(const char *f, int l,
|
||||
uptr mem, uptr size) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateNoOp(const char *f, int l,
|
||||
uptr mem) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateFlushExpectedRaces(const char *f,
|
||||
int l) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
AnnotateEnableRaceDetection(const char *f, int l, int enable) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
AnnotateMutexIsUsedAsCondVar(const char *f, int l, uptr mu) {}
|
||||
extern "C" __attribute__((weak)) void AnnotatePCQGet(const char *f, int l,
|
||||
uptr pcq) {}
|
||||
extern "C" __attribute__((weak)) void AnnotatePCQPut(const char *f, int l,
|
||||
uptr pcq) {}
|
||||
extern "C" __attribute__((weak)) void AnnotatePCQDestroy(const char *f, int l,
|
||||
uptr pcq) {}
|
||||
extern "C" __attribute__((weak)) void AnnotatePCQCreate(const char *f, int l,
|
||||
uptr pcq) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateExpectRace(const char *f, int l,
|
||||
uptr mem, char *desc) {
|
||||
}
|
||||
extern "C" __attribute__((weak)) void
|
||||
AnnotateBenignRaceSized(const char *f, int l, uptr mem, uptr size, char *desc) {
|
||||
}
|
||||
extern "C" __attribute__((weak)) void AnnotateBenignRace(const char *f, int l,
|
||||
uptr mem, char *desc) {
|
||||
}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreReadsBegin(const char *f,
|
||||
int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreReadsEnd(const char *f,
|
||||
int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreWritesBegin(const char *f,
|
||||
int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreWritesEnd(const char *f,
|
||||
int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreSyncBegin(const char *f,
|
||||
int l) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateIgnoreSyncEnd(const char *f,
|
||||
int l) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
AnnotatePublishMemoryRange(const char *f, int l, uptr addr, uptr size) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
AnnotateUnpublishMemoryRange(const char *f, int l, uptr addr, uptr size) {}
|
||||
extern "C" __attribute__((weak)) void AnnotateThreadName(const char *f, int l,
|
||||
char *name) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
WTFAnnotateHappensBefore(const char *f, int l, uptr addr) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
WTFAnnotateHappensAfter(const char *f, int l, uptr addr) {}
|
||||
extern "C" __attribute__((weak)) void
|
||||
WTFAnnotateBenignRaceSized(const char *f, int l, uptr mem, uptr sz,
|
||||
char *desc) {}
|
||||
extern "C" __attribute__((weak)) int RunningOnValgrind() { return 0; }
|
||||
extern "C" __attribute__((weak)) double ValgrindSlowdown(void) { return 0; }
|
||||
extern "C" __attribute__((weak)) const char __attribute__((weak)) *
|
||||
ThreadSanitizerQuery(const char *query) {
|
||||
return 0;
|
||||
}
|
||||
extern "C" __attribute__((weak)) void
|
||||
AnnotateMemoryIsInitialized(const char *f, int l, uptr mem, uptr sz) {}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
* race detection in OpenMP programs.
|
||||
*/
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
|
|
@ -21,7 +20,7 @@
|
|||
|
||||
/* types as used in tsan/rtl/tsan_interface_ann.cc */
|
||||
typedef unsigned long uptr;
|
||||
typedef signed long sptr;
|
||||
typedef signed long sptr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -44,30 +43,32 @@ void AnnotateFlushState(const char *f, int l);
|
|||
void AnnotateNewMemory(const char *f, int l, uptr mem, uptr size);
|
||||
void AnnotateNoOp(const char *f, int l, uptr mem);
|
||||
void AnnotateFlushExpectedRaces(const char *f, int l);
|
||||
void AnnotateEnableRaceDetection( const char *f, int l, int enable);
|
||||
void AnnotateMutexIsUsedAsCondVar( const char *f, int l, uptr mu);
|
||||
void AnnotatePCQGet( const char *f, int l, uptr pcq);
|
||||
void AnnotatePCQPut( const char *f, int l, uptr pcq);
|
||||
void AnnotatePCQDestroy( const char *f, int l, uptr pcq);
|
||||
void AnnotatePCQCreate( const char *f, int l, uptr pcq);
|
||||
void AnnotateExpectRace( const char *f, int l, uptr mem, char *desc);
|
||||
void AnnotateBenignRaceSized( const char *f, int l, uptr mem, uptr size, char *desc);
|
||||
void AnnotateBenignRace( const char *f, int l, uptr mem, char *desc);
|
||||
void AnnotateEnableRaceDetection(const char *f, int l, int enable);
|
||||
void AnnotateMutexIsUsedAsCondVar(const char *f, int l, uptr mu);
|
||||
void AnnotatePCQGet(const char *f, int l, uptr pcq);
|
||||
void AnnotatePCQPut(const char *f, int l, uptr pcq);
|
||||
void AnnotatePCQDestroy(const char *f, int l, uptr pcq);
|
||||
void AnnotatePCQCreate(const char *f, int l, uptr pcq);
|
||||
void AnnotateExpectRace(const char *f, int l, uptr mem, char *desc);
|
||||
void AnnotateBenignRaceSized(const char *f, int l, uptr mem, uptr size,
|
||||
char *desc);
|
||||
void AnnotateBenignRace(const char *f, int l, uptr mem, char *desc);
|
||||
void AnnotateIgnoreReadsBegin(const char *f, int l);
|
||||
void AnnotateIgnoreReadsEnd(const char *f, int l);
|
||||
void AnnotateIgnoreWritesBegin(const char *f, int l);
|
||||
void AnnotateIgnoreWritesEnd(const char *f, int l);
|
||||
void AnnotateIgnoreSyncBegin(const char *f, int l);
|
||||
void AnnotateIgnoreSyncEnd(const char *f, int l);
|
||||
void AnnotatePublishMemoryRange( const char *f, int l, uptr addr, uptr size);
|
||||
void AnnotateUnpublishMemoryRange( const char *f, int l, uptr addr, uptr size);
|
||||
void AnnotateThreadName( const char *f, int l, char *name);
|
||||
void AnnotatePublishMemoryRange(const char *f, int l, uptr addr, uptr size);
|
||||
void AnnotateUnpublishMemoryRange(const char *f, int l, uptr addr, uptr size);
|
||||
void AnnotateThreadName(const char *f, int l, char *name);
|
||||
void WTFAnnotateHappensBefore(const char *f, int l, uptr addr);
|
||||
void WTFAnnotateHappensAfter(const char *f, int l, uptr addr);
|
||||
void WTFAnnotateBenignRaceSized( const char *f, int l, uptr mem, uptr sz, char *desc);
|
||||
void WTFAnnotateBenignRaceSized(const char *f, int l, uptr mem, uptr sz,
|
||||
char *desc);
|
||||
int RunningOnValgrind();
|
||||
double ValgrindSlowdown(void);
|
||||
const char * ThreadSanitizerQuery(const char *query);
|
||||
const char *ThreadSanitizerQuery(const char *query);
|
||||
void AnnotateMemoryIsInitialized(const char *f, int l, uptr mem, uptr sz);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -75,17 +76,27 @@ void AnnotateMemoryIsInitialized(const char *f, int l, uptr mem, uptr sz);
|
|||
#endif
|
||||
|
||||
#ifdef TSAN_SUPPORT
|
||||
#define ANNOTATE_HAPPENS_AFTER(addr) AnnotateHappensAfter(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_HAPPENS_BEFORE(addr) AnnotateHappensBefore(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_IGNORE_WRITES_BEGIN() AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
|
||||
#define ANNOTATE_HAPPENS_AFTER(addr) \
|
||||
AnnotateHappensAfter(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_HAPPENS_BEFORE(addr) \
|
||||
AnnotateHappensBefore(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_IGNORE_WRITES_BEGIN() \
|
||||
AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
|
||||
#define ANNOTATE_IGNORE_WRITES_END() AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
|
||||
#define ANNOTATE_RWLOCK_CREATE(lck) AnnotateRWLockCreate(__FILE__, __LINE__, (uptr)lck)
|
||||
#define ANNOTATE_RWLOCK_RELEASED(lck) AnnotateRWLockAcquired(__FILE__, __LINE__, (uptr)lck, 1)
|
||||
#define ANNOTATE_RWLOCK_ACQUIRED(lck) AnnotateRWLockReleased(__FILE__, __LINE__, (uptr)lck, 1)
|
||||
#define ANNOTATE_BARRIER_BEGIN(addr) AnnotateHappensBefore(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_BARRIER_END(addr) AnnotateHappensAfter(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_REDUCE_AFTER(addr) AnnotateHappensAfter(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_REDUCE_BEFORE(addr) AnnotateHappensBefore(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_RWLOCK_CREATE(lck) \
|
||||
AnnotateRWLockCreate(__FILE__, __LINE__, (uptr)lck)
|
||||
#define ANNOTATE_RWLOCK_RELEASED(lck) \
|
||||
AnnotateRWLockAcquired(__FILE__, __LINE__, (uptr)lck, 1)
|
||||
#define ANNOTATE_RWLOCK_ACQUIRED(lck) \
|
||||
AnnotateRWLockReleased(__FILE__, __LINE__, (uptr)lck, 1)
|
||||
#define ANNOTATE_BARRIER_BEGIN(addr) \
|
||||
AnnotateHappensBefore(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_BARRIER_END(addr) \
|
||||
AnnotateHappensAfter(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_REDUCE_AFTER(addr) \
|
||||
AnnotateHappensAfter(__FILE__, __LINE__, (uptr)addr)
|
||||
#define ANNOTATE_REDUCE_BEFORE(addr) \
|
||||
AnnotateHappensBefore(__FILE__, __LINE__, (uptr)addr)
|
||||
#else
|
||||
#define ANNOTATE_HAPPENS_AFTER(addr)
|
||||
#define ANNOTATE_HAPPENS_BEFORE(addr)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
|
||||
|
||||
# if KMP_MIC
|
||||
//
|
||||
// the 'delay r16/r32/r64' should be used instead of the 'pause'.
|
||||
// The delay operation has the effect of removing the current thread from
|
||||
// the round-robin HT mechanism, and therefore speeds up the issue rate of
|
||||
|
|
@ -70,9 +69,10 @@
|
|||
KMP_PREFIX_UNDERSCORE($0):
|
||||
.endmacro
|
||||
# else // KMP_OS_DARWIN
|
||||
# define KMP_PREFIX_UNDERSCORE(x) x // no extra underscore for Linux* OS symbols
|
||||
# define KMP_PREFIX_UNDERSCORE(x) x //no extra underscore for Linux* OS symbols
|
||||
// Format labels so that they don't override function names in gdb's backtraces
|
||||
// MIC assembler doesn't accept .L syntax, the L works fine there (as well as on OS X*)
|
||||
// MIC assembler doesn't accept .L syntax, the L works fine there (as well as
|
||||
// on OS X*)
|
||||
# if KMP_MIC
|
||||
# define KMP_LABEL(x) L_##x // local label
|
||||
# else
|
||||
|
|
@ -163,12 +163,10 @@ KMP_PREFIX_UNDERSCORE(\proc):
|
|||
|
||||
#ifdef KMP_GOMP_COMPAT
|
||||
|
||||
//
|
||||
// Support for unnamed common blocks.
|
||||
//
|
||||
// Because the symbol ".gomp_critical_user_" contains a ".", we have to
|
||||
// put this stuff in assembly.
|
||||
//
|
||||
|
||||
# if KMP_ARCH_X86
|
||||
# if KMP_OS_DARWIN
|
||||
|
|
@ -221,14 +219,12 @@ __kmp_unnamed_critical_addr:
|
|||
// microtasking routines specifically written for IA-32 architecture
|
||||
// running Linux* OS
|
||||
// -----------------------------------------------------------------------
|
||||
//
|
||||
|
||||
.ident "Intel Corporation"
|
||||
.data
|
||||
ALIGN 4
|
||||
// void
|
||||
// __kmp_x86_pause( void );
|
||||
//
|
||||
|
||||
.text
|
||||
PROC __kmp_x86_pause
|
||||
|
|
@ -238,10 +234,9 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
DEBUG_INFO __kmp_x86_pause
|
||||
|
||||
//
|
||||
// void
|
||||
// __kmp_x86_cpuid( int mode, int mode2, void *cpuid_buffer );
|
||||
//
|
||||
|
||||
PROC __kmp_x86_cpuid
|
||||
|
||||
pushl %ebp
|
||||
|
|
@ -253,7 +248,7 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
movl 8(%ebp), %eax
|
||||
movl 12(%ebp), %ecx
|
||||
cpuid // Query the CPUID for the current processor
|
||||
cpuid // Query the CPUID for the current processor
|
||||
|
||||
movl 16(%ebp), %edi
|
||||
movl %eax, 0(%edi)
|
||||
|
|
@ -275,10 +270,8 @@ __kmp_unnamed_critical_addr:
|
|||
# if !KMP_ASM_INTRINS
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// kmp_int32
|
||||
// __kmp_test_then_add32( volatile kmp_int32 *p, kmp_int32 d );
|
||||
//
|
||||
|
||||
PROC __kmp_test_then_add32
|
||||
|
||||
|
|
@ -291,7 +284,6 @@ __kmp_unnamed_critical_addr:
|
|||
DEBUG_INFO __kmp_test_then_add32
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_fixed8
|
||||
//
|
||||
// kmp_int32
|
||||
|
|
@ -302,7 +294,6 @@ __kmp_unnamed_critical_addr:
|
|||
// d: 8(%esp)
|
||||
//
|
||||
// return: %al
|
||||
|
||||
PROC __kmp_xchg_fixed8
|
||||
|
||||
movl 4(%esp), %ecx // "p"
|
||||
|
|
@ -316,7 +307,6 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_fixed16
|
||||
//
|
||||
// kmp_int16
|
||||
|
|
@ -326,7 +316,6 @@ __kmp_unnamed_critical_addr:
|
|||
// p: 4(%esp)
|
||||
// d: 8(%esp)
|
||||
// return: %ax
|
||||
|
||||
PROC __kmp_xchg_fixed16
|
||||
|
||||
movl 4(%esp), %ecx // "p"
|
||||
|
|
@ -340,7 +329,6 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_fixed32
|
||||
//
|
||||
// kmp_int32
|
||||
|
|
@ -351,7 +339,6 @@ __kmp_unnamed_critical_addr:
|
|||
// d: 8(%esp)
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
PROC __kmp_xchg_fixed32
|
||||
|
||||
movl 4(%esp), %ecx // "p"
|
||||
|
|
@ -364,11 +351,8 @@ __kmp_unnamed_critical_addr:
|
|||
DEBUG_INFO __kmp_xchg_fixed32
|
||||
|
||||
|
||||
//
|
||||
// kmp_int8
|
||||
// __kmp_compare_and_store8( volatile kmp_int8 *p, kmp_int8 cv, kmp_int8 sv );
|
||||
//
|
||||
|
||||
PROC __kmp_compare_and_store8
|
||||
|
||||
movl 4(%esp), %ecx
|
||||
|
|
@ -382,11 +366,8 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
DEBUG_INFO __kmp_compare_and_store8
|
||||
|
||||
//
|
||||
// kmp_int16
|
||||
// __kmp_compare_and_store16( volatile kmp_int16 *p, kmp_int16 cv, kmp_int16 sv );
|
||||
//
|
||||
|
||||
// __kmp_compare_and_store16(volatile kmp_int16 *p, kmp_int16 cv, kmp_int16 sv);
|
||||
PROC __kmp_compare_and_store16
|
||||
|
||||
movl 4(%esp), %ecx
|
||||
|
|
@ -400,11 +381,8 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
DEBUG_INFO __kmp_compare_and_store16
|
||||
|
||||
//
|
||||
// kmp_int32
|
||||
// __kmp_compare_and_store32( volatile kmp_int32 *p, kmp_int32 cv, kmp_int32 sv );
|
||||
//
|
||||
|
||||
// __kmp_compare_and_store32(volatile kmp_int32 *p, kmp_int32 cv, kmp_int32 sv);
|
||||
PROC __kmp_compare_and_store32
|
||||
|
||||
movl 4(%esp), %ecx
|
||||
|
|
@ -412,16 +390,14 @@ __kmp_unnamed_critical_addr:
|
|||
movl 12(%esp), %edx
|
||||
lock
|
||||
cmpxchgl %edx,(%ecx)
|
||||
sete %al // if %eax == (%ecx) set %al = 1 else set %al = 0
|
||||
and $1, %eax // sign extend previous instruction
|
||||
sete %al // if %eax == (%ecx) set %al = 1 else set %al = 0
|
||||
and $1, %eax // sign extend previous instruction
|
||||
ret
|
||||
|
||||
DEBUG_INFO __kmp_compare_and_store32
|
||||
|
||||
//
|
||||
// kmp_int32
|
||||
// __kmp_compare_and_store64( volatile kmp_int64 *p, kmp_int64 cv, kmp_int64 sv );
|
||||
//
|
||||
// __kmp_compare_and_store64(volatile kmp_int64 *p, kmp_int64 cv, kmp_int64 s );
|
||||
PROC __kmp_compare_and_store64
|
||||
|
||||
pushl %ebp
|
||||
|
|
@ -435,8 +411,8 @@ __kmp_unnamed_critical_addr:
|
|||
movl 24(%ebp), %ecx // "sv" high order word
|
||||
lock
|
||||
cmpxchg8b (%edi)
|
||||
sete %al // if %edx:eax == (%edi) set %al = 1 else set %al = 0
|
||||
and $1, %eax // sign extend previous instruction
|
||||
sete %al // if %edx:eax == (%edi) set %al = 1 else set %al = 0
|
||||
and $1, %eax // sign extend previous instruction
|
||||
popl %edi
|
||||
popl %ebx
|
||||
movl %ebp, %esp
|
||||
|
|
@ -445,11 +421,8 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
DEBUG_INFO __kmp_compare_and_store64
|
||||
|
||||
//
|
||||
// kmp_int8
|
||||
// __kmp_compare_and_store_ret8( volatile kmp_int8 *p, kmp_int8 cv, kmp_int8 sv );
|
||||
//
|
||||
|
||||
// __kmp_compare_and_store_ret8(volatile kmp_int8 *p, kmp_int8 cv, kmp_int8 sv);
|
||||
PROC __kmp_compare_and_store_ret8
|
||||
|
||||
movl 4(%esp), %ecx
|
||||
|
|
@ -461,11 +434,9 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
DEBUG_INFO __kmp_compare_and_store_ret8
|
||||
|
||||
//
|
||||
// kmp_int16
|
||||
// __kmp_compare_and_store_ret16( volatile kmp_int16 *p, kmp_int16 cv, kmp_int16 sv );
|
||||
//
|
||||
|
||||
// __kmp_compare_and_store_ret16(volatile kmp_int16 *p, kmp_int16 cv,
|
||||
// kmp_int16 sv);
|
||||
PROC __kmp_compare_and_store_ret16
|
||||
|
||||
movl 4(%esp), %ecx
|
||||
|
|
@ -477,11 +448,9 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
DEBUG_INFO __kmp_compare_and_store_ret16
|
||||
|
||||
//
|
||||
// kmp_int32
|
||||
// __kmp_compare_and_store_ret32( volatile kmp_int32 *p, kmp_int32 cv, kmp_int32 sv );
|
||||
//
|
||||
|
||||
// __kmp_compare_and_store_ret32(volatile kmp_int32 *p, kmp_int32 cv,
|
||||
// kmp_int32 sv);
|
||||
PROC __kmp_compare_and_store_ret32
|
||||
|
||||
movl 4(%esp), %ecx
|
||||
|
|
@ -493,10 +462,9 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
DEBUG_INFO __kmp_compare_and_store_ret32
|
||||
|
||||
//
|
||||
// kmp_int64
|
||||
// __kmp_compare_and_store_ret64( volatile kmp_int64 *p, kmp_int64 cv, kmp_int64 sv );
|
||||
//
|
||||
// __kmp_compare_and_store_ret64(volatile kmp_int64 *p, kmp_int64 cv,
|
||||
// kmp_int64 sv);
|
||||
PROC __kmp_compare_and_store_ret64
|
||||
|
||||
pushl %ebp
|
||||
|
|
@ -520,7 +488,6 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_real32
|
||||
//
|
||||
// kmp_real32
|
||||
|
|
@ -531,8 +498,6 @@ __kmp_unnamed_critical_addr:
|
|||
// data: 8(%esp)
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
|
||||
PROC __kmp_xchg_real32
|
||||
|
||||
pushl %ebp
|
||||
|
|
@ -565,7 +530,6 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_load_x87_fpu_control_word
|
||||
//
|
||||
// void
|
||||
|
|
@ -573,8 +537,6 @@ __kmp_unnamed_critical_addr:
|
|||
//
|
||||
// parameters:
|
||||
// p: 4(%esp)
|
||||
//
|
||||
|
||||
PROC __kmp_load_x87_fpu_control_word
|
||||
|
||||
movl 4(%esp), %eax
|
||||
|
|
@ -585,7 +547,6 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_store_x87_fpu_control_word
|
||||
//
|
||||
// void
|
||||
|
|
@ -593,8 +554,6 @@ __kmp_unnamed_critical_addr:
|
|||
//
|
||||
// parameters:
|
||||
// p: 4(%esp)
|
||||
//
|
||||
|
||||
PROC __kmp_store_x87_fpu_control_word
|
||||
|
||||
movl 4(%esp), %eax
|
||||
|
|
@ -605,14 +564,10 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_clear_x87_fpu_status_word
|
||||
//
|
||||
// void
|
||||
// __kmp_clear_x87_fpu_status_word();
|
||||
//
|
||||
//
|
||||
|
||||
PROC __kmp_clear_x87_fpu_status_word
|
||||
|
||||
fnclex
|
||||
|
|
@ -622,7 +577,6 @@ __kmp_unnamed_critical_addr:
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// typedef void (*microtask_t)( int *gtid, int *tid, ... );
|
||||
//
|
||||
// int
|
||||
|
|
@ -714,7 +668,6 @@ KMP_LABEL(invoke_3):
|
|||
DEBUG_INFO __kmp_hardware_timestamp
|
||||
// -- End __kmp_hardware_timestamp
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
#endif /* KMP_ARCH_X86 */
|
||||
|
||||
|
||||
|
|
@ -732,9 +685,9 @@ KMP_LABEL(invoke_3):
|
|||
.data
|
||||
ALIGN 4
|
||||
|
||||
// To prevent getting our code into .data section .text added to every routine definition for x86_64.
|
||||
// To prevent getting our code into .data section .text added to every routine
|
||||
// definition for x86_64.
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_x86_cpuid
|
||||
//
|
||||
// void
|
||||
|
|
@ -744,7 +697,6 @@ KMP_LABEL(invoke_3):
|
|||
// mode: %edi
|
||||
// mode2: %esi
|
||||
// cpuid_buffer: %rdx
|
||||
|
||||
.text
|
||||
PROC __kmp_x86_cpuid
|
||||
|
||||
|
|
@ -774,7 +726,6 @@ KMP_LABEL(invoke_3):
|
|||
# if !KMP_ASM_INTRINS
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_test_then_add32
|
||||
//
|
||||
// kmp_int32
|
||||
|
|
@ -785,7 +736,6 @@ KMP_LABEL(invoke_3):
|
|||
// d: %esi
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_test_then_add32
|
||||
|
||||
|
|
@ -798,7 +748,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_test_then_add64
|
||||
//
|
||||
// kmp_int64
|
||||
|
|
@ -808,7 +757,6 @@ KMP_LABEL(invoke_3):
|
|||
// p: %rdi
|
||||
// d: %rsi
|
||||
// return: %rax
|
||||
|
||||
.text
|
||||
PROC __kmp_test_then_add64
|
||||
|
||||
|
|
@ -821,7 +769,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_fixed8
|
||||
//
|
||||
// kmp_int32
|
||||
|
|
@ -832,7 +779,6 @@ KMP_LABEL(invoke_3):
|
|||
// d: %sil
|
||||
//
|
||||
// return: %al
|
||||
|
||||
.text
|
||||
PROC __kmp_xchg_fixed8
|
||||
|
||||
|
|
@ -846,7 +792,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_fixed16
|
||||
//
|
||||
// kmp_int16
|
||||
|
|
@ -856,7 +801,6 @@ KMP_LABEL(invoke_3):
|
|||
// p: %rdi
|
||||
// d: %si
|
||||
// return: %ax
|
||||
|
||||
.text
|
||||
PROC __kmp_xchg_fixed16
|
||||
|
||||
|
|
@ -870,7 +814,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_fixed32
|
||||
//
|
||||
// kmp_int32
|
||||
|
|
@ -881,7 +824,6 @@ KMP_LABEL(invoke_3):
|
|||
// d: %esi
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_xchg_fixed32
|
||||
|
||||
|
|
@ -895,7 +837,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_fixed64
|
||||
//
|
||||
// kmp_int64
|
||||
|
|
@ -905,7 +846,6 @@ KMP_LABEL(invoke_3):
|
|||
// p: %rdi
|
||||
// d: %rsi
|
||||
// return: %rax
|
||||
|
||||
.text
|
||||
PROC __kmp_xchg_fixed64
|
||||
|
||||
|
|
@ -919,7 +859,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_compare_and_store8
|
||||
//
|
||||
// kmp_int8
|
||||
|
|
@ -931,7 +870,6 @@ KMP_LABEL(invoke_3):
|
|||
// sv: %edx
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_compare_and_store8
|
||||
|
||||
|
|
@ -946,7 +884,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_compare_and_store16
|
||||
//
|
||||
// kmp_int16
|
||||
|
|
@ -958,7 +895,6 @@ KMP_LABEL(invoke_3):
|
|||
// sv: %dx
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_compare_and_store16
|
||||
|
||||
|
|
@ -973,7 +909,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_compare_and_store32
|
||||
//
|
||||
// kmp_int32
|
||||
|
|
@ -985,7 +920,6 @@ KMP_LABEL(invoke_3):
|
|||
// sv: %edx
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_compare_and_store32
|
||||
|
||||
|
|
@ -1000,7 +934,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_compare_and_store64
|
||||
//
|
||||
// kmp_int32
|
||||
|
|
@ -1011,7 +944,6 @@ KMP_LABEL(invoke_3):
|
|||
// cv: %rsi
|
||||
// sv: %rdx
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_compare_and_store64
|
||||
|
||||
|
|
@ -1025,7 +957,6 @@ KMP_LABEL(invoke_3):
|
|||
DEBUG_INFO __kmp_compare_and_store64
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_compare_and_store_ret8
|
||||
//
|
||||
// kmp_int8
|
||||
|
|
@ -1037,7 +968,6 @@ KMP_LABEL(invoke_3):
|
|||
// sv: %edx
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_compare_and_store_ret8
|
||||
|
||||
|
|
@ -1050,7 +980,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_compare_and_store_ret16
|
||||
//
|
||||
// kmp_int16
|
||||
|
|
@ -1062,7 +991,6 @@ KMP_LABEL(invoke_3):
|
|||
// sv: %dx
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_compare_and_store_ret16
|
||||
|
||||
|
|
@ -1075,7 +1003,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_compare_and_store_ret32
|
||||
//
|
||||
// kmp_int32
|
||||
|
|
@ -1087,7 +1014,6 @@ KMP_LABEL(invoke_3):
|
|||
// sv: %edx
|
||||
//
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_compare_and_store_ret32
|
||||
|
||||
|
|
@ -1100,7 +1026,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_compare_and_store_ret64
|
||||
//
|
||||
// kmp_int64
|
||||
|
|
@ -1111,7 +1036,6 @@ KMP_LABEL(invoke_3):
|
|||
// cv: %rsi
|
||||
// sv: %rdx
|
||||
// return: %eax
|
||||
|
||||
.text
|
||||
PROC __kmp_compare_and_store_ret64
|
||||
|
||||
|
|
@ -1130,7 +1054,6 @@ KMP_LABEL(invoke_3):
|
|||
# if !KMP_ASM_INTRINS
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_real32
|
||||
//
|
||||
// kmp_real32
|
||||
|
|
@ -1141,7 +1064,6 @@ KMP_LABEL(invoke_3):
|
|||
// data: %xmm0 (lower 4 bytes)
|
||||
//
|
||||
// return: %xmm0 (lower 4 bytes)
|
||||
|
||||
.text
|
||||
PROC __kmp_xchg_real32
|
||||
|
||||
|
|
@ -1158,7 +1080,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_xchg_real64
|
||||
//
|
||||
// kmp_real64
|
||||
|
|
@ -1168,8 +1089,6 @@ KMP_LABEL(invoke_3):
|
|||
// addr: %rdi
|
||||
// data: %xmm0 (lower 8 bytes)
|
||||
// return: %xmm0 (lower 8 bytes)
|
||||
//
|
||||
|
||||
.text
|
||||
PROC __kmp_xchg_real64
|
||||
|
||||
|
|
@ -1190,7 +1109,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_load_x87_fpu_control_word
|
||||
//
|
||||
// void
|
||||
|
|
@ -1198,8 +1116,6 @@ KMP_LABEL(invoke_3):
|
|||
//
|
||||
// parameters:
|
||||
// p: %rdi
|
||||
//
|
||||
|
||||
.text
|
||||
PROC __kmp_load_x87_fpu_control_word
|
||||
|
||||
|
|
@ -1210,7 +1126,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_store_x87_fpu_control_word
|
||||
//
|
||||
// void
|
||||
|
|
@ -1218,8 +1133,6 @@ KMP_LABEL(invoke_3):
|
|||
//
|
||||
// parameters:
|
||||
// p: %rdi
|
||||
//
|
||||
|
||||
.text
|
||||
PROC __kmp_store_x87_fpu_control_word
|
||||
|
||||
|
|
@ -1230,14 +1143,10 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_clear_x87_fpu_status_word
|
||||
//
|
||||
// void
|
||||
// __kmp_clear_x87_fpu_status_word();
|
||||
//
|
||||
//
|
||||
|
||||
.text
|
||||
PROC __kmp_clear_x87_fpu_status_word
|
||||
|
||||
|
|
@ -1256,7 +1165,6 @@ KMP_LABEL(invoke_3):
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// typedef void (*microtask_t)( int *gtid, int *tid, ... );
|
||||
//
|
||||
// int
|
||||
|
|
@ -1267,8 +1175,7 @@ KMP_LABEL(invoke_3):
|
|||
// return 1;
|
||||
// }
|
||||
//
|
||||
// note:
|
||||
// at call to pkfn must have %rsp 128-byte aligned for compiler
|
||||
// note: at call to pkfn must have %rsp 128-byte aligned for compiler
|
||||
//
|
||||
// parameters:
|
||||
// %rdi: pkfn
|
||||
|
|
@ -1291,8 +1198,6 @@ KMP_LABEL(invoke_3):
|
|||
// %rbx: used to hold pkfn address, and zero constant, callee-save
|
||||
//
|
||||
// return: %eax (always 1/TRUE)
|
||||
//
|
||||
|
||||
__gtid = -16
|
||||
__tid = -24
|
||||
|
||||
|
|
@ -1442,13 +1347,10 @@ KMP_LABEL(kmp_1_exit):
|
|||
// -- End __kmp_hardware_timestamp
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// FUNCTION __kmp_bsr32
|
||||
//
|
||||
// int
|
||||
// __kmp_bsr32( int );
|
||||
//
|
||||
|
||||
.text
|
||||
PROC __kmp_bsr32
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -42,13 +42,10 @@ endif
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_x86_pause
|
||||
;
|
||||
; void
|
||||
; __kmp_x86_pause( void )
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_x86_pause
|
||||
_p$ = 4
|
||||
_d$ = 8
|
||||
|
|
@ -64,13 +61,10 @@ ___kmp_x86_pause ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_x86_cpuid
|
||||
;
|
||||
; void
|
||||
; __kmp_x86_cpuid( int mode, int mode2, struct kmp_cpuid *p );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_x86_cpuid
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -115,13 +109,10 @@ ___kmp_x86_cpuid ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_test_then_add32
|
||||
;
|
||||
; kmp_int32
|
||||
; __kmp_test_then_add32( volatile kmp_int32 *p, kmp_int32 d );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_test_then_add32
|
||||
_p$ = 4
|
||||
_d$ = 8
|
||||
|
|
@ -138,13 +129,10 @@ ___kmp_test_then_add32 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_compare_and_store8
|
||||
;
|
||||
; kmp_int8
|
||||
; __kmp_compare_and_store8( volatile kmp_int8 *p, kmp_int8 cv, kmp_int8 sv );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_compare_and_store8
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -166,13 +154,10 @@ ___kmp_compare_and_store8 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_compare_and_store16
|
||||
;
|
||||
; kmp_int16
|
||||
; __kmp_compare_and_store16( volatile kmp_int16 *p, kmp_int16 cv, kmp_int16 sv );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_compare_and_store16
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -194,13 +179,10 @@ ___kmp_compare_and_store16 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_compare_and_store32
|
||||
;
|
||||
; kmp_int32
|
||||
; __kmp_compare_and_store32( volatile kmp_int32 *p, kmp_int32 cv, kmp_int32 sv );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_compare_and_store32
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -222,13 +204,10 @@ ___kmp_compare_and_store32 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_compare_and_store64
|
||||
;
|
||||
; kmp_int32
|
||||
; __kmp_compare_and_store64( volatile kmp_int64 *p, kmp_int64 cv, kmp_int64 sv );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_compare_and_store64
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -262,13 +241,10 @@ ___kmp_compare_and_store64 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_xchg_fixed8
|
||||
;
|
||||
; kmp_int8
|
||||
; __kmp_xchg_fixed8( volatile kmp_int8 *p, kmp_int8 d );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_xchg_fixed8
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -286,13 +262,10 @@ ___kmp_xchg_fixed8 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_xchg_fixed16
|
||||
;
|
||||
; kmp_int16
|
||||
; __kmp_xchg_fixed16( volatile kmp_int16 *p, kmp_int16 d );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_xchg_fixed16
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -310,13 +283,10 @@ ___kmp_xchg_fixed16 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_xchg_fixed32
|
||||
;
|
||||
; kmp_int32
|
||||
; __kmp_xchg_fixed32( volatile kmp_int32 *p, kmp_int32 d );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_xchg_fixed32
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -335,13 +305,10 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_xchg_real32
|
||||
;
|
||||
; kmp_real32
|
||||
; __kmp_xchg_real32( volatile kmp_real32 *p, kmp_real32 d );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_xchg_real32
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -378,13 +345,10 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_compare_and_store_ret8
|
||||
;
|
||||
; kmp_int8
|
||||
; __kmp_compare_and_store_ret8( volatile kmp_int8 *p, kmp_int8 cv, kmp_int8 sv );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_compare_and_store_ret8
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -404,13 +368,10 @@ ___kmp_compare_and_store_ret8 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_compare_and_store_ret16
|
||||
;
|
||||
; kmp_int16
|
||||
; __kmp_compare_and_store_ret16( volatile kmp_int16 *p, kmp_int16 cv, kmp_int16 sv );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_compare_and_store_ret16
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -430,13 +391,10 @@ ___kmp_compare_and_store_ret16 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_compare_and_store_ret32
|
||||
;
|
||||
; kmp_int32
|
||||
; __kmp_compare_and_store_ret32( volatile kmp_int32 *p, kmp_int32 cv, kmp_int32 sv );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_compare_and_store_ret32
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -456,13 +414,10 @@ ___kmp_compare_and_store_ret32 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_compare_and_store_ret64
|
||||
;
|
||||
; kmp_int64
|
||||
; __kmp_compare_and_store_ret64( volatile kmp_int64 *p, kmp_int64 cv, kmp_int64 sv );
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_compare_and_store_ret64
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -494,7 +449,6 @@ ___kmp_compare_and_store_ret64 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_load_x87_fpu_control_word
|
||||
;
|
||||
; void
|
||||
|
|
@ -502,7 +456,6 @@ _TEXT ENDS
|
|||
;
|
||||
; parameters:
|
||||
; p: 4(%esp)
|
||||
|
||||
PUBLIC ___kmp_load_x87_fpu_control_word
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -518,7 +471,6 @@ ___kmp_load_x87_fpu_control_word ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_store_x87_fpu_control_word
|
||||
;
|
||||
; void
|
||||
|
|
@ -526,7 +478,6 @@ _TEXT ENDS
|
|||
;
|
||||
; parameters:
|
||||
; p: 4(%esp)
|
||||
|
||||
PUBLIC ___kmp_store_x87_fpu_control_word
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -542,13 +493,10 @@ ___kmp_store_x87_fpu_control_word ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_clear_x87_fpu_status_word
|
||||
;
|
||||
; void
|
||||
; __kmp_clear_x87_fpu_status_word();
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_clear_x87_fpu_status_word
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -563,7 +511,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_invoke_microtask
|
||||
;
|
||||
; typedef void (*microtask_t)( int *gtid, int *tid, ... );
|
||||
|
|
@ -572,8 +519,6 @@ _TEXT ENDS
|
|||
; __kmp_invoke_microtask( microtask_t pkfn,
|
||||
; int gtid, int tid,
|
||||
; int argc, void *p_argv[] )
|
||||
;
|
||||
|
||||
PUBLIC ___kmp_invoke_microtask
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -677,7 +622,6 @@ endif
|
|||
ifdef _M_AMD64
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_x86_cpuid
|
||||
;
|
||||
; void
|
||||
|
|
@ -687,7 +631,6 @@ ifdef _M_AMD64
|
|||
; mode: ecx
|
||||
; mode2: edx
|
||||
; cpuid_buffer: r8
|
||||
|
||||
PUBLIC __kmp_x86_cpuid
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -722,7 +665,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_test_then_add32
|
||||
;
|
||||
; kmp_int32
|
||||
|
|
@ -733,7 +675,6 @@ _TEXT ENDS
|
|||
; d: edx
|
||||
;
|
||||
; return: eax
|
||||
|
||||
PUBLIC __kmp_test_then_add32
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -748,7 +689,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_test_then_add64
|
||||
;
|
||||
; kmp_int32
|
||||
|
|
@ -759,7 +699,6 @@ _TEXT ENDS
|
|||
; d: rdx
|
||||
;
|
||||
; return: rax
|
||||
|
||||
PUBLIC __kmp_test_then_add64
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -774,7 +713,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_compare_and_store8
|
||||
;
|
||||
; kmp_int8
|
||||
|
|
@ -785,7 +723,6 @@ _TEXT ENDS
|
|||
; sv: r8d
|
||||
;
|
||||
; return: eax
|
||||
|
||||
PUBLIC __kmp_compare_and_store8
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -804,7 +741,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_compare_and_store16
|
||||
;
|
||||
; kmp_int16
|
||||
|
|
@ -815,7 +751,6 @@ _TEXT ENDS
|
|||
; sv: r8d
|
||||
;
|
||||
; return: eax
|
||||
|
||||
PUBLIC __kmp_compare_and_store16
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -834,7 +769,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_compare_and_store32
|
||||
;
|
||||
; kmp_int32
|
||||
|
|
@ -845,7 +779,6 @@ _TEXT ENDS
|
|||
; sv: r8d
|
||||
;
|
||||
; return: eax
|
||||
|
||||
PUBLIC __kmp_compare_and_store32
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -864,7 +797,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_compare_and_store64
|
||||
;
|
||||
; kmp_int32
|
||||
|
|
@ -875,7 +807,6 @@ _TEXT ENDS
|
|||
; sv: r8
|
||||
;
|
||||
; return: eax
|
||||
|
||||
PUBLIC __kmp_compare_and_store64
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -894,7 +825,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_xchg_fixed8
|
||||
;
|
||||
; kmp_int8
|
||||
|
|
@ -905,7 +835,6 @@ _TEXT ENDS
|
|||
; d: dl
|
||||
;
|
||||
; return: al
|
||||
|
||||
PUBLIC __kmp_xchg_fixed8
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -921,7 +850,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_xchg_fixed16
|
||||
;
|
||||
; kmp_int16
|
||||
|
|
@ -932,7 +860,6 @@ _TEXT ENDS
|
|||
; d: dx
|
||||
;
|
||||
; return: ax
|
||||
|
||||
PUBLIC __kmp_xchg_fixed16
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -948,7 +875,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_xchg_fixed32
|
||||
;
|
||||
; kmp_int32
|
||||
|
|
@ -959,7 +885,6 @@ _TEXT ENDS
|
|||
; d: edx
|
||||
;
|
||||
; return: eax
|
||||
|
||||
PUBLIC __kmp_xchg_fixed32
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -974,7 +899,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION ___kmp_xchg_fixed64
|
||||
;
|
||||
; kmp_int64
|
||||
|
|
@ -985,7 +909,6 @@ _TEXT ENDS
|
|||
; d: rdx
|
||||
;
|
||||
; return: rax
|
||||
|
||||
PUBLIC __kmp_xchg_fixed64
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1000,7 +923,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_compare_and_store_ret8
|
||||
;
|
||||
; kmp_int8
|
||||
|
|
@ -1011,7 +933,6 @@ _TEXT ENDS
|
|||
; sv: r8d
|
||||
;
|
||||
; return: eax
|
||||
|
||||
PUBLIC __kmp_compare_and_store_ret8
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1030,7 +951,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_compare_and_store_ret16
|
||||
;
|
||||
; kmp_int16
|
||||
|
|
@ -1041,7 +961,6 @@ _TEXT ENDS
|
|||
; sv: r8d
|
||||
;
|
||||
; return: eax
|
||||
|
||||
PUBLIC __kmp_compare_and_store_ret16
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1058,7 +977,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_compare_and_store_ret32
|
||||
;
|
||||
; kmp_int32
|
||||
|
|
@ -1069,7 +987,6 @@ _TEXT ENDS
|
|||
; sv: r8d
|
||||
;
|
||||
; return: eax
|
||||
|
||||
PUBLIC __kmp_compare_and_store_ret32
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1086,7 +1003,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_compare_and_store_ret64
|
||||
;
|
||||
; kmp_int64
|
||||
|
|
@ -1097,7 +1013,6 @@ _TEXT ENDS
|
|||
; sv: r8
|
||||
;
|
||||
; return: rax
|
||||
|
||||
PUBLIC __kmp_compare_and_store_ret64
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1114,7 +1029,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_compare_and_store_loop8
|
||||
;
|
||||
; kmp_int8
|
||||
|
|
@ -1125,7 +1039,6 @@ _TEXT ENDS
|
|||
; sv: r8d
|
||||
;
|
||||
; return: al
|
||||
|
||||
PUBLIC __kmp_compare_and_store_loop8
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1153,7 +1066,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_xchg_real32
|
||||
;
|
||||
; kmp_real32
|
||||
|
|
@ -1164,7 +1076,6 @@ _TEXT ENDS
|
|||
; d: xmm1 (lower 4 bytes)
|
||||
;
|
||||
; return: xmm0 (lower 4 bytes)
|
||||
|
||||
PUBLIC __kmp_xchg_real32
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1182,7 +1093,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_xchg_real64
|
||||
;
|
||||
; kmp_real64
|
||||
|
|
@ -1193,7 +1103,6 @@ _TEXT ENDS
|
|||
; d: xmm1 (lower 8 bytes)
|
||||
;
|
||||
; return: xmm0 (lower 8 bytes)
|
||||
|
||||
PUBLIC __kmp_xchg_real64
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1210,7 +1119,6 @@ __kmp_xchg_real64 ENDP
|
|||
_TEXT ENDS
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_load_x87_fpu_control_word
|
||||
;
|
||||
; void
|
||||
|
|
@ -1218,8 +1126,6 @@ _TEXT ENDS
|
|||
;
|
||||
; parameters:
|
||||
; p: rcx
|
||||
;
|
||||
|
||||
PUBLIC __kmp_load_x87_fpu_control_word
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1233,7 +1139,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_store_x87_fpu_control_word
|
||||
;
|
||||
; void
|
||||
|
|
@ -1241,8 +1146,6 @@ _TEXT ENDS
|
|||
;
|
||||
; parameters:
|
||||
; p: rcx
|
||||
;
|
||||
|
||||
PUBLIC __kmp_store_x87_fpu_control_word
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1256,13 +1159,10 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_clear_x87_fpu_status_word
|
||||
;
|
||||
; void
|
||||
; __kmp_clear_x87_fpu_status_word()
|
||||
;
|
||||
|
||||
PUBLIC __kmp_clear_x87_fpu_status_word
|
||||
_TEXT SEGMENT
|
||||
ALIGN 16
|
||||
|
|
@ -1276,7 +1176,6 @@ _TEXT ENDS
|
|||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; FUNCTION __kmp_invoke_microtask
|
||||
;
|
||||
; typedef void (*microtask_t)( int *gtid, int *tid, ... );
|
||||
|
|
@ -1307,8 +1206,6 @@ _TEXT ENDS
|
|||
; r10: used to hold pkfn function pointer argument
|
||||
;
|
||||
; return: eax (always 1/TRUE)
|
||||
;
|
||||
|
||||
$_pkfn = 16
|
||||
$_gtid = 24
|
||||
$_tid = 32
|
||||
|
|
|
|||
|
|
@ -17,147 +17,118 @@
|
|||
|
||||
#if (KMP_ARCH_X86 || KMP_ARCH_X86_64)
|
||||
/* Only 32-bit "add-exchange" instruction on IA-32 architecture causes us to
|
||||
* use compare_and_store for these routines
|
||||
*/
|
||||
use compare_and_store for these routines */
|
||||
|
||||
kmp_int8
|
||||
__kmp_test_then_or8( volatile kmp_int8 *p, kmp_int8 d )
|
||||
{
|
||||
kmp_int8 old_value, new_value;
|
||||
kmp_int8 __kmp_test_then_or8(volatile kmp_int8 *p, kmp_int8 d) {
|
||||
kmp_int8 old_value, new_value;
|
||||
|
||||
old_value = TCR_1( *p );
|
||||
old_value = TCR_1(*p);
|
||||
new_value = old_value | d;
|
||||
|
||||
while (!__kmp_compare_and_store8(p, old_value, new_value)) {
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_1(*p);
|
||||
new_value = old_value | d;
|
||||
|
||||
while ( ! __kmp_compare_and_store8 ( p, old_value, new_value ) )
|
||||
{
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_1( *p );
|
||||
new_value = old_value | d;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
|
||||
kmp_int8
|
||||
__kmp_test_then_and8( volatile kmp_int8 *p, kmp_int8 d )
|
||||
{
|
||||
kmp_int8 old_value, new_value;
|
||||
kmp_int8 __kmp_test_then_and8(volatile kmp_int8 *p, kmp_int8 d) {
|
||||
kmp_int8 old_value, new_value;
|
||||
|
||||
old_value = TCR_1( *p );
|
||||
old_value = TCR_1(*p);
|
||||
new_value = old_value & d;
|
||||
|
||||
while (!__kmp_compare_and_store8(p, old_value, new_value)) {
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_1(*p);
|
||||
new_value = old_value & d;
|
||||
|
||||
while ( ! __kmp_compare_and_store8 ( p, old_value, new_value ) )
|
||||
{
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_1( *p );
|
||||
new_value = old_value & d;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
|
||||
kmp_int32
|
||||
__kmp_test_then_or32( volatile kmp_int32 *p, kmp_int32 d )
|
||||
{
|
||||
kmp_int32 old_value, new_value;
|
||||
kmp_int32 __kmp_test_then_or32(volatile kmp_int32 *p, kmp_int32 d) {
|
||||
kmp_int32 old_value, new_value;
|
||||
|
||||
old_value = TCR_4( *p );
|
||||
old_value = TCR_4(*p);
|
||||
new_value = old_value | d;
|
||||
|
||||
while (!__kmp_compare_and_store32(p, old_value, new_value)) {
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_4(*p);
|
||||
new_value = old_value | d;
|
||||
|
||||
while ( ! __kmp_compare_and_store32 ( p, old_value, new_value ) )
|
||||
{
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_4( *p );
|
||||
new_value = old_value | d;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
|
||||
kmp_int32
|
||||
__kmp_test_then_and32( volatile kmp_int32 *p, kmp_int32 d )
|
||||
{
|
||||
kmp_int32 old_value, new_value;
|
||||
kmp_int32 __kmp_test_then_and32(volatile kmp_int32 *p, kmp_int32 d) {
|
||||
kmp_int32 old_value, new_value;
|
||||
|
||||
old_value = TCR_4( *p );
|
||||
old_value = TCR_4(*p);
|
||||
new_value = old_value & d;
|
||||
|
||||
while (!__kmp_compare_and_store32(p, old_value, new_value)) {
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_4(*p);
|
||||
new_value = old_value & d;
|
||||
|
||||
while ( ! __kmp_compare_and_store32 ( p, old_value, new_value ) )
|
||||
{
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_4( *p );
|
||||
new_value = old_value & d;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
|
||||
kmp_int8
|
||||
__kmp_test_then_add8( volatile kmp_int8 *p, kmp_int8 d )
|
||||
{
|
||||
kmp_int64 old_value, new_value;
|
||||
kmp_int8 __kmp_test_then_add8(volatile kmp_int8 *p, kmp_int8 d) {
|
||||
kmp_int64 old_value, new_value;
|
||||
|
||||
old_value = TCR_1( *p );
|
||||
old_value = TCR_1(*p);
|
||||
new_value = old_value + d;
|
||||
while (!__kmp_compare_and_store8(p, old_value, new_value)) {
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_1(*p);
|
||||
new_value = old_value + d;
|
||||
while ( ! __kmp_compare_and_store8 ( p, old_value, new_value ) )
|
||||
{
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_1( *p );
|
||||
new_value = old_value + d;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
|
||||
#if KMP_ARCH_X86
|
||||
kmp_int64
|
||||
__kmp_test_then_add64( volatile kmp_int64 *p, kmp_int64 d )
|
||||
{
|
||||
kmp_int64 old_value, new_value;
|
||||
kmp_int64 __kmp_test_then_add64(volatile kmp_int64 *p, kmp_int64 d) {
|
||||
kmp_int64 old_value, new_value;
|
||||
|
||||
old_value = TCR_8( *p );
|
||||
old_value = TCR_8(*p);
|
||||
new_value = old_value + d;
|
||||
while (!__kmp_compare_and_store64(p, old_value, new_value)) {
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_8(*p);
|
||||
new_value = old_value + d;
|
||||
while ( ! __kmp_compare_and_store64 ( p, old_value, new_value ) )
|
||||
{
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_8( *p );
|
||||
new_value = old_value + d;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
return old_value;
|
||||
}
|
||||
#endif /* KMP_ARCH_X86 */
|
||||
|
||||
kmp_int64
|
||||
__kmp_test_then_or64( volatile kmp_int64 *p, kmp_int64 d )
|
||||
{
|
||||
kmp_int64 old_value, new_value;
|
||||
kmp_int64 __kmp_test_then_or64(volatile kmp_int64 *p, kmp_int64 d) {
|
||||
kmp_int64 old_value, new_value;
|
||||
|
||||
old_value = TCR_8( *p );
|
||||
old_value = TCR_8(*p);
|
||||
new_value = old_value | d;
|
||||
while (!__kmp_compare_and_store64(p, old_value, new_value)) {
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_8(*p);
|
||||
new_value = old_value | d;
|
||||
while ( ! __kmp_compare_and_store64 ( p, old_value, new_value ) )
|
||||
{
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_8( *p );
|
||||
new_value = old_value | d;
|
||||
}
|
||||
}
|
||||
|
||||
return old_value;
|
||||
return old_value;
|
||||
}
|
||||
|
||||
kmp_int64
|
||||
__kmp_test_then_and64( volatile kmp_int64 *p, kmp_int64 d )
|
||||
{
|
||||
kmp_int64 old_value, new_value;
|
||||
kmp_int64 __kmp_test_then_and64(volatile kmp_int64 *p, kmp_int64 d) {
|
||||
kmp_int64 old_value, new_value;
|
||||
|
||||
old_value = TCR_8( *p );
|
||||
old_value = TCR_8(*p);
|
||||
new_value = old_value & d;
|
||||
while (!__kmp_compare_and_store64(p, old_value, new_value)) {
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_8(*p);
|
||||
new_value = old_value & d;
|
||||
while ( ! __kmp_compare_and_store64 ( p, old_value, new_value ) )
|
||||
{
|
||||
KMP_CPU_PAUSE();
|
||||
old_value = TCR_8( *p );
|
||||
new_value = old_value & d;
|
||||
}
|
||||
}
|
||||
|
||||
return old_value;
|
||||
return old_value;
|
||||
}
|
||||
|
||||
#endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue