Commit 1eb8f523 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

refactor: whitespaces for references

parent 1f6a181a
......@@ -45,25 +45,25 @@ public:
std::string getName() const;
GpuAllocator& getAllocator() const
GpuAllocator &getAllocator() const
{ return *allocator; }
bool makeAccessibleToPCIeAndVA(const MemoryBlock& mem);
bool makeAccessibleToPCIeAndVA(const MemoryBlock &mem);
/// Make some memory block accssible for this GPU
bool makeAccessibleFromPCIeOrHostRam(const MemoryBlock& mem);
bool makeAccessibleFromPCIeOrHostRam(const MemoryBlock &mem);
void memcpySync(const MemoryBlock& src, const MemoryBlock& dst, size_t size);
void memcpySync(const MemoryBlock &src, const MemoryBlock &dst, size_t size);
void memcpyKernel(const MemoryBlock& src, const MemoryBlock& dst, size_t size);
void memcpyKernel(const MemoryBlock &src, const MemoryBlock &dst, size_t size);
MemoryTranslation
translate(const MemoryBlock& dst);
translate(const MemoryBlock &dst);
private:
bool registerIoMemory(const MemoryBlock& mem);
bool registerHostMemory(const MemoryBlock& mem);
bool registerIoMemory(const MemoryBlock &mem);
bool registerHostMemory(const MemoryBlock &mem);
private:
class impl;
......@@ -86,7 +86,7 @@ class GpuAllocator : public BaseAllocator<GpuAllocator> {
public:
static constexpr size_t GpuPageSize = 64UL << 10;
GpuAllocator(Gpu& gpu);
GpuAllocator(Gpu &gpu);
std::string getName() const;
......@@ -94,7 +94,7 @@ public:
allocateBlock(size_t size);
private:
Gpu& gpu;
Gpu &gpu;
// TODO: replace by multimap (key is available memory)
std::list<std::unique_ptr<LinearAllocator>> chunks;
};
......
......@@ -30,7 +30,7 @@
#include <villas/gpu.hpp>
#include <villas/log.hpp>
#include <villas/kernel/pci.h>
#include <villas/kernel/pci.hpp>
#include <villas/memory_manager.hpp>
#include <cuda.h>
......@@ -44,7 +44,7 @@ namespace gpu {
static GpuFactory gpuFactory;
GpuAllocator::GpuAllocator(Gpu& gpu) :
GpuAllocator::GpuAllocator(Gpu &gpu) :
BaseAllocator(gpu.masterPciEAddrSpaceId),
gpu(gpu)
{
......@@ -77,7 +77,7 @@ GpuFactory::GpuFactory() :
// required to be defined here for PIMPL to compile
Gpu::~Gpu()
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
mm.removeAddressSpace(masterPciEAddrSpaceId);
}
......@@ -104,9 +104,9 @@ std::string Gpu::getName() const
return name.str();
}
bool Gpu::registerIoMemory(const MemoryBlock& mem)
bool Gpu::registerIoMemory(const MemoryBlock &mem)
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
const auto pciAddrSpaceId = mm.getPciAddressSpace();
// Check if we need to map anything at all, maybe it's already reachable
......@@ -187,9 +187,9 @@ bool Gpu::registerIoMemory(const MemoryBlock& mem)
}
bool
Gpu::registerHostMemory(const MemoryBlock& mem)
Gpu::registerHostMemory(const MemoryBlock &mem)
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
auto translation = mm.getTranslationFromProcess(mem.getAddrSpaceId());
auto localBase = reinterpret_cast<void*>(translation.getLocalAddr(0));
......@@ -214,14 +214,14 @@ Gpu::registerHostMemory(const MemoryBlock& mem)
return true;
}
bool Gpu::makeAccessibleToPCIeAndVA(const MemoryBlock& mem)
bool Gpu::makeAccessibleToPCIeAndVA(const MemoryBlock &mem)
{
if (pImpl->gdr == nullptr) {
logger->warn("GDRcopy not available");
return false;
}
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
try {
auto path = mm.findPath(masterPciEAddrSpaceId, mem.getAddrSpaceId());
......@@ -311,14 +311,14 @@ bool Gpu::makeAccessibleToPCIeAndVA(const MemoryBlock& mem)
}
bool
Gpu::makeAccessibleFromPCIeOrHostRam(const MemoryBlock& mem)
Gpu::makeAccessibleFromPCIeOrHostRam(const MemoryBlock &mem)
{
// Check which kind of memory this is and where it resides
// There are two possibilities:
// - Host memory not managed by CUDA
// - IO memory somewhere on the PCIe bus
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
bool isIoMemory = false;
try {
......@@ -341,9 +341,9 @@ Gpu::makeAccessibleFromPCIeOrHostRam(const MemoryBlock& mem)
}
}
void Gpu::memcpySync(const MemoryBlock& src, const MemoryBlock& dst, size_t size)
void Gpu::memcpySync(const MemoryBlock &src, const MemoryBlock &dst, size_t size)
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
auto src_translation = mm.getTranslation(masterPciEAddrSpaceId,
src.getAddrSpaceId());
......@@ -357,9 +357,9 @@ void Gpu::memcpySync(const MemoryBlock& src, const MemoryBlock& dst, size_t size
cudaMemcpy(dst_buf, src_buf, size, cudaMemcpyDefault);
}
void Gpu::memcpyKernel(const MemoryBlock& src, const MemoryBlock& dst, size_t size)
void Gpu::memcpyKernel(const MemoryBlock &src, const MemoryBlock &dst, size_t size)
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
auto src_translation = mm.getTranslation(masterPciEAddrSpaceId,
src.getAddrSpaceId());
......@@ -375,9 +375,9 @@ void Gpu::memcpyKernel(const MemoryBlock& src, const MemoryBlock& dst, size_t si
}
MemoryTranslation
Gpu::translate(const MemoryBlock& dst)
Gpu::translate(const MemoryBlock &dst)
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
return mm.getTranslation(masterPciEAddrSpaceId, dst.getAddrSpaceId());
}
......@@ -388,10 +388,10 @@ GpuAllocator::allocateBlock(size_t size)
cudaSetDevice(gpu.gpuId);
void* addr;
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
// search for an existing chunk that has enough free memory
auto chunk = std::find_if(chunks.begin(), chunks.end(), [&](const auto& chunk) {
auto chunk = std::find_if(chunks.begin(), chunks.end(), [&](const auto &chunk) {
return chunk->getAvailableMemory() >= size;
});
......@@ -452,7 +452,7 @@ Gpu::Gpu(int gpuId) :
bool Gpu::init()
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
const auto gpuPciEAddrSpaceName = mm.getMasterAddrSpaceName(getName(), "pcie");
masterPciEAddrSpaceId = mm.getOrCreateAddressSpace(gpuPciEAddrSpaceName);
......@@ -517,7 +517,7 @@ GpuFactory::make()
}
logger->info("Initialized {} GPUs", gpuList.size());
for (auto& gpu : gpuList) {
for (auto &gpu : gpuList) {
logger->debug(" - {}", gpu->getName());
}
......
......@@ -75,12 +75,12 @@ public:
bool reset() { return true; }
void dump() { }
ip::Core::Ptr lookupIp(const std::string& name) const;
ip::Core::Ptr lookupIp(const Vlnv& vlnv) const;
ip::Core::Ptr lookupIp(const ip::IpIdentifier& id) const;
ip::Core::Ptr lookupIp(const std::string &name) const;
ip::Core::Ptr lookupIp(const Vlnv &vlnv) const;
ip::Core::Ptr lookupIp(const ip::IpIdentifier &id) const;
bool
mapMemoryBlock(const MemoryBlock& block);
mapMemoryBlock(const MemoryBlock &block);
private:
/// Cache a set of already mapped memory blocks
......
......@@ -74,11 +74,11 @@ public:
{ return vlnv; }
friend std::ostream&
operator<< (std::ostream& stream, const IpIdentifier& id)
operator<< (std::ostream &stream, const IpIdentifier &id)
{ return stream << id.name << " vlnv=" << id.vlnv; }
bool
operator==(const IpIdentifier& otherId) const {
operator==(const IpIdentifier &otherId) const {
const bool vlnvWildcard = otherId.getVlnv() == Vlnv::getWildcard();
const bool nameWildcard = this->getName().empty() or otherId.getName().empty();
......@@ -89,7 +89,7 @@ public:
}
bool
operator!=(const IpIdentifier& otherId) const
operator!=(const IpIdentifier &otherId) const
{ return !(*this == otherId); }
private:
......@@ -144,66 +144,66 @@ public:
/* Operators */
bool
operator==(const Vlnv& otherVlnv) const
operator==(const Vlnv &otherVlnv) const
{ return id.getVlnv() == otherVlnv; }
bool
operator!=(const Vlnv& otherVlnv) const
operator!=(const Vlnv &otherVlnv) const
{ return id.getVlnv() != otherVlnv; }
bool
operator==(const IpIdentifier& otherId) const
operator==(const IpIdentifier &otherId) const
{ return this->id == otherId; }
bool
operator!=(const IpIdentifier& otherId) const
operator!=(const IpIdentifier &otherId) const
{ return this->id != otherId; }
bool
operator==(const std::string& otherName) const
operator==(const std::string &otherName) const
{ return getInstanceName() == otherName; }
bool
operator!=(const std::string& otherName) const
operator!=(const std::string &otherName) const
{ return getInstanceName() != otherName; }
bool
operator==(const Core& otherIp) const
operator==(const Core &otherIp) const
{ return this->id == otherIp.id; }
bool
operator!=(const Core& otherIp) const
operator!=(const Core &otherIp) const
{ return this->id != otherIp.id; }
friend std::ostream&
operator<< (std::ostream& stream, const Core& ip)
operator<< (std::ostream &stream, const Core &ip)
{ return stream << ip.id; }
protected:
uintptr_t
getBaseAddr(const MemoryBlockName& block) const
getBaseAddr(const MemoryBlockName &block) const
{ return getLocalAddr(block, 0); }
uintptr_t
getLocalAddr(const MemoryBlockName& block, uintptr_t address) const;
getLocalAddr(const MemoryBlockName &block, uintptr_t address) const;
MemoryManager::AddressSpaceId
getAddressSpaceId(const MemoryBlockName& block) const
getAddressSpaceId(const MemoryBlockName &block) const
{ return slaveAddressSpaces.at(block); }
InterruptController*
getInterruptController(const std::string& interruptName) const;
getInterruptController(const std::string &interruptName) const;
MemoryManager::AddressSpaceId
getMasterAddrSpaceByInterface(const std::string& masterInterfaceName) const
getMasterAddrSpaceByInterface(const std::string &masterInterfaceName) const
{ return busMasterInterfaces.at(masterInterfaceName); }
template<typename T>
T readMemory(const std::string& block, uintptr_t address) const
T readMemory(const std::string &block, uintptr_t address) const
{ return *(reinterpret_cast<T*>(getLocalAddr(block, address))); }
template<typename T>
void writeMemory(const std::string& block, uintptr_t address, T value)
void writeMemory(const std::string &block, uintptr_t address, T value)
{ T* ptr = reinterpret_cast<T*>(getLocalAddr(block, address)); *ptr = value; }
protected:
......@@ -266,7 +266,7 @@ protected:
private:
static CoreFactory*
lookup(const Vlnv& vlnv);
lookup(const Vlnv &vlnv);
};
/** @} */
......
......@@ -59,7 +59,7 @@ private:
class BramFactory : public CoreFactory {
public:
bool configureJson(Core& ip, json_t *json_ip);
bool configureJson(Core &ip, json_t *json_ip);
Core* create()
{ return new Bram; }
......
......@@ -44,10 +44,10 @@ public:
bool reset();
// memory-mapped to stream (MM2S)
bool write(const MemoryBlock& mem, size_t len);
bool write(const MemoryBlock &mem, size_t len);
// stream to memory-mapped (S2MM)
bool read(const MemoryBlock& mem, size_t len);
bool read(const MemoryBlock &mem, size_t len);
size_t writeComplete()
{ return hasScatterGather() ? writeCompleteSG() : writeCompleteSimple(); }
......@@ -55,10 +55,10 @@ public:
size_t readComplete()
{ return hasScatterGather() ? readCompleteSG() : readCompleteSimple(); }
bool memcpy(const MemoryBlock& src, const MemoryBlock& dst, size_t len);
bool memcpy(const MemoryBlock &src, const MemoryBlock &dst, size_t len);
bool makeAccesibleFromVA(const MemoryBlock& mem);
bool makeInaccesibleFromVA(const MemoryBlock& mem);
bool makeAccesibleFromVA(const MemoryBlock &mem);
bool makeInaccesibleFromVA(const MemoryBlock &mem);
inline bool
hasScatterGather() const
......@@ -87,7 +87,7 @@ public:
static constexpr const char* s2mmPort = "S2MM";
static constexpr const char* mm2sPort = "MM2S";
bool isMemoryBlockAccesible(const MemoryBlock& mem, const std::string& interface);
bool isMemoryBlockAccesible(const MemoryBlock &mem, const std::string &interface);
virtual void dump();
......
......@@ -13,7 +13,7 @@ class Hls : public virtual Core
public:
virtual bool init()
{
auto& registers = addressTranslations.at(registerMemory);
auto &registers = addressTranslations.at(registerMemory);
controlRegister = reinterpret_cast<ControlRegister*>(registers.getLocalAddr(registerControlAddr));
globalIntRegister = reinterpret_cast<GlobalIntRegister*>(registers.getLocalAddr(registerGlobalIntEnableAddr));
......
......@@ -70,7 +70,7 @@ public:
getCompatibleVlnvString()
{ return "xilinx.com:ip:axi_pcie:"; }
bool configureJson(Core& ip, json_t *json_ip);
bool configureJson(Core &ip, json_t *json_ip);
Core* create()
{ return new AxiPciExpressBridge; }
......
......@@ -34,16 +34,16 @@ public:
void dump(spdlog::level::level_enum logLevel = spdlog::level::info);
bool startOnce(const MemoryBlock& mem, size_t frameSize, size_t dataOffset, size_t doorbellOffset);
bool startOnce(const MemoryBlock &mem, size_t frameSize, size_t dataOffset, size_t doorbellOffset);
size_t getMaxFrameSize();
void dumpDoorbell(uint32_t doorbellRegister) const;
bool doorbellIsValid(const uint32_t& doorbellRegister) const
bool doorbellIsValid(const uint32_t &doorbellRegister) const
{ return reinterpret_cast<const reg_doorbell_t&>(doorbellRegister).is_valid; }
void doorbellReset(uint32_t& doorbellRegister) const
void doorbellReset(uint32_t &doorbellRegister) const
{ doorbellRegister = 0; }
static constexpr const char* registerMemory = "Reg";
......
......@@ -46,11 +46,11 @@ public:
bool init();
bool connectInternal(const std::string& slavePort,
const std::string& masterPort);
bool connectInternal(const std::string &slavePort,
const std::string &masterPort);
private:
int portNameToNum(const std::string& portName);
int portNameToNum(const std::string &portName);
private:
static constexpr const char* PORT_DISABLED = "DISABLED";
......@@ -77,7 +77,7 @@ public:
getCompatibleVlnvString()
{ return "xilinx.com:ip:axis_switch:"; }
bool configureJson(Core& ip, json_t *json_ip);
bool configureJson(Core &ip, json_t *json_ip);
Core* create()
{ return new AxiStreamSwitch; }
......
......@@ -44,14 +44,14 @@ namespace ip {
class StreamVertex : public graph::Vertex {
public:
StreamVertex(const std::string& node, const std::string& port, bool isMaster) :
StreamVertex(const std::string &node, const std::string &port, bool isMaster) :
nodeName(node), portName(port), isMaster(isMaster) {}
std::string getName() const
{ return nodeName + "/" + portName + "(" + (isMaster ? "M" : "S") + ")"; }
friend std::ostream&
operator<< (std::ostream& stream, const StreamVertex& vertex)
operator<< (std::ostream &stream, const StreamVertex &vertex)
{ return stream << vertex.getIdentifier() << ": " << vertex.getName(); }
public:
......@@ -66,12 +66,12 @@ public:
StreamGraph() : graph::DirectedGraph<StreamVertex>("StreamGraph") {}
std::shared_ptr<StreamVertex>
getOrCreateStreamVertex(const std::string& node,
const std::string& port,
getOrCreateStreamVertex(const std::string &node,
const std::string &port,
bool isMaster)
{
for (auto& vertexEntry : vertices) {
auto& vertex = vertexEntry.second;
for (auto &vertexEntry : vertices) {
auto &vertex = vertexEntry.second;
if (vertex->nodeName == node and vertex->portName == port and vertex->isMaster == isMaster)
return vertex;
}
......@@ -95,14 +95,12 @@ public:
std::string nodeName;
};
bool connect(const StreamVertex& from, const StreamVertex& to);
const StreamVertex&
getMasterPort(const std::string& name) const
getMasterPort(const std::string &name) const
{ return *portsMaster.at(name); }
const StreamVertex&
getSlavePort(const std::string& name) const
getSlavePort(const std::string &name) const
{ return *portsSlave.at(name); }
// easy-usage assuming that the slave IP to connect to only has one slave
......
......@@ -53,14 +53,14 @@ public:
toString() const;
bool
operator==(const Vlnv& other) const;
operator==(const Vlnv &other) const;
bool
operator!=(const Vlnv& other) const
operator!=(const Vlnv &other) const
{ return !(*this == other); }
friend std::ostream&
operator<< (std::ostream& stream, const Vlnv& vlnv)
operator<< (std::ostream &stream, const Vlnv &vlnv)
{
return stream
<< (vlnv.vendor.empty() ? "*" : vlnv.vendor) << ":"
......
......@@ -119,10 +119,10 @@ PCIeCardFactory::create()
PCIeCard::~PCIeCard()
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
// unmap all memory blocks
for (auto& mappedMemoryBlock : memoryBlocksMapped) {
for (auto &mappedMemoryBlock : memoryBlocksMapped) {
auto translation = mm.getTranslation(addrSpaceIdDeviceToHost,
mappedMemoryBlock);
......@@ -137,9 +137,9 @@ PCIeCard::~PCIeCard()
ip::Core::Ptr
PCIeCard::lookupIp(const std::string& name) const
PCIeCard::lookupIp(const std::string &name) const
{
for (auto& ip : ips) {
for (auto &ip : ips) {
if (*ip == name) {
return ip;
}
......@@ -150,9 +150,9 @@ PCIeCard::lookupIp(const std::string& name) const
ip::Core::Ptr
PCIeCard::lookupIp(const Vlnv& vlnv) const
PCIeCard::lookupIp(const Vlnv &vlnv) const
{
for (auto& ip : ips) {
for (auto &ip : ips) {
if (*ip == vlnv) {
return ip;
}
......@@ -162,9 +162,9 @@ PCIeCard::lookupIp(const Vlnv& vlnv) const
}
ip::Core::Ptr
PCIeCard::lookupIp(const ip::IpIdentifier& id) const
PCIeCard::lookupIp(const ip::IpIdentifier &id) const
{
for (auto& ip : ips) {
for (auto &ip : ips) {
if (*ip == id) {
return ip;
}
......@@ -175,15 +175,15 @@ PCIeCard::lookupIp(const ip::IpIdentifier& id) const
bool
PCIeCard::mapMemoryBlock(const MemoryBlock& block)
PCIeCard::mapMemoryBlock(const MemoryBlock &block)
{
if (not vfioContainer->isIommuEnabled()) {
logger->warn("VFIO mapping not supported without IOMMU");
return false;
}
auto& mm = MemoryManager::get();
const auto& addrSpaceId = block.getAddrSpaceId();
auto &mm = MemoryManager::get();
const auto &addrSpaceId = block.getAddrSpaceId();
if (memoryBlocksMapped.find(addrSpaceId) != memoryBlocksMapped.end()) {
// block already mapped
......
......@@ -85,7 +85,7 @@ CoreFactory::make(PCIeCard* card, json_t *json_ips)
// first to be initialized.
vlnvInitializationOrder.reverse();
for (auto& vlnvInitFirst : vlnvInitializationOrder) {
for (auto &vlnvInitFirst : vlnvInitializationOrder) {
// iterate over IPs, if VLNV matches, push to front and remove from list
for (auto it = allIps.begin(); it != allIps.end(); ++it) {
if (vlnvInitFirst == it->getVlnv()) {
......@@ -99,12 +99,12 @@ CoreFactory::make(PCIeCard* card, json_t *json_ips)
orderedIps.splice(orderedIps.end(), allIps);
loggerStatic->debug("IP initialization order:");
for (auto& id : orderedIps) {
for (auto &id : orderedIps) {
loggerStatic->debug(" " CLR_BLD("{}"), id.getName());
}
// configure all IPs
for (auto& id : orderedIps) {
for (auto &id : orderedIps) {
loggerStatic->info("Configuring {}", id);
// find the appropriate factory that can create the specified VLNV
......@@ -162,10 +162,10 @@ CoreFactory::make(PCIeCard* card, json_t *json_ips)