예제 #1
0
파일: codegen.py 프로젝트: faasm/faasm
def _do_codegen_file(path):
    binary = find_codegen_shared_lib()

    env = copy(environ)
    env.update(
        {
            "LD_LIBRARY_PATH": "/usr/local/lib/",
        }
    )
    run("{} {}".format(binary, path), env=env, shell=True, check=True)
예제 #2
0
파일: libs.py 프로젝트: seemhuei/faasm
def fake(ctx, clean=False):
    """
    Compile and install the fake library used for testing
    """
    work_dir = join(PROJ_ROOT, "func", "dynlink")
    build_dir = join(PROJ_ROOT, "build", "libfake")

    clean_dir(build_dir, clean)

    build_cmd = [
        "cmake",
        "-GNinja",
        "-DFAASM_BUILD_SHARED=ON",
        "-DFAASM_BUILD_TYPE=wasm",
        "-DCMAKE_TOOLCHAIN_FILE={}".format(CMAKE_TOOLCHAIN_FILE),
        "-DCMAKE_BUILD_TYPE=Release",
        "-DCMAKE_INSTALL_PREFIX={}".format(WASM_SYSROOT),
        work_dir,
    ]

    run(" ".join(build_cmd), shell=True, cwd=build_dir, check=True)
    run("ninja", shell=True, cwd=build_dir, check=True)
    run("ninja install", shell=True, cwd=build_dir, check=True)

    # Copy shared object into place
    sysroot_files = join(WASM_SYSROOT, "lib", "wasm32-wasi", "libfake*.so")

    runtime_lib_dir = join(FAASM_RUNTIME_ROOT, "lib")
    if not exists(runtime_lib_dir):
        makedirs(runtime_lib_dir)

    run(
        "cp {} {}".format(sysroot_files, runtime_lib_dir),
        shell=True,
        check=True,
    )

    # Update env
    shell_env = copy(environ)
    shell_env.update({
        "LD_LIBRARY_PATH": "/usr/local/lib/",
    })

    # Run codegen
    shared_objs = [
        join(FAASM_RUNTIME_ROOT, "lib", "libfakeLibA.so"),
        join(FAASM_RUNTIME_ROOT, "lib", "libfakeLibB.so"),
    ]

    binary = find_codegen_shared_lib()

    for so in shared_objs:
        print("Running codegen for {}".format(so))
        run("{} {}".format(binary, so), env=shell_env, shell=True, check=True)
예제 #3
0
def set_up_package(ctx, pkg_name):
    """
    Set up a given Python package
    """
    _do_set_up_python_packages([pkg_name])

    # Run codegen for just this package
    binary = cg.find_codegen_shared_lib()
    pkg_install_dir = join(PY_RUNTIME_ROOT, "site-packages", pkg_name)

    if not exists(pkg_install_dir):
        print(
            "Expected to find package installed at {}".format(pkg_install_dir))
        return 1

    check_output("{} {}".format(binary, pkg_install_dir), shell=True)
예제 #4
0
def codegen(ctx):
    """
    Run Python codegen
    """
    # Update env
    shell_env = copy(environ)
    shell_env.update({
        "LD_LIBRARY_PATH": "/usr/local/lib/",
    })

    binary = cg.find_codegen_shared_lib()
    run(
        "{} {}".format(binary, PY_RUNTIME_ROOT),
        env=shell_env,
        shell=True,
        check=True,
    )
예제 #5
0
파일: libs.py 프로젝트: paulmchen/faasm
def fake(ctx, clean=False):
    """
    Compile and install the fake library used for testing
    """
    work_dir = join(PROJ_ROOT, "func", "dynlink")
    build_dir = join(PROJ_ROOT, "build", "libfake")

    clean_dir(build_dir, clean)

    build_cmd = [
        "cmake",
        "-GNinja",
        "-DFAASM_BUILD_TYPE=wasm",
        "-DCMAKE_TOOLCHAIN_FILE={}".format(FAASM_TOOLCHAIN_FILE),
        "-DCMAKE_BUILD_TYPE=Release",
        "-DCMAKE_INSTALL_PREFIX={}".format(SYSROOT_INSTALL_PREFIX),
        work_dir,
    ]

    call(" ".join(build_cmd), shell=True, cwd=build_dir)
    call("ninja VERBOSE=1 ", shell=True, cwd=build_dir)
    call("ninja install", shell=True, cwd=build_dir)

    # Copy shared object into place
    sysroot_files = join(SYSROOT_INSTALL_PREFIX, "lib", "wasm32-wasi",
                         "libfake*.so")

    runtime_lib_dir = join(FAASM_RUNTIME_ROOT, "lib")
    if not exists(runtime_lib_dir):
        makedirs(runtime_lib_dir)

    call("cp {} {}".format(sysroot_files, runtime_lib_dir), shell=True)

    # Run codegen
    shared_objs = [
        join(FAASM_RUNTIME_ROOT, "lib", "libfakeLibA.so"),
        join(FAASM_RUNTIME_ROOT, "lib", "libfakeLibB.so"),
    ]

    binary = find_codegen_shared_lib()

    for so in shared_objs:
        print("Running codegen for {}".format(so))
        check_output("{} {}".format(binary, so), shell=True)
예제 #6
0
파일: codegen.py 프로젝트: yifei-xue/faasm
def local(ctx):
    """
    Runs codegen on functions used in tests
    """
    _do_codegen_user("demo")
    _do_codegen_user("errors")
    _do_codegen_user("omp")
    _do_codegen_user("mpi")
    _do_codegen_user("rust")

    # Run these in parallel
    p = Pool(3)
    users = ["python", "sgd", "tf"]
    p.map(_do_codegen_user, users)

    print("Running codegen on python shared objects")
    binary = find_codegen_shared_lib()
    shared_obj_dir = join(FAASM_RUNTIME_ROOT, "lib", "python3.7")
    check_output("{} {}".format(binary, shared_obj_dir), shell=True)
예제 #7
0
파일: codegen.py 프로젝트: rabbah/faasm
def local(ctx, wamr=False):
    """
    Runs codegen on functions used in tests
    """
    _do_codegen_user("demo", wamr=wamr)
    _do_codegen_user("errors", wamr=wamr)
    _do_codegen_user("omp", wamr=wamr)
    _do_codegen_user("mpi", wamr=wamr)
    _do_codegen_user("rust", wamr=wamr)

    # Always run the codegen required by the tests
    codegen(ctx, "demo", "echo", wamr=True)

    # Run these in parallel
    p = Pool(2)
    users = [
        ("python", wamr),
        ("sgd", wamr),
    ]
    p.starmap(_do_codegen_user, users)

    print("Running codegen on python shared objects")
    binary = find_codegen_shared_lib()
    check_output("{} {}".format(binary, PY_RUNTIME_ROOT), shell=True)
예제 #8
0
def codegen(ctx):
    """
    Run Python codegen
    """
    binary = cg.find_codegen_shared_lib()
    check_output("{} {}".format(binary, PY_RUNTIME_ROOT), shell=True)