SPO600 Project – Choosing a glibc function

After several weeks of working with assembler, that time of the semester is now upon us where we must use what we’ve learned and apply that theory into something practical. We have been tasked with picking a glibc function and optimizing it for Aarch64. Now whether we use assembly or pure C is totally up to us. We have been given nearly absolute freedom where normally we would be guided by strict instruction sets. As liberating as it is, I would still say it is a daunting task. Not often do we get to work with something so widely used as the glibc functions.

With so many functions, I would say actually picking function is just as hard as the implementation, which is actually the major reason it took me so long to get this post going. But after a lot of research, I think I’ve picked a decent function. Now whether or not I can actually go ahead and optimize is a whole other blog post.

So which function have I picked you ask? I’ve gone with strcpy, which by the name you can probably guess is the function to copy strings. So why this function over the rest? Well when I really sat down to think about the best way to make something better, it made sense to pick a function who’s instructions would be repeated multiple times. Even by simply looking at a portion of the naive implementation we can see that there is basically a copy operation that is done many times.

      c = *s++;
      s[off] = c;
  while (c != '\0');

So I thought, after learning so much about vectorization and SIMD functions, why not take these repeated copy instructions and do them in parallel. Good in theory but the actual execution is quite challenging. I will discuss in further detail my thought processes and experiences in the next few blog posts!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s