Skip to content

Commit 2c57726

Browse files
committed
hip - don't use JiT options that chipStar cannot process
1 parent 59b5803 commit 2c57726

3 files changed

Lines changed: 36 additions & 15 deletions

File tree

backends/hip/ceed-hip-compile.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <ceed.h>
1111
#include <ceed/backend.h>
1212
#include <ceed/jit-tools.h>
13+
#include <ceed/jit-source/hip/hip-chipstar.h>
1314
#include <stdarg.h>
1415
#include <string.h>
1516
#include <hip/hiprtc.h>
@@ -37,7 +38,6 @@ static int CeedCompileCore_Hip(Ceed ceed, const char *source, const bool throw_e
3738
const CeedInt num_defines, va_list args) {
3839
size_t ptx_size;
3940
char *ptx;
40-
const int num_opts = 4;
4141
CeedInt num_jit_source_dirs = 0, num_jit_defines = 0;
4242
const char **opts;
4343
int runtime_version;
@@ -78,13 +78,24 @@ static int CeedCompileCore_Hip(Ceed ceed, const char *source, const bool throw_e
7878

7979
// Non-macro options
8080
CeedCallBackend(CeedCalloc(num_opts, &opts));
81+
#if CEED_HIP_USE_CHIPSTAR
82+
const int num_opts = 1;
83+
84+
opts[0] = "-DCEED_RUNNING_JIT_PASS=1";
85+
#else
86+
const int num_opts = 4;
87+
8188
opts[0] = "-default-device";
82-
CeedCallBackend(CeedGetData(ceed, (void **)&ceed_data));
83-
CeedCallHip(ceed, hipGetDeviceProperties(&prop, ceed_data->device_id));
84-
std::string arch_arg = "--gpu-architecture=" + std::string(prop.gcnArchName);
85-
opts[1] = arch_arg.c_str();
86-
opts[2] = "-munsafe-fp-atomics";
87-
opts[3] = "-DCEED_RUNNING_JIT_PASS=1";
89+
{
90+
CeedCallBackend(CeedGetData(ceed, (void **)&ceed_data));
91+
CeedCallHip(ceed, hipGetDeviceProperties(&prop, ceed_data->device_id));
92+
std::string arch_arg = "--gpu-architecture=" + std::string(prop.gcnArchName);
93+
94+
opts[1] = arch_arg.c_str();
95+
}
96+
opts[2] = "-munsafe-fp-atomics";
97+
opts[3] = "-DCEED_RUNNING_JIT_PASS=1";
98+
#endif
8899
// Additional include dirs
89100
{
90101
const char **jit_source_dirs;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2+
// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3+
//
4+
// SPDX-License-Identifier: BSD-2-Clause
5+
//
6+
// This file is part of CEED: http://github.com/ceed
7+
8+
/// @file
9+
/// Internal header for HIP chipStar detection
10+
11+
// If we are using Chipstar, then we have to ensure all threads have the same workloads
12+
// and hit __syncthreads() at the same places/number of times
13+
#ifdef __HIP_PLATFORM_SPIRV__
14+
#define CEED_HIP_USE_CHIPSTAR true
15+
#else
16+
#define CEED_HIP_USE_CHIPSTAR false
17+
#endif

include/ceed/jit-source/hip/hip-jit.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,5 @@
1313
#define CeedPragmaSIMD
1414
#define CEED_Q_VLA 1
1515

16-
// If we are using Chipstar, then we have to ensure all threads have the same workloads
17-
// and hit __syncthreads() at the same places/number of times
18-
#ifdef __HIP_PLATFORM_SPIRV__
19-
#define CEED_HIP_USE_CHIPSTAR true
20-
#else
21-
#define CEED_HIP_USE_CHIPSTAR false
22-
#endif
23-
16+
#include "hip-chipstar.h"
2417
#include "hip-types.h"

0 commit comments

Comments
 (0)