Warrior_EA/DirectML/smoke_test.cpp

29 lines
1 KiB
C++
Raw Permalink Normal View History

#include <iostream>
#include <vector>
#include "WarriorDML.h"
int main()
{
int err = 0;
DmlHandle ctx = DML_Init(&err);
std::cout << "init=" << (ctx != 0 ? 1 : 0) << " err=" << err << "\n";
if(!ctx)
return 1;
int handle = DML_BufferCreate(ctx, 8);
std::cout << "buffer=" << handle << "\n";
if(handle < 0)
return 2;
std::vector<double> data = {1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0};
int writeOk = DML_BufferWrite(ctx, handle, data.data(), (int)data.size());
std::cout << "write=" << writeOk << " last=" << DML_GetLastError(ctx) << "\n";
if(!writeOk)
return 3;
std::vector<double> readBack(8, 0.0);
int readOk = DML_BufferRead(ctx, handle, readBack.data(), (int)readBack.size());
std::cout << "read=" << readOk << " last=" << DML_GetLastError(ctx) << "\n";
for(size_t i = 0; i < readBack.size(); ++i)
std::cout << readBack[i] << (i + 1 == readBack.size() ? "\n" : " ");
DML_BufferFree(ctx, handle);
DML_Shutdown(ctx);
return 0;
}