|
| 1 | +non_parametric_routines = ["init_matrix_handle", "release_matrix_handle", "set_matrix_property", |
| 2 | +"init_matmat_descr", "release_matmat_descr", "set_matmat_data", "get_matmat_data", "matmat", |
| 3 | +"omatcopy", "sort_matrix", "optimize_gemv", "optimize_trmv", "optimize_trsv", "optimize_trsm"] |
| 4 | + |
| 5 | +function analyzer_template(library::String, cpp_headers::String, name_routine::String) |
| 6 | + list_parameters = Vector{String}[] |
| 7 | + list_types = Vector{String}[] |
| 8 | + list_versions = String[] |
| 9 | + list_suffix = String[] |
| 10 | + |
| 11 | + if (library == "blas") || (library == "sparse" && !(name_routine ∈ non_parametric_routines)) |
| 12 | + prefix = (library == "sparse") ? "SPARSE_" : "BUF_" |
| 13 | + |
| 14 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(T)", cpp_headers) && (list_parameters = ["T"]) |
| 15 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(FpType)", cpp_headers) && (list_parameters = ["FpType"]) |
| 16 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(Tf, Ti)", cpp_headers) && (list_parameters = ["Tf", "Ti"]) |
| 17 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(T, Ts)", cpp_headers) && (list_parameters = ["T", "Ts"]) |
| 18 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(IntType, FpType)", cpp_headers) && (list_parameters = ["IntType", "FpType"]) |
| 19 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(Ta, Tb, Tc, Ts)", cpp_headers) && (list_parameters = ["Ta", "Tb", "Tc", "Ts"]) |
| 20 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(T, Tres)", cpp_headers) && (list_parameters = ["T", "Tres"]) |
| 21 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(T, Treal)", cpp_headers) && (list_parameters = ["T", "Treal"]) |
| 22 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(T, Tc, Ts)", cpp_headers) && (list_parameters = ["T", "Tc", "Ts"]) |
| 23 | + occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))(T, Tc)", cpp_headers) && (list_parameters = ["T", "Tc"]) |
| 24 | + |
| 25 | + (list_parameters == []) && @warn("Unable to determine the parametric parameters of $(name_routine).") |
| 26 | + |
| 27 | + for (type, version, suffix) in [(["sycl::half"], "H", ""), |
| 28 | + (["float"], "S", ""), |
| 29 | + (["double"], "D", ""), |
| 30 | + (["std::complex<float>"], "C", ""), |
| 31 | + (["std::complex<double>"], "Z", "")] |
| 32 | + if occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))($(type[1]))", cpp_headers) |
| 33 | + push!(list_types, type) |
| 34 | + push!(list_versions, version) |
| 35 | + push!(list_suffix, suffix) |
| 36 | + end |
| 37 | + end |
| 38 | + |
| 39 | + for (type, version, suffix) in [(["int32_t","float"], "S", ""), |
| 40 | + (["int64_t","float"], "S", "_64"), |
| 41 | + (["int32_t","double"], "D", ""), |
| 42 | + (["int64_t","double"], "D", "_64"), |
| 43 | + (["int32_t","std::complex<float>"], "C", ""), |
| 44 | + (["int64_t","std::complex<float>"], "C", "_64"), |
| 45 | + (["int32_t","std::complex<double>"], "Z", ""), |
| 46 | + (["int64_t","std::complex<double>"], "Z", "_64"), |
| 47 | + (["float","int32_t"], "S", ""), |
| 48 | + (["float","int64_t"], "S", "_64"), |
| 49 | + (["double","int32_t"], "D", ""), |
| 50 | + (["double","int64_t"], "D", "_64"), |
| 51 | + (["std::complex<float>","int32_t"], "C", ""), |
| 52 | + (["std::complex<float>","int64_t"], "C", "_64"), |
| 53 | + (["std::complex<double>","int32_t"], "Z", ""), |
| 54 | + (["std::complex<double>","int64_t"], "Z", "_64"), |
| 55 | + (["sycl::half","sycl::half"], "H", ""), |
| 56 | + (["float","float"], "S", ""), |
| 57 | + (["double","double"], "D", ""), |
| 58 | + (["std::complex<float>","float"], "CS", ""), |
| 59 | + (["std::complex<double>","double"], "ZD", ""), |
| 60 | + (["std::complex<float>","std::complex<float>"], "C", ""), |
| 61 | + (["std::complex<double>","std::complex<double>"], "Z", "")] |
| 62 | + if occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))($(type[1]), $(type[2]))", cpp_headers) |
| 63 | + push!(list_types, type) |
| 64 | + push!(list_versions, version) |
| 65 | + push!(list_suffix, suffix) |
| 66 | + end |
| 67 | + end |
| 68 | + |
| 69 | + for (type, version, suffix) in [(["sycl::half","sycl::half","sycl::half"], "H", ""), |
| 70 | + (["float","float","float"], "S", ""), |
| 71 | + (["double","double","double"], "D", ""), |
| 72 | + (["std::complex<float>","float","float"], "CS", ""), |
| 73 | + (["std::complex<float>","float", "std::complex<float>"], "C", ""), |
| 74 | + (["std::complex<double>","double","double"], "ZD", ""), |
| 75 | + (["std::complex<double>","double","std::complex<double>"], "Z", "")] |
| 76 | + if occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))($(type[1]), $(type[2]), $(type[3]))", cpp_headers) |
| 77 | + push!(list_types, type) |
| 78 | + push!(list_versions, version) |
| 79 | + push!(list_suffix, suffix) |
| 80 | + end |
| 81 | + end |
| 82 | + |
| 83 | + for (type, version, suffix) in [(["sycl::half","sycl::half","sycl::half","sycl::half"], "H", ""), |
| 84 | + (["float","float","float","float"], "S", ""), |
| 85 | + (["double","double","double","double"], "D", ""), |
| 86 | + (["std::complex<float>","std::complex<float>","std::complex<float>","std::complex<float>"], "C", ""), |
| 87 | + (["std::complex<double>","std::complex<double>","std::complex<double>","std::complex<double>"], "Z", "")] |
| 88 | + if occursin("ONEMKL_DECLARE_$(prefix)$(uppercase(name_routine))($(type[1]), $(type[2]), $(type[3]), $(type[4]))", cpp_headers) |
| 89 | + push!(list_types, type) |
| 90 | + push!(list_versions, version) |
| 91 | + push!(list_suffix, suffix) |
| 92 | + end |
| 93 | + end |
| 94 | + end |
| 95 | + |
| 96 | + return list_parameters, list_types, list_versions, list_suffix |
| 97 | +end |
0 commit comments