Gcc openmp programming problem

[solved]

Dear Linux users,
I'm a noob at openmp, gcc and c programming. I can run my own openmp code in terminal with no problem, eg. gcc -fopenmp program.c -o program.

But now I'm trying to compile and run another person's code, it contains a makefile and multiple .c and .h files. I don't know how to compile/run this?
Link to the files - https ://github.com/awreece/memory-bandwidth-demo

My attempt to make and run it:

linux@linux ~ $ make
gcc -O3 -march=native main.c monotonic_timer.c functions.c -o memory_profiler -fopenmp -DWITH_OPENMP

linux@linux ~ $ ./memory_profiler
           read_memory_rep_lodsq:  6.96 GiB/s
                read_memory_loop:  7.89 GiB/s
                 read_memory_sse:  7.79 GiB/s
               write_memory_loop:  6.58 GiB/s
          write_memory_rep_stosq:  7.28 GiB/s
                write_memory_sse:  6.61 GiB/s
    write_memory_nontemporal_sse:  5.86 GiB/s
             write_memory_memset:  6.64 GiB/s
memory_profiler: main.c:51: timeitp: Assertion `(1*(1024*1024*1024LL)) % omp_get_max_threads() == 0' failed.
Aborted

Program aborts half way when trying to run openmp code from main.c . I don't think I'm using openmp properly? How can I fix this?

Thankyou for your time,
pigeon

You're compiling it correctly.

How many cores does your system have? The failing assert amounts to, "your system must have a power-of-2 number of cores". So 1, 2, 4, 8, ... cores would be okay -- 6 cores would not.

I don't know very much about OMP at all. I'm not sure whether this is referring to physical cores or just the number OMP is allowed to use in this context.

Thanks for the reply. I needed to specify in the terminal how many cores I'm using. The code is now running properly :slight_smile: