-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify UQ interfaces under the uq module (#38)
* Unify UQ interfaces under the uq module - Separate random from hdcache - Remove defaults and improve error checking
- Loading branch information
1 parent
bb5bac3
commit 00589c2
Showing
7 changed files
with
141 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2021-2023 Lawrence Livermore National Security, LLC and other | ||
* AMSLib Project Developers | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
*/ | ||
|
||
#ifndef __AMS_RANDOM_UQ_HPP__ | ||
#define __AMS_RANDOM_UQ_HPP__ | ||
|
||
#include "AMS.h" | ||
#include "wf/debug.h" | ||
#include "wf/utils.hpp" | ||
|
||
class RandomUQ | ||
{ | ||
public: | ||
PERFFASPECT() | ||
inline void evaluate(const size_t ndata, bool *is_acceptable) const | ||
{ | ||
if (resourceLocation == AMSResourceType::DEVICE) { | ||
#ifdef __ENABLE_CUDA__ | ||
random_uq_device<<<1, 1>>>(is_acceptable, ndata, threshold); | ||
#else | ||
THROW(std::runtime_error, | ||
"Random-uq is not configured to use device allocations"); | ||
#endif | ||
} else { | ||
random_uq_host(is_acceptable, ndata, threshold); | ||
} | ||
} | ||
RandomUQ(AMSResourceType resourceLocation, float threshold) | ||
: resourceLocation(resourceLocation), threshold(threshold) | ||
{ | ||
} | ||
|
||
private: | ||
AMSResourceType resourceLocation; | ||
float threshold; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.