Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
CGen MPI init finalize generated folder
Browse files Browse the repository at this point in the history
support for distributed mode
  • Loading branch information
Ehsan Totoni committed Dec 11, 2015
1 parent cc6ba6f commit 2dc5d04
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/cgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ import ..ParallelIR
import CompilerTools
export setvectorizationlevel, generate, from_root, writec, compile, link, set_include_blas
import ParallelAccelerator, ..getPackageRoot
import ParallelAccelerator.isDistributedMode


if isDistributedMode()
using MPI
MPI.Init()
end

# uncomment this line for using Debug.jl
#using Debug
Expand Down Expand Up @@ -237,7 +244,12 @@ tokenXlate = Dict(
replacedTokens = Set("#")
scrubbedTokens = Set(",.({}):")

if CompilerTools.DebugMsg.PROSPECT_DEV_MODE
if isDistributedMode()
package_root = getPackageRoot()
rank = MPI.Comm_rank(MPI.COMM_WORLD)
generated_file_dir = "$package_root/deps/generated$rank"
mkdir(generated_file_dir)
elseif CompilerTools.DebugMsg.PROSPECT_DEV_MODE
package_root = getPackageRoot()
generated_file_dir = "$package_root/deps/generated"
else
Expand All @@ -254,13 +266,16 @@ function generate_new_file_name()
return "cgen_output$file_counter"
end

function cleanup_generated_files()
function CGen_finalize()
if !CompilerTools.DebugMsg.PROSPECT_DEV_MODE
rm(generated_file_dir; recursive=true)
end
if isDistributedMode()
MPI.Finalize()
end
end

atexit(cleanup_generated_files)
atexit(CGen_finalize)

function __init__()
packageroot = joinpath(dirname(@__FILE__), "..")
Expand Down

0 comments on commit 2dc5d04

Please sign in to comment.