diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index e6f347c..132e862 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(Dialect) \ No newline at end of file +add_subdirectory(Dialect) +add_subdirectory(Interface) \ No newline at end of file diff --git a/include/Interface/Container.h b/include/Interface/Container.h new file mode 100644 index 0000000..24c0e59 --- /dev/null +++ b/include/Interface/Container.h @@ -0,0 +1,54 @@ +//===- Container.h --------------------------------------------------------===// +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//===----------------------------------------------------------------------===// +// +// Container descriptor. +// +//===----------------------------------------------------------------------===// + + +#ifndef INTERFACE_GRAPH_CORE_CONTAINER_H +#define INTERFACE_GRAPH_CORE_CONTAINER_H + +#include +#include +#include + +// MemRef descriptor. +// - T represents the type of the elements. +// - N represents the number of dimensions. +template class MemRef { + +protected: + // Default constructor. + MemRef() {}; + + // Data. + // The `aligned` and `allocated` members point to the same address, `aligned` + // member is responsible for handling data, and `allocated` member is + // resposible for handling the memory space. + T *allocated; + T *aligned; + // Offset. + intptr_t offset = 0; + // Shape. + intptr_t sizes[N]; + // Strides. + intptr_t strides[N]; + // Number of elements. + size_t size; +}; + +#endif // INTERFACE_GRAPH_CORE_CONTAINER. \ No newline at end of file diff --git a/include/Interface/GraphContainer.h b/include/Interface/GraphContainer.h new file mode 100644 index 0000000..a1afe3a --- /dev/null +++ b/include/Interface/GraphContainer.h @@ -0,0 +1,42 @@ +//===- GraphContainer.h ---------------------------------------------------===// +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//===----------------------------------------------------------------------===// +// +// Graph container descriptor. +// +//===----------------------------------------------------------------------===// + +#ifndef INTERFACE_GRAPHCONTAINER_H +#define INTERFACE_GRAPHCONTAINER_H + +#include "Interface/Container.h" + +// Graph container. +// - T represents the type of the elements. +// - N represents the number of dimensions. +template class Graph : public MemRef { + // V is the number of vertices/nodes. + T V; + +public: + // For Adjaceny Matrix. + Graph(T V, T** adjMatrix); + // TODO: + // Add Different contructors. +}; + +#include "Interface/GraphContainer.cpp" + +#endif // INTERFACE_GRAPHCONTAINER_H \ No newline at end of file diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 629c08a..6965fb1 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(Conversion) add_subdirectory(Dialect) +add_subdirectory(Interface) diff --git a/lib/Interface/GraphContainer.cpp b/lib/Interface/GraphContainer.cpp new file mode 100644 index 0000000..48d6d16 --- /dev/null +++ b/lib/Interface/GraphContainer.cpp @@ -0,0 +1,42 @@ +//===- GraphContainer.cpp -------------------------------------------------===// +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//===----------------------------------------------------------------------===// +// +// This file implements the Graph container descriptor. +// +//===----------------------------------------------------------------------===// + +#ifndef GRAPH_CONTAINER_DEF +#define GRAPH_CONTAINER_DEF + +#include "Interface/Container.h" +#include "Interface/GraphContainer.h" + +// Adjaceny Matrix constructor. +template Graph::Graph(T V, T **adjMatrix) : MemRef() { + this->size[0] = V; + this->size[1] = V; + this->strides[0] = V; + this->strides[1] = V; + this->allocated = new T[this->size]; + //TODO + // Add the implementation for passing data to alignned. +}; + + +// TODO +// Implement the contructor for different implementation. + +#endif // GRAPH_CONTAINER_DEF \ No newline at end of file