Skip to content

Commit 5ad8d86

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

3 files changed

Lines changed: 37 additions & 15 deletions

File tree

backends/hip/ceed-hip-compile.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <ceed.h>
1111
#include <ceed/backend.h>
12+
#include <ceed/jit-source/hip/hip-chipstar.h>
1213
#include <ceed/jit-tools.h>
1314
#include <stdarg.h>
1415
#include <string.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;
@@ -77,14 +77,26 @@ static int CeedCompileCore_Hip(Ceed ceed, const char *source, const bool throw_e
7777
code << "#include <ceed/jit-source/hip/hip-jit.h>\n\n";
7878

7979
// Non-macro options
80+
#if CEED_HIP_USE_CHIPSTAR
81+
const int num_opts = 1;
82+
83+
CeedCallBackend(CeedCalloc(num_opts, &opts));
84+
opts[0] = "-DCEED_RUNNING_JIT_PASS=1";
85+
#else
86+
const int num_opts = 4;
87+
8088
CeedCallBackend(CeedCalloc(num_opts, &opts));
8189
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";
90+
{
91+
CeedCallBackend(CeedGetData(ceed, (void **)&ceed_data));
92+
CeedCallHip(ceed, hipGetDeviceProperties(&prop, ceed_data->device_id));
93+
std::string arch_arg = "--gpu-architecture=" + std::string(prop.gcnArchName);
94+
95+
opts[1] = arch_arg.c_str();
96+
}
97+
opts[2] = "-munsafe-fp-atomics";
98+
opts[3] = "-DCEED_RUNNING_JIT_PASS=1";
99+
#endif
88100
// Additional include dirs
89101
{
90102
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)