1 2from os.path import exists 3 4print('Performing tune prebuild ...') 5 6basic = [ 7 'dc_bdiv_qr.c', 'dc_bdiv_qr_n.c', 'dc_bdiv_q.c', 'dc_divappr_q.c', 8 'dc_div_qr.c', 'dc_div_qr_n.c', 'divrem_2.c', 'divrem_euclidean_r_1.c', 9 'divrem_hensel_qr_1.c', 'gcd.c', 'gcdext.c', 'get_str.c', 'hgcd.c', 10 'hgcd_appr.c', 'hgcd_reduce.c', 'inv_divappr_q.c', 'inv_div_qr.c', 11 'matrix22_mul.c', 'mul.c', 'mulhigh_n.c', 'mullow_n.c', 'mulmod_2expm1.c', 12 'mulmod_2expp1_basecase.c', 'mul_n.c', 'rootrem.c', 'rsh_divrem_hensel_qr_1.c', 13 'sb_divappr_q.c', 'sb_div_qr.c', 'set_str.c', 'tdiv_q.c', 'tdiv_qr.c', 14 'toom3_mul.c', 'toom3_mul_n.c', 'toom4_mul.c', 'toom4_mul_n.c', 15 'toom8h_mul.c', 'toom8_sqr_n.c' 16] 17 18fft_basic = [ 19 'adjust.c', 'adjust_sqrt2.c', 'butterfly_lshB.c', 'butterfly_rshB.c', 20 'combine_bits.c', 'div_2expmod_2expp1.c', 'fermat_to_mpz.c', 21 'fft_mfa_trunc_sqrt2.c', 'fft_mfa_trunc_sqrt2_inner.c', 'fft_negacyclic.c', 22 'fft_radix2.c', 'fft_trunc.c', 'ifft_negacyclic.c', 'ifft_radix2.c', 23 'ifft_trunc.c', 'ifft_trunc_sqrt2.c', 'mul_2expmod_2expp1.c', 24 'mul_fft_main.c', 'mul_mfa_trunc_sqrt2.c', 'mulmod_2expp1.c', 25 'mul_trunc_sqrt2.c', 'normmod_2expp1.c', 'revbin.c', 'split_bits.c' 26] 27 28for n in basic: 29 if not exists(n) : 30 with open(n, "wb") as f : 31 lines = [('#define TUNE_PROGRAM_BUILD 1\r\n').encode()] 32 lines += [('#include "..\\..\\..\\mpn\\generic\\' + n + '"\r\n').encode()] 33 f.writelines(lines) 34 35for n in fft_basic: 36 if not exists(n) : 37 with open(n, "wb") as f : 38 lines = [('#define TUNE_PROGRAM_BUILD 1\r\n').encode()] 39 lines += [('#include "..\\..\\..\\fft\\' + n + '"\r\n').encode()] 40 f.writelines(lines) 41 42n = 'divrem_1.c' 43if not exists(n) : 44 with open(n, "wb") as f : 45 lines = [('#define TUNE_PROGRAM_BUILD 1\r\n').encode()] 46 lines += [('#define __gmpn_divrem_1 mpn_divrem_1_tune\r\n').encode()] 47 lines += [('#include "..\\..\\..\\mpn\\generic\\' + n + '"\r\n').encode()] 48 f.writelines(lines) 49 50n = 'mod_1.c' 51if not exists(n) : 52 with open(n, "wb") as f : 53 lines = [('#define TUNE_PROGRAM_BUILD 1\r\n').encode()] 54 lines += [('#define __gmpn_mod_1 mpn_mod_1_tune\r\n').encode()] 55 lines += [('#include "..\\..\\..\\mpn\\generic\\' + n + '"\r\n').encode()] 56 f.writelines(lines) 57 58 59n = 'sqr_basecase.asm' 60if not exists(n) : 61 with open(n, "wb") as f : 62 lines = [('%define SQR_KARATSUBA_THRESHOLD_OVERRIDE SQR_KARATSUBA_THRESHOLD_MAX\r\n').encode()] 63 lines += [('%include "..\\..\\..\\mpn\\x86_64w\\' + n + '"\r\n').encode()] 64 f.writelines(lines) 65 66n = 'fac_ui.c' 67if not exists(n) : 68 with open(n, "wb") as f : 69 lines = [('#define TUNE_PROGRAM_BUILD 1\r\n').encode()] 70 lines += [('#define __gmpz_fac_ui mpz_fac_ui_tune\r\n').encode()] 71 lines += [('#define __gmpz_oddfac_1 mpz_oddfac_1_tune\r\n').encode()] 72 lines += [('#include "..\\..\\..\\mpz\\' + 'oddfac_1.c' + '"\r\n').encode()] 73 lines += [('#include "..\\..\\..\\mpz\\' + 'fac_ui.c' + '"\r\n').encode()] 74 f.writelines(lines) 75