Permalink
Browse files

Update vsn.mk and added a msvc++ proj and fixed issue with function c…

…alls

make MCL=true to build with Microsofts tools instead of gcc
  • Loading branch information...
dgud committed Mar 3, 2011
1 parent 2eadf1c commit f0eec68b684213ea3f34702a04cc136d7108353a
Showing with 249 additions and 43 deletions.
  1. +5 −1 .gitignore
  2. +3 −0 Makefile
  3. +9 −0 README
  4. +26 −0 c_src/CL.sln
  5. +156 −0 c_src/CL.vcxproj
  6. +28 −20 c_src/Makefile
  7. +21 −21 c_src/cl_nif.c
  8. +1 −1 vsn.mk
View
@@ -15,4 +15,8 @@ TAGS
# c_src
/c_src/autom4te.cache
/c_src/config.*
-/c_src/configure
+/c_src/configure
+
+# Derivates
+/obj/*
+/lib/*
View
@@ -10,3 +10,6 @@ all32:
doc:
(cd src; make edoc)
+clean:
+ (cd c_src; make $@)
+ (cd src; make $@)
View
9 README
@@ -17,6 +17,8 @@ mkdir -p /opt/local/lib
Download all headers from http://www.khronos.org/registry/cl/
and put them in /opt/local/include/CL
+You can also use the environment variable OPENCL_DIR to point
+out other locations.
Find a OpenCL.lib available in Nvidia or ATI developments kits
cp /c/CUDA/lib/OpenCL.dll /opt/local/lib
@@ -27,3 +29,10 @@ http://sourceforge.net/projects/mingw/files_beta/MSYS/
OpenCL with ATI drivers for CPU usage don't work when erlang
is started within a mingw shell but does if you start it from
a Windows CMD.exe shell.
+
+If you don't like mingws compiler you can use Microsoft compiler by running
+$ make MCL=true
+This assumes that you have all the environment variables set.
+They can be set by adding first in your 'msys.bat':
+call "c:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd"
+
View
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual C++ Express 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CL", "CL.vcxproj", "{89357C94-6CA8-1FBB-CD61-970E629AE38B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {89357C94-6CA8-1FBB-CD61-970E629AE38B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {89357C94-6CA8-1FBB-CD61-970E629AE38B}.Debug|Win32.Build.0 = Debug|Win32
+ {89357C94-6CA8-1FBB-CD61-970E629AE38B}.Debug|x64.ActiveCfg = Debug|Win32
+ {89357C94-6CA8-1FBB-CD61-970E629AE38B}.Debug|x64.Build.0 = Debug|Win32
+ {89357C94-6CA8-1FBB-CD61-970E629AE38B}.Release|Win32.ActiveCfg = Release|Win32
+ {89357C94-6CA8-1FBB-CD61-970E629AE38B}.Release|Win32.Build.0 = Release|Win32
+ {89357C94-6CA8-1FBB-CD61-970E629AE38B}.Release|x64.ActiveCfg = Release|x64
+ {89357C94-6CA8-1FBB-CD61-970E629AE38B}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>..\lib\$(Configuration)\32\</OutDir>
+ <IncludePath>$(OPENCL_DIR)\include;$(ERL_C_INCLUDE_DIR);$(IncludePath)</IncludePath>
+ <LibraryPath>$(OPENCL_DIR)\lib;$(LibraryPath)</LibraryPath>
+ <IntDir>..\obj\$(Configuration)\32\</IntDir>
+ <TargetName>cl_nif</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>.\lib\$(Configuration)\32\</OutDir>
+ <IncludePath>C:\msysgit\opt\local\include\;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IncludePath>$(OPENCL_DIR)\include;$(ERL_C_INCLUDE_DIR);$(IncludePath)</IncludePath>
+ <LibraryPath>$(OPENCL_DIR)\lib;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>
+ <OutDir>..\lib\$(Configuration)\32\</OutDir>
+ <IntDir>..\obj\$(Configuration)\32\</IntDir>
+ <TargetName>cl_nif</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CL_EXPORTS;debug;DEBUG;MD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <TargetMachine>MachineX86</TargetMachine>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalDependencies>OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CL_EXPORTS;-Ddebug -DDEBUG -MD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>C:/msysgit/opt/local/;c:/PROGRA~1/erl5.8/usr/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CL_EXPORTS;-MD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <TargetMachine>MachineX86</TargetMachine>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>OpenCL.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CL_EXPORTS;-Ddebug -DDEBUG -MD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>C:/msysgit/opt/local/;c:/PROGRA~1/erl5.8/usr/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="cl_hash.c" />
+ <ClCompile Include="cl_nif.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="cl_hash.h" />
+ <ClInclude Include="config.32.h" />
+ <ClInclude Include="config.64.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
View
@@ -5,6 +5,8 @@ OUT_C = -o
OUT_L = -o
OBJ = o
+## make MCL=1 to build with microsoft compiler using msbuild (MSVC-10)
+
ERLDIR := $(shell erl -noshell -eval "io:format([126,115,126,110],[code:root_dir()])" -s erlang halt)
ERL_C_INCLUDE_DIR := $(ERLDIR)/usr/include
OCL_DIR := $(shell cd ..; pwd)
@@ -68,35 +70,32 @@ endif
endif
## Windows start
-ifeq ($(OSNAME), MINGW32_NT-6.0)
-MINGW = Yes
-endif
-ifeq ($(OSNAME), MINGW32_NT-6.1)
+ifneq (, $(findstring MINGW32,$(OSNAME)))
MINGW = Yes
endif
ifeq ($(MINGW), Yes)
EXT = dll
-MCL = $(shell which cl.exe)
-#ifneq ($(MCL), )
-ifeq ($(MCL), buggy)
+ifneq ($(MCL), )
## Use Microsoft CL
WIN32_CL = Yes
-CC = cl.exe
-OUT_C = -Fo
-OUT_L = -out:
-LD_SHARED := link.exe -DLL
-OPENCL_DIR = c:/msysgit/opt/local/
+ifeq ($(OPENCL_DIR), )
+ OPENCL_DIR = c:/msysgit/opt/local/
+endif
else
## Use mingw-gcc
WIN32_GCC = Yes
CFLAGS += -D__WIN32__
+ifeq ($(OPENCL_DIR), )
+ OPENCL_DIR = /opt/local/
+endif
+
ifeq ($(WORDSIZE), 32)
-CFLAGS += -shared -I/opt/local/include -m32 -DWIN32 -DWORDSIZE=32
+CFLAGS += -shared -I$(OPENCL_DIR)/include -m32 -DWIN32 -DWORDSIZE=32
endif
ifeq ($(WORDSIZE), 64)
-CFLAGS += -shared -I/opt/local/include -m64 -DWIN32 -DWORDSIZE=64
+CFLAGS += -shared -I$(OPENCL_DIR)/include -m64 -DWIN32 -DWORDSIZE=64
endif
LD_SHARED := $(CC) -shared
@@ -158,12 +157,7 @@ endif
ifeq ($(WIN32_GCC),Yes)
CFLAGS += -DWIN32
- LDFLAGS += -Wl--enable-stdcall-fixup -L/opt/local/lib -lOpenCL
-endif
-
-ifeq ($(WIN32_CL),Yes)
- CFLAGS = -I$(OPENCL_DIR)/include -I$(ERL_C_INCLUDE_DIR) -MD -D_THREAD_SAFE -DWIN32 -D__WIN32__ $(WIN_DEBUG)
- LDFLAGS = $(OPENCL_DIR)/lib/OpenCL.lib
+ LDFLAGS += -Wl--enable-stdcall-fixup -L$(OPENCL_DIR)/lib -lOpenCL
endif
CL_DRV = $(LIBDIR)/$(WORDSIZE)/cl_drv.$(EXT)
@@ -178,6 +172,10 @@ CL_NIF_OBJS = \
$(OBJDIR)/$(WORDSIZE)/cl_nif.$(OBJ) \
$(OBJDIR)/$(WORDSIZE)/cl_hash.$(OBJ)
+CL_NIF_SRC = \
+ cl_nif.c \
+ cl_hash.c
+
CL_ASM = \
$(OBJDIR)/$(WORDSIZE)/cl_drv.s \
$(OBJDIR)/$(WORDSIZE)/cl_hash.s
@@ -230,11 +228,21 @@ endif
depend:
+ifeq ($(WIN32_CL),No)
clean_internal:
-rm -f $(OBJDIR)/$(WORDSIZE)/*.$(OBJ)
+ -rm -f $(LIBDIR)/$(WORDSIZE)/*.$(EXT)
$(CL_NIF): $(OCL_LIB) $(CL_NIF_OBJS) # $(CL_ASM)
$(LD_SHARED) $(OUT_L) $@ $(CL_NIF_OBJS) $(LDFLAGS)
+else
+clean_internal:
+ msbuild.exe CL.sln -t:clean
+
+$(CL_NIF): $(CL_NIF_SRC) cl_hash.h
+ msbuild.exe CL.sln -p:Configuration=$(TYPE) -p:ERL_C_INCLUDE_DIR=$(ERL_C_INCLUDE_DIR) \
+ -p:OPENCL_DIR=$(OPENCL_DIR)
+endif
$(OBJDIR)/$(WORDSIZE)/cl_nif.$(OBJ): cl_hash.h
Oops, something went wrong.

0 comments on commit f0eec68

Please sign in to comment.