17ec681f3Smrg// 27ec681f3Smrg// Copyright 2012 Francisco Jerez 37ec681f3Smrg// 47ec681f3Smrg// Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg// copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg// to deal in the Software without restriction, including without limitation 77ec681f3Smrg// the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg// and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg// Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg// 117ec681f3Smrg// The above copyright notice and this permission notice shall be included in 127ec681f3Smrg// all copies or substantial portions of the Software. 137ec681f3Smrg// 147ec681f3Smrg// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 157ec681f3Smrg// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 167ec681f3Smrg// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 177ec681f3Smrg// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 187ec681f3Smrg// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 197ec681f3Smrg// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 207ec681f3Smrg// OTHER DEALINGS IN THE SOFTWARE. 217ec681f3Smrg// 227ec681f3Smrg 237ec681f3Smrg#include "api/util.hpp" 247ec681f3Smrg#include "core/kernel.hpp" 257ec681f3Smrg#include "core/event.hpp" 267ec681f3Smrg 277ec681f3Smrgusing namespace clover; 287ec681f3Smrg 297ec681f3SmrgCLOVER_API cl_kernel 307ec681f3SmrgclCreateKernel(cl_program d_prog, const char *name, cl_int *r_errcode) try { 317ec681f3Smrg auto &prog = obj(d_prog); 327ec681f3Smrg 337ec681f3Smrg if (!name) 347ec681f3Smrg throw error(CL_INVALID_VALUE); 357ec681f3Smrg 367ec681f3Smrg auto &sym = find(name_equals(name), prog.symbols()); 377ec681f3Smrg 387ec681f3Smrg ret_error(r_errcode, CL_SUCCESS); 397ec681f3Smrg return new kernel(prog, name, range(sym.args)); 407ec681f3Smrg 417ec681f3Smrg} catch (std::out_of_range &) { 427ec681f3Smrg ret_error(r_errcode, CL_INVALID_KERNEL_NAME); 437ec681f3Smrg return NULL; 447ec681f3Smrg 457ec681f3Smrg} catch (error &e) { 467ec681f3Smrg ret_error(r_errcode, e); 477ec681f3Smrg return NULL; 487ec681f3Smrg} 497ec681f3Smrg 507ec681f3SmrgCLOVER_API cl_int 517ec681f3SmrgclCreateKernelsInProgram(cl_program d_prog, cl_uint count, 527ec681f3Smrg cl_kernel *rd_kerns, cl_uint *r_count) try { 537ec681f3Smrg auto &prog = obj(d_prog); 547ec681f3Smrg auto &syms = prog.symbols(); 557ec681f3Smrg 567ec681f3Smrg if (rd_kerns && count < syms.size()) 577ec681f3Smrg throw error(CL_INVALID_VALUE); 587ec681f3Smrg 597ec681f3Smrg if (rd_kerns) 607ec681f3Smrg copy(map([&](const binary::symbol &sym) { 617ec681f3Smrg return desc(new kernel(prog, 627ec681f3Smrg std::string(sym.name.begin(), 637ec681f3Smrg sym.name.end()), 647ec681f3Smrg range(sym.args))); 657ec681f3Smrg }, syms), 667ec681f3Smrg rd_kerns); 677ec681f3Smrg 687ec681f3Smrg if (r_count) 697ec681f3Smrg *r_count = syms.size(); 707ec681f3Smrg 717ec681f3Smrg return CL_SUCCESS; 727ec681f3Smrg 737ec681f3Smrg} catch (error &e) { 747ec681f3Smrg return e.get(); 757ec681f3Smrg} 767ec681f3Smrg 777ec681f3SmrgCLOVER_API cl_int 787ec681f3SmrgclRetainKernel(cl_kernel d_kern) try { 797ec681f3Smrg obj(d_kern).retain(); 807ec681f3Smrg return CL_SUCCESS; 817ec681f3Smrg 827ec681f3Smrg} catch (error &e) { 837ec681f3Smrg return e.get(); 847ec681f3Smrg} 857ec681f3Smrg 867ec681f3SmrgCLOVER_API cl_int 877ec681f3SmrgclReleaseKernel(cl_kernel d_kern) try { 887ec681f3Smrg if (obj(d_kern).release()) 897ec681f3Smrg delete pobj(d_kern); 907ec681f3Smrg 917ec681f3Smrg return CL_SUCCESS; 927ec681f3Smrg 937ec681f3Smrg} catch (error &e) { 947ec681f3Smrg return e.get(); 957ec681f3Smrg} 967ec681f3Smrg 977ec681f3SmrgCLOVER_API cl_int 987ec681f3SmrgclSetKernelArg(cl_kernel d_kern, cl_uint idx, size_t size, 997ec681f3Smrg const void *value) try { 1007ec681f3Smrg obj(d_kern).args().at(idx).set(size, value); 1017ec681f3Smrg return CL_SUCCESS; 1027ec681f3Smrg 1037ec681f3Smrg} catch (std::out_of_range &) { 1047ec681f3Smrg return CL_INVALID_ARG_INDEX; 1057ec681f3Smrg 1067ec681f3Smrg} catch (error &e) { 1077ec681f3Smrg return e.get(); 1087ec681f3Smrg} 1097ec681f3Smrg 1107ec681f3SmrgCLOVER_API cl_int 1117ec681f3SmrgclGetKernelInfo(cl_kernel d_kern, cl_kernel_info param, 1127ec681f3Smrg size_t size, void *r_buf, size_t *r_size) try { 1137ec681f3Smrg property_buffer buf { r_buf, size, r_size }; 1147ec681f3Smrg auto &kern = obj(d_kern); 1157ec681f3Smrg 1167ec681f3Smrg switch (param) { 1177ec681f3Smrg case CL_KERNEL_FUNCTION_NAME: 1187ec681f3Smrg buf.as_string() = kern.name(); 1197ec681f3Smrg break; 1207ec681f3Smrg 1217ec681f3Smrg case CL_KERNEL_NUM_ARGS: 1227ec681f3Smrg buf.as_scalar<cl_uint>() = kern.args().size(); 1237ec681f3Smrg break; 1247ec681f3Smrg 1257ec681f3Smrg case CL_KERNEL_REFERENCE_COUNT: 1267ec681f3Smrg buf.as_scalar<cl_uint>() = kern.ref_count(); 1277ec681f3Smrg break; 1287ec681f3Smrg 1297ec681f3Smrg case CL_KERNEL_CONTEXT: 1307ec681f3Smrg buf.as_scalar<cl_context>() = desc(kern.program().context()); 1317ec681f3Smrg break; 1327ec681f3Smrg 1337ec681f3Smrg case CL_KERNEL_PROGRAM: 1347ec681f3Smrg buf.as_scalar<cl_program>() = desc(kern.program()); 1357ec681f3Smrg break; 1367ec681f3Smrg 1377ec681f3Smrg case CL_KERNEL_ATTRIBUTES: 1387ec681f3Smrg buf.as_string() = find(name_equals(kern.name()), kern.program().symbols()).attributes; 1397ec681f3Smrg break; 1407ec681f3Smrg 1417ec681f3Smrg default: 1427ec681f3Smrg throw error(CL_INVALID_VALUE); 1437ec681f3Smrg } 1447ec681f3Smrg 1457ec681f3Smrg return CL_SUCCESS; 1467ec681f3Smrg 1477ec681f3Smrg} catch (error &e) { 1487ec681f3Smrg return e.get(); 1497ec681f3Smrg} 1507ec681f3Smrg 1517ec681f3SmrgCLOVER_API cl_int 1527ec681f3SmrgclGetKernelWorkGroupInfo(cl_kernel d_kern, cl_device_id d_dev, 1537ec681f3Smrg cl_kernel_work_group_info param, 1547ec681f3Smrg size_t size, void *r_buf, size_t *r_size) try { 1557ec681f3Smrg property_buffer buf { r_buf, size, r_size }; 1567ec681f3Smrg auto &kern = obj(d_kern); 1577ec681f3Smrg auto &dev = (d_dev ? *pobj(d_dev) : unique(kern.program().devices())); 1587ec681f3Smrg 1597ec681f3Smrg if (!count(dev, kern.program().devices())) 1607ec681f3Smrg throw error(CL_INVALID_DEVICE); 1617ec681f3Smrg 1627ec681f3Smrg switch (param) { 1637ec681f3Smrg case CL_KERNEL_WORK_GROUP_SIZE: 1647ec681f3Smrg buf.as_scalar<size_t>() = dev.max_threads_per_block(); 1657ec681f3Smrg break; 1667ec681f3Smrg 1677ec681f3Smrg case CL_KERNEL_COMPILE_WORK_GROUP_SIZE: 1687ec681f3Smrg buf.as_vector<size_t>() = kern.required_block_size(); 1697ec681f3Smrg break; 1707ec681f3Smrg 1717ec681f3Smrg case CL_KERNEL_LOCAL_MEM_SIZE: 1727ec681f3Smrg buf.as_scalar<cl_ulong>() = kern.mem_local(); 1737ec681f3Smrg break; 1747ec681f3Smrg 1757ec681f3Smrg case CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: 1767ec681f3Smrg buf.as_scalar<size_t>() = dev.subgroup_size(); 1777ec681f3Smrg break; 1787ec681f3Smrg 1797ec681f3Smrg case CL_KERNEL_PRIVATE_MEM_SIZE: 1807ec681f3Smrg buf.as_scalar<cl_ulong>() = kern.mem_private(); 1817ec681f3Smrg break; 1827ec681f3Smrg 1837ec681f3Smrg default: 1847ec681f3Smrg throw error(CL_INVALID_VALUE); 1857ec681f3Smrg } 1867ec681f3Smrg 1877ec681f3Smrg return CL_SUCCESS; 1887ec681f3Smrg 1897ec681f3Smrg} catch (error &e) { 1907ec681f3Smrg return e.get(); 1917ec681f3Smrg 1927ec681f3Smrg} catch (std::out_of_range &) { 1937ec681f3Smrg return CL_INVALID_DEVICE; 1947ec681f3Smrg} 1957ec681f3Smrg 1967ec681f3SmrgCLOVER_API cl_int 1977ec681f3SmrgclGetKernelArgInfo(cl_kernel d_kern, 1987ec681f3Smrg cl_uint idx, cl_kernel_arg_info param, 1997ec681f3Smrg size_t size, void *r_buf, size_t *r_size) try { 2007ec681f3Smrg property_buffer buf { r_buf, size, r_size }; 2017ec681f3Smrg 2027ec681f3Smrg auto info = obj(d_kern).args_infos().at(idx); 2037ec681f3Smrg 2047ec681f3Smrg if (info.arg_name.empty()) 2057ec681f3Smrg return CL_KERNEL_ARG_INFO_NOT_AVAILABLE; 2067ec681f3Smrg 2077ec681f3Smrg switch (param) { 2087ec681f3Smrg case CL_KERNEL_ARG_ADDRESS_QUALIFIER: 2097ec681f3Smrg buf.as_scalar<cl_kernel_arg_address_qualifier>() = info.address_qualifier; 2107ec681f3Smrg break; 2117ec681f3Smrg 2127ec681f3Smrg case CL_KERNEL_ARG_ACCESS_QUALIFIER: 2137ec681f3Smrg buf.as_scalar<cl_kernel_arg_access_qualifier>() = info.access_qualifier; 2147ec681f3Smrg break; 2157ec681f3Smrg 2167ec681f3Smrg case CL_KERNEL_ARG_TYPE_NAME: 2177ec681f3Smrg buf.as_string() = info.type_name; 2187ec681f3Smrg break; 2197ec681f3Smrg 2207ec681f3Smrg case CL_KERNEL_ARG_TYPE_QUALIFIER: 2217ec681f3Smrg buf.as_scalar<cl_kernel_arg_type_qualifier>() = info.type_qualifier; 2227ec681f3Smrg break; 2237ec681f3Smrg 2247ec681f3Smrg case CL_KERNEL_ARG_NAME: 2257ec681f3Smrg buf.as_string() = info.arg_name; 2267ec681f3Smrg break; 2277ec681f3Smrg 2287ec681f3Smrg default: 2297ec681f3Smrg throw error(CL_INVALID_VALUE); 2307ec681f3Smrg } 2317ec681f3Smrg 2327ec681f3Smrg return CL_SUCCESS; 2337ec681f3Smrg 2347ec681f3Smrg} catch (std::out_of_range &) { 2357ec681f3Smrg return CL_INVALID_ARG_INDEX; 2367ec681f3Smrg 2377ec681f3Smrg} catch (error &e) { 2387ec681f3Smrg return e.get(); 2397ec681f3Smrg} 2407ec681f3Smrg 2417ec681f3Smrgnamespace { 2427ec681f3Smrg /// 2437ec681f3Smrg /// Common argument checking shared by kernel invocation commands. 2447ec681f3Smrg /// 2457ec681f3Smrg void 2467ec681f3Smrg validate_common(const command_queue &q, kernel &kern, 2477ec681f3Smrg const ref_vector<event> &deps) { 2487ec681f3Smrg if (kern.program().context() != q.context() || 2497ec681f3Smrg any_of([&](const event &ev) { 2507ec681f3Smrg return ev.context() != q.context(); 2517ec681f3Smrg }, deps)) 2527ec681f3Smrg throw error(CL_INVALID_CONTEXT); 2537ec681f3Smrg 2547ec681f3Smrg if (any_of([](kernel::argument &arg) { 2557ec681f3Smrg return !arg.set(); 2567ec681f3Smrg }, kern.args())) 2577ec681f3Smrg throw error(CL_INVALID_KERNEL_ARGS); 2587ec681f3Smrg 2597ec681f3Smrg // If the command queue's device is not associated to the program, we get 2607ec681f3Smrg // a binary, with no sections, which will also fail the following test. 2617ec681f3Smrg auto &b = kern.program().build(q.device()).bin; 2627ec681f3Smrg if (!any_of(type_equals(binary::section::text_executable), b.secs)) 2637ec681f3Smrg throw error(CL_INVALID_PROGRAM_EXECUTABLE); 2647ec681f3Smrg } 2657ec681f3Smrg 2667ec681f3Smrg std::vector<size_t> 2677ec681f3Smrg validate_grid_size(const command_queue &q, cl_uint dims, 2687ec681f3Smrg const size_t *d_grid_size) { 2697ec681f3Smrg auto grid_size = range(d_grid_size, dims); 2707ec681f3Smrg 2717ec681f3Smrg if (dims < 1 || dims > q.device().max_block_size().size()) 2727ec681f3Smrg throw error(CL_INVALID_WORK_DIMENSION); 2737ec681f3Smrg 2747ec681f3Smrg return grid_size; 2757ec681f3Smrg } 2767ec681f3Smrg 2777ec681f3Smrg std::vector<size_t> 2787ec681f3Smrg validate_grid_offset(const command_queue &q, cl_uint dims, 2797ec681f3Smrg const size_t *d_grid_offset) { 2807ec681f3Smrg if (d_grid_offset) 2817ec681f3Smrg return range(d_grid_offset, dims); 2827ec681f3Smrg else 2837ec681f3Smrg return std::vector<size_t>(dims, 0); 2847ec681f3Smrg } 2857ec681f3Smrg 2867ec681f3Smrg std::vector<size_t> 2877ec681f3Smrg validate_block_size(const command_queue &q, const kernel &kern, 2887ec681f3Smrg cl_uint dims, const size_t *d_grid_size, 2897ec681f3Smrg const size_t *d_block_size) { 2907ec681f3Smrg auto grid_size = range(d_grid_size, dims); 2917ec681f3Smrg 2927ec681f3Smrg if (d_block_size) { 2937ec681f3Smrg auto block_size = range(d_block_size, dims); 2947ec681f3Smrg 2957ec681f3Smrg if (any_of(is_zero(), block_size) || 2967ec681f3Smrg any_of(greater(), block_size, q.device().max_block_size())) 2977ec681f3Smrg throw error(CL_INVALID_WORK_ITEM_SIZE); 2987ec681f3Smrg 2997ec681f3Smrg if (any_of(modulus(), grid_size, block_size)) 3007ec681f3Smrg throw error(CL_INVALID_WORK_GROUP_SIZE); 3017ec681f3Smrg 3027ec681f3Smrg if (fold(multiplies(), 1u, block_size) > 3037ec681f3Smrg q.device().max_threads_per_block()) 3047ec681f3Smrg throw error(CL_INVALID_WORK_GROUP_SIZE); 3057ec681f3Smrg 3067ec681f3Smrg return block_size; 3077ec681f3Smrg 3087ec681f3Smrg } else { 3097ec681f3Smrg return kern.optimal_block_size(q, grid_size); 3107ec681f3Smrg } 3117ec681f3Smrg } 3127ec681f3Smrg} 3137ec681f3Smrg 3147ec681f3SmrgCLOVER_API cl_int 3157ec681f3SmrgclEnqueueNDRangeKernel(cl_command_queue d_q, cl_kernel d_kern, 3167ec681f3Smrg cl_uint dims, const size_t *d_grid_offset, 3177ec681f3Smrg const size_t *d_grid_size, const size_t *d_block_size, 3187ec681f3Smrg cl_uint num_deps, const cl_event *d_deps, 3197ec681f3Smrg cl_event *rd_ev) try { 3207ec681f3Smrg auto &q = obj(d_q); 3217ec681f3Smrg auto &kern = obj(d_kern); 3227ec681f3Smrg auto deps = objs<wait_list_tag>(d_deps, num_deps); 3237ec681f3Smrg auto grid_size = validate_grid_size(q, dims, d_grid_size); 3247ec681f3Smrg auto grid_offset = validate_grid_offset(q, dims, d_grid_offset); 3257ec681f3Smrg auto block_size = validate_block_size(q, kern, dims, 3267ec681f3Smrg d_grid_size, d_block_size); 3277ec681f3Smrg 3287ec681f3Smrg validate_common(q, kern, deps); 3297ec681f3Smrg 3307ec681f3Smrg auto hev = create<hard_event>( 3317ec681f3Smrg q, CL_COMMAND_NDRANGE_KERNEL, deps, 3327ec681f3Smrg [=, &kern, &q](event &) { 3337ec681f3Smrg kern.launch(q, grid_offset, grid_size, block_size); 3347ec681f3Smrg }); 3357ec681f3Smrg 3367ec681f3Smrg ret_object(rd_ev, hev); 3377ec681f3Smrg return CL_SUCCESS; 3387ec681f3Smrg 3397ec681f3Smrg} catch (error &e) { 3407ec681f3Smrg return e.get(); 3417ec681f3Smrg} 3427ec681f3Smrg 3437ec681f3SmrgCLOVER_API cl_int 3447ec681f3SmrgclEnqueueTask(cl_command_queue d_q, cl_kernel d_kern, 3457ec681f3Smrg cl_uint num_deps, const cl_event *d_deps, 3467ec681f3Smrg cl_event *rd_ev) try { 3477ec681f3Smrg auto &q = obj(d_q); 3487ec681f3Smrg auto &kern = obj(d_kern); 3497ec681f3Smrg auto deps = objs<wait_list_tag>(d_deps, num_deps); 3507ec681f3Smrg 3517ec681f3Smrg validate_common(q, kern, deps); 3527ec681f3Smrg 3537ec681f3Smrg auto hev = create<hard_event>( 3547ec681f3Smrg q, CL_COMMAND_TASK, deps, 3557ec681f3Smrg [=, &kern, &q](event &) { 3567ec681f3Smrg kern.launch(q, { 0 }, { 1 }, { 1 }); 3577ec681f3Smrg }); 3587ec681f3Smrg 3597ec681f3Smrg ret_object(rd_ev, hev); 3607ec681f3Smrg return CL_SUCCESS; 3617ec681f3Smrg 3627ec681f3Smrg} catch (error &e) { 3637ec681f3Smrg return e.get(); 3647ec681f3Smrg} 3657ec681f3Smrg 3667ec681f3SmrgCLOVER_API cl_int 3677ec681f3SmrgclEnqueueNativeKernel(cl_command_queue d_q, void (*func)(void *), 3687ec681f3Smrg void *args, size_t args_size, 3697ec681f3Smrg cl_uint num_mems, const cl_mem *d_mems, 3707ec681f3Smrg const void **mem_handles, cl_uint num_deps, 3717ec681f3Smrg const cl_event *d_deps, cl_event *rd_ev) { 3727ec681f3Smrg return CL_INVALID_OPERATION; 3737ec681f3Smrg} 3747ec681f3Smrg 3757ec681f3SmrgCLOVER_API cl_int 3767ec681f3SmrgclSetKernelArgSVMPointer(cl_kernel d_kern, 3777ec681f3Smrg cl_uint arg_index, 3787ec681f3Smrg const void *arg_value) try { 3797ec681f3Smrg if (!any_of(std::mem_fn(&device::svm_support), obj(d_kern).program().devices())) 3807ec681f3Smrg return CL_INVALID_OPERATION; 3817ec681f3Smrg obj(d_kern).args().at(arg_index).set_svm(arg_value); 3827ec681f3Smrg return CL_SUCCESS; 3837ec681f3Smrg 3847ec681f3Smrg} catch (std::out_of_range &) { 3857ec681f3Smrg return CL_INVALID_ARG_INDEX; 3867ec681f3Smrg 3877ec681f3Smrg} catch (error &e) { 3887ec681f3Smrg return e.get(); 3897ec681f3Smrg} 3907ec681f3Smrg 3917ec681f3SmrgCLOVER_API cl_int 3927ec681f3SmrgclSetKernelExecInfo(cl_kernel d_kern, 3937ec681f3Smrg cl_kernel_exec_info param_name, 3947ec681f3Smrg size_t param_value_size, 3957ec681f3Smrg const void *param_value) try { 3967ec681f3Smrg 3977ec681f3Smrg if (!any_of(std::mem_fn(&device::svm_support), obj(d_kern).program().devices())) 3987ec681f3Smrg return CL_INVALID_OPERATION; 3997ec681f3Smrg 4007ec681f3Smrg auto &kern = obj(d_kern); 4017ec681f3Smrg 4027ec681f3Smrg const bool has_system_svm = all_of(std::mem_fn(&device::has_system_svm), 4037ec681f3Smrg kern.program().context().devices()); 4047ec681f3Smrg 4057ec681f3Smrg if (!param_value) 4067ec681f3Smrg return CL_INVALID_VALUE; 4077ec681f3Smrg 4087ec681f3Smrg switch (param_name) { 4097ec681f3Smrg case CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM: 4107ec681f3Smrg case CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM_ARM: { 4117ec681f3Smrg if (param_value_size != sizeof(cl_bool)) 4127ec681f3Smrg return CL_INVALID_VALUE; 4137ec681f3Smrg 4147ec681f3Smrg cl_bool val = *static_cast<const cl_bool*>(param_value); 4157ec681f3Smrg if (val == CL_TRUE && !has_system_svm) 4167ec681f3Smrg return CL_INVALID_OPERATION; 4177ec681f3Smrg else 4187ec681f3Smrg return CL_SUCCESS; 4197ec681f3Smrg } 4207ec681f3Smrg 4217ec681f3Smrg case CL_KERNEL_EXEC_INFO_SVM_PTRS: 4227ec681f3Smrg case CL_KERNEL_EXEC_INFO_SVM_PTRS_ARM: 4237ec681f3Smrg if (has_system_svm) 4247ec681f3Smrg return CL_SUCCESS; 4257ec681f3Smrg 4267ec681f3Smrg CLOVER_NOT_SUPPORTED_UNTIL("2.0"); 4277ec681f3Smrg return CL_INVALID_VALUE; 4287ec681f3Smrg 4297ec681f3Smrg default: 4307ec681f3Smrg return CL_INVALID_VALUE; 4317ec681f3Smrg } 4327ec681f3Smrg 4337ec681f3Smrg} catch (error &e) { 4347ec681f3Smrg return e.get(); 4357ec681f3Smrg} 436