[flang-commits] [flang] [Flang] Generalize intrinsic CUBLAS USE association (PR #220024)

via flang-commits flang-commits at lists.llvm.org
Thu Sep 3 01:10:01 PDT 2026


================
@@ -4281,23 +4281,29 @@ static bool HasCUDADummyDataAttribute(const Symbol &procedure) {
 
 struct IntrinsicModuleUseAssociationRule {
   const char *moduleName;
-  const char *genericName;
-  bool (*matches)(SemanticsContext &, const GenericDetails &, const Symbol &);
+  bool (*matches)(SemanticsContext &, const Symbol &, const Symbol &);
 };
 
-static bool MatchesCublasGemm(SemanticsContext &context,
-    const GenericDetails &generic, const Symbol &other) {
-  const Symbol *specific{generic.specific()};
+static bool MatchesCublasBlas(
+    SemanticsContext &context, const Symbol &generic, const Symbol &other) {
+  if (generic.GetUltimate().name().ToString().rfind("cublas", 0) == 0) {
+    return false;
+  }
+  const auto &details{generic.get<GenericDetails>()};
+  const Symbol *specific{details.specific()};
   if (!specific ||
       !AreSameProcedureForUseAssociation(context, *specific, other)) {
     return false;
   }
   bool containsSpecific{false};
   bool hasCUDAOverload{false};
-  for (const Symbol &candidate : generic.specificProcs()) {
+  for (const Symbol &candidate : details.specificProcs()) {
     containsSpecific |= &candidate.GetUltimate() == &specific->GetUltimate();
     hasCUDAOverload |= HasCUDADummyDataAttribute(candidate);
   }
+  // If a CUBLAS generic is found whose CUDA specifics are not compatible
+  // enough with its homonymous host specific, also consider checking their
+  // basic procedure shapes here while ignoring CUDA-specific attributes.
----------------
jeanPerier wrote:

I do not really understand if this comment is about something the code is doing, or something that the code could do in the future in case some problem arise. If this is a future design note, I would highlight it with different tense or "for now". Something like "Their basic procedure shapes could be check here while ignoring CUDA-specific attributes, which is not done for now".

https://github.com/llvm/llvm-project/pull/220024


More information about the flang-commits mailing list