in this article, i will write my note on cuda string library which is written by a professor in the hkust.
first, let us look at strcpy implemented in cuda.
in cuda,it is recommended to use build-in vector like char4 and int4, because gpu can fetch the entire vector in one clock cycle from the memory.
strcmp is very like strcpy. it uses build-in vector char4 to speed up memory fetch.
it is a good idea to first compare the first n characters , where n is the length of the shorter string because we don't need to always worry about the end mark '/0' of the string.
if the first n characters of two strings are equal then we just need to compare their length to get the result.
additionally, we also can use this method in the memset.look at the code as follows.