Tag: Beginner

  • OpenMP: Set number of threads using omp_set_num_threads

    by

    in

    OpenMP allows setting number of threads using omp_set_num_threads() function while the program is executing. This function is a part of Runtime Library Routines provided by OpenMP. This function helps developer to have greater control over number of threads used inside the OpenMP codes. This function can be called any number of times inside the OpenMP…

  • OpenMP Barrier Construct

    by

    in

    In OpenMP, Barrier construct is used for synchronization among the threads within a given parallel region. This is the easiest way to synchronize across all the threads. Synchronization is required in many cases. For example, data produced by some/all threads needs to be used/consumed by some/all the other threads in the same parallel region. Here,…

  • OpenMP C/C++: Hello World!

    by

    in

    This is the first OpenMP program, one can write for understanding the parallelization process using OpenMP. First, let us find out how to compile and execute this code. The ‘-fopenmp’ option here requests compiler to generate parallel threads for the given code using OpenMP. If we do not provide this option, compiler will ignore all…

  • Profiling Serial C codes using GNU’s profiler – gprof

    This post covers the steps to profile a C code using GNU’s profiler – gprof. Profiling your serial code is one of the most important step in writing parallel codes. We use profilers to find out the most time consuming parts of the code. Let us consider following sample C code. Fore this code, we…