Skip to content

Commit

Permalink
Starting work on OpenCL
Browse files Browse the repository at this point in the history
  • Loading branch information
Zack Rusin committed Dec 8, 2008
0 parents commit 22c6e1a
Show file tree
Hide file tree
Showing 36 changed files with 4,226 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .emacs-dirvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
;; -*- emacs-lisp -*-
;;
;; This file is processed by the dirvars emacs package. Each variable
;; setting below is performed when this dirvars file is loaded.
;;
indent-tabs-mode: nil
tab-width: 8
c-basic-offset: 3
kde-emacs-after-parent-string: ""
evaluate: (c-set-offset 'inline-open '0)
111 changes: 111 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
TOP = .
include $(TOP)/configs/current


CL_SOURCES = \
src/api_command.c \
src/api_context.c \
src/api_device.c \
src/api_enqueue.c \
src/api_event.c \
src/api_flush.c \
src/api_kernel.c \
src/api_memory.c \
src/api_platform.c \
src/api_profiling.c \
src/api_program.c \
src/api_sampler.c \
cpuwinsys/cpuwinsys.c


### All the core C sources

ALL_SOURCES = \
$(CL_SOURCES)


### Object files
CL_OBJECTS = \
$(CL_SOURCES:.c=.o)

### Include directories

INCLUDE_DIRS = \
-I$(TOP)/include \
-I$(GALLIUM)/include \
-I$(GALLIUM)/src/gallium/include \
-I$(GALLIUM)/src/gallium/auxiliary

CL_LIB = OpenCL
CL_LIB_NAME = lib$(CL_LIB).so

CL_MAJOR = 1
CL_MINOR = 0
CL_TINY = 0

GALLIUM_LIBS = \
$(GALLIUM)/src/gallium/auxiliary/pipebuffer/libpipebuffer.a \
$(GALLIUM)/src/gallium/auxiliary/sct/libsct.a \
$(GALLIUM)/src/gallium/auxiliary/draw/libdraw.a \
$(GALLIUM)/src/gallium/auxiliary/rtasm/librtasm.a \
$(GALLIUM)/src/gallium/auxiliary/translate/libtranslate.a \
$(GALLIUM)/src/gallium/auxiliary/cso_cache/libcso_cache.a \
$(GALLIUM)/src/gallium/auxiliary/tgsi/libtgsi.a \
$(GALLIUM)/src/gallium/auxiliary/util/libutil.a

.SUFFIXES : .cpp

.c.o:
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@

.cpp.o:
$(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@

.S.o:
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@


default: depend subdirs $(TOP)/$(LIB_DIR)/$(CL_LIB_NAME)

# Make the OpenCL library
$(TOP)/$(LIB_DIR)/$(CL_LIB_NAME): $(CL_OBJECTS) $(GALLIUM_LIBS)
$(TOP)/bin/mklib -o $(CL_LIB) \
-major $(CL_MAJOR) \
-minor $(CL_MINOR) \
-patch $(CL_TINY) \
-install $(TOP)/$(LIB_DIR) \
$(CL_OBJECTS) $(GALLIUM_LIBS) \
-Wl,--whole-archive $(LIBS) -Wl,--no-whole-archive $(SYS_LIBS)

######################################################################
# Generic stuff

depend: $(ALL_SOURCES)
@ echo "running $(MKDEP)"
@ rm -f depend # workaround oops on gutsy?!?
@ touch depend
@ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \
> /dev/null 2>/dev/null


subdirs:

install: default
$(INSTALL) -d $(INSTALL_DIR)/include/OpenCL
$(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
$(INSTALL) -m 644 $(TOP)/include/OpenCL/*.h $(INSTALL_DIR)/include/OpenCL
@if [ -e $(TOP)/$(LIB_DIR)/$(CL_LIB_NAME) ]; then \
$(INSTALL) $(TOP)/$(LIB_DIR)/libOpenCL* $(INSTALL_DIR)/$(LIB_DIR); \
fi

# Emacs tags
tags:
etags `find . -name \*.[ch]` $(TOP)/include/OpenCL/*.h

clean:
-rm -f */*.o
-rm -f */*/*.o
-rm -f depend depend.bak

include depend

74 changes: 74 additions & 0 deletions bin/installmesa
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/sh

#
# Simple shell script for installing Mesa's header and library files.
# If the copy commands below don't work on a particular system (i.e. the
# -f or -d flags), we may need to branch on `uname` to do the right thing.
#


TOP=.

INCLUDE_DIR="/usr/local/include"
LIB_DIR="/usr/local/lib"

if [ "x$#" = "x0" ] ; then
echo
echo "***** Mesa installation - You may need root privileges to do this *****"
echo
echo "Default directory for header files is:" ${INCLUDE_DIR}
echo "Enter new directory or press <Enter> to accept this default."

read INPUT
if [ "x${INPUT}" != "x" ] ; then
INCLUDE_DIR=${INPUT}
fi

echo
echo "Default directory for library files is:" ${LIB_DIR}
echo "Enter new directory or press <Enter> to accept this default."

read INPUT
if [ "x${INPUT}" != "x" ] ; then
LIB_DIR=${INPUT}
fi

echo
echo "About to install Mesa header files (GL/*.h) in: " ${INCLUDE_DIR}/GL
echo "and Mesa library files (libGL.*, etc) in: " ${LIB_DIR}
echo "Press <Enter> to continue, or <ctrl>-C to abort."

read INPUT

else
INCLUDE_DIR=$1/include
LIB_DIR=$1/lib
fi

# flags:
# -f = force
# -d = preserve symlinks (does not work on BSD)

if [ `uname` = "FreeBSD" ] ; then
CP_FLAGS="-f"
elif [ `uname` = "Darwin" ] ; then
CP_FLAGS="-f"
elif [ `uname` = "AIX" ] ; then
CP_FLAGS="-fh"
else
CP_FLAGS="-fd"
fi


set -v

mkdir -p ${INCLUDE_DIR}
mkdir -p ${INCLUDE_DIR}/GL
# NOT YET: mkdir -p ${INCLUDE_DIR}/GLES
mkdir -p ${LIB_DIR}
cp -f ${TOP}/include/GL/*.h ${INCLUDE_DIR}/GL
cp -f ${TOP}/src/glw/*.h ${INCLUDE_DIR}/GL
# NOT YET: cp -f ${TOP}/include/GLES/*.h ${INCLUDE_DIR}/GLES
cp ${CP_FLAGS} ${TOP}/lib*/lib* ${LIB_DIR}

echo "Done."
89 changes: 89 additions & 0 deletions bin/minstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/sh


# A minimal replacement for 'install' that supports installing symbolic links.
# Only a limited number of options are supported:
# -d dir Create a directory
# -m mode Sets a file's mode when installing


# If these commands aren't portable, we'll need some "if (arch)" type stuff
SYMLINK="ln -s"
MKDIR="mkdir -p"
RM="rm -f"

MODE=""

if [ "$1" = "-d" ] ; then
# make a directory path
$MKDIR "$2"
exit 0
fi

if [ "$1" = "-m" ] ; then
# set file mode
MODE=$2
shift 2
fi

# install file(s) into destination
if [ $# -ge 2 ] ; then

# Last cmd line arg is the dest dir
for FILE in $@ ; do
DEST="$FILE"
done

# Loop over args, moving them to DEST directory
I=1
for FILE in $@ ; do
if [ $I = $# ] ; then
# stop, don't want to install $DEST into $DEST
exit 0
fi

# determine file's type
if [ -h "$FILE" ] ; then
#echo $FILE is a symlink
# Unfortunately, cp -d isn't universal so we have to
# use a work-around.

# Use ls -l to find the target that the link points to
LL=`ls -l "$FILE"`
for L in $LL ; do
TARGET=$L
done
#echo $FILE is a symlink pointing to $TARGET

FILE=`basename "$FILE"`
# Go to $DEST and make the link
PWDSAVE="$PWD"
cd "$DEST" # pushd
$RM "$FILE"
$SYMLINK "$TARGET" "$FILE"
cd "$PWDSAVE" # popd

elif [ -f "$FILE" ] ; then
#echo "$FILE" is a regular file
$RM "$DEST/`basename $FILE`"
cp "$FILE" "$DEST"
if [ $MODE ] ; then
FILE=`basename "$FILE"`
chmod $MODE "$DEST/$FILE"
fi
else
echo "Unknown type of argument: " "$FILE"
exit 1
fi

I=`expr $I + 1`
done

exit 0
fi

# If we get here, we didn't find anything to do
echo "Usage:"
echo " install -d dir Create named directory"
echo " install [-m mode] file [...] dest Install files in destination"

Loading

0 comments on commit 22c6e1a

Please sign in to comment.