Commit fcd254f6 authored by Andrey Filippov's avatar Andrey Filippov

CODEX: Keep pose task streams resident

Co-authored-by: 's avatarCodex <codex@elphel.com>
parent b2ba5af2
...@@ -61,11 +61,14 @@ extern "C" { ...@@ -61,11 +61,14 @@ extern "C" {
int tp_proc_set_image(void*, int, const float*); int tp_proc_set_image(void*, int, const float*);
int tp_proc_set_tasks(void*, const float*, int, int); int tp_proc_set_tasks(void*, const float*, int, int);
int tp_proc_get_tasks(void*, float*, int); int tp_proc_get_tasks(void*, float*, int);
int tp_proc_set_tasks_slot(void*, const float*, int, int, int);
int tp_proc_get_tasks_slot(void*, float*, int, int);
int tp_proc_set_const(void*, const char*, const float*, int); int tp_proc_set_const(void*, const char*, const float*, int);
int tp_proc_exec_geometry(void*, int); int tp_proc_exec_geometry(void*, int);
int tp_proc_exec_convert_direct(void*, int, int, int); int tp_proc_exec_convert_direct(void*, int, int, int);
int tp_proc_set_clt(void*, int, const float*, int); int tp_proc_set_clt(void*, int, const float*, int);
int tp_proc_exec_consolidate(void*, const float*, const float*, int, int, float, float, int*); int tp_proc_exec_consolidate(void*, const float*, const float*, int, int, float, float, int*);
int tp_proc_exec_consolidate_slots(void*, int, int, int, int, float, float, int*);
int tp_proc_setup_rbg_corr(void*, int, int,int,int,int, float,float,float, int); int tp_proc_setup_rbg_corr(void*, int, int,int,int,int, float,float,float, int);
int tp_proc_exec_corr2d_inter_td(void*, int, float,float,float); int tp_proc_exec_corr2d_inter_td(void*, int, float,float,float);
int tp_proc_get_corr_indices(void*, int*, int); int tp_proc_get_corr_indices(void*, int*, int);
...@@ -265,8 +268,8 @@ int main(int argc, char** argv){ ...@@ -265,8 +268,8 @@ int main(int argc, char** argv){
snprintf(nm,sizeof(nm),"ftasks%d_it%d",nset,k); snprintf(nm,sizeof(nm),"ftasks%d_it%d",nset,k);
const int n = (int)(data.elements(nm)/task_size); const int n = (int)(data.elements(nm)/task_size);
n_set[nset] = n; n_set[nset] = n;
if(timed(prof_tasks_h2d,[&](){ return tp_proc_set_tasks( if(timed(prof_tasks_h2d,[&](){ return tp_proc_set_tasks_slot(
p,data.hostFloat(nm),n,n*task_size); })){ p,data.hostFloat(nm),n,n*task_size,nset); })){
printf("FAIL set_tasks: %s\n",tp_last_error()); return EXIT_FAILURE; } printf("FAIL set_tasks: %s\n",tp_last_error()); return EXIT_FAILURE; }
// Production GpuQuadJna.execSetTilesOffsets refreshes this small vector // Production GpuQuadJna.execSetTilesOffsets refreshes this small vector
// for every task set even though the current CUAS policy often repeats it. // for every task set even though the current CUAS policy often repeats it.
...@@ -277,8 +280,11 @@ int main(int argc, char** argv){ ...@@ -277,8 +280,11 @@ int main(int argc, char** argv){
printf("FAIL exec_geometry: %s\n", tp_last_error()); return EXIT_FAILURE; } printf("FAIL exec_geometry: %s\n", tp_last_error()); return EXIT_FAILURE; }
{ // checkpoint: GPU-filled tasks vs the oracle post-offsets stream (bit-exact) { // checkpoint: GPU-filled tasks vs the oracle post-offsets stream (bit-exact)
std::vector<float> got((size_t)n*task_size); std::vector<float> got((size_t)n*task_size);
if(timed(prof_tasks_d2h,[&](){ return tp_proc_get_tasks( // Production skips this readback. Keep it as the exact slot oracle, but
p,got.data(),n*task_size); })){ // exclude it from --profile-chain timing. By Codex on 07/15/2026.
const int get_rc = chain_profile ? tp_proc_get_tasks_slot(p,got.data(),n*task_size,nset) :
timed(prof_tasks_d2h,[&](){ return tp_proc_get_tasks_slot(p,got.data(),n*task_size,nset); });
if(get_rc){
printf("FAIL get_tasks: %s\n",tp_last_error()); return EXIT_FAILURE; } printf("FAIL get_tasks: %s\n",tp_last_error()); return EXIT_FAILURE; }
char lbl[64]; snprintf(lbl,sizeof(lbl),"tasks%d_it%d",nset,k); char lbl[64]; snprintf(lbl,sizeof(lbl),"tasks%d_it%d",nset,k);
snprintf(nm,sizeof(nm),"expected_tasks%d_it%d",nset,k); snprintf(nm,sizeof(nm),"expected_tasks%d_it%d",nset,k);
...@@ -289,15 +295,12 @@ int main(int argc, char** argv){ ...@@ -289,15 +295,12 @@ int main(int argc, char** argv){
p,0,(nset==0)?1:-1,0); })){ p,0,(nset==0)?1:-1,0); })){
printf("FAIL exec_convert_direct: %s\n", tp_last_error()); return EXIT_FAILURE; } printf("FAIL exec_convert_direct: %s\n", tp_last_error()); return EXIT_FAILURE; }
} }
// consolidation: the oracle post-offsets streams = the exact bytes production flattens // Consolidation consumes the post-offset streams directly from device slots;
snprintf(nm,sizeof(nm),"expected_tasks0_it%d",k); // no task D2H -> host flatten -> H2D bridge. By Codex on 07/15/2026.
const float* cons0 = data.hostFloat(nm);
const float* cons1 = nullptr;
if (has_mb){ snprintf(nm,sizeof(nm),"expected_tasks1_it%d",k); cons1 = data.hostFloat(nm); }
int stats[3] = {-1,-1,-1}; int stats[3] = {-1,-1,-1};
if(timed(prof_consolidate,[&](){ return tp_proc_exec_consolidate( if(timed(prof_consolidate,[&](){ return tp_proc_exec_consolidate_slots(
p,cons0,cons1,n_set[0],task_size,soft_margin,hard_margin,stats); })){ p,0,has_mb?1:-1,n_set[0],task_size,soft_margin,hard_margin,stats); })){
printf("FAIL exec_consolidate: %s\n", tp_last_error()); return EXIT_FAILURE; } printf("FAIL exec_consolidate_slots: %s\n", tp_last_error()); return EXIT_FAILURE; }
// the single conj-multiply vs the resident center TD; device tasks = the LAST // the single conj-multiply vs the resident center TD; device tasks = the LAST
// uploaded set (set 1 in MB mode), exactly the state execCorr2D_inter_TD sees // uploaded set (set 1 in MB mode), exactly the state execCorr2D_inter_TD sees
const int num_corr = timed(prof_corr,[&](){ return tp_proc_exec_corr2d_inter_td( const int num_corr = timed(prof_corr,[&](){ return tp_proc_exec_corr2d_inter_td(
...@@ -475,12 +478,12 @@ int main(int argc, char** argv){ ...@@ -475,12 +478,12 @@ int main(int argc, char** argv){
} }
if(chain_profile){ if(chain_profile){
const double total=prof_images+prof_tasks_h2d+prof_cv_h2d+prof_geometry+ const double total=prof_images+prof_tasks_h2d+prof_cv_h2d+prof_geometry+
prof_tasks_d2h+prof_convert+prof_consolidate+prof_corr+prof_indices+ prof_convert+prof_consolidate+prof_corr+prof_indices+
prof_normalize+prof_peak+prof_peaks_d2h; prof_normalize+prof_peak+prof_peaks_d2h;
printf("production-call chain profile (1 scene, %d cycles, %d task sets):\n",num_iters,num_iters*(has_mb?2:1)); printf("production-call chain profile (1 scene, %d cycles, %d task sets):\n",num_iters,num_iters*(has_mb?2:1));
printf(" images H2D once/scene %9.3f ms\n",prof_images); printf(" images H2D once/scene %9.3f ms\n",prof_images);
printf(" tasks H2D + corr-vector H2D %9.3f ms\n",prof_tasks_h2d+prof_cv_h2d); printf(" tasks H2D + corr-vector H2D %9.3f ms\n",prof_tasks_h2d+prof_cv_h2d);
printf(" geometry + tasks D2H %9.3f ms\n",prof_geometry+prof_tasks_d2h); printf(" geometry (tasks stay GPU) %9.3f ms\n",prof_geometry);
printf(" convert_direct %9.3f ms\n",prof_convert); printf(" convert_direct %9.3f ms\n",prof_convert);
printf(" consolidate %9.3f ms\n",prof_consolidate); printf(" consolidate %9.3f ms\n",prof_consolidate);
printf(" correlate_inter %9.3f ms\n",prof_corr); printf(" correlate_inter %9.3f ms\n",prof_corr);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment