Skip to content

Commit

Permalink
tdg WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
littlemine committed Apr 1, 2024
1 parent 0111edd commit 37d17db
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
2 changes: 2 additions & 0 deletions projects/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ target_sources(zeno PRIVATE
utils/Tracing.cu
utils/Noise.cu
utils/Groom.cpp

graph/Task.cpp
)

add_subdirectory(remesh)
Expand Down
73 changes: 73 additions & 0 deletions projects/CUDA/graph/Task.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "zensim/ZpcTuple.hpp"
#include "zensim/zpc_tpls/fmt/format.h"
#include <cctype>
#include <filesystem>
#include <fstream>
#include <random>
#include <sstream>
#include <zeno/core/Graph.h>
#include <zeno/extra/assetDir.h>
#include <zeno/funcs/PrimitiveUtils.h>
#include <zeno/types/DictObject.h>
#include <zeno/types/ListObject.h>
#include <zeno/types/NumericObject.h>
#include <zeno/types/PrimitiveObject.h>
#include <zeno/types/StringObject.h>
#include <zeno/types/UserData.h>
#include <zeno/utils/log.h>
#include <zeno/utils/string.h>
#include <zeno/zeno.h>

namespace zeno {

using GenericWorkAttribute =
std::variant<int, zs::tuple<int, int, int>, std::vector<int>>;

struct WorkNode : IObject {
int localIndex;

std::map<std::string, GenericWorkAttribute> attributes;
std::map<std::string, std::shared_ptr<WorkNode>> deps;
};

struct CommandGenerator : INode {
void apply() override {
auto tag = get_input2<std::string>("name_tag");
if (tag.empty())
throw std::runtime_error("work name must not be empty!");

auto cmdFmtStr = get_input2<std::string>("cmd_fmt_string");
auto cmd = fmt::format(cmdFmtStr, 0);

// fmt::print("parsed: [[{}]]\n", cmd);
auto ret = std::make_shared<WorkNode>();

set_output("job", ret);
}
};

ZENO_DEFNODE(CommandGenerator)
({/* inputs: */
{
{"string", "name_tag", ""},
{"count"}, // int, int list, int range
{"int", "batch_size", "1"},

{"string", "cmd_fmt_string", ""},
{"list", "arguments"},
{"DictObject", "options"},

{"DictObject", "attributes"},
},
/* outputs: */
{
{"JobNode", "job"},
},
/* params: */
{},
/* category: */
{
"task",
}});

} // namespace zeno

0 comments on commit 37d17db

Please sign in to comment.