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

Commit

Permalink
Merge branch 'main' of github.com:microsoft/dpdpu into main
Browse files Browse the repository at this point in the history
  • Loading branch information
qizzz committed Dec 23, 2023
2 parents fba12bd + 31b777d commit 1abaaf0
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 47 deletions.
36 changes: 12 additions & 24 deletions DPDPU/OffloadEngine/UDFSamples/OffloadFunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,22 @@
#include "OffloadTypes.h"
#include <stdio.h>

struct MessageHeader {
long long TimeSend;
uint16_t BatchId;
uint16_t FileId;
uint64_t Offset;
int Length;
};

void OffloadFunc(
void* Msg,
RequestDescriptorT* Req,
CacheTableT* CacheTable,
OffloadWorkRequest* ReadOp
) {
// Msg is basically one packet, descriptor's offset and bytes point to the data we are interested in
//printf("offload func got msg: %s, offset: %hu, bytes: %hu\n", Msg, Req->Offset, Req->Bytes);
// ReadOp->RequestId = ??; // it's already assigned when we got it, don't touch
printf("request id: %u\n", ReadOp->RequestId);
ReadOp->FileId = 0; // always 0th file
ReadOp->Bytes = 8192;
ReadOp->Offset = 8192;
/*CacheItemT Item = {.Key = ReadOp->RequestId, .Version = 0, .FileId = 0, .Offset = 0, .Size = 8192};
int ret = AddToCacheTable(&Item);
CacheItemT* GotItem = LookUpCacheTable(&ReadOp->RequestId);
if (GotItem == NULL) {
printf("LookUpCacheTable returned NULL!!!\n");
return;
}
printf("Got item back, key %u, offset %u, size %u\n", GotItem->Key, GotItem->Offset, GotItem->Size);
// GotItem = NULL;
DeleteFromCacheTable(&ReadOp->RequestId);
GotItem = LookUpCacheTable(&ReadOp->RequestId);
if (GotItem != NULL) {
printf("LookUpCacheTable returned non NULL after delete!!!\n");
return;
}*/

//// once the read request is prepared it will eventually be completed and send the raw read content back to tcp client
struct MessageHeader* msg = (struct MessageHeader*)(((char*)Msg) + Req->Offset);
ReadOp->FileId = msg->FileId;
ReadOp->Bytes = msg->Length;
ReadOp->Offset = msg->Offset;
}
23 changes: 23 additions & 0 deletions DPDPU/OffloadEngine/UDFSamples/OffloadFuncDisaggApp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "CacheTable.h"
#include "OffloadTypes.h"
#include <stdio.h>

struct MessageHeader {
long long TimeSend;
uint16_t BatchId;
uint16_t FileId;
uint64_t Offset;
int Length;
};

void OffloadFunc(
void* Msg,
RequestDescriptorT* Req,
CacheTableT* CacheTable,
OffloadWorkRequest* ReadOp
) {
struct MessageHeader* msg = (struct MessageHeader*)(((char*)Msg) + Req->Offset);
ReadOp->FileId = msg->FileId;
ReadOp->Bytes = msg->Length;
ReadOp->Offset = msg->Offset;
}
35 changes: 35 additions & 0 deletions DPDPU/OffloadEngine/UDFSamples/OffloadFuncExample.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "CacheTable.h"
#include "OffloadTypes.h"
#include <stdio.h>

void OffloadFunc(
void* Msg,
RequestDescriptorT* Req,
CacheTableT* CacheTable,
OffloadWorkRequest* ReadOp
) {
// Msg is basically one packet, descriptor's offset and bytes point to the data we are interested in
//printf("offload func got msg: %s, offset: %hu, bytes: %hu\n", Msg, Req->Offset, Req->Bytes);
// ReadOp->RequestId = ??; // it's already assigned when we got it, don't touch
printf("request id: %u\n", ReadOp->RequestId);
ReadOp->FileId = 0; // always 0th file
ReadOp->Bytes = 8192;
ReadOp->Offset = 8192;
/*CacheItemT Item = {.Key = ReadOp->RequestId, .Version = 0, .FileId = 0, .Offset = 0, .Size = 8192};
int ret = AddToCacheTable(&Item);
CacheItemT* GotItem = LookUpCacheTable(&ReadOp->RequestId);
if (GotItem == NULL) {
printf("LookUpCacheTable returned NULL!!!\n");
return;
}
printf("Got item back, key %u, offset %u, size %u\n", GotItem->Key, GotItem->Offset, GotItem->Size);
// GotItem = NULL;
DeleteFromCacheTable(&ReadOp->RequestId);
GotItem = LookUpCacheTable(&ReadOp->RequestId);
if (GotItem != NULL) {
printf("LookUpCacheTable returned non NULL after delete!!!\n");
return;
}*/

//// once the read request is prepared it will eventually be completed and send the raw read content back to tcp client
}
37 changes: 14 additions & 23 deletions DPDPU/OffloadEngine/UDFSamples/OffloadPred.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
#include "OffloadTypes.h"
#include <stdio.h>

/* struct MessageHeader {
bool OffloadedToDPU;
bool LastMessage;
int MessageSize;
struct MessageHeader {
long long TimeSend;
uint16_t BatchId;
uint16_t FileId;
uint64_t Offset;
int Length;
};

void OffloadPred(
Expand All @@ -18,24 +19,14 @@ void OffloadPred(
uint8_t* NumReqsForHost,
uint8_t* NumReqsForDPU
) {
*NumReqsForHost = 1;
*NumReqsForDPU = 0;
ReqsForHost[0].Offset = 0;
ReqsForHost[0].Bytes = Bytes;
} */
const uint16_t reqSize = sizeof(struct MessageHeader);
const int numReqsForDPU = Bytes / reqSize;

void OffloadPred(
void* Msg,
uint16_t Bytes,
CacheTableT* CacheTable,
RequestDescriptorT* ReqsForHost,
RequestDescriptorT* ReqsForDPU,
uint8_t* NumReqsForHost,
uint8_t* NumReqsForDPU
) {
*NumReqsForHost = 0;
*NumReqsForDPU = 1;
ReqsForDPU[0].Offset = 0;
ReqsForDPU[0].Bytes = Bytes;
printf("offload pred got msg, bytes: %hu\n", Bytes);
}
*NumReqsForDPU = numReqsForDPU;

for (int i = 0; i != numReqsForDPU; i++) {
ReqsForDPU[i].Offset = i * reqSize;
ReqsForDPU[i].Bytes = reqSize;
}
}
32 changes: 32 additions & 0 deletions DPDPU/OffloadEngine/UDFSamples/OffloadPredDisaggApp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "CacheTable.h"
#include "OffloadTypes.h"
#include <stdio.h>

struct MessageHeader {
long long TimeSend;
uint16_t BatchId;
uint16_t FileId;
uint64_t Offset;
int Length;
};

void OffloadPred(
void* Msg,
uint16_t Bytes,
CacheTableT* CacheTable,
RequestDescriptorT* ReqsForHost,
RequestDescriptorT* ReqsForDPU,
uint8_t* NumReqsForHost,
uint8_t* NumReqsForDPU
) {
const uint16_t reqSize = sizeof(struct MessageHeader);
const int numReqsForDPU = Bytes / reqSize;

*NumReqsForHost = 0;
*NumReqsForDPU = numReqsForDPU;

for (int i = 0; i != numReqsForDPU; i++) {
ReqsForDPU[i].Offset = i * reqSize;
ReqsForDPU[i].Bytes = reqSize;
}
}
41 changes: 41 additions & 0 deletions DPDPU/OffloadEngine/UDFSamples/OffloadPredExample.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "CacheTable.h"
#include "OffloadTypes.h"
#include <stdio.h>

/* struct MessageHeader {
bool OffloadedToDPU;
bool LastMessage;
int MessageSize;
long long TimeSend;
};
void OffloadPred(
void* Msg,
uint16_t Bytes,
CacheTableT* CacheTable,
RequestDescriptorT* ReqsForHost,
RequestDescriptorT* ReqsForDPU,
uint8_t* NumReqsForHost,
uint8_t* NumReqsForDPU
) {
*NumReqsForHost = 1;
*NumReqsForDPU = 0;
ReqsForHost[0].Offset = 0;
ReqsForHost[0].Bytes = Bytes;
} */

void OffloadPred(
void* Msg,
uint16_t Bytes,
CacheTableT* CacheTable,
RequestDescriptorT* ReqsForHost,
RequestDescriptorT* ReqsForDPU,
uint8_t* NumReqsForHost,
uint8_t* NumReqsForDPU
) {
*NumReqsForHost = 0;
*NumReqsForDPU = 1;
ReqsForDPU[0].Offset = 0;
ReqsForDPU[0].Bytes = Bytes;
printf("offload pred got msg, bytes: %hu\n", Bytes);
}

0 comments on commit 1abaaf0

Please sign in to comment.