Parallel processing 如何在hpc中并行化此代码?

Parallel processing 如何在hpc中并行化此代码?,parallel-processing,octave,hpc,Parallel Processing,Octave,Hpc,上述倍频程代码用于生成写入文本文件的数字序列。由于它生成大约2^36个数字,因此需要几天才能完成执行。因此,任何人都可以告诉我们如何在hpc中并行化此代码。您可能不需要并行化此代码;通过使用编译语言,可以将速度提高大约10000x。(严肃地说,请看下面)倍频程甚至matlab都会像糖蜜一样慢。它们非常适合于大型矩阵运算,但其中包含if语句的大量嵌套循环将运行缓慢。通常我会建议将Octave/Matlab代码移到FORTRAN,但由于您已经基本上用C语句编写了文件I/O,因此该代码的C等价物几乎可

上述倍频程代码用于生成写入文本文件的数字序列。由于它生成大约2^36个数字,因此需要几天才能完成执行。因此,任何人都可以告诉我们如何在hpc中并行化此代码。

您可能不需要并行化此代码;通过使用编译语言,可以将速度提高大约10000x。(严肃地说,请看下面)倍频程甚至matlab都会像糖蜜一样慢。它们非常适合于大型矩阵运算,但其中包含if语句的大量嵌套循环将运行缓慢。通常我会建议将Octave/Matlab代码移到FORTRAN,但由于您已经基本上用C语句编写了文件I/O,因此该代码的C等价物几乎可以自己编写:

s=1

r=m=n=o=p=q=u=t=19

myfile = fopen ("sequence2.txt", "w", "ieee-le");

for a=0:1

  if(a==1)

      r=5

  endif

  for b=0:r

    if(a==1 && b==5)

    m=11

    endif   

for c=0:m

n=o=19

  for d=0:1

if(d==1)

  n=5

  endif

for e=0:n

  if(d==1 && e==5)

    o=11

        endif   

  for f=0:o

    p=q=19

    for g=0:1

      if(g==1)

    p=5

      endif

      for h=0:p

    if(g==1 && h==5)

      q=11

        endif   

    for i=0:q

      t=u=19

      for j=0:1

        if(j==1)

          t=5

        endif

        for k=0:t

          if(j==1 && k==5)

        u=11

              endif   

          for l=0:u



        s=s+1

        fputs(myfile,num2str(a));

        fputs(myfile,".");

        fputs(myfile,num2str(b)); 

        fputs(myfile,".");

        fputs(myfile,num2str(c));

        fputs(myfile,":");

        fflush(stdout);

        fputs(myfile,num2str(d));

        fputs(myfile,".");

        fputs(myfile,num2str(e)); 

        fputs(myfile,".");

        fputs(myfile,num2str(f));

        fputs(myfile,":");

        fflush(stdout);

        fputs(myfile,num2str(g));

        fputs(myfile,".");

        fputs(myfile,num2str(h)); 

        fputs(myfile,".");

        fputs(myfile,num2str(i));

        fputs(myfile,":");

        fflush(stdout);

        fputs(myfile,num2str(j));

        fputs(myfile,".");

        fputs(myfile,num2str(k)); 

        fputs(myfile,".");

        fputs(myfile,num2str(l));

        fputs(myfile,"\n");

        fflush(stdout);

        end

          end

        end

      end

        end

      end

    end

      end 

end

  end

end 

  end
#包括
int main(int argc,字符**argv){
int a,b,c,d,e,f,g,h,i,j,k,l;
int s,r,m,n,o,p,q,u,t;
文件*myfile;
s=1;
r=m=n=o=p=q=u=t=19;
myfile=fopen(“sequence2-c.txt”,“w”);

对于(a=0;atks for ur reply sir…v实际上是通过在各个机器中给出不同的限制来划分代码来执行的。但是现在v r希望使用mpi在hpc中运行它。但是v甚至无法在mpi中运行简单的prgms。你能帮助我们在mpi中执行吗??
#include <stdio.h>

int main(int argc, char **argv) {
    int a,b,c,d,e,f,g,h,i,j,k,l;
    int s,r,m,n,o,p,q,u,t;
    FILE *myfile;

    s=1;

    r=m=n=o=p=q=u=t=19;

    myfile = fopen ("sequence2-c.txt", "w");
    for (a=0; a<=1; a++) {

        if (a == 1)
            r = 5;

        for (b=0; b<=r; b++) {
            if (a == 1 && b == 5) 
                m = 11;

            for (c=0; c<=m; c++) {
                n = o = 19;

                for (d=0; d<=1; d++) {
                    if (d==1)
                        n = 5;

                    for (e=0; e<=n; e++) {
                        if (d==1 && e == 5)
                            o = 11;


                        for (f=0; f<=o; f++) {
                            p = q = 19;

                            for (g=0; g<=1; g++) {
                                if (g == 1)
                                    p = 5;


                                for (h=0; h<=p; h++) {
                                    if (g == 1 && h==5) 
                                        q = 11;                                           

                                    for (i = 0; i<=q; i++) {
                                        t=u=19;

                                        for (j=0; j<=1; j++) {
                                            if (j==1)
                                                t=5;

                                            for (k=0; k<=t; k++) {
                                                if (j==1 && k==5)
                                                    u=11;                                                    

                                                for (l=0;l<=u;l++){
                                                    s++;                                                        
                                                    fprintf(myfile,"%d.%d.%d:%d.%d.%d:%d.%d.%d:%d.%d.%d\n",a,b,c,d,e,f,g,h,i,j,k,l);

                                                }
                                            }
                                        }
                                    }
                                }
                            }                            
                        }
                    }
                }
            }
        }
    }
    return 0;
}