Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final charm backend #644

Open
wants to merge 19 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ if(NOT FORMAT_ONLY)
#----------------------------------------------------------------------------#
# Add options for runtime selection
#----------------------------------------------------------------------------#

set(FLECSI_RUNTIME_MODELS legion mpi hpx)
set(FLECSI_RUNTIME_MODELS legion mpi hpx charm)

if(NOT FLECSI_RUNTIME_MODEL)
list(GET FLECSI_RUNTIME_MODELS 0 FLECSI_RUNTIME_MODEL)
Expand All @@ -129,9 +128,13 @@ if(NOT FORMAT_ONLY)
elseif(FLECSI_RUNTIME_MODEL STREQUAL "hpx")
set(ENABLE_MPI ON CACHE BOOL "Enable MPI" FORCE)
set(ENABLE_HPX ON CACHE BOOL "Enable HPX" FORCE)
elseif(FLECSI_RUNTIME_MODEL STREQUAL "charm")
set(ENABLE_MPI ON CACHE BOOL "Enable MPI" FORCE)
set(ENABLE_CHARM ON CACHE BOOL "Enable Charm" FORCE)
set(ENABLE_LEGION OFF CACHE BOOL "Enable Legion" FORCE)
endif()

mark_as_advanced(ENABLE_MPI ENABLE_LEGION ENABLE_HPX)
mark_as_advanced(ENABLE_MPI ENABLE_LEGION ENABLE_HPX ENABLE_CHARM)

#----------------------------------------------------------------------------#
# Legion
Expand All @@ -157,6 +160,14 @@ if(NOT FORMAT_ONLY)
include(hpx)
endif()

#----------------------------------------------------------------------------#
# Charm
#----------------------------------------------------------------------------#

if(ENABLE_CHARM)
include(charm)
endif()

#----------------------------------------------------------------------------#
# OpenMP.
#----------------------------------------------------------------------------#
Expand Down Expand Up @@ -259,6 +270,10 @@ if(NOT FORMAT_ONLY)

set(FLECSI_RUNTIME_LIBRARIES ${DL_LIBS} ${MPI_LIBRARIES})

#----------------------------------------------------------------------------#
# HPX interface
#----------------------------------------------------------------------------#

elseif(FLECSI_RUNTIME_MODEL STREQUAL "hpx")

if(NOT HPX_FOUND)
Expand All @@ -269,10 +284,23 @@ if(NOT FORMAT_ONLY)
message (FATAL_ERROR "MPI is required for the hpx runtime model")
endif()

set(FLECSI_RUNTIME_LIBRARIES ${DL_LIBS} ${MPI_LIBRARIES})
set(FLECSI_RUNTIME_LIBRARIES ${DL_LIBS} ${MPI_LIBRARIES})

set(_runtime_path ${PROJECT_SOURCE_DIR}/flecsi/execution/hpx)

#----------------------------------------------------------------------------#
# Charm interface
#----------------------------------------------------------------------------#
elseif(FLECSI_RUNTIME_MODEL STREQUAL "charm")

if(NOT MPI_${MPI_LANGUAGE}_FOUND)
message (FATAL_ERROR "MPI is required for the charm runtime model")
endif()

set(_runtime_path ${PROJECT_SOURCE_DIR}/flecsi/execution/charm)

set(FLECSI_RUNTIME_LIBRARIES ${DL_LIBS} ${MPI_LIBRARIES})

#----------------------------------------------------------------------------#
# Default
#----------------------------------------------------------------------------#
Expand Down
37 changes: 37 additions & 0 deletions cmake/charm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#------------------------------------------------------------------------------#
# @@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
# /@@///// /@@ @@////@@ @@////// /@@
# /@@ /@@ @@@@@ @@ // /@@ /@@
# /@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
# /@@//// /@@/@@@@@@@/@@ ////////@@/@@
# /@@ /@@/@@//// //@@ @@ /@@/@@
# /@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
# // /// ////// ////// //////// //
#
# Copyright (c) 2016 Los Alamos National Laboratory, LLC
# All rights reserved
#------------------------------------------------------------------------------#

option(ENABLE_CHARM "Enable Charm" OFF)

if(ENABLE_CHARM)

add_definitions(-DREALM_USE_CMAKE)

file(GLOB_RECURSE ci-files ${CMAKE_SOURCE_DIR}/flecsi/*.ci)

foreach(in_file ${ci-files})
get_filename_component(ci-output ${in_file} NAME_WE)
get_filename_component(ci-dir ${in_file} DIRECTORY)
string(APPEND ci-output ".decl.h")
set(all-ci-outputs ${all-cioutputs} ${ci-dir}/${ci-output})
add_custom_command(
OUTPUT ${ci-dir}/${ci-output}
COMMAND ${CMAKE_CXX_COMPILER} ${in_file}
WORKING_DIRECTORY ${ci-dir}
DEPENDS ${in_file}
)
endforeach()
message (STATUS "Created command for " ${all-ci-outputs})

endif(ENABLE_CHARM)
20 changes: 19 additions & 1 deletion cmake/unit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ mark_as_advanced(ENABLE_EXPENSIVE_TESTS)

if(ENABLE_UNIT_TESTS)
enable_testing()
add_library(unit-main OBJECT ${CMAKE_SOURCE_DIR}/flecsi/util/unit/main.cc)

if(FLECSI_RUNTIME_MODEL STREQUAL "charm")
# Ensure that decl and def headers are generated before tests are compiled
add_library(unit-main OBJECT
${CMAKE_SOURCE_DIR}/flecsi/util/unit/main.cc ${all-ci-outputs})
else()
add_library(unit-main OBJECT ${CMAKE_SOURCE_DIR}/flecsi/util/unit/main.cc)
endif()
endif()

function(add_unit name)
Expand Down Expand Up @@ -123,6 +130,17 @@ function(add_unit name)
set(unit_policy_exec_preflags ${MPIEXEC_PREFLAGS})
set(unit_policy_exec_postflags ${MPIEXEC_POSTFLAGS})

elseif(FLECSI_RUNTIME_MODEL STREQUAL "charm"
AND MPI_${MPI_LANGUAGE}_FOUND)

set(unit_policy_flags ${MPI_${MPI_LANGUAGE}_COMPILE_FLAGS})
set(unit_policy_includes ${MPI_${MPI_LANGUAGE}_INCLUDE_PATH})
set(unit_policy_libraries ${MPI_${MPI_LANGUAGE}_LIBRARIES})
set(unit_policy_exec ${MPIEXEC})
set(unit_policy_exec_threads ${MPIEXEC_NUMPROC_FLAG})
set(unit_policy_exec_preflags ${MPIEXEC_PREFLAGS})
set(unit_policy_exec_postflags ${MPIEXEC_POSTFLAGS})

else()

message(WARNING "invalid runtime")
Expand Down
2 changes: 2 additions & 0 deletions config/flecsi-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define FLECSI_RUNTIME_MODEL_legion 1
#define FLECSI_RUNTIME_MODEL_mpi 2
#define FLECSI_RUNTIME_MODEL_hpx 3
#define FLECSI_RUNTIME_MODEL_charm 4
#cmakedefine FLECSI_RUNTIME_MODEL FLECSI_RUNTIME_MODEL_@FLECSI_RUNTIME_MODEL@

//----------------------------------------------------------------------------//
Expand All @@ -19,6 +20,7 @@

#cmakedefine FLECSI_ENABLE_MPI
#cmakedefine FLECSI_ENABLE_LEGION
#cmakedefine FLECSI_ENABLE_CHARM

//----------------------------------------------------------------------------//
// Enable Legion thread-local storage interface
Expand Down
11 changes: 11 additions & 0 deletions flecsi/data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ elseif(FLECSI_RUNTIME_MODEL STREQUAL "hpx")
${data_SOURCES}
)

elseif(FLECSI_RUNTIME_MODEL STREQUAL "charm")

set(data_HEADERS
charm/policy.hh
${data_HEADERS}
)

set(data_SOURCES
${data_SOURCES}
)

endif()

#------------------------------------------------------------------------------#
Expand Down
4 changes: 4 additions & 0 deletions flecsi/data/backend.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ constexpr inline std::size_t logical_size = 1ul << 32;

#include <flecsi/data/hpx/policy.hh>

#elif FLECSI_RUNTIME_MODEL == FLECSI_RUNTIME_MODEL_charm

#include "flecsi/data/charm/policy.hh"

#endif // FLECSI_RUNTIME_MODEL
81 changes: 81 additions & 0 deletions flecsi/data/charm/policy.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
@@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
/@@///// /@@ @@////@@ @@////// /@@
/@@ /@@ @@@@@ @@ // /@@ /@@
/@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
/@@//// /@@/@@@@@@@/@@ ////////@@/@@
/@@ /@@/@@//// //@@ @@ /@@/@@
/@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
// /// ////// ////// //////// //

Copyright (c) 2016, Triad National Security, LLC
All rights reserved.
*/
#pragma once

/*! @file */

#if !defined(__FLECSI_PRIVATE__)
#error Do not include this file directly!
#endif

#if !defined(FLECSI_ENABLE_CHARM)
#error FLECSI_ENABLE_CHARM not defined! This file depends on Charm!
#endif

#include "flecsi/run/backend.hh"
#include "flecsi/topo/core.hh" // single_space

namespace flecsi {
namespace data {
namespace charm {

// TODO: These are just placeholder definitions for region and partition
// while the topo interface for Flecsi is still in flux.
struct region {
region(size2 s, const fields & fs) : s_(s) {}
size2 size() const { return s_; }
template<topo::single_space>
region & get_region() {
return *this;
}
template<class D>
void cleanup(field_id_t f, D d) {}

size2 s_;
};

struct partition {
using row = std::size_t;
static row make_row(std::size_t i, std::size_t n) {
return i;
}
static std::size_t row_size(const row& r) {
return 0;
}
partition(const region & reg) {}
partition(const region & reg,
const partition & src,
field_id_t fid,
completeness cpt = incomplete) {}

std::size_t colors() const {
// TODO: This may not be correct
return CkNumPes();
}

template<topo::single_space>
const partition & get_partition() const {
return *this;
}

void
update(const partition& src, field_id_t fid, completeness cpt = incomplete) {
}
};
} // namespace charm

using charm::region, charm::partition; // for backend-agnostic interface

} // namespace data
} // namespace flecsi
11 changes: 11 additions & 0 deletions flecsi/exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ elseif(FLECSI_RUNTIME_MODEL STREQUAL "mpi")

elseif(FLECSI_RUNTIME_MODEL STREQUAL "hpx")

elseif(FLECSI_RUNTIME_MODEL STREQUAL "charm")

set(exec_HEADERS
${exec_HEADERS}
charm/bind_accessors.hh
charm/task_wrapper.hh
charm/policy.hh
charm/future.hh
charm/task_prologue.hh
)

endif()

#------------------------------------------------------------------------------#
Expand Down
4 changes: 4 additions & 0 deletions flecsi/exec/backend.hh
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ auto execute(ARGS &&...);

#include "flecsi/exec/hpx/policy.hh"

#elif FLECSI_RUNTIME_MODEL == FLECSI_RUNTIME_MODEL_charm

#include "flecsi/exec/charm/policy.hh"

#endif // FLECSI_RUNTIME_MODEL
Loading