Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-blas/blob/main/receipts/cublas-gb10-20261114/cublas_sweep.cu # omega-blas aien-dev/omega-blas Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-blas / receipts / cublas-gb10-20261114 / cublas_sweep.cu` 110 lines ยท 4497 bytes Raw Blame History 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 #define CHECK_CUDA(x) do { cudaError_t e=(x); if(e){ fprintf(stderr,"CUDA %s:%d %s\n",__FILE__,__LINE__,cudaGetErrorString(e)); std::exit(1);} } while(0) 10 #define CHECK_CUBLAS(x) do { cublasStatus_t s=(x); if(s!=CUBLAS_STATUS_SUCCESS){ fprintf(stderr,"cuBLAS %s:%d status %d\n",__FILE__,__LINE__,(int)s); std::exit(1);} } while(0) 11 12 static double elapsed_ms(cudaEvent_t a, cudaEvent_t b){ 13 float ms=0; CHECK_CUDA(cudaEventElapsedTime(&ms,a,b)); return (double)ms; 14 } 15 16 template 17 static void fill(T* p, size_t n){ 18 // deterministic small values 19 for(size_t i=0;i& ms, long long flops){ 23 std::vector v=ms; std::sort(v.begin(), v.end()); 24 double med=v[v.size()/2]; 25 double mn=v.front(), mx=v.back(); 26 double tflops = (flops / 1e12) / (med/1e3); 27 printf("%s n=%d runs=%zu median_ms=%.4f min_ms=%.4f max_ms=%.4f spread_ms=%.4f tflops=%.3f\n", 28 name,n,v.size(),med,mn,mx,mx-mn,tflops); 29 fflush(stdout); 30 } 31 32 int main(int argc, char** argv){ 33 int only_n=0; int once=0; 34 const char* kind="both"; 35 for(int i=1;i ha(ne),hb(ne),hc(ne); 49 fill(ha.data(),ne); fill(hb.data(),ne); 50 float *A,*B,*C; CHECK_CUDA(cudaMalloc(&A,ne*sizeof(float))); 51 CHECK_CUDA(cudaMalloc(&B,ne*sizeof(float))); 52 CHECK_CUDA(cudaMalloc(&C,ne*sizeof(float))); 53 CHECK_CUDA(cudaMemcpy(A,ha.data(),ne*sizeof(float),cudaMemcpyHostToDevice)); 54 CHECK_CUDA(cudaMemcpy(B,hb.data(),ne*sizeof(float),cudaMemcpyHostToDevice)); 55 const float alpha=1.f, beta=0.f; 56 int warm = once?1:3, reps= once?1:5; 57 for(int i=0;i ms; 60 for(int i=0;i ha(ne),hb(ne),hc(ne); 75 for(size_t i=0;i ms; 86 for(int i=0;i