Skip to content

Commit

Permalink
adjusting setup operation to get the right offset
Browse files Browse the repository at this point in the history
  • Loading branch information
caiomcbr committed Nov 11, 2024
1 parent 9526d76 commit a55ce5a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/executor/execution_plan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,19 @@ void ExecutionPlan::Impl::setupChannels(const json& gpus) {
}

void ExecutionPlan::Impl::setupOperations(const json& gpus, size_t contsSrcOffset, size_t constDstOffset) {
auto getConstOffset = [&](BufferType type) -> size_t {
switch (type) {
case BufferType::INPUT:
return contsSrcOffset;
case BufferType::OUTPUT:
return constDstOffset;
case BufferType::SCRATCH:
return 0;
default:
throw Error("Invalid buffer type", ErrorCode::ExecutorError);
}
};

// setup threadblocks and operations
for (const auto& gpu : gpus) {
int rank = gpu["id"];
Expand Down Expand Up @@ -326,7 +339,7 @@ void ExecutionPlan::Impl::setupOperations(const json& gpus, size_t contsSrcOffse
channelIndexes[{srcBufferType, dstBufferType, operation.channelType}][op["i_cids"][i]["id"]];
operation.inputOffsets[i] =
this->getOffset(rank, this->inputSize, this->outputSize, (uint32_t)op["i_cids"][i]["off"]) +
(srcBufferType != BufferType::SCRATCH ? contsSrcOffset : 0);
getConstOffset(srcBufferType);
chunkIndexes.push_back((uint32_t)op["i_cids"][i]["off"]);
}
}
Expand All @@ -337,7 +350,7 @@ void ExecutionPlan::Impl::setupOperations(const json& gpus, size_t contsSrcOffse
for (int i = 0; i < operation.nInputs; i++) {
operation.inputOffsets[i] =
this->getOffset(rank, this->inputSize, this->outputSize, (uint32_t)op["srcs"][i]["off"]) +
(operation.inputBufferType != BufferType::SCRATCH ? contsSrcOffset : 0);
getConstOffset(operation.inputBufferType);
chunkIndexes.push_back((uint32_t)op["srcs"][i]["off"]);
}
}
Expand All @@ -350,7 +363,7 @@ void ExecutionPlan::Impl::setupOperations(const json& gpus, size_t contsSrcOffse
channelIndexes[{srcBufferType, dstBufferType, operation.channelType}][op["o_cids"][i]["id"]];
operation.outputOffsets[i] =
this->getOffset(rank, this->inputSize, this->outputSize, (uint32_t)op["o_cids"][i]["off"]) +
(dstBufferType != BufferType::SCRATCH ? constDstOffset : 0);
getConstOffset(dstBufferType);
chunkIndexes.push_back((uint32_t)op["o_cids"][i]["off"]);
}
}
Expand All @@ -361,7 +374,7 @@ void ExecutionPlan::Impl::setupOperations(const json& gpus, size_t contsSrcOffse
for (int i = 0; i < operation.nOutputs; i++) {
operation.outputOffsets[i] =
this->getOffset(rank, this->inputSize, this->outputSize, (uint32_t)op["dsts"][i]["off"]) +
(operation.outputBufferType != BufferType::SCRATCH ? constDstOffset : 0);
getConstOffset(operation.outputBufferType);
chunkIndexes.push_back((uint32_t)op["dsts"][i]["off"]);
}
}
Expand Down

0 comments on commit a55ce5a

Please sign in to comment.