A metatable can be defined like
local t = setmetatable({}, {
__tostring = function() return 'custom tostring behavior!' end
})
Here are the metamethods that you can define, and their behavior
#include <new> | |
#include <vector> | |
#include <iostream> | |
#pragma omp declare target | |
// polymorphic Abstract Base Class | |
class Base { | |
public: | |
virtual double doOne(double x) = 0; // do something interesting | |
virtual Base* getDevPtr() = 0; // get a device pointer to device shadow instance of class |
#!/usr/bin/env python | |
""" | |
Demo of how to pass GPU memory managed by pycuda to mpi4py. | |
Notes | |
----- | |
This code can be used to perform peer-to-peer communication of data via | |
NVIDIA's GPUDirect technology if mpi4py has been built against a | |
CUDA-enabled MPI implementation. |
-- split a string | |
function string:split(delimiter) | |
local result = { } | |
local from = 1 | |
local delim_from, delim_to = string.find( self, delimiter, from ) | |
while delim_from do | |
table.insert( result, string.sub( self, from , delim_from-1 ) ) | |
from = delim_to + 1 | |
delim_from, delim_to = string.find( self, delimiter, from ) | |
end |