Files
TheRock/debug-tools/rocgdb/source/gdb/testsuite/gdb.rocm/lane-execution.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

146 lines
3.6 KiB
C++

/* Copyright 2021-2024 Free Software Foundation, Inc.
Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#define CHECK(cmd) \
do \
{ \
hipError_t error = cmd; \
if (error != hipSuccess) \
{ \
fprintf(stderr, "error: '%s'(%d) at %s:%d\n", \
hipGetErrorString (error), error, \
__FILE__, __LINE__); \
exit (EXIT_FAILURE); \
} \
} while (0)
struct test_struct
{
int int_elem;
char char_elem;
int array_elem[32];
};
__device__ const struct test_struct const_struct = {
32, '2',
{
32, 31, 30, 29, 28, 27, 26, 25,
24, 23, 22, 21, 20, 19, 18, 17,
16, 15, 14, 13, 12, 11, 10, 9,
8, 7, 6, 5, 4, 3, 2, 1
}
};
__device__ const int const_array[32] = {
1, 1, 1, 1, 1, 5, 5, 7,
2, 2, 2, 2, 2, 5, 5, 10,
3, 3, 3, 3, 3, 5, 5, 2,
4, 4, 4, 4, 4, 5, 5, 3
};
__device__ int
bar (int val)
{
return val;
}
__device__ int
foo (int val)
{
return bar (val);
}
__device__ void
lane_pc_test (unsigned gid, const int *in, struct test_struct *out)
{
int elem;
/* This first divergence is here so GDB can check which lane is the
'then' and which is the 'else' lane, based on which lanes become
active/inactive. This if/then/else block is stepped with "maint
set lane-divergence-support off". */
if (gid % 2) /* if_0_cond */
elem = const_array[gid] + 1; /* if_0_then */
else
elem = const_array[gid] + 3; /* if_0_else */
out->int_elem = const_struct.int_elem;
out->char_elem = const_struct.char_elem;
if (gid % 2) /* if_1_cond */
{
elem = const_array[gid] + 1; /* if_1_then */
elem = const_array[gid] + 2; /* if_1_then_2 */
} /* if_1_then_3 */
else
{
elem = const_array[gid] + 3; /* if_1_else */
elem = const_array[gid] + 4; /* if_1_else_2 */
}
/* if_1_end */
if (gid % 2) /* if_2_cond */
elem = foo (const_array[gid]); /* if_2_then */
else
elem = const_array[gid]; /* if_2_else */
/* if_2_end */
/* This condition is always false. */
if (gid == -1) /* if_3_cond */
elem = const_array[gid] + 1; /* if_3_then */
else
elem = const_array[gid] + 2; /* if_3_else */
/* if_3_end */
atomicAdd (&out->int_elem, elem);
out->array_elem[gid] = elem;
}
__global__ void
kernel (const int *in, struct test_struct *out)
{
unsigned gid0 = blockIdx.x * blockDim.x + threadIdx.x;
lane_pc_test (gid0, in, out);
}
int
main ()
{
dim3 grid_dim (1);
dim3 block_dim (32);
struct test_struct *sOutBuff;
int *sInBuff;
CHECK (hipMalloc (&sOutBuff, sizeof (struct test_struct)));
CHECK (hipMalloc (&sInBuff, sizeof (int)
* (grid_dim.x * grid_dim.y * grid_dim.z
* block_dim.x
* block_dim.y
* block_dim.z)));
hipLaunchKernelGGL (kernel, grid_dim, block_dim, 0, 0, sInBuff, sOutBuff);
CHECK (hipDeviceSynchronize ());
return 0;
}