Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

At QT project so qtcreator can be used to edit #222

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions include/pal_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@
#define P_PROP_MEMARCH 12
#define P_PROP_WHOAMI 13

/*
***********************************************************************
* allow unused varaibles to be in function headers without generating
* a warning
***********************************************************************
*/

#ifndef UNUSED
#define UNUSED(x) (void)(x)
#endif

/*
***********************************************************************
* OPAQUE OBJECT TYPES
Expand Down
134 changes: 134 additions & 0 deletions qt/pal/pal.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#-------------------------------------------------
#
# Project created by QtCreator 2015-08-31T10:59:14
#
#-------------------------------------------------

QT -= core gui

TARGET = pal
TEMPLATE = lib

INCLUDEPATH += ../../include

DEFINES += PAL_LIBRARY

SOURCES += \
../../src/base/p_append.c \
../../src/base/p_atomic_add.c \
../../src/base/p_atomic_and.c \
../../src/base/p_atomic_compswap.c \
../../src/base/p_atomic_or.c \
../../src/base/p_atomic_sub.c \
../../src/base/p_atomic_swap.c \
../../src/base/p_atomic_xor.c \
../../src/base/p_barrier.c \
../../src/base/p_broadcast.c \
../../src/base/p_close.c \
../../src/base/p_fence.c \
../../src/base/p_finalize.c \
../../src/base/p_free.c \
../../src/base/p_gather.c \
../../src/base/p_getaddr.c \
../../src/base/p_get_err.c \
../../src/base/p_getsymbol.c \
../../src/base/p_init.c \
../../src/base/p_load.c \
../../src/base/p_malloc.c \
../../src/base/p_memcpy.c \
../../src/base/p_mutex_init.c \
../../src/base/p_mutex_lock.c \
../../src/base/p_mutex_trylock.c \
../../src/base/p_mutex_unlock.c \
../../src/base/p_open.c \
../../src/base/p_query.c \
../../src/base/p_read.c \
../../src/base/p_remove.c \
../../src/base/p_rmalloc.c \
../../src/base/p_run.c \
../../src/base/p_scatter.c \
../../src/base/p_wait.c \
../../src/base/p_write.c \
../../src/dsp/p_acorr.c \
../../src/dsp/p_conv.c \
../../src/dsp/p_fir.c \
../../src/dsp/p_firdec.c \
../../src/dsp/p_firint.c \
../../src/dsp/p_firsym.c \
../../src/dsp/p_iir.c \
../../src/dsp/p_xcorr.c \
../../src/math/p_abs.c \
../../src/math/p_absdiff.c \
../../src/math/p_acos.c \
../../src/math/p_acosh.c \
../../src/math/p_add.c \
../../src/math/p_a_inv.c \
../../src/math/p_asin.c \
../../src/math/p_asinh.c \
../../src/math/p_atan.c \
../../src/math/p_atan2.c \
../../src/math/p_atanh.c \
../../src/math/p_cbrt.c \
../../src/math/p_cos.c \
../../src/math/p_cosh.c \
../../src/math/p_div.c \
../../src/math/p_dot.c \
../../src/math/p_exp.c \
../../src/math/p_ftoi.c \
../../src/math/p_inv.c \
../../src/math/p_invcbrt.c \
../../src/math/p_invsqrt.c \
../../src/math/p_itof.c \
../../src/math/p_ln.c \
../../src/math/p_log10.c \
../../src/math/p_mac.c \
../../src/math/p_max.c \
../../src/math/p_mean.c \
../../src/math/p_median.c \
../../src/math/p_min.c \
../../src/math/p_mode.c \
../../src/math/p_mul.c \
../../src/math/p_popcount.c \
../../src/math/p_pow.c \
../../src/math/p_rand.c \
../../src/math/p_sin.c \
../../src/math/p_sincos.c \
../../src/math/p_sinh.c \
../../src/math/p_sort.c \
../../src/math/p_sqrt.c \
../../src/math/p_stddev.c \
../../src/math/p_sub.c \
../../src/math/p_sum.c \
../../src/math/p_sumsq.c \
../../src/math/p_tan.c \
../../src/math/p_tanh.c \
../../src/image/p_box3x3.c \
../../src/image/p_conv2d.c \
../../src/image/p_gauss3x3.c \
../../src/image/p_grayscale.c \
../../src/image/p_harris3x3.c \
../../src/image/p_laplace3x3.c \
../../src/image/p_median3x3.c \
../../src/image/p_prewitt3x3.c \
../../src/image/p_sad8x8.c \
../../src/image/p_sad16x16.c \
../../src/image/p_scharr3x3.c \
../../src/image/p_sobel3x3.c \
../../src/fft/p_cfft.c

HEADERS +=\
../../include/pal.h \
../../include/pal_base.h \
../../include/pal_dsp.h \
../../include/pal_fft.h \
../../include/pal_image.h \
../../include/pal_math.h \
../../src/math/p_asin.h \
../../src/math/p_exp.h \
../../src/math/p_sqrt.h


unix {
target.path = /usr/lib
INSTALLS += target
}
7 changes: 6 additions & 1 deletion src/base/p_append.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
* Add members to an existing team of processors.
*
* @todo need to implement
*
* @param team Team number
*
* @param start Index of first processor from 'dev' (referenced by 'team')
Expand All @@ -13,14 +15,17 @@
*
* @return Returns reference to team if successfull. Negative number
* indicates error.
*
*/
#include <stdio.h>
#include "pal_base.h"
#include "pal_base_private.h"

p_team_t p_append(p_team_t team, int start, int size)
{
UNUSED(team);
UNUSED(start);
UNUSED(size);

printf("Running p_append(p_team_t,%d,%d)\n", start, size);
// need to implement
return (0);
Expand Down
32 changes: 29 additions & 3 deletions src/base/p_broadcast.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
#include <pal.h>

#include <stdio.h>
#include <stddef.h>
#include "pal_base.h"
#include "pal_base_private.h"

ssize_t p_broadcast(p_mem_t *mlist[], void *src, size_t nsrc, size_t ndst,
/**
*
* Broadcasts an array based to a list of destination pointers
*
* @todo need to implement
*
* @param mlist destination array
*
* @param mcount Total size of destination array
*
* @param src source of item to be broadcast
*
* @param nb size of item to be broadcast
*
* @flags no idea
*
* @return Returns size that was broadcast
*/


ssize_t p_broadcast(p_mem_t *mlist[], int mcount, void *src, size_t nb,
int flags)
{
printf("Running p_broadcast()\n");
UNUSED(mlist);
UNUSED(mcount);
UNUSED(src);
UNUSED(nb);
UNUSED(flags);
/*PLACE CODE HERE*/

return (0);
}
17 changes: 12 additions & 5 deletions src/base/p_scatter.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#include <pal.h>

#include <stdio.h>
#include <stddef.h>
#include "pal_base.h"
#include "pal_base_private.h"

ssize_t p_scatter(void *src, size_t nsrc, size_t ndst, int flags, void **dstlist)
{

/*PLACE CODE HERE*/

ssize_t p_scatter(p_mem_t *mlist[], int mcount, void *suf, size_t scount,
int disp[], int flags)
{
UNUSED(mlist);
UNUSED(mcount);
UNUSED(suf);
UNUSED(scount);
UNUSED(disp);
UNUSED(flags);
printf("Running p_broadcast()\n");
return (0);
}

4 changes: 2 additions & 2 deletions src/image/p_box3x3.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* |1 1 1|
*
* Notes: cols and rows must be 3 or more
* @todo rows isn't being used, why?
*
* @param x Pointer to input image, a 2D array of size 'rows' x 'cols'
*
Expand All @@ -23,8 +24,7 @@
void p_box3x3_f32(const float *x, float *r, int rows, int cols)
{

int ia, ja;
float E;
int ia, ja;
const float *px;
float *pr;
float r1avg, r2avg, r3avg;
Expand Down
5 changes: 2 additions & 3 deletions src/image/p_harris3x3.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ static void _sst3x3(const float *x, float *r, int rows, int cols)
{
int i, j;
int ic3 = 1 - 3 * cols;
int cm3 = cols - 3;
//int cm3 = cols - 3;
int rm2 = rows - 2;
int cm2 = cols - 2;
float Dx, Dy;
Expand Down Expand Up @@ -70,8 +70,7 @@ void p_harris3x3_f32(const float *x, float *r, float *t, int rows, int cols)
int rm4 = rows - 4;
int cm4 = cols - 4;
int ci = (cols - 2)*3 - 8;
int cj = (cols - 2)*6 + 5;
float P1, dy2, dxy;
int cj = (cols - 2)*6 + 5;
float *pr, *pt;

pr = r;
Expand Down
12 changes: 8 additions & 4 deletions src/math/p_absdiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ void p_absdiff_f32(const float *a, const float *b, float *c, int n)
float f;
uint32_t u;
} diff;
for (int i = 0; i < n; i++) {
diff.f = a[i] - b[i];
diff.u &= 0x7FFFFFFF;
c[i] = diff.f;
{
int i=0; // outside of for loop for c compatibility

for (; i < n; i++) {
diff.f = a[i] - b[i];
diff.u &= 0x7FFFFFFF;
c[i] = diff.f;
}
}
}
7 changes: 5 additions & 2 deletions src/math/p_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ void p_add_f32(const float *a, const float *b, float *c, int n)
return;
}
#endif // __epiphany__
for (int i = 0; i < n; i++)
*(c + i) = *(a + i) + *(b + i);
{
int i=0; // outside of "for" loop for c compatibility
for (; i < n; i++)
*(c + i) = *(a + i) + *(b + i);
}
}
5 changes: 4 additions & 1 deletion src/math/p_ftoi.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ void p_ftoi(const float *a, int *c, int n)
float f;
uint32_t u;
} rounding;
{
int i=0; // outside of for loop for C compatibility

for (int i = 0; i < n; i++) {
for (; i < n; i++) {
rounding.f = *(a + i);
rounding.u = (rounding.u & 0x80000000) | ZERO_POINT_FIVE;
*(c+i) = (int) (*(a+i) + rounding.f);
}
}
}
3 changes: 2 additions & 1 deletion src/math/p_itof.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
void p_itof(const int *a, float *c, int n)
{
for(int i = 0; i < n; i++)
int i=0; // outside of for loop for C compatibility
for(; i < n; i++)
*(c + i) = (float)(*(a + i));
}
4 changes: 2 additions & 2 deletions src/math/p_max.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
void p_max_f32(const float *a, float *c, int *index, int n)
{
if (n==0) return; // only do work if there are elements
int pos = 0;
int pos = 0,i=1;

for (int i = 1; i < n; i++) {
for (; i < n; i++) {
int greater = (*(a + i) > *(a + pos));
pos = greater * i + (1 - greater) * pos;
}
Expand Down
2 changes: 1 addition & 1 deletion src/math/p_median.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void p_median_f32(const float *a, float *c, int n)

memcpy(search_a, a, sizeof(float) * n);

for (; median_index <= (n >> 1); ++median_index) {
for (; median_index <= ((unsigned int)n >> 1); ++median_index) {
unsigned int right = n - 1;
unsigned int pivot_index = 0;

Expand Down
Loading