Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heat 3D #6

Merged
merged 4 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,12 @@ int main(int argc, char **argv)

runtime_blacksholes_kernel += std::chrono::duration<double, std::micro>(blacksholes_calc_stop_clk_point - blacksholes_calc_start_clk_point).count();

#ifdef DEBUG_VERBOSE
//fetching back result
ops_dat_fetch_data_host(dat_current, 0, (char*)(grid_ops_result + offset + 1));

auto device_to_host_stop_clk_point = std::chrono::high_resolution_clock::now();

runtime_device_to_host += std::chrono::duration<double, std::micro>(device_to_host_stop_clk_point - blacksholes_calc_stop_clk_point).count();
#endif
}

auto ops_stop_clk_point = std::chrono::high_resolution_clock::now();
Expand All @@ -330,12 +330,12 @@ int main(int argc, char **argv)
<< " explicit1_ops_val: " << grid_ops_result[offset + i]<< std::endl;
}
}
#endif

std::cout << "call option[0] price from explicit method: " << get_call_option(grid_u1_cpu, calcParam[0]) << std::endl;
std::cout << "call option[0] price from ops explicit method: " << get_call_option(grid_ops_result, calcParam[0]) << std::endl;

std::cout << "=============================================" << std::endl << std::endl;

#endif

// for (int i = 0; i < gridProp.logical_size_x; i++)
// {
Expand Down
86 changes: 86 additions & 0 deletions FPGA/Xilinx/Batched/heat3D/SLR.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include <ap_int.h>
#include <hls_stream.h>
#include <ap_axi_sdata.h>
#include <math.h>
#include "stencil.h"
#include "stencil.cpp"

void process_SLR(hls::stream <t_pkt> &in, hls::stream<t_pkt> &out, const int xdim0, const unsigned short size_x,
const unsigned int size_y, const unsigned int size_z, const unsigned short batches, const float calcParam_K)
{
hls::stream<uint256_dt> streamArray[SLR_P_STAGE + 1];
#pragma HLS STREAM variable = streamArray depth = 10

data_G data_g;
data_g.sizex = size_x;
data_g.sizey = size_y;
data_g.sizez = size_z;
data_g.offset_x = 0;
data_g.grid_size_x = xdim0;
data_g.xblocks = (data_g.grid_size_x >> SHIFT_BITS);
data_g.offset_y = 0;
data_g.grid_size_y = size_y + 2;
data_g.offset_z = 0;
data_g.grid_size_z = size_z + 2;
data_g.batches = batches;
data_g.limit_z = size_z + 3;

unsigned short tile_y_1 = data_g.grid_size_y - 1;
unsigned int plane_size = data_g.xblocks * data_g.grid_size_y;

data_g.plane_diff = data_g.xblocks * tile_y_1;
data_g.line_diff = data_g.xblocks - 1;
data_g.gridsize_pr = plane_size * register_it(data_g.grid_size_z * batches + 1);
data_g.gridsize_da = register_it(plane_size * data_g.grid_size_z) * batches;

const float coefficients[7] = {calcParam_K, calcParam_K, calcParam_K, 1-6*calcParam_K, calcParam_K, calcParam_K, calcParam_K};
#pragma HLS ARRAY_PARTITION variable=coefficients complete dim=1

#pragma HLS DATAFLOW
{
axis2_fifo256(in, streamArray[0], data_g.gridsize_da);

for (int i = 0; i < SLR_P_STAGE; i++)
{
#pragma HLS unroll
process_grid(streamArray[i], streamArray[i+1], data_g, coefficients);
}

fifo256_2axis(streamArray[SLR_P_STAGE], out, data_g.gridsize_da);

}

}

extern "C"
{
void stencil_SLR(
const int sizex,
const int sizey,
const int sizez,
const int xdim0,
const int batches,
const int count,
const float calcParam_K,
hls::stream <t_pkt> &in,
hls::stream <t_pkt> &out)
{
#pragma HLS INTERFACE axis port = in register
#pragma HLS INTERFACE axis port = out register

#pragma HLS INTERFACE s_axilite port = sizex bundle = control
#pragma HLS INTERFACE s_axilite port = sizey bundle = control
#pragma HLS INTERFACE s_axilite port = sizez bundle = control
#pragma HLS INTERFACE s_axilite port = xdim0 bundle = control
#pragma HLS INTERFACE s_axilite port = batches bundle = control
#pragma HLS INTERFACE s_axilite port = count bundle = control
#pragma HLS INTERFACE s_axilite port = calcParam_K bundle = control
#pragma HLS INTERFACE s_axilite port = return bundle = control

for (unsigned int i = 0; i < count * 2; i++)
{
process_SLR(in, out, xdim0, sizex, sizey, sizez, batches, calcParam_K);
}

}
}
Loading