Skip to content

Commit

Permalink
Cpu device
Browse files Browse the repository at this point in the history
  • Loading branch information
inakleinbottle committed Aug 18, 2023
1 parent 3e42f3e commit 26227ed
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
2 changes: 2 additions & 0 deletions platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ add_roughpy_component(Platform
src/configuration.cpp
src/threading/openmp_threading.cpp
src/device.cpp
src/cpu_device/CPUDevice.cpp
src/cpu_device/CPUDevice.h
PUBLIC_HEADERS
include/roughpy/platform.h
include/roughpy/platform/filesystem.h
Expand Down
12 changes: 6 additions & 6 deletions platform/include/roughpy/platform/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ class RPY_EXPORT DeviceHandle {
const DeviceInfo& info() const noexcept { return m_info; }

RPY_NO_DISCARD
virtual const fs::path& runtime_library() const noexcept = 0;
virtual optional<fs::path> runtime_library() const noexcept = 0;


virtual void launch_kernel(const void* kernel,
const void* launch_config,
void** args
) = 0;
// virtual void launch_kernel(const void* kernel,
// const void* launch_config,
// void** args
// ) = 0;


};



std::shared_ptr<DeviceHandle> get_cpu_device_handle() noexcept;



Expand Down
11 changes: 11 additions & 0 deletions platform/src/cpu_device/CPUDevice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Created by sam on 18/08/23.
//

#include "CPUDevice.h"

std::optional<std::filesystem::path>
rpy::platform::CPUDevice::runtime_library() const noexcept
{
return {};
}
28 changes: 28 additions & 0 deletions platform/src/cpu_device/CPUDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Created by sam on 18/08/23.
//

#ifndef ROUGHPY_CPUDEVICE_H
#define ROUGHPY_CPUDEVICE_H

#include <roughpy/platform/device.h>

namespace rpy {
namespace platform {

class CPUDevice : public DeviceHandle
{

public:

CPUDevice() : DeviceHandle(DeviceType::CPU, 0) {}

RPY_NO_DISCARD
optional<fs::path> runtime_library() const noexcept override;

};

}// namespace platform
}// namespace rpy

#endif// ROUGHPY_CPUDEVICE_H
7 changes: 6 additions & 1 deletion platform/src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

#include <roughpy/platform/device.h>

#include "cpu_device/CPUDevice.h"

using namespace rpy;
using namespace rpy::platform;


std::shared_ptr<DeviceHandle> get_cpu_device_handle() noexcept
{
static std::shared_ptr<DeviceHandle> cpu_handle(new CPUDevice);
return cpu_handle;
}

DeviceHandle::~DeviceHandle() = default;

0 comments on commit 26227ed

Please sign in to comment.