numaprof icon indicating copy to clipboard operation
numaprof copied to clipboard

will support other platform such as ARM?

Open ender233 opened this issue 5 years ago • 8 comments

hello will support other platform such as ARM?

ender233 avatar Jun 13 '19 01:06 ender233

Hi, as long as I'm based on Pintool no because it is x86 only.

I would like to make an additional port on top of DynamoRIO which provide mostly the same thing but free/open-source and available for both x86 and ARM. (see #5).

My problem, I currently do not have enougth continuous time to make this kind of work. But if ever you know someone or you are interested I will be more than happy to take time to assist/guide/help making it.

In principle DyanmoRIO offer a very similar API approach than Pin except less predefine functions to intercept Load/Stores, this just require a little bit more codes but there is exemples in there doc for what we need in theory, I already looked for that.

If we have DynamoRIO, there should be mostly nothing extra to change to support ARM for the rest of the code except really minor things I can for sure do by myself.

It will be also really nice as it removed the strong dependency on Pin which is not open.

Cheers.

svalat avatar Jun 13 '19 01:06 svalat

I can make a course to help starting if it is interesting.

svalat avatar Jun 13 '19 02:06 svalat

hello, sounds good. where can someone start from?

ender233 avatar Jun 24 '19 16:06 ender233

Hi, Thanks for your interest.

The main things to be done is to convert the Pin instrumentation glue to make the same into DynamoRIO. The only point is such there is a bit more automation for load/store interception in Pin which require a bit more code (not too much, and there is the required bases in examples).

So if ever you want to start or someone one, I would first:

  • [ ] Look quickly the numaprof Pin glue (mostly intercept all events and forward to the tool state tracking): https://github.com/memtt/numaprof/blob/master/src/integration/pintool/numaprof.cpp
  • [ ] If you want to better understand the global Pin philosophy to understand this code, the documentation is really well done : https://software.intel.com/sites/landingpage/pintool/docs/97971/Pin/html/

Then look for equivalent in DyanmoRIO which also have pretty nice doc: http://dynamorio.org/. For the NUMAPROF case, the requirement is to:

  • [ ] Intercept loads/stores, you can start looking the memtrace example : https://github.com/DynamoRIO/dynamorio/blob/master/api/samples/memtrace_x86.c
  • [ ] Intercept the malloc/free... calls, same you can look the DrMemory example: http://drmemory.org/

From this you might get all the points to make the wrapper to replace the pin glue.

To make the work easier I would first run totaly outside of NUMAPROF just making an interception script writing events into a file as text to debug start making working, then we can look together to glue everything, there should not be too much work once the interception is done, this is the most hard part.

I can start a project board with tasks ordered in ways to make life easier if you want I track progress to help when needed, this will be with pleasure to share knowledge.

svalat avatar Jun 24 '19 20:06 svalat

nice, very useful info. i will read your numaprof document&code , try to get a whole picture. as know little about techniques. actually numaprof may give us lots help as we are optimizing apps running on numa arm know nothing about memory traffic.

ender233 avatar Jun 29 '19 08:06 ender233

hello,I am very interested in converting Pin instrument glue to DynamoRIO to enable NUMAPROF to support ARM. However, DynamoRIO's API is quite complex, and I would like to know if you can provide more detailed courses to replace pin glue.

ismeFUFU avatar Oct 17 '23 06:10 ismeFUFU

Hi @ismeFUFU , sorry for the long delay to answer.

I would say that you can first me some tries as explain in the previous pose outside of numaprof.

For me the first point is :

  • [ ] to see how to capture all load/store instructions (this is probably the harder as DynamoRIO provide less wrapper than PIN for this, so maybe you will need to handle several issues, probably with vector instruction of I don't know what).
  • [ ] see how to extract the source line from the intercepted address. At least the address in the binary (not necessarily trivial because the actual address will be the rewritten instruction). But probably DynamoRIO provide functions for this, I didn't yet checked.
  • [ ] see how to intecept a function call (which will be malloc/free)
  • [ ] see if you can call some C++ function inside the instrumentation code to mimic the needs to call my numaprof internal lib.

Once you have this, the rest is makeing the glue with the numaprof internal lib which might not be blocking as the API is short.

svalat avatar Nov 16 '23 18:11 svalat

Remark that the first steps you can do totaly out of numaprof, just making an instrumentation file standalone.

In code reading, as said in the older comment, the good start is to see if you understand this as it will be probably the most harder part to play put in place in the wrapper (intercepting the load/stores) : https://github.com/DynamoRIO/dynamorio/blob/master/api/samples/memtrace_x86.c

svalat avatar Nov 16 '23 18:11 svalat