How to model a graph into a riscv custom instruction in c - riscv

Instruction recommender tool Graph
I am trying to create a custom instruction and add it to the riscv-gnu-toolchain and spike.
The above link will show the graph that I have generated using rvnewop which is basically an instruction recommender tool. So what the tool does is that it runs through my dump file and then recommends what can be done to basically optimize the code by suggesting instructions in a graphical format.
Is there any way I can model this graph which basically shows the instruction flow into a c code which then can be added to the toolchain and spike?

Related

C-API Asynchronous Batch Inference with OpenVino

I'm trying to find an example of using the C-API (not C++) asynchronous batch interface for OpenVino image inference.
I'm able to do inference on a single image at a time no problem, but its not clear to me how to expand this to batch inference with the C-API.
Does anyone have an example or reference for doing so? The OpenVino documentation is limited on this front, nor do they provide any C-based examples for doing so that I've been able to find.
EDIT: Per comment below, clarifying that the challenge is in understanding how to load up the input blobs with multiple images. The existing examples either assume the C++ interface and use vectors to move things around, or are unclear in what is idiomatic to the example (e.g. the object detection sample using the C-API)
You can use the following functions: ie_infer_request_infer_async() and ie_infer_request_set_batch().
Relevant information is available at the following link:
https://docs.openvinotoolkit.org/2020.4/ie_c_api/group__InferRequest.html
I suggest you refer to the following two C API based samples:
Hello Classification C Sample
https://docs.openvinotoolkit.org/2020.4/openvino_inference_engine_ie_bridges_c_samples_hello_classification_README.html
Hello NV12 Input Classification C Sample
https://docs.openvinotoolkit.org/2020.4/openvino_inference_engine_ie_bridges_c_samples_hello_nv12_input_classification_README.html
High-level description of the process of integrating the Inference Engine into your application is available at the following page:
https://docs.openvinotoolkit.org/2020.4/openvino_docs_IE_DG_Integrate_with_customer_application_new_API.html

profiling dynamic library in linux using perf

I have decision tree classifer class implemented in C++ and I want to profile only C++ shared library of my decision tree class. I am using linux perf tool but I do not want to profile the whole application just the shared library which I have created for decision tree class.
is it possible to generate perf.data for shared library and then get a flame graph?
any help will be highly appreciated in this regards,
Arslan

How to use Matlab embedded coder under Windows to compile for LINUX?

I'm trying to compile a Simulink algorithm to a CarPC. The CarPC is based on a Intel Atom processor and runs in LINUX. The idea is compile the Simulink code with the Matlab embedded coder to the specific target.
The problem is I don't know if I can use my Windows version of Matlab to compile the algorithm and then use it on LINUX. I mean, compile from Windows to LINUX.
Is it possible with my Matlab R2014a from Windows to the Intel Atom processor with LINUX?
As #ThP said, yes you can. One option is to generate the C code on the Windows machine and then move the generated code to a machine that has a C compiler for the embedded target and compile the C code there.
Make sure that you set up the target hardware in:
Simulation > Model Configuration Parameters > Hardware Implementation
to be compatible with your Atom processor/compiler. Also set up the model to generate code only in:
Simulation > Model Configuration Parameters > Code Generation
if you are planning on compiling the generated code on another machine.
There is a good deal of additional information about generating code for other targets in the Simulink Coder documentation.

Measure function time execution without modification code

I have found some piece of code (function) in library which could be improved by the optimization of compiler (as the main idea - to find good stuff to go deep into compilers). And I want to automate measurement of time execution of this function by script. As it's low-level function in library and get arguments it's difficult to extract this one. Thus I want to find out the way of measurement exactly this function (precise CPU time) without library/application/environment modifications. Have you any ideas how to achieve that?
I could write wrapper but I'll need in near future much more applications for performance testing and I think to write wrapper for every one is very ugly.
P.S.: My code will run on ARM (armv7el) architecture, which has some kind of "Performance Monitor Control" registers. I have learned about "perf" in linux kernel. But don't know is it what I need?
It is not clear if you have access to the source code of the function you want to profile or improve, i.e. if you are able to recompile the considered library.
If you are using a recent GCC (that is 4.6 at least) on a recent Linux system, you could use profilers like gprof (assuming you are able to recompile the library) or better oprofile (which you could use without recompiling), and you could customize GCC for your needs.
Be aware that like any measurements, profiling may alter the observed phenomenon.
If you are considering customizing the GCC compiler for optimization purposes, consider making a GCC plugin, or better yet, a MELT extension, for that purpose (MELT is a high-level domain specific language to extend GCC). You could also customize GCC (with MELT) for your own specific profiling purposes.

linux disassembler

how can I write just a simple disassembler for linux from scratches?
Are there any libs to use? I need something that "just works".
Instead of writing one, try Objdump.
Based on your comment, and your desire to implement from scratch, I take it this is a school project. You could get the source for objdump and see what libraries and techniques it uses.
The BFD library might be of use.
you have to understand the ELF file format first. Then, you can start processing the various sections of code according to the opcodes of your architecture.
You can use libbfd and libopcodes, which are libraries distributed as part of binutils.
http://www.gnu.org/software/binutils/
As an example of the power of these libraries, check out the Online Disassembler (ODA).
http://www.onlinedisassembler.com
ODA supports a myriad of architectures and provides a basic feature set. You can enter binary data in the Live View and watch the disassembly appear as you type, or you can upload a file to disassemble. A nice feature of this site is that you can share the link to the disassembly with others.
You can take a look at the code of ERESI
The ERESI Reverse Engineering Software Interface is a multi-architecture binary analysis framework with a tailored domain specific language for reverse engineering and program manipulation.

Resources