Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit e06dd34

Browse files
authored
CUDA-11.6-fix (#509)
* Fix cuda CFG parsing problem for CUDA >= 11.5: target label names were changed from .L_<number> to .L_x_<number>. Code was adjusted to be less sensitive to the form of the label name.
1 parent c4bb41b commit e06dd34

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

src/lib/banal/gpu/DotCFG.hpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,26 @@ struct CudaInst : public Inst {
125125
}
126126
}
127127
} else {
128-
// Target
128+
// Extract target name of the jump or the sync instruction
129+
// The target name can be in two forms:
130+
// "**.L_<number>**" for CUDA < 11.5
131+
// "**.L_x_<number>**" for CUDA >= 11.5
132+
// We assuming the target label will keep the form "**.L_**<number>**" in the further release
133+
static const std::string TARGET_LABEL = ".L_";
129134
operands.push_back(s);
130135
if (is_jump || is_sync) {
131-
auto pos = s.find(".L_");
136+
auto pos = s.find(TARGET_LABEL);
132137
if (pos != std::string::npos) {
133-
auto end_pos = pos + 3;
134-
size_t len = 0;
135-
while (end_pos != std::string::npos) {
136-
if (!std::isdigit(s[end_pos])) {
137-
break;
138-
}
139-
++len;
140-
++end_pos;
138+
auto digit_pos = pos + TARGET_LABEL.size();
139+
// Find the start digit of the number
140+
for (;digit_pos != std::string::npos && !std::isdigit(s[digit_pos]); ++digit_pos);
141+
// Find the end digit of the number
142+
for (;digit_pos != std::string::npos && std::isdigit(s[digit_pos]); ++digit_pos);
143+
if (digit_pos != std::string::npos) {
144+
this->target = s.substr(pos, digit_pos - pos);
141145
}
142-
this->target = s.substr(pos, len + 3);
143146
}
144-
}
147+
}
145148
}
146149
}
147150
}

0 commit comments

Comments
 (0)