title: OpenMP get_num_threads for parallel for
body: <p>What's the best way to find the number of threads that will be used for an omp <code>parallel for</code>? I want to allocate enough memory for use with all the threads, but can't make use of <code>omp_get_num_threads</code> until I'm inside the parallel section. For instance:</p>
  
  <pre><code>int thread_count = ?
  float *data = (float*)malloc(thread_count * data_count * sizeof(float));
  
  #pragma omp parallel for default(shared) private(x)
  for (x=0; x&lt;N; x++)
  {
      int threadid = omp_get_thread_num();
      //... do stuff with data
  }
  
  free(data);
  </code></pre>
  
  <p>What's the proper way of doing it so that I can know how many threads will be used and can allocate accordingly? Thanks</p>