1

I am using python graph-tool for this algorithm in order to find min-cut in a large graph. My algorithm needs several calls to this function, and it seems to be the bottleneck. So I want to ensure if it is being run as efficiently as it could be i.e. using OpenMP.

However, on changing number of threads using openmp_set_num_threads(n), I get the same time for different number of threads viz. 2, 24 and 128.

Is there a way to check if OpenMP is being used by the graph-tool? I have checked the number of threads using openmp_get_num_threads and it is correct. Also how to enable OpenMP in case it is not being used by the graph-tool?

Alternatively, is there a way to check if some particular function of graph-tool, boykov_kolmogorov_max_flow in our case, uses OpenMP?

arpanmangal
  • 1,770
  • 1
  • 17
  • 34
  • How do you use openMP with Python? There is no direct support, see [here](https://stackoverflow.com/questions/11368486/openmp-and-python) – supercheval Jul 29 '18 at 10:34
  • @Imontigny I am using the python library [graph-tool](https://graph-tool.skewed.de/) which is implemented in C++, and thus can use `OpenMP`. At least this is what they claim they do. – arpanmangal Jul 29 '18 at 14:08
  • Ok, can you print the output of graph_tool.openmp_enabled() and graph_tool.openmp_get_num_threads()? – supercheval Jul 29 '18 at 17:18
  • `True` and `correct number of threads` respectively. The problem is that the function call to `boykov_kolmogorov_max_flow` takes the same time for different `num_threads`. – arpanmangal Jul 29 '18 at 17:44
  • 1
    Ok, in the graph-tool source code they include and I don't see any openMP pragma in the corresponding file [here](https://www.boost.org/doc/libs/1_53_0/boost/graph/boykov_kolmogorov_max_flow.hpp). It seems that this algorithm is not implemented in parallel. Only a part of graph-tool is parallelized using openMP, I found some omp pragma for pagerank for example. (You can do "grep -wr omp *" in the source folder of graph-tool) – supercheval Jul 29 '18 at 20:45
  • Yes, that explains the same timings.. Thanks. However does `graph-tool` mentions in its documentation which functions are parallelized and which are not? – arpanmangal Jul 30 '18 at 04:22
  • Unfortunately I don't see such a description. – supercheval Jul 30 '18 at 15:00

1 Answers1

0

Meanwhile there is a function for that:

> import graph_tool as gt
> gt.openmp_enabled()
True

Return True if OpenMP was enabled during compilation.

Suuuehgi
  • 4,547
  • 3
  • 27
  • 32