Exemplo n.º 1
0
def gen_abc_fmm(coeff_filename, dims, level, outfilename):

    coeffs = read_coeffs(coeff_filename)
    #print coeffs
    #print coeffs[0][0]

    #coeffs2= [ transpose( U2 ), transpose( V2 ), transpose( W2 ) ]

    with open(outfilename, 'w') as myfile:

        cur_coeffs = generateCoeffs(coeffs, level)
        #writeCoeffs( cur_coeffs )
        #writeEquation( cur_coeffs, dims, level )

        num_multiplies = len(cur_coeffs[0][0])

        writePartition(myfile, dims, level)

        write_break(myfile)

        create_straprim_caller(myfile, cur_coeffs, dims, num_multiplies, level)
Exemplo n.º 2
0
def gen_abc_fmm(coeff_filename, dims, level, outfilename,
                micro_kernel_filename, kernel_header_filename):

    coeffs = read_coeffs(coeff_filename)
    #print coeffs
    #print coeffs[0][0]

    #coeffs2= [ transpose( U2 ), transpose( V2 ), transpose( W2 ) ]

    with open(outfilename, 'w') as myfile:
        write_line(myfile, 0, '#include "%s"' % kernel_header_filename[10:])
        write_line(myfile, 0, '#include "bl_dgemm.h"')
        write_break(myfile)

        cur_coeffs = generateCoeffs(coeffs, level)
        #writeCoeffs( cur_coeffs )
        #writeEquation( cur_coeffs, dims, level )

        num_multiplies = len(cur_coeffs[0][0])

        create_packm_functions(myfile, cur_coeffs)

        my_micro_file = open(micro_kernel_filename, 'w')
        create_micro_functions(my_micro_file, cur_coeffs,
                               kernel_header_filename[10:])

        my_kernel_header = open(kernel_header_filename, 'w')
        create_kernel_header(my_kernel_header, cur_coeffs)

        create_macro_functions(myfile, cur_coeffs)

        create_straprim_abc_functions(myfile, cur_coeffs, dims, level)

        write_line(
            myfile, 0,
            'void bl_dgemm_strassen_abc( int m, int n, int k, double *XA, int lda, double *XB, int ldb, double *XC, int ldc )'
        )
        write_line(myfile, 0, '{')

        write_abc_strassen_header(myfile)

        writePartition(myfile, dims, level)

        write_break(myfile)

        write_line(myfile, 0, '#ifdef _PARALLEL_')
        write_line(myfile, 1, '#pragma omp parallel num_threads( bl_ic_nt )')
        write_line(myfile, 0, '#endif')
        write_line(myfile, 1, '{')
        create_straprim_caller(myfile, cur_coeffs, dims, num_multiplies, level)
        write_line(myfile, 1, '}')

        write_break(myfile)
        level_dim = exp_dim(dims, level)
        write_line(
            myfile, 1,
            'bl_dynamic_peeling( m, n, k, XA, lda, XB, ldb, XC, ldc, %d * DGEMM_MR, %d, %d * DGEMM_NR );'
            % (level_dim[0], level_dim[1], level_dim[2]))

        write_break(myfile)
        write_line(myfile, 1, '//free( packA );')
        write_line(myfile, 1, '//free( packB );')

        write_line(myfile, 0, '}')