Skip to content
Merged
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.19)
project(pcms VERSION 0.1.2 LANGUAGES CXX)
project(pcms VERSION 0.2.0 LANGUAGES CXX)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand Down
11 changes: 1 addition & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(PCMS_HEADERS
pcms/profile.h
pcms/print.h
pcms/partition.h
pcms/coupler.h
)

set(PCMS_SOURCES
Expand All @@ -43,12 +44,6 @@ if (PCMS_ENABLE_OMEGA_H)
pcms/uniform_grid.h
pcms/point_search.h)
endif ()
if (PCMS_ENABLE_SERVER)
if (NOT PCMS_ENABLE_OMEGA_H)
message(ERROR "PCMS_ENABLE_OMEGA_H is required for server implementation")
endif ()
list(APPEND PCMS_HEADERS pcms/server.h)
endif ()

find_package(Kokkos REQUIRED)
find_package(perfstubs REQUIRED)
Expand All @@ -67,10 +62,6 @@ endif()
if(PCMS_ENABLE_SERVER)
target_compile_definitions(pcms_core PUBLIC -DPCMS_HAS_SERVER)
endif()
if(PCMS_ENABLE_CLIENT)
list(APPEND PCMS_HEADERS pcms/client.h)
target_compile_definitions(pcms_core PUBLIC -DPCMS_HAS_CLIENT)
endif()

if(PCMS_HAS_ASAN)
target_compile_options(pcms_core PRIVATE -fsanitize=address -fno-omit-frame-pointer)
Expand Down
11 changes: 5 additions & 6 deletions src/pcms.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#ifndef PCMS_H_
#define PCMS_H_

#ifdef PCMS_HAS_SERVER
#include "pcms/server.h"
#endif
#ifdef PCMS_HAS_CLIENT
#include "pcms/client.h"
#endif
#include "pcms/common.h"
#include "pcms/field_communicator.h"
#include "pcms/omega_h_field.h"
#include "pcms/profile.h"
#include "pcms/coupler.h"

#endif
62 changes: 33 additions & 29 deletions src/pcms/capi/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ using FieldAdapterVariant =
[[nodiscard]] PcmsClientHandle pcms_create_client(const char* name,
MPI_Comm comm)
{
auto* client = new pcms::CouplerClient(name, comm);
return {reinterpret_cast<void*>(client)};
auto* coupler = new pcms::Coupler(name, comm, false, {});
auto* app = coupler->AddApplication(name);
PcmsClientHandle handle;
handle.couplerPointer = reinterpret_cast<void*>(coupler);
handle.appPointer = reinterpret_cast<void*>(app);
return handle;
}
void pcms_destroy_client(PcmsClientHandle client)
{
if (client.pointer != nullptr)
delete reinterpret_cast<pcms::CouplerClient*>(client.pointer);
if (client.couplerPointer != nullptr)
delete reinterpret_cast<pcms::Coupler*>(client.couplerPointer);
}
PcmsReverseClassificationHandle pcms_load_reverse_classification(
const char* file, MPI_Comm comm)
Expand All @@ -52,9 +56,9 @@ void pcms_destroy_reverse_classification(PcmsReverseClassificationHandle rc)
}
struct AddFieldVariantOperators
{
AddFieldVariantOperators(const char* name, pcms::CouplerClient* client,
AddFieldVariantOperators(const char* name, pcms::Application* app,
int participates)
: name_(name), client_(client), participates_(participates)
: name_(name), app_(app), participates_(participates)
{
}

Expand All @@ -68,11 +72,11 @@ struct AddFieldVariantOperators
pcms::CoupledField* operator()(
const FieldAdapter& field_adapter) const noexcept
{
return client_->AddField(name_, field_adapter, participates_);
return app_->AddField(name_, field_adapter, participates_);
}

const char* name_;
pcms::CouplerClient* client_;
pcms::Application* app_;
bool participates_;
};

Expand All @@ -83,8 +87,8 @@ PcmsFieldHandle pcms_add_field(PcmsClientHandle client_handle, const char* name,

auto* adapter =
reinterpret_cast<pcms::FieldAdapterVariant*>(adapter_handle.pointer);
auto* client = reinterpret_cast<pcms::CouplerClient*>(client_handle.pointer);
PCMS_ALWAYS_ASSERT(client != nullptr);
auto* app = reinterpret_cast<pcms::Application*>(client_handle.appPointer);
PCMS_ALWAYS_ASSERT(app != nullptr);
PCMS_ALWAYS_ASSERT(adapter != nullptr);
// pcms::CoupledField* field = std::visit(
// redev::overloaded{
Expand All @@ -94,20 +98,20 @@ PcmsFieldHandle pcms_add_field(PcmsClientHandle client_handle, const char* name,
// }},
// *adapter);
pcms::CoupledField* field =
std::visit(AddFieldVariantOperators{name, client, participates}, *adapter);
std::visit(AddFieldVariantOperators{name, app, participates}, *adapter);
return {reinterpret_cast<void*>(field)};
}
void pcms_send_field_name(PcmsClientHandle client_handle, const char* name)
{
auto* client = reinterpret_cast<pcms::CouplerClient*>(client_handle.pointer);
PCMS_ALWAYS_ASSERT(client != nullptr);
client->SendField(name);
auto* app = reinterpret_cast<pcms::Application*>(client_handle.appPointer);
PCMS_ALWAYS_ASSERT(app != nullptr);
app->SendField(name);
}
void pcms_receive_field_name(PcmsClientHandle client_handle, const char* name)
{
auto* client = reinterpret_cast<pcms::CouplerClient*>(client_handle.pointer);
PCMS_ALWAYS_ASSERT(client != nullptr);
client->ReceiveField(name);
auto* app = reinterpret_cast<pcms::Application*>(client_handle.appPointer);
PCMS_ALWAYS_ASSERT(app != nullptr);
app->ReceiveField(name);
}
void pcms_send_field(PcmsFieldHandle field_handle)
{
Expand Down Expand Up @@ -198,25 +202,25 @@ int pcms_reverse_classification_count_verts(PcmsReverseClassificationHandle rc)
}
void pcms_begin_send_phase(PcmsClientHandle h)
{
auto* client = reinterpret_cast<pcms::CouplerClient*>(h.pointer);
PCMS_ALWAYS_ASSERT(client != nullptr);
client->BeginSendPhase();
auto* app = reinterpret_cast<pcms::Application*>(h.appPointer);
PCMS_ALWAYS_ASSERT(app != nullptr);
app->BeginSendPhase();
}
void pcms_end_send_phase(PcmsClientHandle h)
{
auto* client = reinterpret_cast<pcms::CouplerClient*>(h.pointer);
PCMS_ALWAYS_ASSERT(client != nullptr);
client->EndSendPhase();
auto* app = reinterpret_cast<pcms::Application*>(h.appPointer);
PCMS_ALWAYS_ASSERT(app != nullptr);
app->EndSendPhase();
}
void pcms_begin_receive_phase(PcmsClientHandle h)
{
auto* client = reinterpret_cast<pcms::CouplerClient*>(h.pointer);
PCMS_ALWAYS_ASSERT(client != nullptr);
client->BeginReceivePhase();
auto* app = reinterpret_cast<pcms::Application*>(h.appPointer);
PCMS_ALWAYS_ASSERT(app != nullptr);
app->BeginReceivePhase();
}
void pcms_end_receive_phase(PcmsClientHandle h)
{
auto* client = reinterpret_cast<pcms::CouplerClient*>(h.pointer);
PCMS_ALWAYS_ASSERT(client != nullptr);
client->EndReceivePhase();
auto* app = reinterpret_cast<pcms::Application*>(h.appPointer);
PCMS_ALWAYS_ASSERT(app != nullptr);
app->EndReceivePhase();
}
3 changes: 2 additions & 1 deletion src/pcms/capi/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ extern "C" {

struct PcmsClientHandle
{
void* pointer;
void* couplerPointer;
void* appPointer;
};
typedef struct PcmsClientHandle PcmsClientHandle;
struct PcmsOmegaHMeshHandle
Expand Down
193 changes: 0 additions & 193 deletions src/pcms/client.h

This file was deleted.

Loading