Exemplo n.º 1
0
import os, sys
#os.environ['PYOPENCL_CTX']='0:1'
#os.environ['PYOPENCL_COMPILER_OUTPUT'] = '0'
#os.environ['CUDA_PROFILE'] = '1'
import chroma.api as api
#api.use_opencl()
api.use_cuda()
from unittest_find import unittest
import numpy as np
from chroma.sim import Simulation
from chroma.event import Photons
import chroma.event as event
from chroma.uboone.uboonedet import ubooneDet
from chroma.gpu.photon import GPUPhotons

try:
    import ROOT as rt
    from rootpy.tree import Tree, TreeModel, FloatCol, IntCol
    from rootpy.io import root_open
    has_root = True
except:
    has_root = False
    raise ValueError("No ROOT")

if has_root:

    class PhotonData(TreeModel):
        end_x = FloatCol()
        end_y = FloatCol()
        end_z = FloatCol()
        reflect_diffuse = IntCol()
Exemplo n.º 2
0
import os
import numpy as np
import chroma.api as gpuapi
gpuapi.use_cuda()
from pycuda import autoinit
from pycuda.compiler import SourceModule
import pycuda.driver as cuda
from pycuda import gpuarray

float3 = gpuarray.vec.float3

print 'device %s' % autoinit.device.name()

current_directory = os.path.split(os.path.realpath(__file__))[0]
from chroma.cuda import srcdir as source_directory

source = open(current_directory + '/linalg_test.cu').read()

mod = SourceModule(source,
                   options=['-I' + source_directory],
                   no_extern_c=True,
                   cache_dir=False)

float3add = mod.get_function('float3add')
float3addequal = mod.get_function('float3addequal')
float3sub = mod.get_function('float3sub')
float3subequal = mod.get_function('float3subequal')
float3addfloat = mod.get_function('float3addfloat')
float3addfloatequal = mod.get_function('float3addfloatequal')
floataddfloat3 = mod.get_function('floataddfloat3')
float3subfloat = mod.get_function('float3subfloat')