Remove old OpenMP 3 code
This commit is contained in:
parent
e6615944f4
commit
469d8d5634
126
OMP3Stream.cpp
126
OMP3Stream.cpp
@ -1,126 +0,0 @@
|
|||||||
|
|
||||||
// Copyright (c) 2015-16 Tom Deakin, Simon McIntosh-Smith,
|
|
||||||
// University of Bristol HPC
|
|
||||||
//
|
|
||||||
// For full license terms please see the LICENSE file distributed with this
|
|
||||||
// source code
|
|
||||||
|
|
||||||
#include "OMP3Stream.h"
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
OMP3Stream<T>::OMP3Stream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c)
|
|
||||||
{
|
|
||||||
array_size = ARRAY_SIZE;
|
|
||||||
this->a = (T*)malloc(sizeof(T)*array_size);
|
|
||||||
this->b = (T*)malloc(sizeof(T)*array_size);
|
|
||||||
this->c = (T*)malloc(sizeof(T)*array_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
OMP3Stream<T>::~OMP3Stream()
|
|
||||||
{
|
|
||||||
free(a);
|
|
||||||
free(b);
|
|
||||||
free(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void OMP3Stream<T>::init_arrays(T initA, T initB, T initC)
|
|
||||||
{
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (int i = 0; i < array_size; i++)
|
|
||||||
{
|
|
||||||
a[i] = initA;
|
|
||||||
b[i] = initB;
|
|
||||||
c[i] = initC;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void OMP3Stream<T>::read_arrays(std::vector<T>& h_a, std::vector<T>& h_b, std::vector<T>& h_c)
|
|
||||||
{
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (int i = 0; i < array_size; i++)
|
|
||||||
{
|
|
||||||
h_a[i] = a[i];
|
|
||||||
h_b[i] = b[i];
|
|
||||||
h_c[i] = c[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void OMP3Stream<T>::copy()
|
|
||||||
{
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (int i = 0; i < array_size; i++)
|
|
||||||
{
|
|
||||||
c[i] = a[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void OMP3Stream<T>::mul()
|
|
||||||
{
|
|
||||||
const T scalar = startScalar;
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (int i = 0; i < array_size; i++)
|
|
||||||
{
|
|
||||||
b[i] = scalar * c[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void OMP3Stream<T>::add()
|
|
||||||
{
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (int i = 0; i < array_size; i++)
|
|
||||||
{
|
|
||||||
c[i] = a[i] + b[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void OMP3Stream<T>::triad()
|
|
||||||
{
|
|
||||||
const T scalar = startScalar;
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (int i = 0; i < array_size; i++)
|
|
||||||
{
|
|
||||||
a[i] = b[i] + scalar * c[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
T OMP3Stream<T>::dot()
|
|
||||||
{
|
|
||||||
T sum = 0.0;
|
|
||||||
|
|
||||||
#pragma omp parallel for reduction(+:sum)
|
|
||||||
for (int i = 0; i < array_size; i++)
|
|
||||||
{
|
|
||||||
sum += a[i] * b[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void listDevices(void)
|
|
||||||
{
|
|
||||||
std::cout << "0: CPU" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getDeviceName(const int)
|
|
||||||
{
|
|
||||||
return std::string("Device name unavailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getDeviceDriver(const int)
|
|
||||||
{
|
|
||||||
return std::string("Device driver unavailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template class OMP3Stream<float>;
|
|
||||||
template class OMP3Stream<double>;
|
|
||||||
41
OMP3Stream.h
41
OMP3Stream.h
@ -1,41 +0,0 @@
|
|||||||
|
|
||||||
// Copyright (c) 2015-16 Tom Deakin, Simon McIntosh-Smith,
|
|
||||||
// University of Bristol HPC
|
|
||||||
//
|
|
||||||
// For full license terms please see the LICENSE file distributed with this
|
|
||||||
// source code
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
#include "Stream.h"
|
|
||||||
|
|
||||||
#define IMPLEMENTATION_STRING "Reference OpenMP"
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
class OMP3Stream : public Stream<T>
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
// Size of arrays
|
|
||||||
unsigned int array_size;
|
|
||||||
// Device side pointers
|
|
||||||
T *a;
|
|
||||||
T *b;
|
|
||||||
T *c;
|
|
||||||
|
|
||||||
public:
|
|
||||||
OMP3Stream(const unsigned int, T*, T*, T*);
|
|
||||||
~OMP3Stream();
|
|
||||||
|
|
||||||
virtual void copy() override;
|
|
||||||
virtual void add() override;
|
|
||||||
virtual void mul() override;
|
|
||||||
virtual void triad() override;
|
|
||||||
virtual T dot() override;
|
|
||||||
|
|
||||||
virtual void init_arrays(T initA, T initB, T initC) override;
|
|
||||||
virtual void read_arrays(std::vector<T>& a, std::vector<T>& b, std::vector<T>& c) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
Loading…
Reference in New Issue
Block a user