def load_precompiled_sdfg(self, path: str, *args, **kwargs) -> None: """ Loads an external compiled SDFG object that will be invoked when the function is called. :param path: Path to SDFG build folder (e.g., ".dacecache/program"). Path has to include ``program.sdfg`` and the binary shared object under the ``build`` folder. :param args: Optional compile-time arguments. :param kwargs: Optional compile-time keyword arguments. """ from dace.sdfg import utils as sdutil # Avoid import loop csdfg = sdutil.load_precompiled_sdfg(path) _, cachekey = self._load_sdfg(None, *args, **kwargs) # Update SDFG cache with the SDFG and compiled version self._cache.add(cachekey, csdfg.sdfg, csdfg)
def test_load_precompiled(): prog = program_generator(10, 2.0) sdfg = prog.to_sdfg() func1 = sdfg.compile() func2 = load_precompiled_sdfg(sdfg.build_folder) inp = np.random.rand(10).astype(np.float64) output_one = np.zeros(10, dtype=np.float64) output_two = np.zeros(10, dtype=np.float64) func1(input=inp, output=output_one) func2(input=inp, output=output_two) assert (np.allclose(output_one, output_two)) del func1 del func2
comm.Scatter(A2, lA) comm.Scatter(B2, lB) comm.Scatter(C2, lC) tC = np.copy(lC) mpi_sdfg = None if rank == 0: mpi_sdfg = gemm_distr3.to_sdfg(coarsen=False) mpi_sdfg.coarsen_dataflow() mpi_func = mpi_sdfg.compile() comm.Barrier() if rank > 0: build_folder = dc.Config.get('default_build_folder') mpi_func = load_precompiled_sdfg( os.path.join(build_folder, gemm_distr3.name)) ldict = locals() comm.Barrier() mpi_func(A=lA, B=lB, C=tC, alpha=alpha, beta=beta, NI=NI, NJ=NJ, NK=NK, lNI=lNI, lNJ=lNJ,
comm.Scatter(B2, lB) comm.Bcast(x, root=0) pi = rank // Py pj = rank % Py lx[:] = x[pj * lN:(pj + 1) * lN] mpi_sdfg = None if rank == 0: mpi_sdfg = gesummv_distr2.to_sdfg(simplify=False) mpi_sdfg.simplify() mpi_func = mpi_sdfg.compile() comm.Barrier() if rank > 0: build_folder = dc.Config.get('default_build_folder') mpi_func = load_precompiled_sdfg(os.path.join(build_folder, gesummv_distr2.name)) ldict = locals() comm.Barrier() mpi_func(A=lA, B=lB, x=lx, alpha=alpha, beta=beta, y=ly, lM=lM, lN=lN, lMy=lMy, Px=Px, Py=Py) # print(rank, ly) if rank == 0: y[0:lMy] = ly for i in range(Py): if i == pj: continue comm.Recv(ly, source=i, tag=i)
return (np.empty( (N, N), dtype=np.float64), np.empty((N, N), dtype=np.float64)) A, B = setup_func(rank) mpi_sdfg = None mpi_sdfg = jacobi_2d_dist.to_sdfg(simplify=False) if rank == 0: mpi_sdfg.simplify() mpi_sdfg.apply_transformations_repeated([MapFusion]) mpi_sdfg.simplify() mpi_func = mpi_sdfg.compile() comm.Barrier() if rank > 0: build_folder = dc.Config.get('default_build_folder') mpi_func = load_precompiled_sdfg( os.path.join(build_folder, jacobi_2d_dist.name)) ldict = locals() comm.Barrier() mpi_func(A=A, B=B, TSTEPS=TSTEPS, lNx=lNx, lNy=lNy, rank=rank, size=size, Px=Px, Py=Py, pi=pi,