Skip to content

Commit

Permalink
Refactor rapidsai#8
Browse files Browse the repository at this point in the history
  • Loading branch information
codereport committed Jul 6, 2020
1 parent 557093d commit 6ca4318
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions cpp/src/jit/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,38 +241,37 @@ std::string ptx_parser::parse_param(const std::string& src)

std::string ptx_parser::parse_param_list(const std::string& src)
{
const size_t length = src.size();
size_t start = 0;
size_t stop = 0;
auto f = src.begin();
auto l = src.begin();

std::string output;
auto item_count = 0;
std::string output{};

int item_count = 0;
std::string first_name;
std::string arg_type;
while (stop < length) {
while (stop < length && src[stop] != ',') { stop++; }
std::string name = parse_param(std::string(src, start, stop - start));
if (pointer_arg_list.find(item_count) != pointer_arg_list.end()) {
if (item_count == 0) {
output += output_arg_type + "* " + name;
} else {
// On a 64-bit machine inside the PTX function body a pointer is
// literally just a uint_64 so here is doesn't make sense to
// have the type of the pointer. Thus we will just use void* here.
output += ",\n const void* " + name;
}
} else {
if (input_arg_list.count(name)) {
output += ", \n " + input_arg_list[name] + " " + name;
while (l < src.end()) {
l = std::find(l, src.end(), ',');

output += [&, name = parse_param(std::string(f, l))] {
if (pointer_arg_list.find(item_count) != pointer_arg_list.end()) {
if (item_count == 0) {
return output_arg_type + "* " + name;
} else {
// On a 64-bit machine inside the PTX function body a pointer is
// literally just a uint_64 so here is doesn't make sense to
// have the type of the pointer. Thus we will just use void* here.
return ",\n const void* " + name;
}
} else {
// This parameter isn't used in the function body so we just pretend
// it's an int. After being inlined they are gone anyway.
output += ", \n int " + name;
if (input_arg_list.count(name)) {
return ", \n " + input_arg_list[name] + " " + name;
} else {
// This parameter isn't used in the function body so we just pretend
// it's an int. After being inlined they are gone anyway.
return ", \n int " + name;
}
}
}
stop++;
start = stop;
}();

f = ++l;
item_count++;
}

Expand Down

0 comments on commit 6ca4318

Please sign in to comment.