static double bench_norm(int s, long scale) { long dims[DIMS] = { 256 * scale, 256 * scale, 1, 16, 1, 1, 1, 1 }; #if 0 complex float* x = md_alloc_gpu(DIMS, dims, CFL_SIZE); complex float* y = md_alloc_gpu(DIMS, dims, CFL_SIZE); #else complex float* x = md_alloc(DIMS, dims, CFL_SIZE); complex float* y = md_alloc(DIMS, dims, CFL_SIZE); #endif md_gaussian_rand(DIMS, dims, x); md_gaussian_rand(DIMS, dims, y); double tic = timestamp(); switch (s) { case 0: md_zscalar(DIMS, dims, x, y); break; case 1: md_zscalar_real(DIMS, dims, x, y); break; case 2: md_znorm(DIMS, dims, x); break; case 3: md_z1norm(DIMS, dims, x); break; } double toc = timestamp(); md_free(x); md_free(y); return toc - tic; }
int main_sdot(int argc, char* argv[]) { cmdline(&argc, argv, 2, 2, usage_str, help_str, 0, NULL); int N = DIMS; long in1_dims[N]; long in2_dims[N]; complex float* in1_data = load_cfl(argv[1], N, in1_dims); complex float* in2_data = load_cfl(argv[2], N, in2_dims); for (int i = 0; i < N; i++) assert(in1_dims[i] == in2_dims[i]); // compute scalar product complex float value = md_zscalar(N, in1_dims, in1_data, in2_data); printf("%+e%+ei\n", crealf(value), cimagf(value)); unmap_cfl(N, in1_dims, in1_data); unmap_cfl(N, in2_dims, in2_data); exit(0); }