def test_parse_preprocess(): src = """ #define DTYPE float kernel void A(global DTYPE *a) {} """ pp = cldrive.preprocess(src) ast = cldrive.parse(pp) assert len(ast.children()) >= 1
def test_extract_args_preprocess(): src = """ #define DTYPE float kernel void A(global DTYPE *a) {} """ pp = cldrive.preprocess(src) args = cldrive.extract_args(pp) assert args[0].typename == 'float'
def test_parse_header(): src = """ #include "header.h" kernel void A(global DTYPE* a) { a[get_global_id(0)] = DOUBLE(a[get_global_id(0)]); } """ pp = cldrive.preprocess(src, include_dirs=[data_path("")]) ast = cldrive.parse(pp) assert len(ast.children()) >= 1
def test_header(): src = """ #include "header.h" kernel void A(global DTYPE* a) { a[get_global_id(0)] = DOUBLE(a[get_global_id(0)]); } """ inputs = [np.arange(16)] outputs_gs = [np.arange(16) * 2] pp = cldrive.preprocess(src, include_dirs=[data_path("")]) outputs = cldrive.drive(ENV, pp, inputs, gsize=(16, 1, 1), lsize=(16, 1, 1)) almost_equal(outputs, outputs_gs)
while True: # get the next program to run subquery = session.query(cldriveCLSmithResult.program_id).filter( cldriveCLSmithResult.testbed == testbed, cldriveCLSmithResult.params == params) program = session.query(CLSmithProgram).filter( ~CLSmithProgram.id.in_(subquery)).order_by( CLSmithProgram.id).first() # we have no program to run if not program: break start_time = time() try: src = cldrive.preprocess( program.src, include_dirs=["~/src/CLSmith/runtime"]) status, stdout, stderr = drive(cli, src) except cldrive.OpenCLPreprocessError: status = 1024 # preprocess error stdout = ''.encode('utf-8') stderr = 'OpenCLPreprocessError' runtime = time() - start_time # assert that executed params match expected verify_params(platform=args.platform, device=args.device, optimizations=params.optimizations, global_size=params.gsize, local_size=params.lsize, stderr=stderr)
def test_preprocess(): pp = cldrive.preprocess("kernel void A() {}") assert pp.split("\n")[-2] == "kernel void A() {}"