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

Gpu link static lib #4

Merged
merged 2 commits into from
Mar 29, 2016
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
14 changes: 7 additions & 7 deletions lib/clamp-link.in
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,11 @@ for ARG in $ARGS
do
# matches -L<path>
if [[ "$ARG" =~ ^-L[^[:space:]]+$ ]]; then

REAL_PATH=$(readlink -f ${ARG:2})
if [ $VERBOSE == 2 ]; then
echo "adding library search path: ${ARG:2}"
fi

if [[ "$ARG" =~ ^-L\/[^[:space:]]+$ ]]; then
REAL_PATH=$(readlink -f ${ARG:2})
LIB_SEARCH_PATHS+=( $REAL_PATH )
echo "add library path: ${ARG:2}, canonical path: $REAL_PATH"
fi
LIB_SEARCH_PATHS+=( $REAL_PATH )
fi
done

Expand Down Expand Up @@ -220,6 +216,10 @@ do
for LIB_PATH in "${LIB_SEARCH_PATHS[@]}"
do
FULL_LIB_PATH=$LIB_PATH"/"$STATIC_LIB_NAME
FULL_LIB_PATH=$(readlink -f $FULL_LIB_PATH)
if [ $VERBOSE == 2 ]; then
echo "trying to detect $FULL_LIB_PATH"
fi
if [ -f $FULL_LIB_PATH ]; then
if [ $VERBOSE == 2 ]; then
echo "$FULL_LIB_PATH detected"
Expand Down
44 changes: 44 additions & 0 deletions tests/Unit/StaticLibrary/static_library2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// RUN: %hc -DSTATIC_LIB %s -c -o %T/static_library2.o
// RUN: ar rcs %T/libstatic_library2.a %T/static_library2.o
// RUN: %hc %s -L./Output -lstatic_library2 -o %t.out && %t.out

#include <cstdio>
#include <hc.hpp>

extern "C" int sum(hc::array_view<int,1>& input);

#ifdef STATIC_LIB

int sum(hc::array_view<int,1>& input) {

hc::array_view<int,1> s(1);
s[0]=0;

hc::parallel_for_each(input.get_extent(), [=](hc::index<1> idx) [[hc]] {
if (idx[0]==0) {
int num = input.get_extent()[0];
for (int i = 0; i < num; i++) {
s[0]+=input[i];
}
}
}).wait();

return s[0];
}

#else

int main() {

hc::array_view<int,1> av(64);
for (int i = 0;i < 64; i++)
av[i] = i;

int s = sum(av);

// printf("sum: %d\n",s);

return !(s==2016);
}

#endif