Skip to content

Commit

Permalink
fix(analytical): Fix MessageStrategy customization for java apps (#…
Browse files Browse the repository at this point in the history
…3762)

The previous implementation didn't set the correct message strategy.
  • Loading branch information
zhanglei1949 authored May 6, 2024
1 parent 784525a commit 8d4b51d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 54 deletions.
46 changes: 15 additions & 31 deletions analytical_engine/apps/java_pie/java_pie_projected_parallel_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@ namespace gs {
*
* @tparam FRAG_T Should be gs::ArrowProjectedFragment<...>
*/
template <typename FRAG_T>
template <typename FRAG_T,
grape::MessageStrategy Strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex>
class JavaPIEProjectedParallelApp
: public grape::ParallelAppBase<FRAG_T,
JavaPIEProjectedParallelContext<FRAG_T>>,
public grape::Communicator {
public:
// specialize the templated worker.
INSTALL_JAVA_PARALLEL_WORKER(JavaPIEProjectedParallelApp<FRAG_T>,
using app_type = JavaPIEProjectedParallelApp<FRAG_T, Strategy>;
INSTALL_JAVA_PARALLEL_WORKER(app_type,
JavaPIEProjectedParallelContext<FRAG_T>, FRAG_T);
static constexpr grape::LoadStrategy load_strategy =
grape::LoadStrategy::kBothOutIn;
static constexpr bool need_split_edges = true;
static constexpr grape::MessageStrategy message_strategy = Strategy;

public:
void PEval(const fragment_t& frag, context_t& ctx,
message_manager_t& messages) {
JNIEnvMark m;
Expand Down Expand Up @@ -120,36 +119,21 @@ class JavaPIEProjectedParallelApp
};

template <typename FRAG_T>
class JavaPIEProjectedParallelAppOE
: public JavaPIEProjectedParallelApp<FRAG_T> {
public:
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex;
};
using JavaPIEProjectedParallelAppOE = JavaPIEProjectedParallelApp<
FRAG_T, grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex>;

template <typename FRAG_T>
class JavaPIEProjectedParallelAppIE
: public JavaPIEProjectedParallelApp<FRAG_T> {
public:
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongIncomingEdgeToOuterVertex;
};
using JavaPIEProjectedParallelAppIE = JavaPIEProjectedParallelApp<
FRAG_T, grape::MessageStrategy::kAlongIncomingEdgeToOuterVertex>;

template <typename FRAG_T>
class JavaPIEProjectedParallelAppE
: public JavaPIEProjectedParallelApp<FRAG_T> {
public:
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongEdgeToOuterVertex;
};
using JavaPIEProjectedParallelAppE = JavaPIEProjectedParallelApp<
FRAG_T, grape::MessageStrategy::kAlongEdgeToOuterVertex>;

template <typename FRAG_T>
class JavaPIEProjectedParallelAppSync
: public JavaPIEProjectedParallelApp<FRAG_T> {
public:
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kSyncOnOuterVertex;
};
using JavaPIEProjectedParallelAppSync =
JavaPIEProjectedParallelApp<FRAG_T,
grape::MessageStrategy::kSyncOnOuterVertex>;

} // namespace gs
#endif
Expand Down
38 changes: 15 additions & 23 deletions analytical_engine/apps/java_pie/java_pie_property_parallel_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ namespace gs {
*
* @tparam FRAG_T Should be vineyard::ArrowFragment<...>
*/
template <typename FRAG_T>
template <typename FRAG_T,
grape::MessageStrategy Strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex>
class JavaPIEPropertyParallelApp
: public ParallelPropertyAppBase<FRAG_T,
JavaPIEPropertyParallelContext<FRAG_T>>,
public grape::Communicator {
public:
using app_type = JavaPIEPropertyParallelApp<FRAG_T, Strategy>;
// specialize the templated worker.
INSTALL_JAVA_PARALLEL_PROPERTY_WORKER(JavaPIEPropertyParallelApp<FRAG_T>,
INSTALL_JAVA_PARALLEL_PROPERTY_WORKER(app_type,
JavaPIEPropertyParallelContext<FRAG_T>,
FRAG_T);
static constexpr grape::LoadStrategy load_strategy =
Expand Down Expand Up @@ -122,33 +125,22 @@ class JavaPIEPropertyParallelApp
};

template <typename FRAG_T>
class JavaPIEPropertyParallelAppOE : public JavaPIEPropertyParallelApp<FRAG_T> {
public:
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex;
};
using JavaPIEPropertyParallelAppOE = JavaPIEPropertyParallelApp<
FRAG_T, grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex>;

template <typename FRAG_T>
class JavaPIEPropertyParallelAppIE : public JavaPIEPropertyParallelApp<FRAG_T> {
public:
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongIncomingEdgeToOuterVertex;
};
using JavaPIEPropertyParallelAppIE = JavaPIEPropertyParallelApp<
FRAG_T, grape::MessageStrategy::kAlongIncomingEdgeToOuterVertex>;

template <typename FRAG_T>
class JavaPIEPropertyParallelAppE : public JavaPIEPropertyParallelApp<FRAG_T> {
public:
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongEdgeToOuterVertex;
};
using JavaPIEPropertyParallelAppE =
JavaPIEPropertyParallelApp<FRAG_T,
grape::MessageStrategy::kAlongEdgeToOuterVertex>;

template <typename FRAG_T>
class JavaPIEPropertyParallelAppSync
: public JavaPIEPropertyParallelApp<FRAG_T> {
public:
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kSyncOnOuterVertex;
};
using JavaPIEPropertyParallelAppSync =
JavaPIEPropertyParallelApp<FRAG_T,
grape::MessageStrategy::kSyncOnOuterVertex>;

} // namespace gs
#endif
Expand Down

0 comments on commit 8d4b51d

Please sign in to comment.