Files
compute-runtime/runtime/mem_obj/map_operations_handler.h
Dunajski, Bartosz dd44a87d5f Map/unmap enqueue fixes [6/n]: Support multiple map operations
- Dont make cpu/gpu writes on read-only unmap
- Read/Write on limited map range only
- Overlaps checks for non read-only maps
- Fixed cmd type on returned event

Change-Id: I98ca542e8d369d2426a87279f86cadb0bf3db299
2018-02-23 10:45:06 +01:00

47 lines
1.7 KiB
C++

/*
* Copyright (c) 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "runtime/helpers/properties_helper.h"
#include <vector>
#include <mutex>
namespace OCLRT {
class MapOperationsHandler {
public:
virtual ~MapOperationsHandler() = default;
bool add(void *ptr, size_t ptrLength, cl_map_flags &mapFlags, MemObjSizeArray &size, MemObjOffsetArray &offset);
void remove(void *mappedPtr);
bool find(void *mappedPtr, MapInfo &outMapInfo);
size_t size() const;
protected:
bool isOverlapping(MapInfo &inputMapInfo);
std::vector<MapInfo> mappedPointers;
mutable std::mutex mtx;
};
} // namespace OCLRT