16 inline bool isInitialized() {
return get_yakl_instance().yakl_is_initialized; }
38 #if defined(YAKL_PROFILE)
42 get_yakl_instance().yakl_is_initialized =
true;
44 get_yakl_instance().pool_enabled = config.get_pool_enabled();
49 size_t initialSize = config.get_pool_initial_mb()*1024*1024;
50 size_t growSize = config.get_pool_grow_mb()*1024*1024;
51 size_t blockSize = config.get_pool_block_bytes();
54 std::function<
void *( size_t )> alloc;
55 std::function<void (
void * )> dealloc;
56 set_device_alloc_free(alloc , dealloc);
57 auto zero = [] (
void *ptr,
size_t bytes) {};
58 std::string pool_name =
"Gator: YAKL's primary memory pool";
59 std::string error_message_out_of_memory =
"Please see https://github.com/mrnorman/YAKL/wiki/Pool-Allocator for more information\n";
60 std::string error_message_cannot_grow = error_message_out_of_memory;
61 get_yakl_instance().pool.init(alloc,dealloc,zero,initialSize,growSize,blockSize,pool_name,
62 error_message_out_of_memory,error_message_cannot_grow);
63 if (
yakl_mainproc()) std::cout <<
"Using memory pool. Initial size: " << (float) initialSize/1024./1024./1024.
64 <<
"GB ; Grow size: " << (
float) growSize/1024./1024./1024. <<
"GB." << std::endl;
70 get_yakl_instance().timer_init_func = [] () {};
71 get_yakl_instance().timer_finalize_func = [] () {
72 #if defined(YAKL_PROFILE)
73 if (
yakl_mainproc()) { get_yakl_instance().timer.print_all_threads(); }
76 get_yakl_instance().timer_start_func = [] (
char const *label) {
77 #if defined(YAKL_PROFILE)
78 fence(); get_yakl_instance().timer.start( label );
81 get_yakl_instance().timer_stop_func = [] (
char const * label) {
82 #if defined(YAKL_PROFILE)
83 fence(); get_yakl_instance().timer.stop( label );
87 get_yakl_instance().device_allocators_are_default =
true;
90 if (config.get_device_allocator ()) {
91 get_yakl_instance().alloc_device_func = config.get_device_allocator ();
92 get_yakl_instance().device_allocators_are_default =
false;
94 if (config.get_device_deallocator()) {
95 get_yakl_instance().free_device_func = config.get_device_deallocator();
96 get_yakl_instance().device_allocators_are_default =
false;
98 if (config.get_timer_init ()) get_yakl_instance().timer_init_func = config.get_timer_init ();
99 if (config.get_timer_finalize ()) get_yakl_instance().timer_finalize_func = config.get_timer_finalize();
100 if (config.get_timer_start ()) get_yakl_instance().timer_start_func = config.get_timer_start ();
101 if (config.get_timer_stop ()) get_yakl_instance().timer_stop_func = config.get_timer_stop ();
103 #ifdef YAKL_ARCH_SYCL
105 << sycl_default_stream().get_device().get_info<sycl::info::device::name>()
110 #if defined(YAKL_ARCH_CUDA)
113 cudaDeviceProp props;
114 cudaGetDeviceProperties(&props,
id);
118 #if defined(YAKL_ARCH_HIP)
121 hipDeviceProp_t props;
122 hipGetDeviceProperties(&props,
id);
127 #if defined(YAKL_AUTO_FENCE)
128 if (
yakl_mainproc()) std::cout <<
"INFORM: Automatically inserting fence() after every parallel_for"
131 #ifdef YAKL_VERBOSE_FILE
135 MPI_Initialized(&is_initialized);
136 if (is_initialized) { MPI_Comm_rank(MPI_COMM_WORLD, &rank); }
138 std::ofstream myfile;
139 std::string fname = std::string(
"yakl_verbose_output_task_") + std::to_string(rank) + std::string(
".log");
140 myfile.open(fname , std::ofstream::out);
144 std::cerr <<
"WARNING: Calling yakl::initialize() when YAKL is already initialized. ";