17#define streqls(s1, s2) (!strcmp(s1, s2))
19#define check(condition) \
21 fprintf(stderr, "error: %s: %d: " STR(condition) "\n", __FILE__, \
32#define BUFFER_SIZE 1024
35#pragma omp threadprivate(buf)
41 va_start(
args, format);
42 retval = vprintf(format,
args);
50 printf(
"Affinity Environment:\n");
51 printf(
" OMP_PROC_BIND=%s\n", getenv(
"OMP_PROC_BIND"));
52 printf(
" OMP_PLACES=%s\n", getenv(
"OMP_PLACES"));
53 printf(
" KMP_AFFINITY=%s\n", getenv(
"KMP_AFFINITY"));
60void list_to_ids(
const char* affinity,
int* ids,
int ids_size) {
61 int id,
b, e, ids_index;
62 char *aff, *
begin, *
end, *absolute_end;
63 aff = strdup(affinity);
64 absolute_end = aff + strlen(aff);
67 while (
end < absolute_end) {
69 while (*
end !=
'\0' && *
end !=
',')
72 if (strchr(
begin,
'-') != NULL) {
74 sscanf(
begin,
"%d-%d", &
b, &e);
80 for (
id =
b;
id <= e; ++
id) {
81 ids[ids_index++] =
id;
82 if (ids_index >= ids_size) {
94 const char *formats[2] = {
"%{thread_affinity}",
"%A"};
95 for (
i = 0;
i <
sizeof(formats) /
sizeof(formats[0]); ++
i) {
100 int place = omp_get_place_num();
101 int num_procs = omp_get_place_num_procs(place);
102 int *ids = (
int *)malloc(
sizeof(
int) * num_procs);
103 int *ids2 = (
int *)malloc(
sizeof(
int) * num_procs);
107 omp_get_place_proc_ids(place, ids);
110 #pragma omp for schedule(static) ordered
115 omp_get_thread_num(),
buf);
116 for (
j = 0;
j < num_procs; ++
j) {
118 omp_get_thread_num(),
j, ids[
j],
j, ids2[
j]);
130int main(
int argc,
char** argv) {
void list_to_ids(const char *affinity, int *ids, int ids_size)
void check_thread_affinity()
static void display_affinity_environment()
static int debug_printf(const char *format,...)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp end
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp begin
#define omp_set_affinity_format
#define omp_capture_affinity
int omp_get_num_threads()