MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / generateBufferOffsets

Function generateBufferOffsets

src/backend/oneapi/jit/kernel_generators.hpp:53–70  ·  view source on GitHub ↗

Generates the code to calculate the offsets for a buffer

Source from the content-addressed store, hash-verified

51
52/// Generates the code to calculate the offsets for a buffer
53inline void generateBufferOffsets(std::stringstream& kerStream, int id,
54 bool is_linear, const std::string& type_str) {
55 UNUSED(type_str);
56 std::string idx_str = std::string("int idx") + std::to_string(id);
57 std::string info_str = std::string("iInfo") + std::to_string(id);
58
59 if (is_linear) {
60 kerStream << idx_str << " = idx + " << info_str << "_offset;\n";
61 } else {
62 kerStream << idx_str << " = (id3 < " << info_str << ".dims[3]) * "
63 << info_str << ".strides[3] * id3 + (id2 < " << info_str
64 << ".dims[2]) * " << info_str << ".strides[2] * id2 + (id1 < "
65 << info_str << ".dims[1]) * " << info_str
66 << ".strides[1] * id1 + (id0 < " << info_str << ".dims[0]) * "
67 << info_str << ".strides[0] * id0 + " << info_str
68 << ".offset;\n";
69 }
70}
71
72/// Generates the code to read a buffer and store it in a local variable
73inline void generateBufferRead(std::stringstream& kerStream, int id,

Callers

nothing calls this directly

Calls 1

to_stringFunction · 0.85

Tested by

no test coverage detected