I am trying to writ the CUDA C++ equivalent code for the following C++ code. I have tried several ways but I can’t find a way to implement this code in parallel.
void func(result, parents, parentslength, matchparents, matchlength) {
int j = 0;
for (int i = 0; i < parentslength; i++) {
if (j < matchlength && parents[i] == matchparents[j]) {
result[i] = j;
++j;
}
else {
result[i] = -1;
}
}
}
This is an example of the inputs and expected output:
parentslength = 12,
parents = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3],
matchlength = 6,
matchparents = [0, 0, 0, 2, 2, 3],
result = [0, 1, 2, -1, -1, -1, -1, 3, 4, -1, 5, -1]
New contributor
mnabc12341 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.