From e98907df8ea673b8817235204130b0e03357a891 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 18 Aug 2026 18:21:52 +0200 Subject: [PATCH] [Phi] fixing name consistency --- build.zig | 2 ++ compile_flags.txt | 1 + src/phi/PhiCommandBuffer.zig | 11 ++++++++++- src/phi/PhiImage.zig | 7 +++---- src/phi/mic/Buffer.c | 18 +++++++++++++----- src/phi/mic/Buffer.h | 4 ++-- src/phi/mic/CommandBuffer.c | 23 ++++++++++++++++------- src/phi/mic/CommandBuffer.h | 4 ++-- src/phi/mic/Daemon.c | 16 ++++++++-------- src/phi/mic/Logger.c | 2 +- src/phi/mic/Logger.h | 33 ++++++++++++++++++++++----------- src/phi/mic/Memory.c | 18 +++++++++--------- src/phi/mic/Transport.c | 12 ++++++------ src/phi/mic/Transport.h | 10 +++++----- src/phi/mic/avx/Copy.c | 15 +++++---------- src/phi/mic/avx/Intrinsic.h | 2 +- src/phi/mic/main.c | 14 +++++++------- src/phi/shared/Protocol.h | 1 + 18 files changed, 114 insertions(+), 79 deletions(-) diff --git a/build.zig b/build.zig index 3328035..776f7dd 100644 --- a/build.zig +++ b/build.zig @@ -576,7 +576,9 @@ fn addPhiDaemonCompilerArgs( "-std=c11", "-Wall", "-Wextra", + "-Werror", "-Wno-unused-parameter", + "-Wno-unused-variable", "-pthread", }); diff --git a/compile_flags.txt b/compile_flags.txt index 11a0a8b..320c958 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,5 +1,6 @@ -xc -std=c11 +-mavx512f -Isrc/phi/shared -Isrc/phi/mic -isystem/opt/mpss/3.8.6/sysroots/k1om-mpss-linux/usr/include/ diff --git a/src/phi/PhiCommandBuffer.zig b/src/phi/PhiCommandBuffer.zig index 0a8164c..e42fa27 100644 --- a/src/phi/PhiCommandBuffer.zig +++ b/src/phi/PhiCommandBuffer.zig @@ -367,8 +367,17 @@ pub fn fillBuffer(interface: *Interface, buffer: *base.Buffer, offset: vk.Device const memory = try remoteMemory(buffer); + var fill_size = if (size == vk.WHOLE_SIZE) + buffer.size - offset + else + size; + + // VK_WHOLE_SIZE fills only complete 4-byte words. Any trailing 1-3 bytes are untouched + if (size == vk.WHOLE_SIZE) + fill_size &= ~@as(vk.DeviceSize, 3); + try self.appendCommand(proto.PhiCmdFillBuffer, proto.PHI_CMD_FILL_BUFFER, .{ - .size = if (size == vk.WHOLE_SIZE) buffer.size - offset else size, + .size = fill_size, .memory = @intCast(memory.remote_handle), .offset = offset, .data = data, diff --git a/src/phi/PhiImage.zig b/src/phi/PhiImage.zig index 88e411d..8d767dc 100644 --- a/src/phi/PhiImage.zig +++ b/src/phi/PhiImage.zig @@ -1,15 +1,13 @@ const std = @import("std"); const vk = @import("vulkan"); const base = @import("base"); +const proto = @import("lib").proto; const VkError = base.VkError; const Self = @This(); pub const Interface = base.Image; -pub const F32x4 = @Vector(4, f32); -pub const U32x4 = @Vector(4, u32); - interface: Interface, pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.ImageCreateInfo) VkError!*Self { @@ -39,7 +37,8 @@ pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void { } pub fn getMemoryRequirements(_: *Interface, requirements: *vk.MemoryRequirements) VkError!void { - _ = requirements; + requirements.alignment = proto.PHI_MEMORY_ALIGNMENT; + requirements.size = std.mem.alignForward(vk.DeviceSize, requirements.size, proto.PHI_MEMORY_ALIGNMENT); } pub fn copyToMemory(interface: *const Interface, memory: []u8, subresource: vk.ImageSubresourceLayers) VkError!void { diff --git a/src/phi/mic/Buffer.c b/src/phi/mic/Buffer.c index c68d507..ce8f5e0 100644 --- a/src/phi/mic/Buffer.c +++ b/src/phi/mic/Buffer.c @@ -1,9 +1,10 @@ #include +#include #include #include -int PhiIsBufferCommand(const PhiCmdHeader* header) +int IsBufferCommand(const PhiCmdHeader* header) { switch((PhiCmdType)header->type) { @@ -19,7 +20,7 @@ int PhiIsBufferCommand(const PhiCmdHeader* header) static PhiStatus CopyBuffer(PhiCommandReader* reader) { PhiCmdCopyBuffer command; - PhiStatus status = PhiReadCommandData(reader, &command, sizeof(command)); + PhiStatus status = ReadCommandData(reader, &command, sizeof(command)); if(status != PHI_STATUS_OK) return status; @@ -41,13 +42,16 @@ static PhiStatus FillBuffer(PhiCommandReader* reader) { PhiCmdFillBuffer command; - PhiStatus status = PhiReadCommandData(reader, &command, sizeof(command)); + PhiStatus status = ReadCommandData(reader, &command, sizeof(command)); if(status != PHI_STATUS_OK) return status; if(command.memory == 0) + { + LogErrorFmt("Invalid memory handle: %p", command.memory); return PHI_STATUS_INVALID_HANDLE; + } Memory* memory = (Memory*)command.memory; @@ -57,8 +61,12 @@ static PhiStatus FillBuffer(PhiCommandReader* reader) const uint32_t value = command.data; // Check if dst and size are 4-byte aligned - if((((uintptr_t)dst | size) & 3) != 0) + uintptr_t alignment = ((uintptr_t)dst | size) & 3; + if(alignment != 0) + { + LogErrorFmt("Invalid memory alignment: %d", alignment); return PHI_STATUS_INVALID_ARGUMENT; + } // Bring dst to a 64-byte cache-line boundary. while(size >= 4 && ((uintptr_t)dst & 63) != 0) @@ -95,7 +103,7 @@ static PhiStatus FillBuffer(PhiCommandReader* reader) return PHI_STATUS_OK; } -PhiStatus PhiExecuteBufferCommand(PhiCommandReader* reader, const PhiCmdHeader* header) +PhiStatus ExecuteBufferCommand(PhiCommandReader* reader, const PhiCmdHeader* header) { switch((PhiCmdType)header->type) { diff --git a/src/phi/mic/Buffer.h b/src/phi/mic/Buffer.h index 90a2a58..194c6eb 100644 --- a/src/phi/mic/Buffer.h +++ b/src/phi/mic/Buffer.h @@ -3,7 +3,7 @@ #include -int PhiIsBufferCommand(const PhiCmdHeader* header); -PhiStatus PhiExecuteBufferCommand(PhiCommandReader* reader, const PhiCmdHeader* header); +int IsBufferCommand(const PhiCmdHeader* header); +PhiStatus ExecuteBufferCommand(PhiCommandReader* reader, const PhiCmdHeader* header); #endif diff --git a/src/phi/mic/CommandBuffer.c b/src/phi/mic/CommandBuffer.c index 5a51d42..3965d19 100644 --- a/src/phi/mic/CommandBuffer.c +++ b/src/phi/mic/CommandBuffer.c @@ -1,8 +1,9 @@ #include +#include #include -PhiStatus PhiReadCommandData(PhiCommandReader* reader, void* data, uint64_t size) +PhiStatus ReadCommandData(PhiCommandReader* reader, void* data, uint64_t size) { if(reader->remaining < size) return PHI_STATUS_BAD_MESSAGE; @@ -14,7 +15,7 @@ PhiStatus PhiReadCommandData(PhiCommandReader* reader, void* data, uint64_t size return PHI_STATUS_OK; } -int PhiDrainCommandReader(PhiCommandReader* reader) +int DrainCommandReader(PhiCommandReader* reader) { if(reader->remaining == 0) return 0; @@ -26,7 +27,7 @@ int PhiDrainCommandReader(PhiCommandReader* reader) static PhiStatus ReadCommandHeader(PhiCommandReader* reader, PhiCmdHeader* command_header) { - PhiStatus status = PhiReadCommandData(reader, command_header, sizeof(*command_header)); + PhiStatus status = ReadCommandData(reader, command_header, sizeof(*command_header)); if(status != PHI_STATUS_OK) return status; @@ -38,12 +39,17 @@ static PhiStatus ReadCommandHeader(PhiCommandReader* reader, PhiCmdHeader* comma static PhiStatus ExecuteCommand(PhiCommandReader* reader, const PhiCmdHeader* command_header) { - if(PhiIsBufferCommand(command_header)) - return PhiExecuteBufferCommand(reader, command_header); + if(IsBufferCommand(command_header)) + return ExecuteBufferCommand(reader, command_header); return PHI_STATUS_BAD_MESSAGE; } +static const char* CommandName[] = { + "CopyBuffer", + "FillBuffer", +}; + int HandleWorkExecution(PhiEndpoint endpoint, const PhiMessageHeader* header) { PhiWorkExecutionRequest request; @@ -71,7 +77,7 @@ int HandleWorkExecution(PhiEndpoint endpoint, const PhiMessageHeader* header) if(reader.remaining != request.command_buffer_size) { - if(PhiDrainCommandReader(&reader) < 0) + if(DrainCommandReader(&reader) < 0) return -1; reply.result.status = PHI_STATUS_BAD_MESSAGE; return SendReply(endpoint, header, &reply, sizeof(reply)); @@ -86,10 +92,13 @@ int HandleWorkExecution(PhiEndpoint endpoint, const PhiMessageHeader* header) reply.result.status = ExecuteCommand(&reader, &cmd_header); if(reply.result.status != PHI_STATUS_OK) + { + LogErrorFmt("Command %s execution failed: %s", CommandName[cmd_header.type], StatusName[reply.result.status]); break; + } } - if(reader.remaining > 0 && PhiDrainCommandReader(&reader) < 0) + if(reader.remaining > 0 && DrainCommandReader(&reader) < 0) return -1; return SendReply(endpoint, header, &reply, sizeof(reply)); diff --git a/src/phi/mic/CommandBuffer.h b/src/phi/mic/CommandBuffer.h index da2a6b9..ec5fdf4 100644 --- a/src/phi/mic/CommandBuffer.h +++ b/src/phi/mic/CommandBuffer.h @@ -10,7 +10,7 @@ typedef struct PhiCommandReader } PhiCommandReader; int HandleWorkExecution(PhiEndpoint endpoint, const PhiMessageHeader* header); -int PhiDrainCommandReader(PhiCommandReader* reader); -PhiStatus PhiReadCommandData(PhiCommandReader* reader, void* data, uint64_t size); +int DrainCommandReader(PhiCommandReader* reader); +PhiStatus ReadCommandData(PhiCommandReader* reader, void* data, uint64_t size); #endif diff --git a/src/phi/mic/Daemon.c b/src/phi/mic/Daemon.c index b2db356..42024ff 100644 --- a/src/phi/mic/Daemon.c +++ b/src/phi/mic/Daemon.c @@ -35,20 +35,20 @@ static int HandleHello(PhiEndpoint endpoint, const PhiMessageHeader* header) PhiEndpoint StartDaemon(void) { - PhiLogInfo("Starting the daemon..."); + LogInfo("Starting the daemon..."); - PhiEndpoint endpoint = PhiTransportListen(PHI_TRANSPORT_PORT); + PhiEndpoint endpoint = TransportListen(PHI_TRANSPORT_PORT); if(endpoint == PHI_ENDPOINT_INVALID) - PhiLogError("Could not listen on the Phi transport"); + LogError("Could not listen on the Phi transport"); - PhiLogInfo("Daemon started"); + LogInfo("Daemon started"); return endpoint; } void ShutdownDaemon(PhiEndpoint endpoint) { - PhiLogInfo("Shutting down the daemon..."); - PhiTransportClose(endpoint); + LogInfo("Shutting down the daemon..."); + TransportClose(endpoint); } int HandlePacket(PhiEndpoint endpoint) @@ -116,7 +116,7 @@ int ReadAll(PhiEndpoint endpoint, void* data, size_t size) while(offset < size) { - ssize_t got = PhiTransportReceive(endpoint, bytes + offset, size - offset); + ssize_t got = TransportReceive(endpoint, bytes + offset, size - offset); if(got <= 0) return -1; offset += (size_t)got; @@ -132,7 +132,7 @@ int WriteAll(PhiEndpoint endpoint, const void* data, size_t size) while(offset < size) { - ssize_t sent = PhiTransportSend(endpoint, bytes + offset, size - offset); + ssize_t sent = TransportSend(endpoint, bytes + offset, size - offset); if(sent <= 0) return -1; offset += (size_t)sent; diff --git a/src/phi/mic/Logger.c b/src/phi/mic/Logger.c index cd1858e..4ed8a67 100644 --- a/src/phi/mic/Logger.c +++ b/src/phi/mic/Logger.c @@ -37,7 +37,7 @@ inline static void SetConsoleColor(FILE* file, int code) fprintf(file, "\033[1;%dm", code); } -void PhiLog(PhiLogLevel level, const char* fmt, const char* file, const char* function, int line, ...) +void Log(LogLevel level, const char* fmt, const char* file, const char* function, int line, ...) { time_t now = time(0); struct tm tstruct = *localtime(&now); diff --git a/src/phi/mic/Logger.h b/src/phi/mic/Logger.h index b0bb4e7..321253e 100644 --- a/src/phi/mic/Logger.h +++ b/src/phi/mic/Logger.h @@ -1,24 +1,35 @@ #ifndef APE_PHI_LOGGER_H #define APE_PHI_LOGGER_H -typedef enum PhiLogLevel +typedef enum LogLevel { PHI_LOG_LEVEL_INFO = 0, PHI_LOG_LEVEL_WARN = 1, PHI_LOG_LEVEL_ERR = 2, PHI_LOG_LEVEL_FATAL = 3, -} PhiLogLevel; +} LogLevel; -void PhiLog(PhiLogLevel level, const char* fmt, const char* file, const char* function, int line, ...); +static const char* StatusName[] = { + "OK", + "Bad Message", + "Unsupported version", + "Unsupported packed", + "Out of memory", + "Invalid handle", + "Host memory map failed", + "Invalid argument", +}; -#define PhiLogError(msg) PhiLog(PHI_LOG_LEVEL_ERR, msg, __FILE__, __FUNCTION__, __LINE__) -#define PhiLogWarning(msg) PhiLog(PHI_LOG_LEVEL_WARN, msg, __FILE__, __FUNCTION__, __LINE__) -#define PhiLogInfo(msg) PhiLog(PHI_LOG_LEVEL_INFO, msg, __FILE__, __FUNCTION__, __LINE__) -#define PhiLogFatal(msg) PhiLog(PHI_LOG_LEVEL_FATAL, msg, __FILE__, __FUNCTION__, __LINE__) +void Log(LogLevel level, const char* fmt, const char* file, const char* function, int line, ...); -#define PhiLogErrorFmt(msg, ...) PhiLog(PHI_LOG_LEVEL_ERR, msg, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) -#define PhiLogWarningFmt(msg, ...) PhiLog(PHI_LOG_LEVEL_WARN, msg, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) -#define PhiLogInfoFmt(msg, ...) PhiLog(PHI_LOG_LEVEL_INFO, msg, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) -#define PhiLogFatalFmt(msg, ...) PhiLog(PHI_LOG_LEVEL_FATAL, msg, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) +#define LogError(msg) Log(PHI_LOG_LEVEL_ERR, msg, __FILE__, __FUNCTION__, __LINE__) +#define LogWarning(msg) Log(PHI_LOG_LEVEL_WARN, msg, __FILE__, __FUNCTION__, __LINE__) +#define LogInfo(msg) Log(PHI_LOG_LEVEL_INFO, msg, __FILE__, __FUNCTION__, __LINE__) +#define LogFatal(msg) Log(PHI_LOG_LEVEL_FATAL, msg, __FILE__, __FUNCTION__, __LINE__) + +#define LogErrorFmt(msg, ...) Log(PHI_LOG_LEVEL_ERR, msg, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) +#define LogWarningFmt(msg, ...) Log(PHI_LOG_LEVEL_WARN, msg, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) +#define LogInfoFmt(msg, ...) Log(PHI_LOG_LEVEL_INFO, msg, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) +#define LogFatalFmt(msg, ...) Log(PHI_LOG_LEVEL_FATAL, msg, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) #endif diff --git a/src/phi/mic/Memory.c b/src/phi/mic/Memory.c index 19e6f4d..f02c1bf 100644 --- a/src/phi/mic/Memory.c +++ b/src/phi/mic/Memory.c @@ -17,7 +17,7 @@ static Memory* MapHostMemory(PhiEndpoint epd, const PhiMapHostMemoryRequest* req if(ptr == MAP_FAILED) { - PhiLogErrorFmt("Failed to map host memory: %s", strerror(errno)); + LogErrorFmt("Failed to map host memory: %s", strerror(errno)); return NULL; } @@ -25,7 +25,7 @@ static Memory* MapHostMemory(PhiEndpoint epd, const PhiMapHostMemoryRequest* req if(!memory) { scif_munmap(ptr, request->scif_size); - PhiLogError("Failed to allocate memory"); + LogError("Failed to allocate memory"); return NULL; } @@ -80,9 +80,9 @@ int HandleNewMemory(PhiEndpoint endpoint, const PhiMessageHeader* header) return -1; memory = AllocMemory(endpoint, &request); if(memory == NULL) - PhiLogErrorFmt("Failed to allocate %zu bytes", (size_t)request.size); + LogErrorFmt("Failed to allocate %zu bytes", (size_t)request.size); else - PhiLogInfoFmt("Allocated %llu bytes to handle 0x%X", request.size, (uintptr_t)memory); + LogInfoFmt("Allocated %llu bytes to handle 0x%X", request.size, (uintptr_t)memory); } else if(header->type == PHI_PACKET_MAP_HOST_MEMORY) { @@ -93,7 +93,7 @@ int HandleNewMemory(PhiEndpoint endpoint, const PhiMessageHeader* header) if(memory == NULL) reply.result.status = PHI_STATUS_MAP_HOST_MEMORY_FAILED; else - PhiLogInfoFmt("Mapped host memory to handle 0x%X", (uint64_t)(uintptr_t)memory); + LogInfoFmt("Mapped host memory to handle 0x%X", (uint64_t)(uintptr_t)memory); } if(memory != NULL) @@ -131,7 +131,7 @@ int HandleDestroyMemory(PhiEndpoint endpoint, const PhiMessageHeader* header) if(request.remote_handle == 0) { reply.result.status = PHI_STATUS_INVALID_HANDLE; - PhiLogErrorFmt("Could not free memory: invalid handle 0x%X", request.remote_handle); + LogErrorFmt("Could not free memory: invalid handle 0x%X", request.remote_handle); } else { @@ -142,9 +142,9 @@ int HandleDestroyMemory(PhiEndpoint endpoint, const PhiMessageHeader* header) else if(memory->type == PHI_MEMORY_HOST_MAPPED) scif_munmap((void*)memory->ptr, memory->size); - PhiLogInfoFmt("Destroyed %s memory handle 0x%X", - memory->type == PHI_MEMORY_LOCAL ? "local" : "host-mapped", - request.remote_handle); + LogInfoFmt("Destroyed %s memory handle 0x%X", + memory->type == PHI_MEMORY_LOCAL ? "local" : "host-mapped", + request.remote_handle); } return SendReply(endpoint, header, &reply, sizeof(reply)); diff --git a/src/phi/mic/Transport.c b/src/phi/mic/Transport.c index 42d4be9..905d533 100644 --- a/src/phi/mic/Transport.c +++ b/src/phi/mic/Transport.c @@ -1,6 +1,6 @@ #include -PhiEndpoint PhiTransportAccept(PhiEndpoint endpoint) +PhiEndpoint TransportAccept(PhiEndpoint endpoint) { struct scif_portID peer; PhiEndpoint client = PHI_ENDPOINT_INVALID; @@ -9,12 +9,12 @@ PhiEndpoint PhiTransportAccept(PhiEndpoint endpoint) return client; } -int PhiTransportClose(PhiEndpoint endpoint) +int TransportClose(PhiEndpoint endpoint) { return scif_close(endpoint); } -PhiEndpoint PhiTransportListen(uint16_t port) +PhiEndpoint TransportListen(uint16_t port) { PhiEndpoint endpoint = scif_open(); if(endpoint == PHI_ENDPOINT_INVALID) @@ -22,18 +22,18 @@ PhiEndpoint PhiTransportListen(uint16_t port) if(scif_bind(endpoint, port) < 0 || scif_listen(endpoint, 16) < 0) { - PhiTransportClose(endpoint); + TransportClose(endpoint); return PHI_ENDPOINT_INVALID; } return endpoint; } -ssize_t PhiTransportReceive(PhiEndpoint endpoint, void* data, size_t size) +ssize_t TransportReceive(PhiEndpoint endpoint, void* data, size_t size) { return scif_recv(endpoint, data, size, SCIF_RECV_BLOCK); } -ssize_t PhiTransportSend(PhiEndpoint endpoint, const void* data, size_t size) +ssize_t TransportSend(PhiEndpoint endpoint, const void* data, size_t size) { return scif_send(endpoint, (void*)data, size, SCIF_SEND_BLOCK); } diff --git a/src/phi/mic/Transport.h b/src/phi/mic/Transport.h index bd0afdd..77e65f2 100644 --- a/src/phi/mic/Transport.h +++ b/src/phi/mic/Transport.h @@ -10,11 +10,11 @@ typedef scif_epd_t PhiEndpoint; #define PHI_ENDPOINT_INVALID ((PhiEndpoint) - 1) -PhiEndpoint PhiTransportAccept(PhiEndpoint endpoint); -int PhiTransportClose(PhiEndpoint endpoint); +PhiEndpoint TransportAccept(PhiEndpoint endpoint); +int TransportClose(PhiEndpoint endpoint); -PhiEndpoint PhiTransportListen(uint16_t port); -ssize_t PhiTransportReceive(PhiEndpoint endpoint, void* data, size_t size); -ssize_t PhiTransportSend(PhiEndpoint endpoint, const void* data, size_t size); +PhiEndpoint TransportListen(uint16_t port); +ssize_t TransportReceive(PhiEndpoint endpoint, void* data, size_t size); +ssize_t TransportSend(PhiEndpoint endpoint, const void* data, size_t size); #endif diff --git a/src/phi/mic/avx/Copy.c b/src/phi/mic/avx/Copy.c index b6120e8..e5a70e5 100644 --- a/src/phi/mic/avx/Copy.c +++ b/src/phi/mic/avx/Copy.c @@ -5,11 +5,6 @@ #define PHI_CACHE_LINE_SIZE 64 -static inline __m512i Load512KNC(const uint8_t* src) -{ - return _mm512_load_epi32((const void*)src); -} - void AvxCopy(uint8_t* dst, const uint8_t* src, size_t size) { if(size == 0) @@ -74,10 +69,10 @@ void AvxCopy(uint8_t* dst, const uint8_t* src, size_t size) // KNC's loadunpack pair implements the conceptual unaligned 64-byte load. while(size >= 256) { - const __m512i v0 = Load512KNC(src + 0); - const __m512i v1 = Load512KNC(src + 64); - const __m512i v2 = Load512KNC(src + 128); - const __m512i v3 = Load512KNC(src + 192); + const __m512i v0 = _mm512_load_epi32((const void*)(src + 0)); + const __m512i v1 = _mm512_load_epi32((const void*)(src + 64)); + const __m512i v2 = _mm512_load_epi32((const void*)(src + 128)); + const __m512i v3 = _mm512_load_epi32((const void*)(src + 192)); _mm512_store_epi32((void*)(dst + 0), v0); _mm512_store_epi32((void*)(dst + 64), v1); @@ -91,7 +86,7 @@ void AvxCopy(uint8_t* dst, const uint8_t* src, size_t size) while(size >= 64) { - const __m512i value = Load512KNC(src); + const __m512i value = _mm512_load_epi32((const void*)src); _mm512_store_epi32((void*)dst, value); diff --git a/src/phi/mic/avx/Intrinsic.h b/src/phi/mic/avx/Intrinsic.h index 8c3dd8a..a0c6d4b 100644 --- a/src/phi/mic/avx/Intrinsic.h +++ b/src/phi/mic/avx/Intrinsic.h @@ -4,7 +4,7 @@ #include #include -static inline __attribute__((always_inline)) __m512i _mm512_set1_epi32_knc(uint32_t value) +inline __attribute__((always_inline)) __m512i _mm512_set1_epi32_knc(uint32_t value) { __m512i result; __asm__("vpbroadcastd %1, %0" : "=x"(result) : "m"(value)); diff --git a/src/phi/mic/main.c b/src/phi/mic/main.c index 102e578..42aaadc 100644 --- a/src/phi/mic/main.c +++ b/src/phi/mic/main.c @@ -10,7 +10,7 @@ static void* HandleClient(void* const argument) PhiEndpoint client = (PhiEndpoint)(intptr_t)argument; (void)HandlePacket(client); - PhiTransportClose(client); + TransportClose(client); return NULL; } @@ -28,30 +28,30 @@ int main(int argc, char** argv) if(pthread_attr_init(&client_thread_attributes) != 0 || pthread_attr_setdetachstate(&client_thread_attributes, PTHREAD_CREATE_DETACHED) != 0) { - PhiLogError("Could not initialize client thread attributes"); + LogError("Could not initialize client thread attributes"); ShutdownDaemon(endpoint); return 1; } for(;;) { - PhiEndpoint client = PhiTransportAccept(endpoint); + PhiEndpoint client = TransportAccept(endpoint); if(client == PHI_ENDPOINT_INVALID) { if(errno == EINTR) continue; - PhiLogError("Could not accept transport connection"); + LogError("Could not accept transport connection"); break; } - PhiLogInfo("Host connected to the daemon"); + LogInfo("Host connected to the daemon"); pthread_t client_thread; if(pthread_create(&client_thread, &client_thread_attributes, HandleClient, (void*)(intptr_t)client) != 0) { - PhiLogError("Could not create transport client thread"); - PhiTransportClose(client); + LogError("Could not create transport client thread"); + TransportClose(client); } } diff --git a/src/phi/shared/Protocol.h b/src/phi/shared/Protocol.h index e4068d6..d61115f 100644 --- a/src/phi/shared/Protocol.h +++ b/src/phi/shared/Protocol.h @@ -26,6 +26,7 @@ typedef enum PhiPacketType PHI_PACKET_MAP_HOST_MEMORY = 8, } PhiPacketType; +// When adding status, update StatusName in Logger.h typedef enum PhiStatus { PHI_STATUS_OK = 0,