[Phi] fixing name consistency
This commit is contained in:
@@ -576,7 +576,9 @@ fn addPhiDaemonCompilerArgs(
|
||||
"-std=c11",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-unused-variable",
|
||||
"-pthread",
|
||||
});
|
||||
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+13
-5
@@ -1,9 +1,10 @@
|
||||
#include <Buffer.h>
|
||||
#include <Logger.h>
|
||||
#include <Memory.h>
|
||||
|
||||
#include <avx/Avx.h>
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <CommandBuffer.h>
|
||||
|
||||
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
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include <CommandBuffer.h>
|
||||
#include <Logger.h>
|
||||
|
||||
#include <Buffer.h>
|
||||
|
||||
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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+22
-11
@@ -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
|
||||
|
||||
@@ -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,7 +142,7 @@ 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",
|
||||
LogInfoFmt("Destroyed %s memory handle 0x%X",
|
||||
memory->type == PHI_MEMORY_LOCAL ? "local" : "host-mapped",
|
||||
request.remote_handle);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <Transport.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+5
-10
@@ -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);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <immintrin.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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));
|
||||
|
||||
+7
-7
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user