File: mock_cif.cpp

package info (click to toggle)
intel-compute-runtime 25.44.36015.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 79,632 kB
  • sloc: cpp: 931,547; lisp: 2,074; sh: 719; makefile: 162; python: 21
file content (131 lines) | stat: -rw-r--r-- 2,720 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * Copyright (C) 2018-2021 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/test/common/mocks/mock_cif.h"

#include "cif/builtins/memory/buffer/buffer.h"
#include "cif/export/library_api.h"

namespace NEO {

bool failCreateCifMain = false;
}

namespace CIF {

namespace Builtins {

template <typename... ArgsT>
Buffer<0>::Buffer(ArgsT &&...args) {
}

Buffer<0>::~Buffer() {
}

void BufferSimple::SetAllocator(CIF::Builtins::AllocatorT allocator, CIF::Builtins::DeallocatorT deallocator,
                                CIF::Builtins::ReallocatorT reallocator) {
}

void BufferSimple::SetUnderlyingStorage(void *memory, size_t size, CIF::Builtins::DeallocatorT deallocator) {
}

void BufferSimple::SetUnderlyingStorage(const void *memory, size_t size) {
}

void *BufferSimple::DetachAllocation() {
    return nullptr;
}

const void *BufferSimple::GetMemoryRaw() const {
    return nullptr;
}

void *BufferSimple::GetMemoryRawWriteable() {
    return nullptr;
}

size_t BufferSimple::GetSizeRaw() const {
    return 0;
}

size_t BufferSimple::GetCapacityRaw() const {
    return 0;
}

bool BufferSimple::Resize(size_t newSize) {
    return false;
}

bool BufferSimple::Reserve(size_t newCapacity) {
    return false;
}

void BufferSimple::Clear() {
}

void BufferSimple::Deallocate() {
}

bool BufferSimple::AlignUp(uint32_t alignment) {
    return false;
}

bool BufferSimple::PushBackRawBytes(const void *newData, size_t size) {
    return false;
}

bool BufferSimple::IsConst() const {
    return false;
}
} // namespace Builtins
} // namespace CIF

namespace NEO {

std::map<CIF::InterfaceId_t, CreatorFuncT> MockCIFMain::globalCreators;

bool MockCIFBuffer::failAllocations = false;

CIF::ICIF *MockCIFBuffer::Create(CIF::InterfaceId_t intId, CIF::Version_t version) {
    if (failAllocations) {
        return nullptr;
    }

    if (version != CIF::Builtins::BufferSimple::GetVersion()) {
        return nullptr;
    }

    return new MockCIFBuffer();
}

MockCIFBuffer::MockCIFBuffer() {
}

MockCIFMain::MockCIFMain() {
    defaultCreators[CIF::Builtins::BufferSimple::GetInterfaceId()] = MockCIFBuffer::Create;
}

CIF::ICIF *MockCIFMain::CreateInterfaceImpl(CIF::InterfaceId_t intId, CIF::Version_t version) {
    auto it = globalCreators.find(intId);
    if ((it == globalCreators.end()) || (it->second == nullptr)) {
        it = defaultCreators.find(intId);
        if ((it == defaultCreators.end()) || (it->second == nullptr)) {
            return nullptr;
        }
    }

    return it->second(intId, version);
}
} // namespace NEO

extern CIF::CIFMain *CreateCIFMainImpl() {
    if (NEO::failCreateCifMain) {
        return nullptr;
    }

    return new NEO::MockCIFMain;
}