Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions backends/hip/ceed-hip-compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <ceed.h>
#include <ceed/backend.h>
#include <ceed/jit-source/hip/hip-chipstar.h>
#include <ceed/jit-tools.h>
#include <stdarg.h>
#include <string.h>
Expand Down Expand Up @@ -37,7 +38,6 @@ static int CeedCompileCore_Hip(Ceed ceed, const char *source, const bool throw_e
const CeedInt num_defines, va_list args) {
size_t ptx_size;
char *ptx;
const int num_opts = 4;
CeedInt num_jit_source_dirs = 0, num_jit_defines = 0;
const char **opts;
int runtime_version;
Expand Down Expand Up @@ -77,14 +77,26 @@ static int CeedCompileCore_Hip(Ceed ceed, const char *source, const bool throw_e
code << "#include <ceed/jit-source/hip/hip-jit.h>\n\n";

// Non-macro options
#if CEED_HIP_USE_CHIPSTAR
const int num_opts = 1;

CeedCallBackend(CeedCalloc(num_opts, &opts));
opts[0] = "-DCEED_RUNNING_JIT_PASS=1";
#else
const int num_opts = 4;

CeedCallBackend(CeedCalloc(num_opts, &opts));
opts[0] = "-default-device";
CeedCallBackend(CeedGetData(ceed, (void **)&ceed_data));
CeedCallHip(ceed, hipGetDeviceProperties(&prop, ceed_data->device_id));
std::string arch_arg = "--gpu-architecture=" + std::string(prop.gcnArchName);
opts[1] = arch_arg.c_str();
opts[2] = "-munsafe-fp-atomics";
opts[3] = "-DCEED_RUNNING_JIT_PASS=1";
{
CeedCallBackend(CeedGetData(ceed, (void **)&ceed_data));
CeedCallHip(ceed, hipGetDeviceProperties(&prop, ceed_data->device_id));
std::string arch_arg = "--gpu-architecture=" + std::string(prop.gcnArchName);

opts[1] = arch_arg.c_str();
}
opts[2] = "-munsafe-fp-atomics";
opts[3] = "-DCEED_RUNNING_JIT_PASS=1";
#endif
// Additional include dirs
{
const char **jit_source_dirs;
Expand Down
17 changes: 17 additions & 0 deletions include/ceed/jit-source/hip/hip-chipstar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
//
// SPDX-License-Identifier: BSD-2-Clause
//
// This file is part of CEED: http://github.com/ceed

/// @file
/// Internal header for HIP chipStar detection

// If we are using Chipstar, then we have to ensure all threads have the same workloads
// and hit __syncthreads() at the same places/number of times
#ifdef __HIP_PLATFORM_SPIRV__
#define CEED_HIP_USE_CHIPSTAR true
#else
#define CEED_HIP_USE_CHIPSTAR false
#endif
9 changes: 1 addition & 8 deletions include/ceed/jit-source/hip/hip-jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,5 @@
#define CeedPragmaSIMD
#define CEED_Q_VLA 1

// If we are using Chipstar, then we have to ensure all threads have the same workloads
// and hit __syncthreads() at the same places/number of times
#ifdef __HIP_PLATFORM_SPIRV__
#define CEED_HIP_USE_CHIPSTAR true
#else
#define CEED_HIP_USE_CHIPSTAR false
#endif

#include "hip-chipstar.h"
#include "hip-types.h"
Loading