Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Fixes for musl support #20

Open
wants to merge 1 commit into
base: rocm-4.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions os/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@

#if defined(__linux__)
#include <sched.h>
#include <libgen.h>
#endif

#ifdef _WIN32
#include <Basetsd.h> // For KAFFINITY
#endif // _WIN32

#ifndef __cpu_mask
typedef unsigned long __cpu_mask;
#endif

// Smallest supported VM page size.
#define MIN_PAGE_SHIFT 12
#define MIN_PAGE_SIZE (1UL << MIN_PAGE_SHIFT)
Expand Down
7 changes: 7 additions & 0 deletions os/os_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,22 @@ const void* Os::createOsThread(amd::Thread* thread) {
for (int i = 0; i < processorCount_; i++) {
CPU_SET(i, &cpuset);
}
#ifdef pthread_attr_setaffinity_np
if (0 != pthread_attr_setaffinity_np(&threadAttr, sizeof(cpu_set_t), &cpuset)) {
fatal("pthread_attr_setaffinity_np failed to set affinity");
}
#endif
}

pthread_t handle = 0;
if (0 != ::pthread_create(&handle, &threadAttr, (void* (*)(void*)) & Thread::entry, thread)) {
thread->setState(Thread::FAILED);
}
#ifndef pthread_attr_setaffinity_np
if (0 != pthread_setaffinity_np(handle, sizeof(cpu_set_t), &cpuset)) {
fatal("pthread_attr_setaffinity_np failed to set affinity");
}
#endif

::pthread_attr_destroy(&threadAttr);
return reinterpret_cast<const void*>(handle);
Expand Down