Merge pull request #246 from vortexgpgpu/bug_fixes

extending divergence test coverage
This commit is contained in:
tinebp 2025-05-04 00:43:54 -07:00 committed by GitHub
commit a9050c4506
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 47 additions and 0 deletions

View file

@ -12,6 +12,8 @@
// limitations under the License.
#include "util.h"
#include <fstream>
#include <sstream>
#include <string.h>
// return file extension
@ -36,4 +38,21 @@ void aligned_free(void *ptr) {
// retreive the stored unaligned address and use it to free the allocation
void* unaligned_addr = ((void**)ptr)[-1];
free(unaligned_addr);
}
std::string vortex::resolve_file_path(const std::string& filename, const std::string& searchPaths) {
std::ifstream ifs(filename);
if (!ifs) {
std::stringstream ss(searchPaths);
std::string path;
while (std::getline(ss, path, ',')) {
if (!path.empty()) {
std::string filePath = path + "/" + filename;
std::ifstream ifs(filePath);
if (ifs)
return filePath;
}
}
}
return filename;
}

View file

@ -17,6 +17,7 @@
#include <algorithm>
#include <assert.h>
#include <bitmanip.h>
#include <string>
template <typename... Args>
void unused(Args&&...) {}
@ -94,4 +95,6 @@ public:
}
};
std::string resolve_file_path(const std::string& filename, const std::string& searchPaths);
}

View file

@ -5,6 +5,14 @@
// Parallel Selection sort
struct key_t {
uint32_t user = 0;
};
static __attribute__((noinline)) void hacker(key_t* key, uint32_t task_id) {
key->user = task_id;
}
void kernel_body(kernel_arg_t* __UNIFORM__ arg) {
int32_t* src_ptr = (int32_t*)arg->src_addr;
int32_t* dst_ptr = (int32_t*)arg->dst_addr;
@ -13,6 +21,15 @@ void kernel_body(kernel_arg_t* __UNIFORM__ arg) {
int value = src_ptr[task_id];
key_t key;
uint32_t samples = arg->num_points;
while (samples--) {
hacker(&key, task_id);
if ((key.user & 0x1) == 0) {
value += 1;
}
}
// none taken
if (task_id >= 0x7fffffff) {
value = 0;

View file

@ -78,6 +78,14 @@ void gen_ref_data(std::vector<int>& ref_data, const std::vector<int>& src_data,
for (int i = 0; i < (int)size; ++i) {
int value = src_data.at(i);
key_t key;
uint32_t samples = size;
while (samples--) {
if ((i & 0x1) == 0) {
value += 1;
}
}
// none taken
if (i >= 0x7fffffff) {
value = 0;