Skip to content

Commit

Permalink
Remove unused code, and enable avx
Browse files Browse the repository at this point in the history
  • Loading branch information
tbttfox committed Sep 16, 2024
1 parent b8fce65 commit 3de34e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 50 deletions.
48 changes: 0 additions & 48 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,54 +224,6 @@ void GetValidUp(
MVector &up
);

template <typename T> struct ThreadData {
unsigned int start;
unsigned int end;
unsigned int numTasks;
double *alignedStorage;
T *pData;

ThreadData()
{
alignedStorage = (double *)_mm_malloc(4 * sizeof(double), 256);
}
~ThreadData() { _mm_free(alignedStorage); }
};

/**
Creates the data stuctures that will be sent to each thread. Divides the
vertices into discrete chunks to be evaluated in the threads.
@param[in] taskCount The number of individual tasks we want to divide the
calculation into.
@param[in] elementCount The number of vertices or elements to be divided up.
@param[in] taskData The TaskData or BindData object.
@param[out] threadData The array of ThreadData objects. It is assumed the
array is of size taskCount.
*/
template <typename T>
void CreateThreadData(
int taskCount, unsigned int elementCount, T *taskData,
ThreadData<T> *threadData
)
{
unsigned int taskLength = (elementCount + taskCount - 1) / taskCount;
unsigned int start = 0;
unsigned int end = taskLength;
int lastTask = taskCount - 1;
for (int i = 0; i < taskCount; i++) {
if (i == lastTask) {
end = elementCount;
}
threadData[i].start = start;
threadData[i].end = end;
threadData[i].numTasks = taskCount;
threadData[i].pData = taskData;

start += taskLength;
end += taskLength;
}
}

#ifdef __AVX__
/**
Calculates 4 dot products at once.
Expand Down
11 changes: 10 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('blurdeform', 'cpp')
project('blurdeform', 'cpp', default_options: ['cpp_std=c++20'])

maya_dep = dependency('maya')
maya_name_suffix = maya_dep.get_variable('name_suffix')
Expand Down Expand Up @@ -27,6 +27,15 @@ else
source_files = source_files + version_h
endif

cc = meson.get_compiler('cpp')
if cc.get_argument_syntax() == 'gcc'
avx = ['-mavx', '-mfma']
else
avx = ['/arch:AVX']
endif
add_project_arguments(avx, language: 'cpp')


outlib = shared_library(
meson.project_name(),
source_files,
Expand Down
2 changes: 1 addition & 1 deletion quick_compile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ REM use VS for the debugger, otherwise use NINJA
REM Until I figure out how to debug using nvim
SET BACKEND=vs
REM "debug" "debugoptimized" "release"
SET BUILDTYPE=debug
SET BUILDTYPE=release
SET BUILDDIR=mayabuild_%BUILDTYPE%_%MAYA_VERSION%_%BACKEND%

if not exist %BUILDDIR%\ (
Expand Down

0 comments on commit 3de34e3

Please sign in to comment.