Loading...
Searching...
No Matches
GPULoopInfo.h
Go to the documentation of this file.
#ifndef GPU_LOOP_INFO_H
#define GPU_LOOP_INFO_H
/** \file
*
* Data structure containing information about the current GPU loop nest
* hierarchy of blocks, threads, etc. Useful when computing GPU features
*/
#include <memory>
#include <vector>
#include "HalidePlugin.h"
#include "ThreadInfo.h"
namespace Halide {
namespace Internal {
namespace Autoscheduler {
struct LoopNest;
struct GPULoopInfo {
explicit GPULoopInfo(const LoopNest *root)
: root{root} {
}
const LoopNest *root = nullptr;
const LoopNest *current_block_loop = nullptr;
const LoopNest *current_thread_loop = nullptr;
std::vector<const LoopNest *> inner_loop_stack;
int64_t num_blocks = 1;
int64_t total_outer_serial_extents = 1;
int64_t total_inner_serial_extents = 1;
void update(const Target &target, const LoopNest *loop);
int64_t total_serial_extents() const;
bool at_or_inside_block() const;
bool at_or_inside_thread() const;
std::vector<int64_t> get_inner_serial_loop_extents(const LoopNest *loop_nest) const;
// assert-fails if create_thread_info() has *already* been called.
const ThreadInfo *create_thread_info();
// Note: if create_thread_info() has not been called yet, this will return nullptr.
// (Note that this is an unusual but legitimate situation, so it should *not*
// assert-fail if the value is null.)
const ThreadInfo *get_thread_info() const {
return thread_info.get();
}
int64_t get_total_inner_serial_extents_outside_realization(const LoopNest *loop_nest) const;
private:
// This is a shared_ptr mainly to allow for an automatic copy ctor to be generated --
// it's shared between different GPULoopInfo instances, but that is never visible to
// the outside world.
std::shared_ptr<const ThreadInfo> thread_info;
};
} // namespace Autoscheduler
} // namespace Internal
} // namespace Halide
#endif // GPU_LOOP_INFO_H
HalidePlugin.h
ThreadInfo.h
Data structure containing information about GPU threads for a particular location in the loop nest an...
Halide::Internal::Autoscheduler
Definition AutoSchedule.h:10
Halide::Internal
Definition AbstractGenerator.h:24
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
int64_t
signed __INT64_TYPE__ int64_t
Definition runtime_internal.h:22
Halide::Internal::Autoscheduler::GPULoopInfo::get_total_inner_serial_extents_outside_realization
int64_t get_total_inner_serial_extents_outside_realization(const LoopNest *loop_nest) const
Halide::Internal::Autoscheduler::GPULoopInfo::num_blocks
int64_t num_blocks
Definition GPULoopInfo.h:31
Halide::Internal::Autoscheduler::GPULoopInfo::total_serial_extents
int64_t total_serial_extents() const
Halide::Internal::Autoscheduler::GPULoopInfo::update
void update(const Target &target, const LoopNest *loop)
Halide::Internal::Autoscheduler::GPULoopInfo::at_or_inside_thread
bool at_or_inside_thread() const
Halide::Internal::Autoscheduler::GPULoopInfo::total_inner_serial_extents
int64_t total_inner_serial_extents
Definition GPULoopInfo.h:33
Halide::Internal::Autoscheduler::GPULoopInfo::root
const LoopNest * root
Definition GPULoopInfo.h:27
Halide::Internal::Autoscheduler::GPULoopInfo::total_outer_serial_extents
int64_t total_outer_serial_extents
Definition GPULoopInfo.h:32
Halide::Internal::Autoscheduler::GPULoopInfo::get_thread_info
const ThreadInfo * get_thread_info() const
Definition GPULoopInfo.h:51
Halide::Internal::Autoscheduler::GPULoopInfo::inner_loop_stack
std::vector< const LoopNest * > inner_loop_stack
Definition GPULoopInfo.h:30
Halide::Internal::Autoscheduler::GPULoopInfo::create_thread_info
const ThreadInfo * create_thread_info()
Halide::Internal::Autoscheduler::GPULoopInfo::GPULoopInfo
GPULoopInfo(const LoopNest *root)
Definition GPULoopInfo.h:23
Halide::Internal::Autoscheduler::GPULoopInfo::current_thread_loop
const LoopNest * current_thread_loop
Definition GPULoopInfo.h:29
Halide::Internal::Autoscheduler::GPULoopInfo::get_inner_serial_loop_extents
std::vector< int64_t > get_inner_serial_loop_extents(const LoopNest *loop_nest) const
Halide::Internal::Autoscheduler::GPULoopInfo::current_block_loop
const LoopNest * current_block_loop
Definition GPULoopInfo.h:28
Halide::Internal::Autoscheduler::GPULoopInfo::at_or_inside_block
bool at_or_inside_block() const
Halide::Internal::Autoscheduler::LoopNest
Definition LoopNest.h:34
Halide::Internal::Autoscheduler::ThreadInfo
Definition ThreadInfo.h:40
Halide::Target
A struct representing a target machine and os to generate code for.
Definition Target.h:19