Exemplo n.º 1
0
import time
import numpy as np

t = time.time()
from mpi4py import MPI
import kokkos.gpu.core as kokkos

comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()

kokkos.start(rank)
t = time.time() - t

print("Kokkos init time: ", t, flush=True)

n_local = 1000000000
N = size * n_local

itemsize = MPI.DOUBLE.Get_size()
if rank == 0:
    nbytes = N * itemsize
else:
    nbytes = 0

t = time.time()
#Create shared block
win = MPI.Win.Allocate_shared(nbytes, itemsize, comm=comm)
#Create numpy array in shared memory
buf, itemsize = win.Shared_query(0)
assert itemsize == MPI.DOUBLE.Get_size()
Exemplo n.º 2
0
import time

if __name__ == '__main__':
    #time.sleep(20)  #To give me enough time to attach strace
    m = 2

    def thing(i):
        n = 100000
        array = np.arange(1, n + 1, dtype='float64')
        result = kokkos.reduction(array, i)
        return result

    for i in range(m):
        multiload_contexts[i].load_stub_library("cuda")
        multiload_contexts[i].load_stub_library("cudart")
        with multiload_contexts[i]:
            a = 1
            import numpy as np
            import kokkos.gpu.core as kokkos
            kokkos.start(i)

    for i in range(m):
        with multiload_contexts[i]:
            ctx = thing(i)
        print(i, ctx)

    for i in range(m):
        with multiload_contexts[i]:
            b = 1
            kokkos.end()
Exemplo n.º 3
0
parser.add_argument('-trials',
                    metavar='trials',
                    type=int,
                    help="Number of warmup runs")
args = parser.parse_args()

if __name__ == '__main__':

    m = args.m
    n_local = 10000**2
    N = m * n_local

    t = time.time()
    import numpy as np
    import kokkos.gpu.core as kokkos
    kokkos.start(m)
    t = time.time() - t
    print("Initilize time: ", t, flush=True)

    t = time.time()
    array = np.arange(1, N + 1, dtype='float64')
    result = np.zeros(m, dtype='float64')
    t = time.time() - t
    print("Initilize array time: ", t, flush=True)

    def reduction(array, i):

        p = kokkos.dev_copy(array, (int)(np.sqrt(len(array))), i)
        result = kokkos.reduction(p, (int)(np.sqrt(len(array))), i)

    times = []
Exemplo n.º 4
0
import numpy as np
import kokkos.gpu.core as kokkos

"Test of Kokkos Wrapper"

n = 1000000
a = np.arange(1, n + 1, dtype='float64')
kokkos.start(0)
result = kokkos.reduction(a)
print(result)
kokkos.end()