From 42195faa522b79f7dc73f2844ba7a503ad89335a Mon Sep 17 00:00:00 2001 From: "Smyth, Edward" Date: Fri, 7 Nov 2025 19:16:46 +0000 Subject: [PATCH] DTL Windows getpid support Use _getpid in Windows builds so that separate DTL log and trace files are used for each process, e.g. each MPI rank. AMD-Internal: [CPUPL-7524] --- aocl_dtl/aoclos.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/aocl_dtl/aoclos.c b/aocl_dtl/aoclos.c index 6787cd00d..39da22919 100644 --- a/aocl_dtl/aoclos.c +++ b/aocl_dtl/aoclos.c @@ -45,6 +45,7 @@ #include "aocldtlcf.h" #if defined(__linux__) + #include #include #include @@ -56,6 +57,10 @@ #endif +#if BLIS_OS_WINDOWS +#include +#endif + // BLIS TODO: This is workaround to check if BLIS is built with // openmp support. Ideally we don't want any library // specific code in dtl. @@ -122,7 +127,9 @@ uint64 AOCL_getTimestamp(void) return micros; } -#else /* Non linux support */ + +#elif BLIS_OS_WINDOWS + AOCL_TID AOCL_gettid(void) { #ifdef BLIS_ENABLE_OPENMP @@ -142,7 +149,37 @@ AOCL_TID AOCL_gettid(void) pid_t AOCL_getpid(void) { - /* stub for other os's */ + return (pid_t) _getpid(); +} + +uint64 AOCL_getTimestamp(void) +{ + /* stub for other os's */ + return 0; +} + +#else /* Non linux, Non Windows support */ + +AOCL_TID AOCL_gettid(void) +{ +#ifdef BLIS_ENABLE_OPENMP + return omp_get_thread_num(); +#else +#ifdef BLIS_ENABLE_PTHREADS + // pthread_self is not suitable for this purpose and may be replaced + // in a later release with something else. It returns a value of type + // pthread_t, whose type may depend upon the operating system. On + // freeBSD it is a pointer to an empty struct. + return (AOCL_TID) pthread_self(); +#else + return 0; +#endif +#endif +} + +pid_t AOCL_getpid(void) +{ + /* stub for other os's */ return 0; }