Naziur Rahman khan Fall 2022 SPO600 Project_Stage2

While I first approach this project I was kind of blank like where to start my first step. I previously had no exposure to work with low level coding neither C coding. Till now I am only comfortable with doing some mid level python coding. My project is to build a tool that can be written in any language whose main purpose is to take function from a single file and create three copy of it with the variation of the function for each auto vectorization type and also add an ifunc resolver to choose which one of those functions to use based on the particular system capability. 

We got our main file from our professor's github repo that he shared with us. I copied the files to my assignment armv8 machine called israel from this link: https://github.com/ctyler/spo600-fall2022-project-test-code.git

I have kept all my project related file in my repo which can be accessed from here https://github.com/myseneca-162912216/SPO-600/tree/main/spo600_stage_2

I have taken some help regarding processing the functions defined in the function.c file from stackoverflow which can be found here: https://stackoverflow.com/questions/55078713/extract-function-code-from-c-sourcecode-file-with-python

I have to use the "makeheaders utility" to find the function prototypes of the functions. We have used the "makeheaders.c" which we have got from this repo: https://github.com/bjconlan/makeheaders.git 


The current directory with all my project files should look like this:



The Auto vectorization tool has been written in python programming language. I have used visual studio code of my local machine as I feel comfortable testing my code there. Also I used the given Aarch64 machine called "israel". 
In order to run the tool we need to provide an input file name of function. In our case we used "function.c"

We can run the tool like this:
$python autovectorization_tool.py --inputfile function.c

After running the tool, it will generate the following files:

  1. makeheaders_exec (after compiling the makeheader.c file
  2. function.h (makeheaders_exec will generate it from function.c to find the function names)
  3. function_asimd.c ( modified function for Advanced SIMD build)
  4. function_sve.c ( modified function for SVE build)
  5. function_sve2.c ( modified function for SVE2 build)
  6. function_asimd.o (compiled output of  function_asimd.c)
  7. function_sve.o (compiled output of  function_sve.c)
  8. function_sve2.o (compiled output of  function_sve2.c)
  9. ifunc.c (generated resolver function for ASIMD, SVE,SVE2 build for the target functions)
  10. ifunc.h (generated header of target functions for ASIMD, SVE,SVE2 variants)
  11. main (final compiled build file with auto vectorization capabilities)

The output should look like this:


In order to test the final compiled build we can run this on israel machine which is an armv8 machine build with asimd. We 

./main tests/input/bree.jpg 1.0 3.0 5.0 tests/output/breelaa.jpg

Then we can emulate SVE2 system using qemu-aarch64:

 qemu-aarch64 ./main tests/input/bree.jpg 1.0 3.0 5.0 tests/output/breel_qemu.jpg

The outputs showing both the SVE2 and the original ASIMD build will look like this:



From the above picture we can see that, when we ran the final compiled binary, it provides the output with:

Using asimd build implementation - Naive (autovectorizable)

and when we used the  qemu-aarch64 emulator, it provides the output with:

Using sve2 build implementation - Naive (autovectorizable)

This proves that our auto vectorization tool is working fine and it is automatically selecting between different functions based on the ASIMD, SVE and SVE2 builds of the ARM architecture. 


So far the tool can work only with a single function name. I also have worked little bit about multiple function capabilities. But I do need to research more to make it fully working for multiple functions. I will focus about that on the stage 3. I will also try to solve any more limitations that are listed in the project page or maybe beyond that. 

Comments

Popular posts from this blog

SPO600-Lab2 (Experimenting with 6502 emulator)

Naziur Rahman khan Fall 2022 SPO600 Project (Algorithm-part1)

Naziur Rahman khan Fall 2022 SPO600 Project (Algorithm-part2)