Skip to content

Porting to macOS arm64 #2

@chadbrewbaker

Description

@chadbrewbaker

I stumbled upon http://www.hybridkernel.com/2015/01/18/binding_threads_to_cores_osx.html Thanks for the article! I was trying to figure out how to pin cores on the M1 to test between fast/slow.

mkdir build; cd build; cmake ../; make

Looks like one x86 -> arm64 register naming issue and shaving osx pthread yaks.


[ 50%] Building C object CMakeFiles/mbw.dir/mbw.c.o
/Users/crb002/github/mbw/mbw.c:107:21: error: unknown register name 'edi' in asm
: "edi", "esi", "ecx", "edx", "memory");
^
/Users/crb002/github/mbw/mbw.c:116:8: error: unknown type name 'pthread_barrier_t'
static pthread_barrier_t mt_barrier;
^
/Users/crb002/github/mbw/mbw.c:123:11: error: implicit declaration of function 'pthread_barrier_wait' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = pthread_barrier_wait(&mt_barrier);
^
/Users/crb002/github/mbw/mbw.c:124:28: error: use of undeclared identifier 'PTHREAD_BARRIER_SERIAL_THREAD'
if (ret != 0 && ret != PTHREAD_BARRIER_SERIAL_THREAD) {
^
/Users/crb002/github/mbw/mbw.c:134:5: error: use of undeclared identifier 'cpu_set_t'
cpu_set_t cs;
^
/Users/crb002/github/mbw/mbw.c:135:5: error: implicit declaration of function 'CPU_ZERO' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
CPU_ZERO(&cs);
^
/Users/crb002/github/mbw/mbw.c:135:15: error: use of undeclared identifier 'cs'
CPU_ZERO(&cs);
^
/Users/crb002/github/mbw/mbw.c:136:5: error: implicit declaration of function 'CPU_SET' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
CPU_SET(tid * core_factor, &cs);
^
/Users/crb002/github/mbw/mbw.c:136:33: error: use of undeclared identifier 'cs'
CPU_SET(tid * core_factor, &cs);
^
/Users/crb002/github/mbw/mbw.c:137:11: error: implicit declaration of function 'pthread_setaffinity_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cs);
^
/Users/crb002/github/mbw/mbw.c:137:57: error: use of undeclared identifier 'cpu_set_t'
ret = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cs);
^
/Users/crb002/github/mbw/mbw.c:137:70: error: use of undeclared identifier 'cs'
ret = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cs);
^
/Users/crb002/github/mbw/mbw.c:163:11: error: implicit declaration of function 'pthread_barrier_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = pthread_barrier_init(&mt_barrier, 0, mt_num);
^
/Users/crb002/github/mbw/mbw.c:163:11: note: did you mean 'pthread_attr_init'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/include/pthread.h:256:5: note: 'pthread_attr_init' declared here
int pthread_attr_init(pthread_attr_t *);
^
/Users/crb002/github/mbw/mbw.c:166:5: error: use of undeclared identifier 'cpu_set_t'
cpu_set_t cs;
^
/Users/crb002/github/mbw/mbw.c:167:5: error: implicit declaration of function 'CPU_ZERO' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
CPU_ZERO(&cs);
^
/Users/crb002/github/mbw/mbw.c:167:15: error: use of undeclared identifier 'cs'
CPU_ZERO(&cs);
^
/Users/crb002/github/mbw/mbw.c:168:5: error: implicit declaration of function 'sched_getaffinity' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
sched_getaffinity(0, sizeof(cs), &cs);
^
/Users/crb002/github/mbw/mbw.c:168:33: error: use of undeclared identifier 'cs'
sched_getaffinity(0, sizeof(cs), &cs);
^
/Users/crb002/github/mbw/mbw.c:168:39: error: use of undeclared identifier 'cs'
sched_getaffinity(0, sizeof(cs), &cs);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions