Skip to content

Commit

Permalink
Merge pull request #83 from OlgaKogiou/make-documentation
Browse files Browse the repository at this point in the history
Adding page for building programs with dlio-profiler using Makefile
  • Loading branch information
hariharan-devarajan authored Jun 7, 2024
2 parents dbdae88 + caee7e5 commit 05e214b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
61 changes: 61 additions & 0 deletions docs/building_applications.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
=========================================================
Building applications with DLIO Profiler Code Annotations
=========================================================

This section provides guidelines on how to build applications with DLIO Profiler Code Annotations.

Building for Projects with Makefiles
------------------------------------

To integrate DLIO Profiler into your Makefile projects, you need to modify the `CFLAGS` or `CXXFLAGS` and `LDFLAGS` in your Makefile to include the DLIO Profiler's headers and libraries. Below are the steps:

1. **Set the DLIO Profiler include and library paths:**

Ensure you know the paths where DLIO Profiler's header files and libraries are located. Typically, they might be in directories like `/path/to/dlio-profiler/include` and `/path/to/dlio-profiler/lib64`. If you have built DLIO Profiler with pip then these paths may look like `/path/to/lib/pythonX/site-packages/dlio_profiler/include` and `/path/to/lib/pythonX/site-packages/dlio_profiler/lib64`.

2. **Modify your Makefile:**

Open your Makefile and locate the sections where `CFLAGS` or `CXXFLAGS` and `LDFLAGS` are defined. Add the include path to `CFLAGS` or `CXXFLAGS` and the library path to `LDFLAGS`.

Here is an example snippet of how to modify a Makefile to build a C program:

.. code-block:: makefile
# Existing CFLAGS and LDFLAGS
CFLAGS = -g -O2 -std=c99
LDFLAGS = -lm
# Add DLIO Profiler include and library paths
DLIO_CFLAGS = -I/path/to/dlio-profiler/include
DLIO_LDFLAGS = -L/path/to/dlio-profiler/lib64 -ldlio_profiler
# Append to existing CFLAGS and LDFLAGS
CFLAGS += $(DLIO_CFLAGS)
LDFLAGS += $(DLIO_LDFLAGS)
3. **Use the DLIO Profiler macros in your source code:**

Ensure that you include the DLIO Profiler header in your source files and use the profiling macros as needed.

Example for a C program:

.. code-block:: c
#include <dlio_profiler/dlio_profiler.h>
void some_function_with_annotations() {
DLIO_PROFILER_C_FUNCTION_START();
sleep(1);
DLIO_PROFILER_C_FUNCTION_END();
return;
}
4. **Build your project:**

Run `make` as usual to build your project with DLIO Profiler annotations integrated.

.. code-block:: sh
make
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ DLIO Profiler: is a library for profiling I/O calls and application functions.
definitions
limitations
build
building_applications
api

.. toctree::
Expand Down

0 comments on commit 05e214b

Please sign in to comment.