ane: procPath issue. don't waste more time with this, focus on core tinygrad
MODIFY
accel/ane/3_run/build.sh
accel/ane/3_run/build.sh
-#!/bin/bash
+#!/bin/bash -e
clang++ test.mm -F /System/Library/PrivateFrameworks/ -framework ANEServices -framework IOSurface -framework Foundation -framework IOKit
codesign --entitlements entitlements.xml -s "Taylor Swift Child 2" a.out

MODIFY
accel/ane/3_run/h11ane.h
accel/ane/3_run/h11ane.h
@@ -5,8 +5,13 @@ enum ANEDeviceUsageType {
};
struct H11ANEDeviceInfoStruct {
- uint64_t nothing;
uint64_t program_handle;
+ uint64_t program_auth_code;
+ uint64_t sleep_timer;
+ uint64_t junk[0x100];
+};
+
+struct H11ANEStatusStruct {
uint64_t junk[0x100];
};
@@ -112,6 +117,8 @@ namespace H11ANE {
void *param_2, ANEDeviceUsageType param_3, H11ANEDeviceInfoStruct *param_4);
void EnableDeviceMessages();
+ int ANE_AddPersistentClient();
+ int ANE_GetStatus(H11ANEStatusStruct *param_1);
// power management
int ANE_IsPowered();

MODIFY
accel/ane/3_run/test.mm
accel/ane/3_run/test.mm
@@ -45,30 +45,41 @@ int main() {
char empty[0x90] = {0};
H11ANEDeviceInfoStruct dis = {0};
+ //dis.nothing = 0x87c15a20a;
+ //dis.sleep_timer = 5000;
ret = dev->H11ANEDeviceOpen(MyH11ANEDeviceMessageNotification, empty, UsageCompile, &dis);
printf("open 0x%x %p\n", ret, dev);
+ /*ret = dev->ANE_AddPersistentClient();
+ printf("add persistent %x\n", ret);*/
+
+ H11ANEStatusStruct blah = {0};
+ ret = dev->ANE_GetStatus(&blah);
+ printf("get status %x\n", ret);
+
+ // this isn't callable anymore, it requires debugger
ret = dev->ANE_PowerOn();
- printf("power on: %d\n", ret);
+ printf("power on: %x\n", ret);
ret = dev->ANE_IsPowered();
printf("powered? %d\n", ret);
- if (ret == 0) {
+ /*if (ret == 0) {
printf("POWER ON FAILED\n");
return -1;
- }
+ }*/
+
+ H11ANEProgramCreateArgsStruct mprog = {0};
+ mprog.program_length = 0xc000;
+ char *prog = (char*)aligned_alloc(0x1000, mprog.program_length);
+ mprog.program = prog;
- char *prog = (char*)aligned_alloc(0x1000, 0x8000);
FILE *f = fopen("../2_compile/model.hwx", "rb");
- int sz = fread(prog, 1, 0x8000, f);
+ assert(f);
+ int sz = fread(prog, 1, mprog.program_length, f);
printf("read %x %p\n", sz, prog);
fclose(f);
- H11ANEProgramCreateArgsStruct mprog = {0};
- mprog.program = prog;
- mprog.program_length = 0x8000;
-
H11ANEProgramCreateArgsStructOutput *out = new H11ANEProgramCreateArgsStructOutput;
memset(out, 0, sizeof(H11ANEProgramCreateArgsStructOutput));
ret = dev->ANE_ProgramCreate(&mprog, out);
@@ -78,6 +89,7 @@ int main() {
H11ANEProgramPrepareArgsStruct pas = {0};
pas.program_handle = program_handle;
pas.flags = 0x0000000100010001;
+ //pas.flags = 0x0000000102010001;
ret = dev->ANE_ProgramPrepare(&pas);
printf("program prepare: %lx\n", ret);
@@ -134,7 +146,20 @@ int main() {
IOCreateReceivePort(kOSAsyncCompleteMessageID, &recvPort);
printf("recv port: 0x%x\n", recvPort);
- // run program
+ // *** reopen with other client ***
+ H11ANEDeviceController dc2(MyH11ANEDeviceControllerNotification, NULL);
+ dc2.SetupDeviceController();
+ assert(device != NULL);
+ dev = device;
+ dev->EnableDeviceMessages();
+
+ char empty2[0x90] = {0};
+ dis.program_handle = program_handle;
+ dis.program_auth_code = 0;
+ ret = dev->H11ANEDeviceOpen(MyH11ANEDeviceMessageNotification, empty2, UsageWithProgram, &dis);
+ printf("reopen 0x%x %p\n", ret, dev);
+
+ // run program (i think we need the other client for this)
ret = dev->ANE_ProgramSendRequest(pras, recvPort);
printf("send 0x%x\n", ret);

ane: procPath issue. don't waste more time with this, focus on core tinygrad