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

[refactor] Move Context to taichi/program #1788

Merged
merged 3 commits into from
Aug 28, 2020
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
11 changes: 7 additions & 4 deletions taichi/backends/cuda/jit_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"

#include "taichi/backends/cuda/cuda_driver.h"
#include "taichi/backends/cuda/cuda_context.h"
#include "taichi/backends/cuda/cuda_driver.h"
#include "taichi/jit/jit_session.h"
#include "taichi/lang_util.h"
#include "taichi/program/program.h"
#include "taichi/runtime/llvm/context.h"
#include "taichi/system/timer.h"
#include "taichi/lang_util.h"
#include "taichi/jit/jit_session.h"
#include "taichi/util/file_sequence_writer.h"

#define TI_RUNTIME_HOST
#include "taichi/program/context.h"
#undef TI_RUNTIME_HOST

TLANG_NAMESPACE_BEGIN

#if defined(TI_WITH_CUDA)
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/metal/kernel_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "taichi/program/kernel.h"
#define TI_RUNTIME_HOST
#include "taichi/runtime/llvm/context.h"
#include "taichi/program/context.h"
#undef TI_RUNTIME_HOST

TLANG_NAMESPACE_BEGIN
Expand Down
2 changes: 1 addition & 1 deletion taichi/program/async_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "taichi/ir/ir.h"
#include "taichi/ir/statements.h"
#include "taichi/lang_util.h"
#include "taichi/runtime/llvm/context.h"
#include "taichi/program/context.h"

TLANG_NAMESPACE_BEGIN

Expand Down
22 changes: 4 additions & 18 deletions taichi/runtime/llvm/context.h → taichi/program/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "taichi/inc/constants.h"

#if defined(TI_RUNTIME_HOST)
yuanming-hu marked this conversation as resolved.
Show resolved Hide resolved
namespace taichi::lang {
using namespace taichi;
namespace taichi {
namespace lang {
#endif

struct LLVMRuntime;
Expand Down Expand Up @@ -36,21 +36,7 @@ struct Context {
#endif
};

struct MemRequest {
std::size_t size;
std::size_t alignment;
uint8 *ptr;
std::size_t __padding;
};

static_assert((sizeof(MemRequest) & (sizeof(MemRequest) - 1)) == 0);

struct MemRequestQueue {
MemRequest requests[taichi_max_num_mem_requests];
int tail;
int processed;
};

#if defined(TI_RUNTIME_HOST)
}
} // namespace lang
} // namespace taichi
#endif
2 changes: 1 addition & 1 deletion taichi/program/program.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "taichi/backends/cc/cc_program.h"
#include "taichi/program/kernel.h"
#include "taichi/program/kernel_profiler.h"
#include "taichi/runtime/llvm/context.h"
#include "taichi/program/context.h"
#include "taichi/runtime/runtime.h"
#include "taichi/backends/metal/struct_metal.h"
#include "taichi/system/memory_pool.h"
Expand Down
29 changes: 29 additions & 0 deletions taichi/runtime/llvm/mem_request.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

// Use relative path here for runtime compilation
#include "taichi/inc/constants.h"

#if defined(TI_RUNTIME_HOST)
namespace taichi {
namespace lang {
#endif

struct MemRequest {
std::size_t size;
std::size_t alignment;
uint8 *ptr;
std::size_t __padding;
};

static_assert((sizeof(MemRequest) & (sizeof(MemRequest) - 1)) == 0);

struct MemRequestQueue {
MemRequest requests[taichi_max_num_mem_requests];
int tail;
int processed;
};

#if defined(TI_RUNTIME_HOST)
} // namespace lang
} // namespace taichi
#endif
5 changes: 3 additions & 2 deletions taichi/runtime/llvm/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ struct PhysicalCoordinates {

STRUCT_FIELD_ARRAY(PhysicalCoordinates, val);

#include "context.h"
#include "taichi/program/context.h"
#include "taichi/runtime/llvm/mem_request.h"

STRUCT_FIELD_ARRAY(Context, args);
STRUCT_FIELD(Context, runtime);
Expand All @@ -324,7 +325,7 @@ int32 Context_get_extra_args(Context *ctx, int32 i, int32 j) {
return ctx->extra_args[i][j];
}

#include "atomic.h"
#include "taichi/runtime/llvm/atomic.h"

// These structures are accessible by both the LLVM backend and this C++ runtime
// file here (for building complex runtime functions in C++)
Expand Down
2 changes: 1 addition & 1 deletion taichi/system/memory_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "taichi/common/core.h"
#include "taichi/system/unified_allocator.h"
#define TI_RUNTIME_HOST
#include "taichi/runtime/llvm/context.h"
#include "taichi/runtime/llvm/mem_request.h"
k-ye marked this conversation as resolved.
Show resolved Hide resolved

#include <mutex>
#include <vector>
Expand Down