Commit b2ba5af2 authored by Andrey Filippov's avatar Andrey Filippov

CODEX: Add production-boundary timing gates

Co-authored-by: 's avatarCodex <codex@elphel.com>
parent 0bab49b8
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
// cd tile_processor_gpu && /usr/local/cuda-12.8/bin/nvcc -std=c++17 -O2 \ // cd tile_processor_gpu && /usr/local/cuda-12.8/bin/nvcc -std=c++17 -O2 \
// jna/test_lma_products_jna.cu -o tests_bin/test_lma_products_jna \ // jna/test_lma_products_jna.cu -o tests_bin/test_lma_products_jna \
// -L jna -ltileproc -Xlinker -rpath -Xlinker $PWD/jna // -L jna -ltileproc -Xlinker -rpath -Xlinker $PWD/jna
// Run: tests_bin/test_lma_products_jna [srcdir] [libcudadevrt.a] [profile_calls]
// //
// Created Jul 14, 2026 by Codex for Elphel. // Created Jul 14, 2026 by Codex for Elphel.
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <chrono>
#include <vector> #include <vector>
extern "C" { extern "C" {
...@@ -37,6 +39,8 @@ int main(int argc, char** argv) ...@@ -37,6 +39,8 @@ int main(int argc, char** argv)
const char* srcdir = (argc > 1) ? argv[1] : "src"; const char* srcdir = (argc > 1) ? argv[1] : "src";
const char* devrt = (argc > 2) ? argv[2] : const char* devrt = (argc > 2) ? argv[2] :
"/usr/local/cuda-12.8/targets/x86_64-linux/lib/libcudadevrt.a"; "/usr/local/cuda-12.8/targets/x86_64-linux/lib/libcudadevrt.a";
const int profile_calls = (argc > 3) ? std::atoi(argv[3]) : 0;
if(profile_calls < 0){ std::fprintf(stderr,"profile_calls must be >= 0\n"); return EXIT_FAILURE; }
void* module = tp_create_module(srcdir, devrt); void* module = tp_create_module(srcdir, devrt);
if(!module){ std::fprintf(stderr,"tp_create_module: %s\n",tp_last_error()); return EXIT_FAILURE; } if(!module){ std::fprintf(stderr,"tp_create_module: %s\n",tp_last_error()); return EXIT_FAILURE; }
void* proc = tp_proc_create(module); void* proc = tp_proc_create(module);
...@@ -79,6 +83,25 @@ int main(int argc, char** argv) ...@@ -79,6 +83,25 @@ int main(int argc, char** argv)
} }
std::printf("NVRTC lma_normal_products: %zu doubles, bit-exact -> %s\n", std::printf("NVRTC lma_normal_products: %zu doubles, bit-exact -> %s\n",
got.size(),bad?"FAIL":"PASS"); got.size(),bad?"FAIL":"PASS");
if(!bad && profile_calls > 0){
for(int i=0;i<20;i++) if(tp_proc_exec_lma_products(
proc,weights.data(),jt.data(),ymfx.data(),np,nv,got.data())){
std::fprintf(stderr,"profile warmup: %s\n",tp_last_error()); bad=1; break;
}
const auto profile = [&](){
const auto t0=std::chrono::steady_clock::now();
for(int i=0;i<profile_calls;i++) if(tp_proc_exec_lma_products(
proc,weights.data(),jt.data(),ymfx.data(),np,nv,got.data())) return -1.0;
const auto t1=std::chrono::steady_clock::now();
return std::chrono::duration<double,std::milli>(t1-t0).count()/profile_calls;
};
if(!bad){
const double a=profile(), b=profile();
if((a < 0)||(b < 0)){ std::fprintf(stderr,"profile: %s\n",tp_last_error()); bad=1; }
else std::printf("LMA products profile (%d calls, 3x303 -> 12 doubles): rounds=[%.6f, %.6f] ms, avg=%.6f ms/call\n",
profile_calls,a,b,0.5*(a+b));
}
}
tp_proc_destroy(proc); tp_destroy_module(module); tp_proc_destroy(proc); tp_destroy_module(module);
return bad?EXIT_FAILURE:EXIT_SUCCESS; return bad?EXIT_FAILURE:EXIT_SUCCESS;
} }
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