Skip to content
Snippets Groups Projects
Commit 82ce1d7d authored by Christoph Alt's avatar Christoph Alt
Browse files

Fix the missing constants for the gpu main file and added a kernel with

a constant to the gpu tests
parent 6e88d389
1 merge request!1Add CUDA support
Pipeline #55139 skipped with stage
......@@ -32,6 +32,12 @@ int main(int argc, char **argv)
cudaMemset({{field_name}}, 0.23, {{elements}});
{% endfor %}
{% for constantName, dataType in kernel.constants %}
// Constant {{constantName}}
{{dataType}} {{constantName}};
{{constantName}} = 0.23;
{% endfor %}
dim3 blocks({{kernel.blocks[0]}}, {{kernel.blocks[1]}}, {{kernel.blocks[2]}});
dim3 grid({{kernel.grid[0]}}, {{kernel.grid[1]}}, {{kernel.grid[2]}});
......
......@@ -48,14 +48,20 @@ gpu_kwargs = ({}, {'launch_bounds': (256,)}, {'launch_bounds': (256, 2)})
def test_generate_gpu(kwargs):
compiler = Compiler.NVCC
a, b, c = ps.fields(a=np.ones(4000000), b=np.ones(4000000), c=np.ones(4000000))
alpha = sp.symbols('alpha')
@ps.kernel_config(ps.CreateKernelConfig(target=ps.Target.GPU))
def vadd():
a[0] @= b[0] + c[0]
kernel_vadd = ps.create_kernel(**vadd)
@ps.kernel_config(ps.CreateKernelConfig(target=ps.Target.GPU))
def daxpy():
b[0] @= alpha * a[0] + b[0]
kernel_daxpy = ps.create_kernel(**daxpy)
with tempfile.TemporaryDirectory(dir=Path.cwd()) as temp_dir:
temp_dir = Path(temp_dir)
pb.gpu.generate_benchmark(kernel_vadd, temp_dir, compiler=compiler, **kwargs)
pb.gpu.generate_benchmark([kernel_vadd, kernel_daxpy], temp_dir, compiler=compiler, **kwargs)
subprocess.run(['make', '-C', f'{temp_dir}'], check=True)
subprocess.run([f'{temp_dir}/benchmark-{compiler.name}', '10'], check=True)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment