Example #1
0
    def generaConf(self):
        ''' Questo metodo genera il file conf.h
            Il file conf.h contiene un sacco di informazioni piu o meno inutili
            sulla computazione da eseguire sotto forma di define

        '''        
        assert os.path.isdir(config.TESTBENCH_DIR)
        with open(config.TESTBENCH_DIR+"conf.h","w") as fout:            
            out = ""
            out += '#ifndef __CONF_H\n#define __CONF_H\n\n#include <mpi.h>\n'
            
            # include for OPENMP
            if config.OPEN_MP:
                out += '#include <omp.h>\n'

            # an include is added for the .h file containing the definition of the function
            out += '#include "'+config.HEADER_FUNZIONE +'"\n'
            
            # basic information is added from a minimal conf file
            with open(config.HEADERS_DIR+"conf.h") as fin:
                out += fin.read()

            partition =  self.partitions[0]

            # user defined data type
            out += ('#define DATATYPE ')+str(config.DATATYPE)+"\n"
            dict = {'int': '"%d\\t"\n','double': '"%lf\\t"\n','float': '"%f\\t"\n'}
            # a format string to output specified data type
            out += "#define FORMAT "+dict[config.DATATYPE]
            dict = {'int': 'MPI_INT\n','double': 'MPI_DOUBLE\n','float': 'MPI_FLOAT\n'}
            # corresponding MPI datatype
            out += "#define MPI_DATATYPE "+dict[config.DATATYPE]

            out += ("#define num_sezioni "+str(len(partition))+"\n")
            out += ("#define num_steps "+str(partition.numberOfSteps)+"\n")
            out += ("#define local_section "+str(section.tagToIndex(partition.getLocalSectionTag()))+"\n")
            out += ("#define ordine "+str(partition.shape.ordine)+"\n")
            out += ("#define dim "+str(self.shape.dim)+"\n")
            out += "#define compile_time_size "+str(partition.size)+"\n"
#            out += ("#define p "+str(self.parallelism)+"\n")
#            out += ("#define M "+str(self.M)+"\n")
#            out += ("#define lato "+str(self.lato)+"\n")
            
#            out += ("#define s "+str(self.partitionSize)+"\n")
#            out += ("#define ppd "+str(self.ppd)+"\n")
            # ottenere l'indice della local section e una cosa tremenda
            
            
            #out += ("#define localsize "+str(self.dimPartizione)+"\n")
            #out += ("#define dim_sezione "+str(self.partitionSize - 2*self.partitions[0].shape.ordine)+"\n")
            
            out += ("\n#endif\n")
            fout.write(out)        
Example #2
0
    def generaConf(self):
        ''' Questo metodo genera il file conf.h
            Il file conf.h contiene un sacco di informazioni piu o meno inutili
            sulla computazione da eseguire sotto forma di define

        '''        
        assert os.path.isdir(config.TESTBENCH_DIR)
        with open(config.TESTBENCH_DIR+"conf.h","w") as fout:
            out = ""
            out += '#ifndef __CONF_H\n#define __CONF_H\n\n#include <mpi.h>\n'
            if config.OPEN_MP:
                out += '#include <omp.h>\n'

            out += '#include "'+config.HEADER_FUNZIONE +'"\n'
            with open(config.HEADERS_DIR+"conf.h") as fin:
                out += fin.read()

            out += ('#define DATATYPE ')+str(config.DATATYPE)+"\n"
            dict = {'int': '"%d\\t"\n','double': '"%lf\\t"\n','float': '"%f\\t"\n'}
            #FIX questo mi sembra un po bruttino
            out += "#define FORMAT "+dict[config.DATATYPE]
            dict = {'int': 'MPI_INT\n','double': 'MPI_DOUBLE\n','float': 'MPI_FLOAT\n'}
            out += "#define MPI_DATATYPE "+dict[config.DATATYPE]
            out += ("#define p "+str(self.parallelism)+"\n")
            out += ("#define M "+str(self.M)+"\n")
            out += ("#define lato "+str(self.lato)+"\n")
            out += ("#define dim "+str(self.shape.dim)+"\n")
            out += ("#define s "+str(self.partitionSize)+"\n")
            out += ("#define ppd "+str(self.ppd)+"\n")
            # ottenere l'indice della local section e una cosa tremenda
            out += ("#define local_section "+str(section.tagToIndex(self.partitions[0].getLocalSectionTag()))+"\n")
            out += ("#define ordine "+str(self.partitions[0].shape.ordine)+"\n")
            out += ("#define localsize "+str(self.dimPartizione)+"\n")
            out += ("#define dim_sezione "+str(self.partitionSize - 2*self.partitions[0].shape.ordine)+"\n")
            out += ("#define num_sezioni "+str(len(self.partitions[0]))+"\n")
            out += ("\n#endif\n")
            fout.write(out)