Skip to content

Commit

Permalink
Merge pull request #159 from marty1885/apichange
Browse files Browse the repository at this point in the history
Various updates
  • Loading branch information
marty1885 committed Sep 7, 2020
2 parents 77c2bad + caeedc4 commit 3b6ece6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Etaler/Backends/OpenCLBackend.cpp
Expand Up @@ -42,7 +42,9 @@ typedef struct __attribute__ ((packed)) _OpenCLView
static void makeOpenCLView(const TensorImpl* x, OpenCLView* v)
{
int dims = int(x->dimensions());
et_assert(dims <= OPENCL_TENSOR_MAX_DIMS, "Too much dimensions for OpenCL backend.");
et_check(dims <= OPENCL_TENSOR_MAX_DIMS
, "The OpenCL backend can only handle up to" + std::to_string(OPENCL_TENSOR_MAX_DIMS) + "D view"
"got " + std::to_string(dims) + "D");
auto stride = x->stride();
auto shape_stride = shapeToStride(x->shape());
for(int i=0;i<dims;i++) {
Expand Down
4 changes: 3 additions & 1 deletion Etaler/Core/Shape.hpp
Expand Up @@ -139,6 +139,8 @@ inline size_t unfold(const IdxType& index, const StrideType& stride)

inline Shape shapeToStride(const Shape& shape)
{
if(shape.empty())
return {};
Shape v;
v.resize(shape.size());
size_t acc = 1;
Expand All @@ -159,7 +161,7 @@ inline size_t unfoldIndex(const IdxType& index, const ShapeType& shape)
template <typename ShapeType>
inline Shape foldIndex(size_t index, const ShapeType& shape)
{
assert(shape.size() != 0);
assert(shape.size() != 0 || index == 0);
svector<intmax_t> v = shapeToStride(shape);
Shape res;
res.resize(v.size());
Expand Down
9 changes: 9 additions & 0 deletions Etaler/Core/SmallVector.hpp
Expand Up @@ -960,6 +960,10 @@ void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSizeInBytes,
void *NewElts;
if (BeginX == FirstEl) {
NewElts = malloc(NewCapacityInBytes);
if(NewElts == NULL) {
fprintf(stderr, "SmallVectorBase::grow_pod failed: mad malloc");
abort();
}

// Copy the elements over. No need to run dtors on PODs.
memcpy(NewElts, this->BeginX, CurSizeBytes);
Expand All @@ -982,4 +986,9 @@ namespace et
using svector = llvm_vecsmall::SmallVector<T, N>;
}

// Undef LLVM macros
#undef LLVM_VECSMALL_NODISCARD
#undef LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE
#undef LLVM_VECSMALL_UNLIKELY

#endif
2 changes: 1 addition & 1 deletion Etaler/Core/Tensor.hpp
Expand Up @@ -60,7 +60,7 @@ struct ETALER_EXPORT TensorIterator
Tensor ETALER_EXPORT brodcast_to(const Tensor& t, Shape s);

ETALER_EXPORT std::ostream& operator<< (std::ostream& os, const Tensor& t);
std::string to_string(const Tensor& t);
ETALER_EXPORT std::string to_string(const Tensor& t);

using IndexList = svector<std::variant<Range, intmax_t, int, size_t, unsigned int>>;

Expand Down
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -88,10 +88,13 @@ Documents are avalible online on [Read the Docs](https://etaler.readthedocs.io/e
| Linux | Yes | Yes |
| OS X | Yes | Yes |
| Windows | Yes | Yes |
| FreeBSD | Yes | *Yes |
* Build with GCC and libstdc++ on OS X 10.11.
* Clang should work after OS X 10.14. See [BuildOnOSX.md](docs/BuildOnOSX.md)
* Build with Visual Studio 2019 on Windows. See [BuildOnMSVC.md](docs/BuildOnMSVC.md)
* OpenCL on FreeBSD is tested using POCL. Which has know bugs preventing Etaler to fully function on ARM.
* See [#151](https://github.com/etaler/Etaler/issues/151)
### Dependencies
Expand Down
1 change: 1 addition & 0 deletions docs/source/DeveloperNotes.md
Expand Up @@ -23,6 +23,7 @@ This file documents some facts about the codebase that might be useful for it's
* Nvidia's OpenCL implementation although very optimized, has piles upon piles of problems.
* Use POCL w/ CUDA backend for debugging. POCL is a lot slower, but very stable.
* Or use Intel/AMD's OpenCL SDK
* Mesa's `clover` [OpenCL SDK](https://cgit.freedesktop.org/mesa/mesa/log/?qt=grep&q=clover) works, but quite slow.

## Programing style

Expand Down

0 comments on commit 3b6ece6

Please sign in to comment.