0

I am trying to enable opeMP in visual studio code. I could not find a guide to do this. Any help?

I am trying to run a code that looks like this:

    //TIME LOOP:
    for (int nt = 0; nt < time_steps; nt++){

#pragma omp parallel for

        //PARTICLE LOOP:
        for (int particle = 0; particle < number_of_particles; particle++){
            double E[3];
            double B[3];
            double x[3]; 
            double v[3];
            fill_vector(X,x,particle);
            fill_vector(V,v,particle);
            get_fields(E, B, x);
            Boris(x, v, E, B);
            update_matrix(X,x,particle); 
            update_matrix(V,v,particle); 
            fprintf(fout1,"%d, %g, %g, %g, %g, %g, %g, %g\n",particle,nt*dt,x[0],x[1],x[2],v[0],v[1],v[2]); 
        }
    }

    fclose(fout1); 

    double time2 = WTime();
    printf("TIME = %g\n",time2-time1);

    return 0;
jokerp
  • 157
  • 1
  • 8
  • 1
    OpenMP is not a visual studio code option, it is a compiler flag, so you have to set it as all other compiler flags ( [How to include compiler flags in Visual Studio Code?](https://stackoverflow.com/questions/57173093/how-to-include-compiler-flags-in-visual-studio-code) ) – Laci Sep 19 '21 at 07:56
  • Did you go through this doc https://learn.microsoft.com/en-us/cpp/build/reference/openmp-enable-openmp-2-0-support?view=msvc-160 – Alan Sep 19 '21 at 07:57
  • 1
    Note that depending on the workload of PARTICLE LOOP and OpenMP version you use, it may be better to use `#pragma omp parallel` and `#pragma omp single` before TIME LOOP and use tasks (e.g. `#pragma omp taskloop`) to parallelize PARTICLE LOOP. – Laci Sep 19 '21 at 08:13

0 Answers0