-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented the very basics of the first three classes.
- Loading branch information
Showing
12 changed files
with
483 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
|
||
|
||
add_library(cudapp SHARED | ||
src/device.cu | ||
src/device_properties.cu | ||
src/device_manager.cu | ||
../include/cudapp/cuda_device_prop.hpp | ||
) | ||
set_property(TARGET cudapp PROPERTY CUDA_ARCHITECTURES OFF) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// Created by olivas on 4/15/24. | ||
// | ||
|
||
#ifndef CUDAPP_CUDA_DEVICE_PROP_HPP | ||
#define CUDAPP_CUDA_DEVICE_PROP_HPP | ||
|
||
#include <array> | ||
#include <string> | ||
|
||
struct cuda_device_prop { | ||
std::string name; | ||
std::string uuid; // 16 byte unique identifier | ||
size_t totalGlobalMem; | ||
size_t sharedMemPerBlock; | ||
unsigned regsPerBlock; | ||
unsigned warpSize; | ||
size_t memPitch; | ||
unsigned maxThreadsPerBlock; | ||
std::array<unsigned, 3> maxThreadsDim; | ||
std::array<unsigned, 3> maxGridSize; | ||
unsigned clockRate; | ||
size_t totalConstMem; | ||
unsigned major; | ||
unsigned minor; | ||
size_t textureAlignment; | ||
size_t texturePitchAlignment; | ||
unsigned deviceOverlap; | ||
unsigned multiProcessorCount; | ||
unsigned kernelExecTimeoutEnabled; | ||
unsigned integrated; | ||
unsigned canMapHostMemory; | ||
unsigned computeMode; | ||
unsigned maxTexture1D; | ||
unsigned maxTexture1DMipmap; | ||
unsigned maxTexture1DLinear; | ||
std::array<unsigned, 2> maxTexture2D; | ||
std::array<unsigned, 2> maxTexture2DMipmap; | ||
std::array<unsigned, 3> maxTexture2DLinear; | ||
std::array<unsigned, 2> maxTexture2DGather; | ||
std::array<unsigned, 3> maxTexture3D; | ||
std::array<unsigned, 3> maxTexture3DAlt; | ||
unsigned maxTextureCubemap; | ||
std::array<unsigned, 2> maxTexture1DLayered; | ||
std::array<unsigned, 3> maxTexture2DLayered; | ||
std::array<unsigned, 2> maxTextureCubemapLayered; | ||
unsigned maxSurface1D; | ||
std::array<unsigned, 2> maxSurface2D; | ||
std::array<unsigned, 3> maxSurface3D; | ||
std::array<unsigned, 2> maxSurface1DLayered; | ||
std::array<unsigned, 3> maxSurface2DLayered; | ||
unsigned maxSurfaceCubemap; | ||
std::array<unsigned, 2> maxSurfaceCubemapLayered; | ||
size_t surfaceAlignment; | ||
unsigned concurrentKernels; | ||
unsigned ECCEnabled; | ||
unsigned pciBusID; | ||
unsigned pciDeviceID; | ||
unsigned pciDomainID; | ||
unsigned tccDriver; | ||
unsigned asyncEngineCount; | ||
unsigned unifiedAddressing; | ||
unsigned memoryClockRate; | ||
unsigned memoryBusWidth; | ||
unsigned l2CacheSize; | ||
unsigned persistingL2CacheMaxSize; | ||
unsigned maxThreadsPerMultiProcessor; | ||
unsigned streamPrioritiesSupported; | ||
unsigned globalL1CacheSupported; | ||
unsigned localL1CacheSupported; | ||
size_t sharedMemPerMultiprocessor; | ||
unsigned regsPerMultiprocessor; | ||
unsigned managedMemory; | ||
unsigned isMultiGpuBoard; | ||
unsigned multiGpuBoardGroupID; | ||
unsigned singleToDoublePrecisionPerfRatio; | ||
unsigned pageableMemoryAccess; | ||
unsigned concurrentManagedAccess; | ||
unsigned computePreemptionSupported; | ||
unsigned canUseHostPointerForRegisteredMem; | ||
unsigned cooperativeLaunch; | ||
unsigned cooperativeMultiDeviceLaunch; | ||
unsigned pageableMemoryAccessUsesHostPageTables; | ||
unsigned directManagedMemAccessFromHost; | ||
unsigned accessPolicyMaxWindowSize; | ||
}; | ||
|
||
|
||
#endif //CUDAPP_CUDA_DEVICE_PROP_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
#pragma once | ||
|
||
class Device{ | ||
public: | ||
Device(int device_number); | ||
~Device(); | ||
namespace cudapp{ | ||
class Device{ | ||
public: | ||
Device(int device_number); | ||
~Device(); | ||
|
||
int multi_processor_count() const { return multi_processor_count_; } | ||
size_t total_global_mem() const { return total_global_mem_; } | ||
|
||
private: | ||
int device_number_; | ||
int multi_processor_count_; | ||
size_t total_global_mem_; | ||
}; | ||
int multi_processor_count() const { return multi_processor_count_; } | ||
size_t total_global_mem() const { return total_global_mem_; } | ||
|
||
private: | ||
int device_number_; | ||
int multi_processor_count_; | ||
size_t total_global_mem_; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
#pragma once | ||
|
||
class DeviceManager{ | ||
public: | ||
DeviceManager(); | ||
~DeviceManager(); | ||
|
||
int multi_processor_count() const { return multi_processor_count_; } | ||
size_t total_global_mem() const { return total_global_mem_; } | ||
|
||
private: | ||
int device_number_; | ||
int multi_processor_count_; | ||
size_t total_global_mem_; | ||
}; | ||
#include <optional> | ||
|
||
namespace cudapp{ | ||
class DeviceManager { | ||
public: | ||
DeviceManager(); | ||
|
||
~DeviceManager(); | ||
|
||
[[nodiscard("this method's job is to return a value.")]] | ||
std::optional<unsigned> device_count() const; | ||
|
||
[[nodiscard("this method's job is to return a value.")]] | ||
std::optional<unsigned> current_device() const; | ||
|
||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
|
||
#include <cudapp/cuda_device_prop.hpp> | ||
|
||
namespace cudapp{ | ||
class DeviceProperties { | ||
public: | ||
|
||
DeviceProperties(unsigned device_number); | ||
|
||
~DeviceProperties(); | ||
|
||
void change_device_number(unsigned device_number); | ||
|
||
cuda_device_prop device_properties; | ||
|
||
void pretty_print(); | ||
|
||
private: | ||
|
||
unsigned device_number_; | ||
|
||
void set_device_properties(const unsigned device_number); | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
#include <cudapp/device_manager.hpp> | ||
#include <cudapp/check_error.cuh> | ||
|
||
DeviceManager::DeviceManager() | ||
{ | ||
CHECK_ERROR(cudaSetDeviceFlags(cudaDeviceBlockingSync)); | ||
CHECK_ERROR(cudaSetDevice(device_number_)); | ||
std::cerr<<"device_number_ = "<<device_number_<<std::endl; | ||
using std::optional; | ||
|
||
cudaDeviceProp device_properties; | ||
CHECK_ERROR(cudaGetDeviceProperties(&device_properties, device_number_)); | ||
total_global_mem_ = device_properties.totalGlobalMem; | ||
multi_processor_count_ = device_properties.multiProcessorCount; | ||
cudapp::DeviceManager::DeviceManager() {} | ||
|
||
optional<unsigned> | ||
cudapp::DeviceManager::device_count() const { | ||
int device_count{0}; | ||
CHECK_ERROR(cudaGetDeviceCount(&device_count)); | ||
return static_cast<unsigned>(device_count); | ||
} | ||
|
||
DeviceManager::~DeviceManager() | ||
{ | ||
CHECK_ERROR(cudaDeviceReset()); | ||
optional<unsigned> | ||
cudapp::DeviceManager::current_device() const { | ||
int device{0}; | ||
CHECK_ERROR(cudaGetDevice(&device)); | ||
return static_cast<unsigned>(device); | ||
} | ||
|
||
cudapp::DeviceManager::~DeviceManager() {} | ||
|
Oops, something went wrong.