diff --git a/ArrayFireWrapper/ArrayFireWrapper.cpp b/ArrayFireWrapper/ArrayFireWrapper.cpp deleted file mode 100644 index a91179a..0000000 --- a/ArrayFireWrapper/ArrayFireWrapper.cpp +++ /dev/null @@ -1,381 +0,0 @@ -// ArrayFireWrapper.cpp : Defines the entry point for the application. -// - -#include "stdafx.h" - -extern "C" { - #include - #include - #include -} - -#include -#include -#include -#include -#include -#include - -// http://www.cplusplus.com/forum/windows/58206/ -void RedirectIOToConsole() -{ - int hConHandle; - long lStdHandle; - CONSOLE_SCREEN_BUFFER_INFO coninfo; - FILE *fp; - -// allocate a console for this app - AllocConsole(); - -// set the screen buffer to be big enough to let us scroll text - GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),&coninfo); - coninfo.dwSize.Y = 20; - SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),coninfo.dwSize); - -// redirect unbuffered STDOUT to the console - lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); - hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); - - fp = _fdopen( hConHandle, "w" ); - - *stdout = *fp; - - setvbuf( stdout, NULL, _IONBF, 0 ); - -// redirect unbuffered STDIN to the console - - lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE); - hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); - - fp = _fdopen( hConHandle, "r" ); - *stdin = *fp; - setvbuf( stdin, NULL, _IONBF, 0 ); - -// redirect unbuffered STDERR to the console - lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); - hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); - - fp = _fdopen( hConHandle, "w" ); - - *stderr = *fp; - - setvbuf( stderr, NULL, _IONBF, 0 ); - -// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog -// point to console as well - std::ios::sync_with_stdio(); -} - -void PushString (lua_State * L, LPTSTR str) -{ - char mbstr[MAX_PATH]; - - size_t n; - - wcstombs_s(&n, mbstr, str, MAX_PATH); - - lua_pushstring(L, mbstr); // ..., str -} - -int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, - _In_opt_ HINSTANCE hPrevInstance, - _In_ LPTSTR lpCmdLine, - _In_ int nCmdShow) -{ - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - - RedirectIOToConsole(); - - // TODO: Restructure this as a loop, allow IO via pipe or whatever as alternative (when a process) - // Want persistent, probably, to facilitate communication - - if (_tcslen(lpCmdLine) > 0) - { - lua_State * L = luaL_newstate(); - - luaL_openlibs(L); - - lua_getglobal(L, "package"); // package - lua_getfield(L, -1, "path"); // package, package.path - -#ifdef _WIN32 - wchar_t dir[MAX_PATH]; - - GetCurrentDirectory(MAX_PATH, dir); - - lua_pushliteral(L, ";");// package, package.path, ";" - - PushString(L, dir); // package, package.path, ";", "!" - - lua_pushliteral(L, "/../../scripts/?.lua"); // package, package.path, ";", "!", "../../scripts/?.lua" - lua_concat(L, 4); // package, "PATH/scripts/?.lua" - lua_setfield(L, -2, "path");// package - lua_pop(L, 1); // (clear) -#else - // ??? -#endif - - lua_getglobal(L, "require");// require - - PushString(L, lpCmdLine); // require, path - - if (lua_pcall(L, 1, 0, 0)) printf("%s\n", lua_tostring(L, -1)); - - lua_close(L); - } - - else printf("Usage: enter a script name"); - - getc(stdin); - - return 0; -} - -/* -wchar_t * wzSecurityDescriptor = -L"D:" -L"(D;OICI;GA;;;BG)" // Deny access to built-in guests -L"(D;OICI;GA;;;AN)" // Deny access to anonymous logon -L"(D;OICI;GA;;;NS)" // Deny access to network service -L"(D;OICI;GA;;;NU)" // Deny access to network users -L"(A;OICI;GRGWGX;;;CO)" // Allow read/write/execute to -creator/owner -L"(A;OICI;GA;;;BA)"; // Allow full control to -administrators - -// Check this return code! -ConvertStringSecurityDescriptorToSecurityDescriptor( -wzSecurityDescriptor, -SDDL_REVISION_1, -&sa.lpSecurityDescriptor, // <-- sa = SECURITY_ATTRIBUTES -NULL -); -*/ - -/* -#include -#include -#include -#include - -#define BUFSIZE 512 - -int _tmain(int argc, TCHAR *argv[]) -{ - HANDLE hPipe; - LPTSTR lpszWrite = TEXT("Default message from client"); - TCHAR chReadBuf[BUFSIZE]; - BOOL fSuccess; - DWORD cbRead, dwMode; - LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe"); - - if( argc > 1) - { - lpszWrite = argv[1]; - } - - // Try to open a named pipe; wait for it, if necessary. - while (1) - { - hPipe = CreateFile( - lpszPipename, // pipe name - GENERIC_READ | // read and write access - GENERIC_WRITE, - 0, // no sharing - NULL, // default security attributes - OPEN_EXISTING, // opens existing pipe - 0, // default attributes - NULL); // no template file - - // Break if the pipe handle is valid. - if (hPipe != INVALID_HANDLE_VALUE) - break; - - // Exit if an error other than ERROR_PIPE_BUSY occurs. - if (GetLastError() != ERROR_PIPE_BUSY) - { - printf("Could not open pipe\n"); - return 0; - } - - // All pipe instances are busy, so wait for 20 seconds. - if (! WaitNamedPipe(lpszPipename, 20000) ) - { - printf("Could not open pipe\n"); - return 0; - } - } - - // The pipe connected; change to message-read mode. - dwMode = PIPE_READMODE_MESSAGE; - fSuccess = SetNamedPipeHandleState( - hPipe, // pipe handle - &dwMode, // new pipe mode - NULL, // don't set maximum bytes - NULL); // don't set maximum time - if (!fSuccess) - { - printf("SetNamedPipeHandleState failed.\n"); - return 0; - } - - // Send a message to the pipe server and read the response. - fSuccess = TransactNamedPipe( - hPipe, // pipe handle - lpszWrite, // message to server - (lstrlen(lpszWrite)+1)*sizeof(TCHAR), // message length - chReadBuf, // buffer to receive reply - BUFSIZE*sizeof(TCHAR), // size of read buffer - &cbRead, // bytes read - NULL); // not overlapped - - if (!fSuccess && (GetLastError() != ERROR_MORE_DATA)) - { - printf("TransactNamedPipe failed.\n"); - return 0; - } - - while(1) - { - _tprintf(TEXT("%s\n"), chReadBuf); - - // Break if TransactNamedPipe or ReadFile is successful - if(fSuccess) - break; - - // Read from the pipe if there is more data in the message. - fSuccess = ReadFile( - hPipe, // pipe handle - chReadBuf, // buffer to receive reply - BUFSIZE*sizeof(TCHAR), // size of buffer - &cbRead, // number of bytes read - NULL); // not overlapped - - // Exit if an error other than ERROR_MORE_DATA occurs. - if( !fSuccess && (GetLastError() != ERROR_MORE_DATA)) - break; - else _tprintf( TEXT("%s\n"), chReadBuf); - } - - _getch(); - - CloseHandle(hPipe); - - return 0; -} -*/ - -/* -#include -#include -#include -#include - -#define BUFSIZE 512 - -int _tmain(int argc, TCHAR *argv[]) -{ - LPTSTR lpszWrite = TEXT("Default message from client"); - TCHAR chReadBuf[BUFSIZE]; - BOOL fSuccess; - DWORD cbRead; - LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe"); - - if( argc > 1) - { - lpszWrite = argv[1]; - } - - fSuccess = CallNamedPipe( - lpszPipename, // pipe name - lpszWrite, // message to server - (lstrlen(lpszWrite)+1)*sizeof(TCHAR), // message length - chReadBuf, // buffer to receive reply - BUFSIZE*sizeof(TCHAR), // size of read buffer - &cbRead, // number of bytes read - 20000); // waits for 20 seconds - - if (fSuccess || GetLastError() == ERROR_MORE_DATA) - { - _tprintf( TEXT("%s\n"), chReadBuf ); - - // The pipe is closed; no more data can be read. - - if (! fSuccess) - { - printf("\nExtra data in message was lost\n"); - } - } - - _getch(); - - return 0; -} - -*/ - -/* -PIPE_ACCESS_DUPLEX (0x00000003) FILE_GENERIC_READ, FILE_GENERIC_WRITE, and SYNCHRONIZE -PIPE_ACCESS_INBOUND (0x00000001) FILE_GENERIC_READ and SYNCHRONIZE -PIPE_ACCESS_OUTBOUND (0x00000002) FILE_GENERIC_WRITE and SYNCHRONIZE -*/ - -/* -CreateProcess(NULL, lpszCommandLine, NULL, NULL, FALSE, - CREATE_NO_WINDOW, NULL, NULL, &si, &pi); - -STARTUPINFO si = { 0 }; - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); - si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); - si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - si.wShowWindow = SW_HIDE; -*/ - -/* -#include -#include -#include - -void _tmain( int argc, TCHAR *argv[] ) -{ - STARTUPINFO si; - PROCESS_INFORMATION pi; - - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - - if( argc != 2 ) - { - printf("Usage: %s [cmdline]\n", argv[0]); - return; - } - - // Start the child process. - if( !CreateProcess( NULL, // No module name (use command line) - argv[1], // Command line - NULL, // Process handle not inheritable - NULL, // Thread handle not inheritable - FALSE, // Set handle inheritance to FALSE - 0, // No creation flags - NULL, // Use parent's environment block - NULL, // Use parent's starting directory - &si, // Pointer to STARTUPINFO structure - &pi ) // Pointer to PROCESS_INFORMATION structure - ) - { - printf( "CreateProcess failed (%d).\n", GetLastError() ); - return; - } - - // Wait until child process exits. - WaitForSingleObject( pi.hProcess, INFINITE ); - - // Close process and thread handles. - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); -} -*/ diff --git a/scripts/lib/af_lib.lua b/lib/af_lib.lua similarity index 89% rename from scripts/lib/af_lib.lua rename to lib/af_lib.lua index 0441693..e8c5b5e 100644 --- a/scripts/lib/af_lib.lua +++ b/lib/af_lib.lua @@ -1,7 +1,7 @@ --- Library entry point. -- Modules -- -require("lib.impl.array") +require("impl.array") -- Exports -- local M = {} @@ -26,7 +26,7 @@ for _, v in ipairs{ "misc.program", "misc.imports" } do - require("lib." .. v).Add(M) + require(v).Add(M) end -- Export the module. diff --git a/scripts/lib/funcs/gfor.lua b/lib/funcs/gfor.lua similarity index 96% rename from scripts/lib/funcs/gfor.lua rename to lib/funcs/gfor.lua index 3e36fa7..a366a51 100644 --- a/scripts/lib/funcs/gfor.lua +++ b/lib/funcs/gfor.lua @@ -4,7 +4,7 @@ local assert = assert -- Modules -- -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local GetLib = array.GetLib diff --git a/scripts/lib/funcs/image.lua b/lib/funcs/image.lua similarity index 94% rename from scripts/lib/funcs/image.lua rename to lib/funcs/image.lua index 6b5171f..390d3e0 100644 --- a/scripts/lib/funcs/image.lua +++ b/lib/funcs/image.lua @@ -1,7 +1,7 @@ --- Image-related functions. -- Modules -- -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local CallWrap = array.CallWrap diff --git a/scripts/lib/funcs/io.lua b/lib/funcs/io.lua similarity index 96% rename from scripts/lib/funcs/io.lua rename to lib/funcs/io.lua index a3b095c..e5bdaae 100644 --- a/scripts/lib/funcs/io.lua +++ b/lib/funcs/io.lua @@ -2,7 +2,7 @@ -- Modules -- local af = require("arrayfire") -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local Call = array.Call diff --git a/scripts/lib/funcs/linear_algebra.lua b/lib/funcs/linear_algebra.lua similarity index 99% rename from scripts/lib/funcs/linear_algebra.lua rename to lib/funcs/linear_algebra.lua index 29eb5d1..5687ebc 100644 --- a/scripts/lib/funcs/linear_algebra.lua +++ b/lib/funcs/linear_algebra.lua @@ -2,7 +2,7 @@ -- Modules -- local af = require("arrayfire") -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local Call = array.Call diff --git a/scripts/lib/funcs/mathematics.lua b/lib/funcs/mathematics.lua similarity index 97% rename from scripts/lib/funcs/mathematics.lua rename to lib/funcs/mathematics.lua index cbb5ced..be2e5bf 100644 --- a/scripts/lib/funcs/mathematics.lua +++ b/lib/funcs/mathematics.lua @@ -2,7 +2,7 @@ -- Modules -- local af = require("arrayfire") -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local CallWrap = array.CallWrap diff --git a/scripts/lib/funcs/signal_processing.lua b/lib/funcs/signal_processing.lua similarity index 98% rename from scripts/lib/funcs/signal_processing.lua rename to lib/funcs/signal_processing.lua index d3d9391..0d2f2f2 100644 --- a/scripts/lib/funcs/signal_processing.lua +++ b/lib/funcs/signal_processing.lua @@ -5,7 +5,7 @@ local min = math.min -- Modules -- local af = require("arrayfire") -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local CallWrap = array.CallWrap diff --git a/scripts/lib/funcs/static.lua b/lib/funcs/static.lua similarity index 95% rename from scripts/lib/funcs/static.lua rename to lib/funcs/static.lua index f76c09d..50320fa 100644 --- a/scripts/lib/funcs/static.lua +++ b/lib/funcs/static.lua @@ -1,7 +1,7 @@ --- Static companions of array methods. -- Modules -- -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local Call = array.Call diff --git a/scripts/lib/funcs/statistics.lua b/lib/funcs/statistics.lua similarity index 95% rename from scripts/lib/funcs/statistics.lua rename to lib/funcs/statistics.lua index 4b0fd75..8b7ca6b 100644 --- a/scripts/lib/funcs/statistics.lua +++ b/lib/funcs/statistics.lua @@ -4,7 +4,7 @@ local type = type -- Modules -- -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local Call = array.Call diff --git a/scripts/lib/funcs/util.lua b/lib/funcs/util.lua similarity index 92% rename from scripts/lib/funcs/util.lua rename to lib/funcs/util.lua index 86fc1db..761018b 100644 --- a/scripts/lib/funcs/util.lua +++ b/lib/funcs/util.lua @@ -4,7 +4,7 @@ local print = print -- Modules -- -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local Call = array.Call diff --git a/scripts/lib/funcs/vector.lua b/lib/funcs/vector.lua similarity index 98% rename from scripts/lib/funcs/vector.lua rename to lib/funcs/vector.lua index 95d5c36..384fdf7 100644 --- a/scripts/lib/funcs/vector.lua +++ b/lib/funcs/vector.lua @@ -7,7 +7,7 @@ local select = select local type = type -- Modules -- -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local Call = array.Call diff --git a/scripts/lib/graphics/window.lua b/lib/graphics/window.lua similarity index 98% rename from scripts/lib/graphics/window.lua rename to lib/graphics/window.lua index 00e29f0..062ab45 100644 --- a/scripts/lib/graphics/window.lua +++ b/lib/graphics/window.lua @@ -7,7 +7,7 @@ local type = type -- Modules -- local af = require("arrayfire") -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local Call = array.Call diff --git a/scripts/lib/impl/array.lua b/lib/impl/array.lua similarity index 96% rename from scripts/lib/impl/array.lua rename to lib/impl/array.lua index 9cd3bb6..eaee0c2 100644 --- a/scripts/lib/impl/array.lua +++ b/lib/impl/array.lua @@ -150,7 +150,7 @@ local Lib --- DOCME function M.GetLib () - Lib = Lib or require("lib.af_lib") + Lib = Lib or require("af_lib") return Lib end @@ -291,11 +291,11 @@ end -- for _, v in ipairs{ - "lib.impl.ephemeral", - "lib.impl.operators", - "lib.impl.seq", -- depends on ephemeral - "lib.impl.index", -- depends on ephemeral, seq - "lib.methods.methods" + "impl.ephemeral", + "impl.operators", + "impl.seq", -- depends on ephemeral + "impl.index", -- depends on ephemeral, seq + "methods.methods" } do require(v).Add(M, ArrayMethodsAndMetatable) end diff --git a/scripts/lib/impl/ephemeral.lua b/lib/impl/ephemeral.lua similarity index 100% rename from scripts/lib/impl/ephemeral.lua rename to lib/impl/ephemeral.lua diff --git a/scripts/lib/impl/index.lua b/lib/impl/index.lua similarity index 100% rename from scripts/lib/impl/index.lua rename to lib/impl/index.lua diff --git a/scripts/lib/impl/operators.lua b/lib/impl/operators.lua similarity index 100% rename from scripts/lib/impl/operators.lua rename to lib/impl/operators.lua diff --git a/scripts/lib/impl/seq.lua b/lib/impl/seq.lua similarity index 100% rename from scripts/lib/impl/seq.lua rename to lib/impl/seq.lua diff --git a/scripts/lib/methods/constructors.lua b/lib/methods/constructors.lua similarity index 99% rename from scripts/lib/methods/constructors.lua rename to lib/methods/constructors.lua index fd4b16f..60a5e9a 100644 --- a/scripts/lib/methods/constructors.lua +++ b/lib/methods/constructors.lua @@ -9,7 +9,7 @@ local unpack = unpack -- Modules -- local af = require("arrayfire") -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local CallWrap = array.CallWrap diff --git a/scripts/lib/methods/device.lua b/lib/methods/device.lua similarity index 91% rename from scripts/lib/methods/device.lua rename to lib/methods/device.lua index b91af69..c888522 100644 --- a/scripts/lib/methods/device.lua +++ b/lib/methods/device.lua @@ -2,7 +2,7 @@ -- Modules -- local af = require("arrayfire") -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local Call = array.Call diff --git a/scripts/lib/methods/methods.lua b/lib/methods/methods.lua similarity index 96% rename from scripts/lib/methods/methods.lua rename to lib/methods/methods.lua index 654662b..a199e4a 100644 --- a/scripts/lib/methods/methods.lua +++ b/lib/methods/methods.lua @@ -65,7 +65,9 @@ function M.Add (array_module, meta) end, -- - elements = Wrap("get_elements"), + elements = function(arr) + return Call("af_get_elements", arr:get()) + end, -- eval = Wrap("eval"), diff --git a/scripts/lib/methods/move_reorder.lua b/lib/methods/move_reorder.lua similarity index 97% rename from scripts/lib/methods/move_reorder.lua rename to lib/methods/move_reorder.lua index daa3747..b79df71 100644 --- a/scripts/lib/methods/move_reorder.lua +++ b/lib/methods/move_reorder.lua @@ -5,7 +5,7 @@ local type = type -- Modules -- local af = require("arrayfire") -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local CallWrap = array.CallWrap diff --git a/scripts/lib/misc/env_loop.lua b/lib/misc/env_loop.lua similarity index 98% rename from scripts/lib/misc/env_loop.lua rename to lib/misc/env_loop.lua index 58c4d1a..8d5b658 100644 --- a/scripts/lib/misc/env_loop.lua +++ b/lib/misc/env_loop.lua @@ -4,7 +4,7 @@ local remove = table.remove -- Modules -- -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local CallWithEnvironment = array.CallWithEnvironment diff --git a/scripts/lib/misc/imports.lua b/lib/misc/imports.lua similarity index 90% rename from scripts/lib/misc/imports.lua rename to lib/misc/imports.lua index 7cd658e..459bd7c 100644 --- a/scripts/lib/misc/imports.lua +++ b/lib/misc/imports.lua @@ -1,7 +1,7 @@ --- Public imports from implementation functions. -- Modules -- -local array = require("lib.impl.array") +local array = require("impl.array") -- Exports -- local M = {} diff --git a/scripts/lib/misc/program.lua b/lib/misc/program.lua similarity index 99% rename from scripts/lib/misc/program.lua rename to lib/misc/program.lua index 46b9582..1f766f1 100644 --- a/scripts/lib/misc/program.lua +++ b/lib/misc/program.lua @@ -11,7 +11,7 @@ local select = select local tonumber = tonumber -- Modules -- -local array = require("lib.impl.array") +local array = require("impl.array") -- Imports -- local GetLib = array.GetLib diff --git a/src/Lua/arrayfire/arrayfire.vcxproj b/src/Lua/arrayfire/arrayfire.vcxproj index e88981d..b2a3ae5 100644 --- a/src/Lua/arrayfire/arrayfire.vcxproj +++ b/src/Lua/arrayfire/arrayfire.vcxproj @@ -97,7 +97,7 @@ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);afcpu.lib;lua.lib - $(AF_PATH)/include;$(SolutionDir)/lua + $(AF_PATH)/include;$(SolutionDir)../../lua _WINDLL;%(PreprocessorDefinitions);AFDLL @@ -107,7 +107,7 @@ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);afcpu.lib;lua.lib - $(AF_PATH)/include;$(SolutionDir)/lua + $(AF_PATH)/include;$(SolutionDir)../../lua _WINDLL;%(PreprocessorDefinitions);AFDLL diff --git a/ArrayFireWrapper.sln b/test/cpp/ArrayFireWrapper.sln similarity index 89% rename from ArrayFireWrapper.sln rename to test/cpp/ArrayFireWrapper.sln index e591dca..f52c9d3 100644 --- a/ArrayFireWrapper.sln +++ b/test/cpp/ArrayFireWrapper.sln @@ -5,12 +5,16 @@ VisualStudioVersion = 12.0.40629.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArrayFireWrapper", "ArrayFireWrapper\ArrayFireWrapper.vcxproj", "{758DF3FB-4744-4BD4-A108-50C6494589DD}" ProjectSection(ProjectDependencies) = postProject + {E60D023E-007C-4412-A508-893A5CE44F37} = {E60D023E-007C-4412-A508-893A5CE44F37} {4A89DAAC-5C9D-4309-92F0-44A3E36DB7AD} = {4A89DAAC-5C9D-4309-92F0-44A3E36DB7AD} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "lua\lua.vcxproj", "{4A89DAAC-5C9D-4309-92F0-44A3E36DB7AD}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "..\..\lua\lua.vcxproj", "{4A89DAAC-5C9D-4309-92F0-44A3E36DB7AD}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "arrayfire", "src\Lua\arrayfire\arrayfire.vcxproj", "{E60D023E-007C-4412-A508-893A5CE44F37}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "arrayfire", "..\..\src\Lua\arrayfire\arrayfire.vcxproj", "{E60D023E-007C-4412-A508-893A5CE44F37}" + ProjectSection(ProjectDependencies) = postProject + {4A89DAAC-5C9D-4309-92F0-44A3E36DB7AD} = {4A89DAAC-5C9D-4309-92F0-44A3E36DB7AD} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/test/cpp/ArrayFireWrapper/ArrayFireWrapper.cpp b/test/cpp/ArrayFireWrapper/ArrayFireWrapper.cpp new file mode 100644 index 0000000..a9f21d3 --- /dev/null +++ b/test/cpp/ArrayFireWrapper/ArrayFireWrapper.cpp @@ -0,0 +1,176 @@ +// ArrayFireWrapper.cpp : Defines the entry point for the application. +// + +#include "stdafx.h" + +extern "C" { + #include + #include + #include +} + +#include +#include +#include +#include +#include +#include + +#ifdef _WIN32 +// http://www.cplusplus.com/forum/windows/58206/ +void RedirectIOToConsole() +{ + int hConHandle; + long lStdHandle; + CONSOLE_SCREEN_BUFFER_INFO coninfo; + FILE *fp; + +// allocate a console for this app + AllocConsole(); + +// set the screen buffer to be big enough to let us scroll text + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),&coninfo); + coninfo.dwSize.Y = 20; + SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),coninfo.dwSize); + +// redirect unbuffered STDOUT to the console + lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + + fp = _fdopen( hConHandle, "w" ); + + *stdout = *fp; + + setvbuf( stdout, NULL, _IONBF, 0 ); + +// redirect unbuffered STDIN to the console + + lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + + fp = _fdopen( hConHandle, "r" ); + *stdin = *fp; + setvbuf( stdin, NULL, _IONBF, 0 ); + +// redirect unbuffered STDERR to the console + lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + + fp = _fdopen( hConHandle, "w" ); + + *stderr = *fp; + + setvbuf( stderr, NULL, _IONBF, 0 ); + +// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog +// point to console as well + std::ios::sync_with_stdio(); +} + +void PushString (lua_State * L, LPTSTR str) +{ + char mbstr[MAX_PATH]; + + size_t n; + + wcstombs_s(&n, mbstr, str, MAX_PATH); + + lua_pushstring(L, mbstr); // ..., str +} + +// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773748(v=vs.85).aspx +void path_strip_filename(TCHAR *Path) { + size_t Len = _tcslen(Path); + if (Len==0) {return;}; + size_t Idx = Len-1; + while (TRUE) { + TCHAR Chr = Path[Idx]; + if (Chr==TEXT('\\')||Chr==TEXT('/')) { + if (Idx==0||Path[Idx-1]==':') {Idx++;}; + break; + } else if (Chr==TEXT(':')) { + Idx++; break; + } else { + if (Idx==0) {break;} else {Idx--;}; + }; + }; + Path[Idx] = TEXT('\0'); +}; +#endif + +#ifdef _WIN32 +int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ LPTSTR lpCmdLine, + _In_ int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + + RedirectIOToConsole(); +#endif + + // TODO: Restructure this as a loop, allow IO via pipe or whatever as alternative (when a process) + // Want persistent, probably, to facilitate communication +#ifdef _WIN32 + if (_tcslen(lpCmdLine) > 0) +#endif + { + lua_State * L = luaL_newstate(); + + luaL_openlibs(L); + + lua_getglobal(L, "package"); // package + lua_getfield(L, -1, "path"); // package, package.path + +#ifdef _WIN32 + wchar_t dir[MAX_PATH]; + + GetCurrentDirectory(MAX_PATH, dir); + + size_t name_len = wcslen(L"cpp"); + + while (true) + { + size_t len = wcslen(dir); + + if (len < name_len) break; + if (wcscmp(dir + len - name_len, L"cpp") == 0) break; + + path_strip_filename(dir); + } + wprintf(L"DIR: %s\n", dir); +#endif + int n = 0; + + for (const char * name : { "/../../lib/?.lua", "/../lua/?.lua" }) + { + lua_pushliteral(L, ";");// package, package.path, ..., ";" +#ifdef _WIN32 + PushString(L, dir); // package, package.path, ..., ";", "!" +#endif + lua_pushstring(L, name); // package, package.path, ..., ";", "!", name + + n += 3; + } + + lua_concat(L, n + 1); // package, "PATH/*.lua" + lua_setfield(L, -2, "path");// package + lua_pop(L, 1); // (clear) + + // ??? + + lua_getglobal(L, "require");// require +#ifdef _WIN32 + PushString(L, lpCmdLine); // require, path +#endif + if (lua_pcall(L, 1, 0, 0)) printf("%s\n", lua_tostring(L, -1)); + + lua_close(L); + } + + else printf("Usage: enter a script name"); + + getc(stdin); + + return 0; +} diff --git a/ArrayFireWrapper/ArrayFireWrapper.ico b/test/cpp/ArrayFireWrapper/ArrayFireWrapper.ico similarity index 100% rename from ArrayFireWrapper/ArrayFireWrapper.ico rename to test/cpp/ArrayFireWrapper/ArrayFireWrapper.ico diff --git a/ArrayFireWrapper/ArrayFireWrapper.vcxproj b/test/cpp/ArrayFireWrapper/ArrayFireWrapper.vcxproj similarity index 97% rename from ArrayFireWrapper/ArrayFireWrapper.vcxproj rename to test/cpp/ArrayFireWrapper/ArrayFireWrapper.vcxproj index ba07c92..3bcd32a 100644 --- a/ArrayFireWrapper/ArrayFireWrapper.vcxproj +++ b/test/cpp/ArrayFireWrapper/ArrayFireWrapper.vcxproj @@ -98,7 +98,7 @@ Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(AF_PATH)/include;$(SolutionDir)/lua + $(AF_PATH)/include;$(SolutionDir)../../lua Windows @@ -133,7 +133,7 @@ true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(AF_PATH)/include;$(SolutionDir)/lua + $(AF_PATH)/include;$(SolutionDir)../../lua Windows @@ -160,11 +160,6 @@ Create - - - {4a89daac-5c9d-4309-92f0-44a3e36db7ad} - - diff --git a/ArrayFireWrapper/ArrayFireWrapper.vcxproj.filters b/test/cpp/ArrayFireWrapper/ArrayFireWrapper.vcxproj.filters similarity index 100% rename from ArrayFireWrapper/ArrayFireWrapper.vcxproj.filters rename to test/cpp/ArrayFireWrapper/ArrayFireWrapper.vcxproj.filters diff --git a/ArrayFireWrapper/ReadMe.txt b/test/cpp/ArrayFireWrapper/ReadMe.txt similarity index 100% rename from ArrayFireWrapper/ReadMe.txt rename to test/cpp/ArrayFireWrapper/ReadMe.txt diff --git a/ArrayFireWrapper/small.ico b/test/cpp/ArrayFireWrapper/small.ico similarity index 100% rename from ArrayFireWrapper/small.ico rename to test/cpp/ArrayFireWrapper/small.ico diff --git a/ArrayFireWrapper/stdafx.cpp b/test/cpp/ArrayFireWrapper/stdafx.cpp similarity index 100% rename from ArrayFireWrapper/stdafx.cpp rename to test/cpp/ArrayFireWrapper/stdafx.cpp diff --git a/ArrayFireWrapper/stdafx.h b/test/cpp/ArrayFireWrapper/stdafx.h similarity index 100% rename from ArrayFireWrapper/stdafx.h rename to test/cpp/ArrayFireWrapper/stdafx.h diff --git a/ArrayFireWrapper/targetver.h b/test/cpp/ArrayFireWrapper/targetver.h similarity index 100% rename from ArrayFireWrapper/targetver.h rename to test/cpp/ArrayFireWrapper/targetver.h diff --git a/scripts/tests/benchmarks/blas.lua b/test/lua/benchmarks/blas.lua similarity index 97% rename from scripts/tests/benchmarks/blas.lua rename to test/lua/benchmarks/blas.lua index b8d38f7..23faa41 100644 --- a/scripts/tests/benchmarks/blas.lua +++ b/test/lua/benchmarks/blas.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") -- create a small wrapper to benchmark local A -- populated before each timing diff --git a/scripts/tests/benchmarks/fft.lua b/test/lua/benchmarks/fft.lua similarity index 96% rename from scripts/tests/benchmarks/fft.lua rename to test/lua/benchmarks/fft.lua index 3291118..c7535fc 100644 --- a/scripts/tests/benchmarks/fft.lua +++ b/test/lua/benchmarks/fft.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") -- create a small wrapper to benchmark local A -- populated before each timing diff --git a/scripts/tests/benchmarks/pi.lua b/test/lua/benchmarks/pi.lua similarity index 96% rename from scripts/tests/benchmarks/pi.lua rename to test/lua/benchmarks/pi.lua index 9f954bc..d972773 100644 --- a/scripts/tests/benchmarks/pi.lua +++ b/test/lua/benchmarks/pi.lua @@ -19,7 +19,7 @@ local random = math.random local sqrt = math.sqrt -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") -- generate millions of random samples local samples = 20e6 @@ -47,7 +47,7 @@ local function pi_host () return 4.0 * count / samples end -lib.main(function() +AF.main(function() AF.printf("device: %.5f seconds to estimate pi = %.5f", AF.timeit(pi_device), pi_device()) -- Lua fine with original signature AF.printf(" host: %.5f seconds to estimate pi = %.5f", AF.timeit(pi_host), pi_host()) end) \ No newline at end of file diff --git a/scripts/tests/computer_vision/fast.lua b/test/lua/computer_vision/fast.lua similarity index 100% rename from scripts/tests/computer_vision/fast.lua rename to test/lua/computer_vision/fast.lua diff --git a/scripts/tests/computer_vision/harris.lua b/test/lua/computer_vision/harris.lua similarity index 100% rename from scripts/tests/computer_vision/harris.lua rename to test/lua/computer_vision/harris.lua diff --git a/scripts/tests/computer_vision/matching.lua b/test/lua/computer_vision/matching.lua similarity index 100% rename from scripts/tests/computer_vision/matching.lua rename to test/lua/computer_vision/matching.lua diff --git a/scripts/tests/computer_vision/susan.lua b/test/lua/computer_vision/susan.lua similarity index 100% rename from scripts/tests/computer_vision/susan.lua rename to test/lua/computer_vision/susan.lua diff --git a/scripts/tests/financial/black_scholes_options.lua b/test/lua/financial/black_scholes_options.lua similarity index 96% rename from scripts/tests/financial/black_scholes_options.lua rename to test/lua/financial/black_scholes_options.lua index 431fd59..54a5c98 100644 --- a/scripts/tests/financial/black_scholes_options.lua +++ b/test/lua/financial/black_scholes_options.lua @@ -10,8 +10,8 @@ ]] -- Modules -- -local input = require("tests.financial.input") -local AF = require("lib.af_lib") +local input = require("financial.input") +local AF = require("af_lib") -- -- local sqrt2 = math.sqrt(2) diff --git a/scripts/tests/financial/heston_model.lua b/test/lua/financial/heston_model.lua similarity index 79% rename from scripts/tests/financial/heston_model.lua rename to test/lua/financial/heston_model.lua index 2db571e..dd308b6 100644 --- a/scripts/tests/financial/heston_model.lua +++ b/test/lua/financial/heston_model.lua @@ -36,31 +36,35 @@ local exp = math.exp local sqrt = math.sqrt -- Modules -- -local lib = require("lib.af_lib") +local AF = require("af_lib") + +print("") +print("N.B. THIS IS A WIP") +print("") local function simulateHestonModel (T, N, R, mu, kappa, vBar, sigmaV, rho, x0, v0) local deltaT = T / (N - 1) - local x = {lib.constant(x0, R), lib.constant(0, R)} - local v = {lib.constant(v0, R), lib.constant(0, R)} + local x = {AF.constant(x0, R), AF.constant(0, R)} + local v = {AF.constant(v0, R), AF.constant(0, R)} local sqrtDeltaT = sqrt(deltaT) local sqrtOneMinusRhoSquare = sqrt(1 - rho*rho) local mArray = {rho, sqrtOneMinusRhoSquare} - local m = lib.array(2, 1, mArray); + local m = AF.array(2, 1, mArray); local tPrevious, tCurrent = 0, 0 - local zeroConstant = lib.constant(0, R) + local zeroConstant = AF.constant(0, R) for t = 1, N - 1 do -- LoopN tPrevious = (t+1) % 2 tCurrent = t % 2 - local dBt = lib.randn(R, 2) * sqrtDeltaT - local sqrtVLag = lib.sqrt(v[tPrevious]) + local dBt = AF.randn(R, 2) * sqrtDeltaT + local sqrtVLag = AF.sqrt(v[tPrevious]) -- x[tCurrent + 1] = x[tPrevious + 1] + (mu - 0.5 * v[tPrevious + 1]) * deltaT + (sqrtVLag * dBt(span, 0)) - local vTmp = v[tPrevious + 1] + kappa * (vBar - v[tPrevious + 1]) * deltaT + sigmaV * (sqrtVLag * lib.matmul(dBt, m)) - v[tCurrent + 1] = af::max(vTmp, zeroConstant) + local vTmp = v[tPrevious + 1] + kappa * (vBar - v[tPrevious + 1]) * deltaT + sigmaV * (sqrtVLag * AF.matmul(dBt, m)) + v[tCurrent + 1] = AF.max(vTmp, zeroConstant) end return x[tCurrent + 1], v[tCurrent + 1] end -lib.main(function() +AF.main(function() local T = 1 local nT = 10 * T local R_first_run = 1000 @@ -76,13 +80,13 @@ lib.main(function() -- Price European call option -- first run simulateHestonModel(T, nT, R_first_run, r, kappa, vBar, sigmaV, rho, x0, v0) -- CallInEnv - lib.sync() -- Ensure the first run is finished - lib.timer_start() + AF.sync() -- Ensure the first run is finished + AF.timer_start() local x, _ = simulateHestonModel(T, nT, R, r, kappa, vBar, sigmaV, rho, x0, v0) -- ditto - lib.sync() - print("Time in simulation: " .. lib.timer_stop()) - local K = lib.exp(lib.constant(k, x:dims())) - local zeroConstant = lib.constant(0, x:dims()) - local C_CPU = exp(-r * T) * lib.mean(lib.max(lib.exp(x) - K, zeroConstant)) - lib.print("C_CPU", C_CPU) + AF.sync() + print("Time in simulation: " .. AF.timer_stop()) + local K = AF.exp(AF.constant(k, x:dims())) + local zeroConstant = AF.constant(0, x:dims()) + local C_CPU = exp(-r * T) * AF.mean(AF.max(AF.exp(x) - K, zeroConstant)) + AF.print("C_CPU", C_CPU) end) \ No newline at end of file diff --git a/scripts/tests/financial/input.lua b/test/lua/financial/input.lua similarity index 100% rename from scripts/tests/financial/input.lua rename to test/lua/financial/input.lua diff --git a/scripts/tests/financial/monte_carlo_options.lua b/test/lua/financial/monte_carlo_options.lua similarity index 98% rename from scripts/tests/financial/monte_carlo_options.lua rename to test/lua/financial/monte_carlo_options.lua index cc7b688..e1cfe81 100644 --- a/scripts/tests/financial/monte_carlo_options.lua +++ b/test/lua/financial/monte_carlo_options.lua @@ -14,7 +14,7 @@ local exp = math.exp local sqrt = math.sqrt -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") -- Shorthands -- local Comp, WC = AF.CompareResult, AF.WrapConstant diff --git a/scripts/tests/getting_started/convolve.lua b/test/lua/getting_started/convolve.lua similarity index 97% rename from scripts/tests/getting_started/convolve.lua rename to test/lua/getting_started/convolve.lua index 8f5ede3..45f4664 100644 --- a/scripts/tests/getting_started/convolve.lua +++ b/test/lua/getting_started/convolve.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local lib = require("lib.af_lib") +local lib = require("af_lib") lib.main(function() -- 5x5 derivative with separable kernels diff --git a/scripts/tests/getting_started/integer.lua b/test/lua/getting_started/integer.lua similarity index 95% rename from scripts/tests/getting_started/integer.lua rename to test/lua/getting_started/integer.lua index 0b92265..be824bb 100644 --- a/scripts/tests/getting_started/integer.lua +++ b/test/lua/getting_started/integer.lua @@ -10,7 +10,11 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") + +print("") +print("N.B. THIS IS A WIP") +print("") AF.main(function() print("\n=== ArrayFire signed(s32) / unsigned(u32) Integer Example ===") diff --git a/scripts/tests/getting_started/rainfall.lua b/test/lua/getting_started/rainfall.lua similarity index 96% rename from scripts/tests/getting_started/rainfall.lua rename to test/lua/getting_started/rainfall.lua index cb9627f..40a4c0e 100644 --- a/scripts/tests/getting_started/rainfall.lua +++ b/test/lua/getting_started/rainfall.lua @@ -8,7 +8,11 @@ * http://arrayfire.com/licenses/BSD-3-Clause ********************************************************/ ]] - + +print("") +print("N.B. THIS IS A WIP") +print("") + -- Investigate rainfall measurements across sites and days -- demonstrating various simple tasks -- Compute various values: @@ -21,7 +25,7 @@ -- note: example adapted from -- "Rapid Problem Solving Using Thrust", Nathan Bell, NVIDIA -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") -- Shorthands -- local Comp, WC = AF.CompareResult, AF.WrapConstant diff --git a/scripts/tests/getting_started/vectorize.lua b/test/lua/getting_started/vectorize.lua similarity index 100% rename from scripts/tests/getting_started/vectorize.lua rename to test/lua/getting_started/vectorize.lua diff --git a/scripts/tests/graphics/conway.lua b/test/lua/graphics/conway.lua similarity index 98% rename from scripts/tests/graphics/conway.lua rename to test/lua/graphics/conway.lua index 284cb67..b0fe934 100644 --- a/scripts/tests/graphics/conway.lua +++ b/test/lua/graphics/conway.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") -- Shorthands -- local Comp, WC = AF.CompareResult, AF.WrapConstant diff --git a/scripts/tests/graphics/conway_pretty.lua b/test/lua/graphics/conway_pretty.lua similarity index 99% rename from scripts/tests/graphics/conway_pretty.lua rename to test/lua/graphics/conway_pretty.lua index 8a01341..0416ca7 100644 --- a/scripts/tests/graphics/conway_pretty.lua +++ b/test/lua/graphics/conway_pretty.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") -- Shorthands -- local Comp, WC = AF.CompareResult, AF.WrapConstant diff --git a/scripts/tests/graphics/fractal.lua b/test/lua/graphics/fractal.lua similarity index 98% rename from scripts/tests/graphics/fractal.lua rename to test/lua/graphics/fractal.lua index aef9ee3..8f7ae40 100644 --- a/scripts/tests/graphics/fractal.lua +++ b/test/lua/graphics/fractal.lua @@ -14,7 +14,7 @@ local abs = math.abs local sqrt = math.sqrt -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") -- Shorthands -- local Comp, WC = AF.CompareResult, AF.WrapConstant diff --git a/scripts/tests/graphics/histogram.lua b/test/lua/graphics/histogram.lua similarity index 95% rename from scripts/tests/graphics/histogram.lua rename to test/lua/graphics/histogram.lua index 91d492a..bdbaa60 100644 --- a/scripts/tests/graphics/histogram.lua +++ b/test/lua/graphics/histogram.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") AF.main(function() local myWindow = AF.Window(512, 512, "Histogram example using ArrayFire") diff --git a/scripts/tests/graphics/plot2d.lua b/test/lua/graphics/plot2d.lua similarity index 96% rename from scripts/tests/graphics/plot2d.lua rename to test/lua/graphics/plot2d.lua index cd6f9df..191ce85 100644 --- a/scripts/tests/graphics/plot2d.lua +++ b/test/lua/graphics/plot2d.lua @@ -13,7 +13,7 @@ local pi = math.pi -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") -- local ITERATIONS = 100 diff --git a/scripts/tests/graphics/plot3d.lua b/test/lua/graphics/plot3d.lua similarity index 96% rename from scripts/tests/graphics/plot3d.lua rename to test/lua/graphics/plot3d.lua index 6c02846..7529857 100644 --- a/scripts/tests/graphics/plot3d.lua +++ b/test/lua/graphics/plot3d.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") local ITERATIONS = 200 local PRECISION = 1.0/ITERATIONS diff --git a/scripts/tests/graphics/surface.lua b/test/lua/graphics/surface.lua similarity index 90% rename from scripts/tests/graphics/surface.lua rename to test/lua/graphics/surface.lua index bc69752..54d39a0 100644 --- a/scripts/tests/graphics/surface.lua +++ b/test/lua/graphics/surface.lua @@ -10,9 +10,13 @@ ]] -- Modules -- -local lib = require("lib.af_lib") +local AF = require("af_lib") -lib.main(function() +print("") +print("N.B. THIS IS A WIP") +print("") + +AF.main(function() --[[ static const int ITERATIONS = 30; static const float PRECISION = 1.0f/ITERATIONS; diff --git a/scripts/tests/helloworld/helloworld.lua b/test/lua/helloworld/helloworld.lua similarity index 97% rename from scripts/tests/helloworld/helloworld.lua rename to test/lua/helloworld/helloworld.lua index cdc6de0..5d5ea54 100644 --- a/scripts/tests/helloworld/helloworld.lua +++ b/test/lua/helloworld/helloworld.lua @@ -10,7 +10,7 @@ --]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") AF.main(function() print("Create a 5-by-3 matrix of random floats on the GPU") diff --git a/scripts/tests/image_processing/adaptive_thresholding.lua b/test/lua/image_processing/adaptive_thresholding.lua similarity index 100% rename from scripts/tests/image_processing/adaptive_thresholding.lua rename to test/lua/image_processing/adaptive_thresholding.lua diff --git a/scripts/tests/image_processing/binary_thresholding.lua b/test/lua/image_processing/binary_thresholding.lua similarity index 100% rename from scripts/tests/image_processing/binary_thresholding.lua rename to test/lua/image_processing/binary_thresholding.lua diff --git a/scripts/tests/image_processing/brain_segmentation.lua b/test/lua/image_processing/brain_segmentation.lua similarity index 100% rename from scripts/tests/image_processing/brain_segmentation.lua rename to test/lua/image_processing/brain_segmentation.lua diff --git a/scripts/tests/image_processing/edge.lua b/test/lua/image_processing/edge.lua similarity index 100% rename from scripts/tests/image_processing/edge.lua rename to test/lua/image_processing/edge.lua diff --git a/scripts/tests/image_processing/filters.lua b/test/lua/image_processing/filters.lua similarity index 100% rename from scripts/tests/image_processing/filters.lua rename to test/lua/image_processing/filters.lua diff --git a/scripts/tests/image_processing/image_demo.lua b/test/lua/image_processing/image_demo.lua similarity index 100% rename from scripts/tests/image_processing/image_demo.lua rename to test/lua/image_processing/image_demo.lua diff --git a/scripts/tests/image_processing/image_editing.lua b/test/lua/image_processing/image_editing.lua similarity index 100% rename from scripts/tests/image_processing/image_editing.lua rename to test/lua/image_processing/image_editing.lua diff --git a/scripts/tests/image_processing/morphing.lua b/test/lua/image_processing/morphing.lua similarity index 100% rename from scripts/tests/image_processing/morphing.lua rename to test/lua/image_processing/morphing.lua diff --git a/scripts/tests/image_processing/optical_flow.lua b/test/lua/image_processing/optical_flow.lua similarity index 100% rename from scripts/tests/image_processing/optical_flow.lua rename to test/lua/image_processing/optical_flow.lua diff --git a/scripts/tests/image_processing/pyramids.lua b/test/lua/image_processing/pyramids.lua similarity index 100% rename from scripts/tests/image_processing/pyramids.lua rename to test/lua/image_processing/pyramids.lua diff --git a/scripts/tests/lin_algebra/cholesky.lua b/test/lua/lin_algebra/cholesky.lua similarity index 96% rename from scripts/tests/lin_algebra/cholesky.lua rename to test/lua/lin_algebra/cholesky.lua index 2401f3c..2c1a656 100644 --- a/scripts/tests/lin_algebra/cholesky.lua +++ b/test/lua/lin_algebra/cholesky.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") AF.main(function() local n = 5 diff --git a/scripts/tests/lin_algebra/lu.lua b/test/lua/lin_algebra/lu.lua similarity index 96% rename from scripts/tests/lin_algebra/lu.lua rename to test/lua/lin_algebra/lu.lua index 79b0d54..1f610ad 100644 --- a/scripts/tests/lin_algebra/lu.lua +++ b/test/lua/lin_algebra/lu.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") AF.main(function() local in_arr = AF.randu(5, 8) diff --git a/scripts/tests/lin_algebra/qr.lua b/test/lua/lin_algebra/qr.lua similarity index 95% rename from scripts/tests/lin_algebra/qr.lua rename to test/lua/lin_algebra/qr.lua index 375f299..ebeffb3 100644 --- a/scripts/tests/lin_algebra/qr.lua +++ b/test/lua/lin_algebra/qr.lua @@ -10,7 +10,7 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") AF.main(function() print("Running QR InPlace") diff --git a/scripts/tests/lin_algebra/svd.lua b/test/lua/lin_algebra/svd.lua similarity index 91% rename from scripts/tests/lin_algebra/svd.lua rename to test/lua/lin_algebra/svd.lua index aa99047..9fd254a 100644 --- a/scripts/tests/lin_algebra/svd.lua +++ b/test/lua/lin_algebra/svd.lua @@ -10,7 +10,11 @@ ]] -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") + +print("") +print("N.B. THIS IS A WIP") +print("") AF.main(function() local h_buffer = {1, 4, 2, 5, 3, 6 } -- host array diff --git a/scripts/tests/machine_learning/bagging.lua b/test/lua/machine_learning/bagging.lua similarity index 100% rename from scripts/tests/machine_learning/bagging.lua rename to test/lua/machine_learning/bagging.lua diff --git a/scripts/tests/machine_learning/deep_belief_net.lua b/test/lua/machine_learning/deep_belief_net.lua similarity index 100% rename from scripts/tests/machine_learning/deep_belief_net.lua rename to test/lua/machine_learning/deep_belief_net.lua diff --git a/scripts/tests/machine_learning/kmeans.lua b/test/lua/machine_learning/kmeans.lua similarity index 100% rename from scripts/tests/machine_learning/kmeans.lua rename to test/lua/machine_learning/kmeans.lua diff --git a/scripts/tests/machine_learning/knn.lua b/test/lua/machine_learning/knn.lua similarity index 100% rename from scripts/tests/machine_learning/knn.lua rename to test/lua/machine_learning/knn.lua diff --git a/scripts/tests/machine_learning/logistic_regression.lua b/test/lua/machine_learning/logistic_regression.lua similarity index 100% rename from scripts/tests/machine_learning/logistic_regression.lua rename to test/lua/machine_learning/logistic_regression.lua diff --git a/scripts/tests/machine_learning/naive_bayes.lua b/test/lua/machine_learning/naive_bayes.lua similarity index 100% rename from scripts/tests/machine_learning/naive_bayes.lua rename to test/lua/machine_learning/naive_bayes.lua diff --git a/scripts/tests/machine_learning/neural_network.lua b/test/lua/machine_learning/neural_network.lua similarity index 100% rename from scripts/tests/machine_learning/neural_network.lua rename to test/lua/machine_learning/neural_network.lua diff --git a/scripts/tests/machine_learning/perceptron.lua b/test/lua/machine_learning/perceptron.lua similarity index 100% rename from scripts/tests/machine_learning/perceptron.lua rename to test/lua/machine_learning/perceptron.lua diff --git a/scripts/tests/machine_learning/rbm.lua b/test/lua/machine_learning/rbm.lua similarity index 100% rename from scripts/tests/machine_learning/rbm.lua rename to test/lua/machine_learning/rbm.lua diff --git a/scripts/tests/machine_learning/softmax_regression.lua b/test/lua/machine_learning/softmax_regression.lua similarity index 100% rename from scripts/tests/machine_learning/softmax_regression.lua rename to test/lua/machine_learning/softmax_regression.lua diff --git a/scripts/tests/pde/swe.lua b/test/lua/pde/swe.lua similarity index 98% rename from scripts/tests/pde/swe.lua rename to test/lua/pde/swe.lua index 47d5a6e..848bc9c 100644 --- a/scripts/tests/pde/swe.lua +++ b/test/lua/pde/swe.lua @@ -2,7 +2,7 @@ local floor = math.floor -- Modules -- -local AF = require("lib.af_lib") +local AF = require("af_lib") AF.main(function(argc, arv) local win diff --git a/scripts/tests/test1.lua b/test/lua/test1.lua similarity index 100% rename from scripts/tests/test1.lua rename to test/lua/test1.lua diff --git a/scripts/tests/unified/basic.lua b/test/lua/unified/basic.lua similarity index 100% rename from scripts/tests/unified/basic.lua rename to test/lua/unified/basic.lua