-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
939 additions
and
32 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
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
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,57 @@ | ||
#ifndef OCCA_C_DTYPE_HEADER | ||
#define OCCA_C_DTYPE_HEADER | ||
|
||
#include <occa/c/defines.h> | ||
#include <occa/c/types.h> | ||
|
||
OCCA_START_EXTERN_C | ||
|
||
//-----[ Methods ]---------------------- | ||
OCCA_LFUNC occaDtype OCCA_RFUNC occaCreateDtype(const char *name, | ||
const int bytes); | ||
|
||
OCCA_LFUNC const char* OCCA_RFUNC occaDtypeGetName(occaDtype type); | ||
OCCA_LFUNC int OCCA_RFUNC occaDtypeGetBytes(occaDtype type); | ||
|
||
OCCA_LFUNC void OCCA_RFUNC occaDtypeAddField(occaDtype type, | ||
const char *field, | ||
occaDtype fieldType); | ||
|
||
OCCA_LFUNC int OCCA_RFUNC occaDtypeIsEqual(occaDtype a, | ||
occaDtype b); | ||
|
||
OCCA_LFUNC occaDtype OCCA_RFUNC occaDtypeFromJson(occaJson json); | ||
OCCA_LFUNC occaDtype OCCA_RFUNC occaDtypeFromJsonString(const char *str); | ||
|
||
OCCA_LFUNC occaJson OCCA_RFUNC occaDtypeToJson(occaDtype type); | ||
//====================================== | ||
|
||
//-----[ Builtins ]--------------------- | ||
extern occaDtype occaDtypeNone; | ||
|
||
extern occaDtype occaDtypeVoid; | ||
extern occaDtype occaDtypeByte; | ||
|
||
extern occaDtype occaDtypeBool; | ||
extern occaDtype occaDtypeChar; | ||
extern occaDtype occaDtypeShort; | ||
extern occaDtype occaDtypeInt; | ||
extern occaDtype occaDtypeLong; | ||
extern occaDtype occaDtypeFloat; | ||
extern occaDtype occaDtypeDouble; | ||
|
||
extern occaDtype occaDtypeInt8; | ||
extern occaDtype occaDtypeUint8; | ||
extern occaDtype occaDtypeInt16; | ||
extern occaDtype occaDtypeUint16; | ||
extern occaDtype occaDtypeInt32; | ||
extern occaDtype occaDtypeUint32; | ||
extern occaDtype occaDtypeInt64; | ||
extern occaDtype occaDtypeUint64; | ||
extern occaDtype occaDtypeFloat32; | ||
extern occaDtype occaDtypeFloat64; | ||
//====================================== | ||
|
||
OCCA_END_EXTERN_C | ||
|
||
#endif |
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
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
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,7 @@ | ||
#ifndef OCCA_DTYPE_HEADER | ||
#define OCCA_DTYPE_HEADER | ||
|
||
#include <occa/dtype/dtype.hpp> | ||
#include <occa/dtype/builtins.hpp> | ||
|
||
#endif |
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,34 @@ | ||
#ifndef OCCA_DTYPE_BUILTINS_HEADER | ||
#define OCCA_DTYPE_BUILTINS_HEADER | ||
|
||
#include <occa/dtype/dtype.hpp> | ||
|
||
namespace occa { | ||
namespace dtypes { | ||
extern dtype none; | ||
|
||
extern dtype void_; | ||
extern dtype byte; | ||
|
||
extern dtype bool_; | ||
extern dtype char_; | ||
extern dtype short_; | ||
extern dtype int_; | ||
extern dtype long_; | ||
extern dtype float_; | ||
extern dtype double_; | ||
|
||
extern dtype int8; | ||
extern dtype uint8; | ||
extern dtype int16; | ||
extern dtype uint16; | ||
extern dtype int32; | ||
extern dtype uint32; | ||
extern dtype int64; | ||
extern dtype uint64; | ||
extern dtype float32; | ||
extern dtype float64; | ||
} | ||
} | ||
|
||
#endif |
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,65 @@ | ||
#ifndef OCCA_DTYPE_DTYPE_HEADER | ||
#define OCCA_DTYPE_DTYPE_HEADER | ||
|
||
#include <iostream> | ||
#include <map> | ||
#include <vector> | ||
|
||
#include <occa/tools/json.hpp> | ||
|
||
|
||
namespace occa { | ||
class dtype; | ||
class dtypeField; | ||
|
||
typedef std::map<std::string, dtype*> dtypeNameMap_t; | ||
|
||
class dtype { | ||
private: | ||
std::string name; | ||
int bytes; | ||
std::vector<dtypeField> fields; | ||
|
||
public: | ||
dtype(const std::string &name_); | ||
dtype(const std::string &name_, | ||
const int bytes_); | ||
dtype(const dtype &other); | ||
|
||
const std::string& getName() const; | ||
int getBytes() const; | ||
|
||
dtype& addField(const std::string field, | ||
const dtype &type); | ||
|
||
bool operator == (const dtype &other) const; | ||
bool operator != (const dtype &other) const; | ||
|
||
static const dtype& byName(const std::string name); | ||
|
||
static dtype fromJson(const std::string &str); | ||
static dtype fromJson(const json &j); | ||
|
||
json toJson() const; | ||
|
||
friend std::ostream& operator << (std::ostream &out, | ||
const dtype &type); | ||
}; | ||
|
||
std::ostream& operator << (std::ostream &out, | ||
const dtype &type); | ||
class dtypeField { | ||
friend class dtype; | ||
|
||
private: | ||
std::string name; | ||
dtype type; | ||
|
||
public: | ||
dtypeField(const std::string &name_, | ||
const dtype &type_); | ||
dtypeField(const dtypeField &other); | ||
}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.