#include "./mixed_precision.hpp" #include #include int main(){ using namespace saw; constexpr uint64_t max_test_size = 1024ul * 1024ul * 256ul; std::random_device r; std::default_random_engine e1{r()}; std::uniform_real_distribution<> dis{-1.0,1.0}; saw::event_loop loop; saw::wait_scope wait{loop}; remote rmt; own> rmt_addr{}; rmt.resolve_address().then([&](auto addr){ rmt_addr = std::move(addr); }).detach(); wait.poll(); if(!rmt_addr){ return -1; } cl::sycl::event mixed_ev; cl::sycl::event float32_ev; cl::sycl::event float64_ev; auto sycl_iface = listen_mixed_precision(mixed_ev, float64_ev, float32_ev); data mixed_host_data; data float64_host_data; data float32_host_data; auto time_eval = [](std::stringstream& sstr, cl::sycl::event& ev){ auto end = ev.get_profiling_info(); auto start = ev.get_profiling_info(); sstr<<(end-start) / 1.0e9; }; auto& device = rmt_addr->get_device(); /** * Warmup */ std::cout<<"Warming up ..."<(gen_num); float64_host_data.at(i) = static_cast(gen_num); float32_host_data.at(i) = static_cast(gen_num); } data mixed_device_data{mixed_host_data}; data float64_device_data{float64_host_data}; data float32_device_data{float32_host_data}; sycl_iface.template call<"float64_32">(mixed_device_data, &(device.get_handle())); sycl_iface.template call<"float64">(float64_device_data, &(device.get_handle())); sycl_iface.template call<"float32">(float32_device_data, &(device.get_handle())); device.get_handle().wait(); } std::cout<<"Benchmark starting ..."< mixed_host_data; data float64_host_data; data float32_host_data; mixed_host_data = {test_size}; float64_host_data = {test_size}; float32_host_data = {test_size}; for(uint64_t i = 0; i < test_size; ++i){ double gen_num = dis(e1); mixed_host_data.at(i) = static_cast(gen_num); float64_host_data.at(i) = static_cast(gen_num); float32_host_data.at(i) = static_cast(gen_num); } data mixed_device_data{mixed_host_data}; data float64_device_data{float64_host_data}; data float32_device_data{float32_host_data}; sstr<(mixed_device_data, &(device.get_handle())); device.get_handle().wait(); time_eval(sstr, mixed_ev); sstr<<",\t"; sycl_iface.template call<"float64">(float64_device_data, &(device.get_handle())); device.get_handle().wait(); time_eval(sstr, float64_ev); sstr<<",\t"; sycl_iface.template call<"float32">(float32_device_data, &(device.get_handle())); device.get_handle().wait(); time_eval(sstr, float32_ev); sstr<<'\n'; } std::cout<