Skip to content

Commit

Permalink
end to end single source works :))))
Browse files Browse the repository at this point in the history
  • Loading branch information
hughperkins committed Apr 10, 2022
1 parent 0fdc00f commit a693786
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/cpp_single_source/sum_ints/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ g++ -o sum_ints sum_ints-hostpatched.o -L${BASEDIR}/prot/verilator/prot_single_s

set +x

for i in {1..10}; do {
# for i in {1..10}; do {
./sum_ints +verilator+rand+reset+2 +verilator+seed+$(($RANDOM * 65536 + $RANDOM))
} done
# } done
2 changes: 2 additions & 0 deletions examples/cpp_single_source/sum_ints/sum_ints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ int main(int argc, char **argv, char **env)
gpuCopyFromDevice((void *)&returnValue, ptrGpuOut, 1 * sizeof(uint32_t));
std::cout << "returned result " << returnValue << std::endl;
assert(returnValue == 31);
std::cout << "sum_ints.cpp before destroycontext" << std::endl;

gpuDestroyContext();
std::cout << "sum_ints.cpp after destroycontext" << std::endl;

exit(EXIT_SUCCESS);
}
7 changes: 6 additions & 1 deletion prot/verilator/prot_single_source/gpu_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ void gpuCreateContext()

void gpuDestroyContext()
{
std::cout << "gpuDestroyContext before delete dut" << std::endl;
delete dut;
std::cout << "gpuDestroyContext after delete dut" << std::endl;
dut = 0;
}

Expand Down Expand Up @@ -189,8 +191,11 @@ void gpuLaunchKernel(void *kernelPos, uint32_t numParams, const uint32_t *const
dut->cpu_in_data = p_params[i];
tick();
}
dut->cpu_recv_instr = NOP;

while (!dut->cpu_out_ack) {
while (!dut->cpu_out_ack)
{
std::cout << "gpu_runtime.cpp awaiting cpu_out_ack" << std::endl;
tick();
}
std::cout << "gpu_runtime.cpp gpuLaunchKernel kernel finished" << std::endl;
Expand Down
1 change: 1 addition & 0 deletions src/core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ module core(
c2_instr <= c2_instr_next;

if (set_pc_req) begin
$display("core updating PC to %0d", set_pc_addr);
pc <= set_pc_addr;
end

Expand Down
5 changes: 3 additions & 2 deletions src/gpu_controller.sv
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ module gpu_controller(
n_core_set_pc_addr = '0;

for(int i = 0; i < MAX_PARAMS; i++) begin
n_params[i] = '0;
n_params[i] = params[i];
end

if(rst) begin
Expand Down Expand Up @@ -267,7 +267,7 @@ module gpu_controller(
end
end
STATE_KERNEL_LAUNCH: begin
$display("gpu_controller state STATE_KERNEL_LAUNCH");
$display("gpu_controller state STATE_KERNEL_LAUNCH set PC to %0d", params[0]);
// n_core_ena = 1;
n_core_set_pc_req = 1;
n_core_set_pc_addr = params[0];
Expand Down Expand Up @@ -377,6 +377,7 @@ module gpu_controller(
param_pos <= n_param_pos;
num_params <= n_num_params;

// this probalby needs to be redone a bit, more like a register file
for(int i = 0; i < MAX_PARAMS; i++) begin
params[i] <= n_params[i];
end
Expand Down

0 comments on commit a693786

Please sign in to comment.