Skip to content

Commit

Permalink
more control of FS (#243)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Applencourt <[email protected]>
  • Loading branch information
TApplencourt and Thomas Applencourt authored Jun 24, 2024
1 parent d3486f3 commit 6db1c9c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ jobs:
bats_file: ['mpi_sync_daemon', 'mpi_iprof']
include:
- bats_file: 'iprof'
thapi_sync_daemon: 'fs' # Need to force, if not `THAPI_SYNC_DAEMON` will be set to empty list
env:
THAPI_TEST_BIN: clinfo
THAPI_BIN_DIR: ./build/ici/bin
Expand Down
2 changes: 1 addition & 1 deletion xprof/sync_daemon_fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require 'etc'

FOLDER_JOBID = File.join('.thapi_lock', mpi_job_id)
SHARED_LOCAL_FILESYSTEM = File.join('/', 'dev', 'shm', Etc.getlogin, FOLDER_JOBID)
SHARED_GLOBAL_FILESYSTEM = File.join(env_fetch_first('HOME'), FOLDER_JOBID)
SHARED_GLOBAL_FILESYSTEM = File.join(env_fetch_first('THAPI_SHARED_PATH', 'HOME'), FOLDER_JOBID)

# Use a log distribution seem to be a good tradeoff
# between being nice to the FileSystem (not to many call)
Expand Down
30 changes: 23 additions & 7 deletions xprof/xprof.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ require 'date'
module LoggerRefinement
refine(Logger) do
def info_block(message, &block)
info(message + ': entry') if message
info("#{message}: entry") if message
block.call
info(message + ': exit') if message
info("#{message}: exit") if message
end
end
end
Expand Down Expand Up @@ -259,14 +259,28 @@ class Sync_daemon
end

def initialize
daemon_type = env_fetch_first('THAPI_SYNC_DAEMON', default: 'mpi')
lazy_exec("Initialize Sync_daemon #{daemon_type}") do
daemon = if File.exist?("#{__dir__}/sync_daemon_mpi") && daemon_type == 'mpi'
daemon_type = env_fetch_first('THAPI_SYNC_DAEMON')
daemon = case daemon_type
when nil
# Default is MPI
if File.exist?("#{__dir__}/sync_daemon_mpi")
"#{__dir__}/sync_daemon_mpi"
else
LOGGER.warn("No #{__dir__}/sync_daemon_mpi binary. Fall back to #{__dir__}/syc_daemon_f'")
"#{__dir__}/sync_daemon_fs"
end
LOGGER.debug { "spawn(#{daemon} #{Process.pid})" }
when 'mpi'
raise("No #{__dir__}/sync_daemon_mpi binary") unless File.exist?("#{__dir__}/sync_daemon_mpi")

"#{__dir__}/sync_daemon_mpi"
when 'fs'
"#{__dir__}/sync_daemon_fs"
else
raise("Error: THAPI_SYNC_DAEMON value (#{daemon_type}) if not supported. Allowed: [mpi,fs] ")
end

LOGGER.debug { "spawn(#{daemon} #{Process.pid})" }
lazy_exec("Initialize Sync_daemon #{daemon_type}") do
@pid = spawn("#{daemon} #{Process.pid}")
end
end
Expand All @@ -293,8 +307,10 @@ class Sync_daemon
# we always call clean-up the daemon
def self.open
yield f = new
rescue StandardError
raise
ensure
f.finalize
f.finalize if f
end
end

Expand Down

0 comments on commit 6db1c9c

Please sign in to comment.